public abstract class AbstractLease extends Object implements Lease, Serializable
Modifier and Type | Field and Description |
---|---|
protected long |
expiration
The lease expiration, in local absolute time.
|
protected int |
serialFormat
Serialization format for the expiration.
|
private static long |
serialVersionUID |
Modifier | Constructor and Description |
---|---|
protected |
AbstractLease(long expiration)
Construct a relative-format lease.
|
Modifier and Type | Method and Description |
---|---|
protected abstract long |
doRenew(long duration)
Renew the lease for a duration relative to now, and return
the duration actually granted.
|
long |
getExpiration()
Return the lease expiration.
|
int |
getSerialFormat()
Return the serialization format for the expiration.
|
private void |
readObject(ObjectInputStream stream)
If serialFormat is DURATION, add the current time to the expiration,
to make it absolute (and if the result of the addition is negative,
correct the overflow by resetting the expiration to Long.MAX_VALUE).
|
private void |
readObjectNoData()
Throws an
InvalidObjectException . |
void |
renew(long duration)
Renew the lease for a duration relative to now.
|
void |
setSerialFormat(int format)
Set the serialization format for the expiration.
|
private void |
writeObject(ObjectOutputStream stream) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canBatch, cancel, createLeaseMap
private static final long serialVersionUID
protected transient long expiration
protected int serialFormat
protected AbstractLease(long expiration)
public long getExpiration()
getExpiration
in interface Lease
long
that indicates the time that the
lease will expirepublic int getSerialFormat()
getSerialFormat
in interface Lease
Lease.setSerialFormat(int)
public void setSerialFormat(int format)
setSerialFormat
in interface Lease
format
- DURATION or ABSOLUTELease.getSerialFormat()
public void renew(long duration) throws UnknownLeaseException, LeaseDeniedException, RemoteException
renew
in interface Lease
duration
- the requested duration in millisecondsUnknownLeaseException
- the lease being renewed is unknown
to the lease grantorLeaseDeniedException
- the lease grantor is unable or
unwilling to renew the leaseRemoteException
protected abstract long doRenew(long duration) throws UnknownLeaseException, LeaseDeniedException, RemoteException
private void writeObject(ObjectOutputStream stream) throws IOException
IOException
private void readObjectNoData() throws InvalidObjectException
InvalidObjectException
.InvalidObjectException
- unconditionallyprivate void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException
InvalidObjectException
- if serialFormat is neither ABSOLUTE
nor DURATIONIOException
ClassNotFoundException
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.