Overview | Package | Class | Use | Tree | Deprecated | Index | Help
|  | BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## weblogic.cluster.singleton
Class LeaseManager

    java.lang.Object
      weblogic.cluster.singleton.LeaseManager

All Implemented Interfaces:
  Leasing, weblogic.timers.NakedTimerListener, weblogic.timers.TimerListener

    public class LeaseManager

extends Object
implements Leasing, weblogic.timers.NakedTimerListener

Implementation of the `Leasing` interface.

Field Summary
`static String` | `DELIMITER`

Constructor Summary
`LeaseManager(LeasingBasis basis, int heartbeatPeriod, int healthCheckPeriod, int gracePeriod, String leaseType)` Create a new `LeaseManager`.

Method Summary
`void` | `acquire(String leaseName, LeaseObtainedListener listener)` Registers interest in claiming ownership of a lease for this server whenever it becomes available.
`void` | `addLeaseLostListener(LeaseLostListener listener)` Add a LeaseLostListener.
`String[]` | `findExpiredLeases()` Returns a list of the servers that have consistently missed sending heartbeats in a timely manner, AND have gone past their grace period.
`String` | `findOwner(String leaseName)` Returns the identity of the server that currently owns the lease.
`String` | `findPreviousOwner(String leaseName)`
`int` | `getGracePeriod()`
`static String` | `getOwnerIdentity(weblogic.protocol.ServerIdentity id)`
`static String` | `getServerNameFromOwnerIdentity(String ownerIdentity)`
`void` | `release(String leaseName)` If the lease is owned by this server, attempts to give up ownership.
`void` | `removeLeaseLostListener(LeaseLostListener listener)` Remove a LeaseLostListener.
`void` | `start()`
`void` | `stop()` During shutdown operation, LeaseManager should give up his leases so that some other server in the cluster can take over the role.
`void` | `timerExpired(weblogic.timers.Timer timer)` Regularly called by the timer service.
`boolean` | `tryAcquire(String leaseName)` Attempts to claim immediate ownership of a lease for this server.
`void` | `voidLeases()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DELIMITER

    public static final String DELIMITER

See Also:
  Constant Field Values

Constructor Detail

### LeaseManager

    public LeaseManager(LeasingBasis basis,
                        int heartbeatPeriod,
                        int healthCheckPeriod,
                        int gracePeriod,
                        String leaseType)

  Create a new `LeaseManager`.

  Parameters:
    `basis` - The underlying implementation of Leasing.
    `heartbeatPeriod` - The rate at which heartbeats are sent in ms
    `healthCheckPeriod` - If a server is unable to send a heartbeat within the healthCheckPeriod in ms, it must take corrective action.
    `gracePeriod` - How long to wait, in ms, after the last time the previous owner has successfully sent a heartbeat before it is permissible migrate a server based on that lease.
    `leaseType` - the type of the lease, in the form of a unique string. For example, 'singletonService', 'server', 'timer', 'ejbtimer', etc. All leases of a particular type should have the same leaseType.

Method Detail

### tryAcquire

    public boolean tryAcquire(String leaseName)
                       throws LeasingException

  Attempts to claim immediate ownership of a lease for this server. Returns true if the lease was successfully claimed or if it is already owned by the server. Returns false if the lease is owned by another server. Throws a LeasingException if this server is already waiting to get the lease (through lease()) or if there were infrastructure problems trying to get ownership.

  Specified by:
    `tryAcquire` in interface `Leasing`
  Throws:
    `LeasingException` - if this server is already waiting to get the lease (through `Leasing.acquire(java.lang.String, weblogic.cluster.singleton.LeaseObtainedListener)`) or if there were infrastructure problems trying to get ownership.

### acquire

    public void acquire(String leaseName,
                        LeaseObtainedListener listener)
                 throws LeasingException

  Registers interest in claiming ownership of a lease for this server whenever it becomes available. Notification of successful claiming of the lease is provided through the LeaseObtainedListener. Notification occurs (again) if the lease is already owned by this server. Throws a LeasingException if this server is already waiting to get the lease (through a previous call to lease()). Does NOT throw an exception if there were infrastructure problems trying to get ownership.

  Specified by:
    `acquire` in interface `Leasing`
  Throws:
    `LeasingException` - if this server is already waiting to get the lease (through a previous call to lease()). Will callback via `LeaseObtainedListener` with an exception if there are infrastructure problems obtaining the lease. This callback will NOT cancel the interest in claiming ownership. The leaser must do so themselves via release.

### release

    public void release(String leaseName)
                 throws LeasingException

  If the lease is owned by this server, attempts to give up ownership. If this server is waiting to get the lease (through lease()), cancels the registration. Otherwise does nothing. Throws a LeasingException if infrastructure problems make it impossible to access the lease.

  Specified by:
    `release` in interface `Leasing`
  Throws:
    `LeasingException` - if infrastructure problems make it impossible to access the lease.

### findOwner

    public String findOwner(String leaseName)
                     throws LeasingException

  Returns the identity of the server that currently owns the lease. Returns null if the lease is not owned. The lease is not considered to be owned if it has been claimed by a server that has missed heartbeats. This is a best-effort result in that the answer may change after the value is returned. Throws a LeasingException if infrastructure problems make it impossible to determine who owns the lease.

  Specified by:
    `findOwner` in interface `Leasing`
  Throws:
    `LeasingException` - if infrastructure problems make it impossible to determine who owns the lease.

### findPreviousOwner

    public String findPreviousOwner(String leaseName)
                             throws LeasingException

  Throws:
    `LeasingException`

### getOwnerIdentity

    public static String getOwnerIdentity(weblogic.protocol.ServerIdentity id)

### getServerNameFromOwnerIdentity

    public static String getServerNameFromOwnerIdentity(String ownerIdentity)

### addLeaseLostListener

    public void addLeaseLostListener(LeaseLostListener listener)

  Add a LeaseLostListener. Called back if the local server ever misses sending a heartbeat in a timely manner.

  Specified by:
    `addLeaseLostListener` in interface `Leasing`

### removeLeaseLostListener

    public void removeLeaseLostListener(LeaseLostListener listener)

  Remove a LeaseLostListener.

  Specified by:
    `removeLeaseLostListener` in interface `Leasing`

### getGracePeriod

    public int getGracePeriod()

### findExpiredLeases

    public String[] findExpiredLeases()

  Returns a list of the servers that have consistently missed sending heartbeats in a timely manner, AND have gone past their grace period. Will only return the leases associated with this LeaseManager's Lease Type.

  Leasing services also include a method `LeaseManager.findExpiredLeases()` that returns a list of all servers in the cluster that have consistently missed sending heartbeats in a timely manner. INVARIANT: If a server stops heartbeating PERMANENTLY, then it will EVENTUALLY be returned in this list, although there is no guarantee as to how long that will take. This method might be used by a centralized control process, such as a Cluster Master, to migrate failed servers.

### stop

    public void stop()

  During shutdown operation, LeaseManager should give up his leases so that some other server in the cluster can take over the role.

### start

    public void start()

### voidLeases

    public void voidLeases()

### timerExpired

    public void timerExpired(weblogic.timers.Timer timer)

  Regularly called by the timer service. Attempts to send a heartbeat to prove the health of the server. If a heartbeat was missed, calls back any registered leaseLostListeners. Checks whether any leases that this server is waiting to obtain have become available.

  Specified by:
    `timerExpired` in interface `weblogic.timers.TimerListener`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Documentation is available at http://e-docs.bea.com/wls/docs92 Copyright 2006 BEA Systems Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD