public class PassiveLeaseTimeSet<E> extends java.lang.Object implements ILeaseTimeSet<E>
Modifier and Type | Field and Description |
---|---|
protected java.util.PriorityQueue<E> |
entries
The entries.
|
protected long |
leasetime
The leasetime.
|
static long |
NONE
Constant for no leasetime.
|
protected ICommand<Tuple2<E,java.lang.Long>> |
removecmd
The cleaner.
|
protected java.util.Map<E,Tuple2<java.lang.Long,java.lang.Long>> |
times
The timestamps.
|
static long |
UNSET
Constant for unset leasetime (use global default otherwise no leasetime).
|
Constructor and Description |
---|
PassiveLeaseTimeSet()
Create a new lease time handling object.
|
PassiveLeaseTimeSet(ICommand<Tuple2<E,java.lang.Long>> removecmd)
Create a new lease time handling object.
|
PassiveLeaseTimeSet(long leasetime)
Create a new lease time handling object.
|
PassiveLeaseTimeSet(long leasetime,
ICommand<Tuple2<E,java.lang.Long>> removecmd)
Create a new lease time handling object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e) |
boolean |
add(E e,
long leasetime)
Add a new entry.
|
boolean |
addAll(java.util.Collection<? extends E> c) |
void |
checkStale()
Start removing discovered entries.
|
void |
clear() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
boolean |
equals(java.lang.Object o) |
protected long |
getClockTime()
Get the current time.
|
protected java.lang.Long |
getExpirationTime(long leasetime)
Get the expiration time.
|
long |
getLeaseTime()
Get the leasetime.
|
int |
hashCode()
Get the hashcode.
|
boolean |
isEmpty() |
java.util.Iterator<E> |
iterator() |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c) |
boolean |
retainAll(java.util.Collection<?> c) |
void |
setRemoveCommand(ICommand<Tuple2<E,java.lang.Long>> cmd)
Set the remove cmd.
|
int |
size() |
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
void |
touch(E e)
Update the timestamp of e.
|
void |
touch(E e,
long leasetime)
Update the timestamp of e.
|
boolean |
update(E e)
Add a new entry or update an existing entry.
|
boolean |
update(E e,
long leasetime)
Add a new entry or update an existing entry.
|
public static final long NONE
public static final long UNSET
protected java.util.PriorityQueue<E> entries
protected long leasetime
public PassiveLeaseTimeSet()
public PassiveLeaseTimeSet(long leasetime)
public PassiveLeaseTimeSet(ICommand<Tuple2<E,java.lang.Long>> removecmd)
public void setRemoveCommand(ICommand<Tuple2<E,java.lang.Long>> cmd)
setRemoveCommand
in interface ILeaseTimeSet<E>
public int size()
size
in interface java.util.Collection<E>
public boolean isEmpty()
isEmpty
in interface java.util.Collection<E>
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<E>
public java.util.Iterator<E> iterator()
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<E>
public <T> T[] toArray(T[] a)
toArray
in interface java.util.Collection<E>
public boolean add(E e, long leasetime)
ILeaseTimeSet
add
in interface ILeaseTimeSet<E>
e
- The entry.leasetime
- The leasetime.public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection<E>
public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<E>
public boolean addAll(java.util.Collection<? extends E> c)
addAll
in interface java.util.Collection<E>
public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<E>
public boolean retainAll(java.util.Collection<?> c)
retainAll
in interface java.util.Collection<E>
public void clear()
clear
in interface java.util.Collection<E>
public boolean equals(java.lang.Object o)
equals
in interface java.util.Collection<E>
equals
in class java.lang.Object
public int hashCode()
hashCode
in interface java.util.Collection<E>
hashCode
in class java.lang.Object
public boolean update(E e)
update
in interface ILeaseTimeSet<E>
entry
- The entry.public boolean update(E e, long leasetime)
update
in interface ILeaseTimeSet<E>
entry
- The entry.public void touch(E e)
touch
in interface ILeaseTimeSet<E>
entry
- The entry.public void touch(E e, long leasetime)
touch
in interface ILeaseTimeSet<E>
entry
- The entry.protected java.lang.Long getExpirationTime(long leasetime)
leasetime
- public void checkStale()
protected long getClockTime()
public long getLeaseTime()