org.jgroups.service.lease

Class LeaseFactoryClient

Implemented Interfaces:
LeaseFactory

public class LeaseFactoryClient
extends java.lang.Object
implements LeaseFactory

LeaseFactoryClient is an implementation of LeaseFactory interface that delegates lease granting to group containing one or more LeaseFactoryService instances.

This service tries to implement semi-synchronous communication pattern: each call blocks until reply from service received or timeout occurs.

Also this implementation assumes that pending new lease request conflicts with renewal request and request that came last is aborted.

Author:
Roman Rokytskyy (rrokytskyy@acm.org)

Field Summary

static int
DEFAULT_CANCEL_TIMEOUT
static int
DEFAULT_LEASE_TIMEOUT
protected int
cancelTimeout
protected PullPushAdapter
clientAdapter
protected Channel
clientChannel
protected int
leaseTimeout
protected Log
log
protected HashMap
pendingCancels
protected HashMap
pendingLeases
protected HashMap
pendingRenewals

Fields inherited from interface org.jgroups.service.lease.LeaseFactory

DURATION_ANY, DURATION_FOREVER

Constructor Summary

LeaseFactoryClient(Channel clientChannel)
Create instance of this class for specified client channel with default timeouts.
LeaseFactoryClient(Channel clientChannel, int leaseTimeout, int cancelTimeout)
Create instance of this class for the specified channel with specified timeouts.

Method Summary

void
cancelLease(Lease existingLease)
Cancel existing lease.
Address
getAddress()
Get address of this client in group.
Lease
newLease(Object leaseTarget, Object tenant, long requestedDuration, boolean isAbsolute)
Get new lease.
Lease
renewLease(Lease existingLease, long requestedDuration, boolean isAbsolute)
Renew existing lease.

Field Details

DEFAULT_CANCEL_TIMEOUT

public static final int DEFAULT_CANCEL_TIMEOUT

Field Value:
1000


DEFAULT_LEASE_TIMEOUT

public static final int DEFAULT_LEASE_TIMEOUT

Field Value:
10000


cancelTimeout

protected int cancelTimeout


clientAdapter

protected PullPushAdapter clientAdapter


clientChannel

protected Channel clientChannel


leaseTimeout

protected int leaseTimeout


log

protected Log log


pendingCancels

protected HashMap pendingCancels


pendingLeases

protected HashMap pendingLeases


pendingRenewals

protected HashMap pendingRenewals

Constructor Details

LeaseFactoryClient

public LeaseFactoryClient(Channel clientChannel)
Create instance of this class for specified client channel with default timeouts.


LeaseFactoryClient

public LeaseFactoryClient(Channel clientChannel,
                          int leaseTimeout,
                          int cancelTimeout)
Create instance of this class for the specified channel with specified timeouts.

Parameters:
clientChannel - channel that will be used for client-service communication.
leaseTimeout - timeout for "new lease" and "renew lease" requests.
cancelTimeout - timeout for "cancel lease" timeout.

Method Details

cancelLease

public void cancelLease(Lease existingLease)
            throws UnknownLeaseException
Cancel existing lease.
Specified by:
cancelLease in interface LeaseFactory


getAddress

public Address getAddress()
Get address of this client in group.


newLease

public Lease newLease(Object leaseTarget,
                      Object tenant,
                      long requestedDuration,
                      boolean isAbsolute)
            throws LeaseDeniedException
Get new lease.
Specified by:
newLease in interface LeaseFactory


renewLease

public Lease renewLease(Lease existingLease,
                        long requestedDuration,
                        boolean isAbsolute)
            throws LeaseDeniedException
Renew existing lease. This method is used to extend lease time, therefore existingLease must be valid.
Specified by:
renewLease in interface LeaseFactory


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