org.jgroups.service.lease

Class LeaseRequestHeader

Implemented Interfaces:
Cloneable, Externalizable

public class LeaseRequestHeader
extends Header

Message header that represents lease request. Request has type. Requests for new lease or renew lease contain desired lease duration and entity requesting the lease, cancel requests does not contain lease duration, only entity cancelling lease. Resource identifier is sent as message payload.
Author:
Roman Rokytskyy (rrokytskyy@acm.org)

Field Summary

static int
CANCEL_LEASE_REQUEST
static String
HEADER_KEY
static int
NEW_LEASE_REQUEST
static int
RENEW_LEASE_REQUEST

Fields inherited from class org.jgroups.Header

HDR_OVERHEAD

Constructor Summary

LeaseRequestHeader()
Constructs empty header.
LeaseRequestHeader(int headerType, long duration, boolean isAbsolute, Object tenant)
Create lease request header of the specified type with specified duration.

Method Summary

long
getDuration()
Get requested duration of a lease.
Object
getTenant()
Get identifier of an object that requests the lease.
int
getType()
Get type of lease request.
boolean
isAbsolute()
Check if duration is relative or absolute.
void
readExternal(ObjectInput in)
Read state of this object from object input stream.
void
writeExternal(ObjectOutput out)
Write state of this object into object output stream.

Methods inherited from class org.jgroups.Header

size, toString

Field Details

CANCEL_LEASE_REQUEST

public static final int CANCEL_LEASE_REQUEST
Field Value:
3

HEADER_KEY

public static final String HEADER_KEY

NEW_LEASE_REQUEST

public static final int NEW_LEASE_REQUEST
Field Value:
1

RENEW_LEASE_REQUEST

public static final int RENEW_LEASE_REQUEST
Field Value:
2

Constructor Details

LeaseRequestHeader

public LeaseRequestHeader()

LeaseRequestHeader

public LeaseRequestHeader(int headerType,
                          long duration,
                          boolean isAbsolute,
                          Object tenant)
Create lease request header of the specified type with specified duration.

Method Details

getDuration

public long getDuration()
Get requested duration of a lease. If type of lease request is CANCEL_LEASE_REQUEST value is ignored.
Returns:
requested duration of lease in milliseconds.

getTenant

public Object getTenant()
Get identifier of an object that requests the lease.
Returns:
object identifying entity that requests lease.

getType

public int getType()
Get type of lease request.

isAbsolute

public boolean isAbsolute()
Check if duration is relative or absolute. If type of lease reques is CANCEL_LEASE_REQUEST value is ignored.
Returns:
true if duration is absolute, otherwise false.

readExternal

public void readExternal(ObjectInput in)
            throws IOException,
                   ClassNotFoundException
Read state of this object from object input stream. Format of data in the stream is:
  1. headerType - int;
  2. duration - long (not applicable for lease ;
  3. isAbsolute - boolean;
  4. tenant - Object.

writeExternal

public void writeExternal(ObjectOutput out)
            throws IOException
Write state of this object into object output stream. Format of data in the stream is:
  1. headerType - int;
  2. duration - long;
  3. isAbsolute - boolean;
  4. tenant - Object.

Copyright B) 2001,2002 www.jgroups.com . All Rights Reserved.