public class LeaseTimeCollection<E>
extends java.lang.Object
implements java.util.Collection<E>
Modifier and Type | Class and Description |
---|---|
class |
LeaseTimeCollection.Checker |
Modifier and Type | Field and Description |
---|---|
protected LeaseTimeCollection.Checker |
checker
The current checker.
|
protected java.util.PriorityQueue<E> |
entries
The entries.
|
protected long |
leasetime
The leasetime.
|
static long |
NONE
Constant for no leasetime.
|
protected ICommand<E> |
removecmd
The cleaner.
|
protected java.util.Timer |
timer
The timer.
|
protected java.util.Map<E,java.lang.Long> |
times
The timestamps.
|
static long |
UNSET
Constant for unset leasetime (use global default otherwise no leasetime).
|
Constructor and Description |
---|
LeaseTimeCollection()
Create a new lease time handling object.
|
LeaseTimeCollection(ICommand<E> removecmd)
Create a new lease time handling object.
|
LeaseTimeCollection(long leasetime)
Create a new lease time handling object.
|
LeaseTimeCollection(long leasetime,
ICommand<E> removecmd)
Create a new lease time handling object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e) |
boolean |
add(E e,
long leasetime) |
boolean |
addAll(java.util.Collection<? extends E> c) |
void |
checkStale()
Start removing discovered proxies.
|
void |
clear() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
void |
dispose()
Release all resources.
|
protected java.lang.Runnable |
doWaitFor(long delay,
java.lang.Runnable step)
Overriden wait for to not use platform clock.
|
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() |
boolean |
isEmpty() |
java.util.Iterator<E> |
iterator() |
static void |
main(java.lang.String[] args)
Main for testing.
|
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c) |
boolean |
retainAll(java.util.Collection<?> c) |
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 java.util.Map<E,java.lang.Long> times
protected java.util.Timer timer
protected long leasetime
protected LeaseTimeCollection.Checker checker
public LeaseTimeCollection()
public LeaseTimeCollection(long leasetime)
public LeaseTimeCollection(ICommand<E> removecmd)
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)
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)
entry
- The entry.public boolean update(E e, long leasetime)
entry
- The entry.public void touch(E e)
entry
- The entry.public void touch(E e, long leasetime)
entry
- The entry.protected java.lang.Long getExpirationTime(long leasetime)
leasetime
- public void checkStale()
protected java.lang.Runnable doWaitFor(long delay, java.lang.Runnable step)
protected long getClockTime()
public long getLeaseTime()
public void dispose()
public static void main(java.lang.String[] args)