org.jgroups.service.lease

Class LeaseResponseHeader

Implemented Interfaces:
Cloneable, Externalizable

public class LeaseResponseHeader
extends Header

Message header representing service response. Presence of this header in message means that previous request succeeded. Header type determines what type of request was satisfied. If this header represents new lease or lease renewal, granted lease duration is passed within. Also each header contains entity that requested factory operation.

Author:
Roman Rokytskyy (rrokytskyy@acm.org)

Field Summary

static String
HEADER_KEY
static int
LEASE_CANCELED
static int
LEASE_GRANTED
static int
LEASE_RENEWED
static int
NONE

Fields inherited from class org.jgroups.Header

HDR_OVERHEAD

Constructor Summary

LeaseResponseHeader()
Create uninitialized instance of this class.
LeaseResponseHeader(int headerType, Object tenant)
Create instance of this class of type LEASE_CANCELED or LEASE_RENEWED.
LeaseResponseHeader(int headerType, long duration, boolean isAbsolute, Object tenant)
Create instance of this class of type either LEASE_GRANTED or LEASE_RENEWED.

Method Summary

long
getDuration()
Get requested duration of a lease.
Object
getTenant()
Get tenant, to which this request is addressed to.
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.
void
writeExternal(ObjectOutput out)
Write state of this object into object output.

Methods inherited from class org.jgroups.Header

size, toString

Field Details

HEADER_KEY

public static final String HEADER_KEY


LEASE_CANCELED

public static final int LEASE_CANCELED

Field Value:
3


LEASE_GRANTED

public static final int LEASE_GRANTED

Field Value:
1


LEASE_RENEWED

public static final int LEASE_RENEWED

Field Value:
2


NONE

public static final int NONE

Field Value:
0

Constructor Details

LeaseResponseHeader

public LeaseResponseHeader()
Create uninitialized instance of this class. This constructor is used for implementation of java.io.Externalizable interface. There is no other way to set state of this object except reading it from object input using readExternal(java.io.ObjectInput) method.


LeaseResponseHeader

public LeaseResponseHeader(int headerType,
                           Object tenant)
Create instance of this class of type LEASE_CANCELED or LEASE_RENEWED.


LeaseResponseHeader

public LeaseResponseHeader(int headerType,
                           long duration,
                           boolean isAbsolute,
                           Object tenant)
Create instance of this class of type either LEASE_GRANTED or LEASE_RENEWED.

Method Details

getDuration

public long getDuration()
Get requested duration of a lease.

Returns:
requested duration of lease in milliseconds.


getTenant

public Object getTenant()
Get tenant, to which this request is addressed to.


getType

public int getType()
Get type of lease request.


isAbsolute

public boolean isAbsolute()
Check if duration is relative or absolute.

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.


writeExternal

public void writeExternal(ObjectOutput out)
            throws IOException
Write state of this object into object output.


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