public class LeaseTimeSet<E> extends java.lang.Object implements ILeaseTimeSet<E>
Modifier and Type | Class and Description |
---|---|
class |
LeaseTimeSet.Checker
The checker for removing entries.
|
static class |
LeaseTimeSet.SynchronizedLeaseTimeCollection<E>
Synchronized lease time collection.
|
Modifier and Type | Field and Description |
---|---|
protected LeaseTimeSet.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<Tuple2<E,java.lang.Long>> |
removecmd
The cleaner.
|
protected IDelayRunner |
timer
The timer.
|
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).
|
Modifier | Constructor and Description |
---|---|
protected |
LeaseTimeSet()
Create a new lease time handling object.
|
protected |
LeaseTimeSet(ICommand<Tuple2<E,java.lang.Long>> removecmd)
Create a new lease time handling object.
|
protected |
LeaseTimeSet(long leasetime)
Create a new lease time handling object.
|
protected |
LeaseTimeSet(long leasetime,
ICommand<Tuple2<E,java.lang.Long>> removecmd)
Create a new lease time handling object.
|
|
LeaseTimeSet(long leasetime,
ICommand<Tuple2<E,java.lang.Long>> removecmd,
IDelayRunner timer)
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 proxies.
|
void |
clear() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
static <E> ILeaseTimeSet<E> |
createLeaseTimeCollection(long leasetime)
Create a lease time collection.
|
static <E> ILeaseTimeSet<E> |
createLeaseTimeCollection(long leasetime,
ICommand<Tuple2<E,java.lang.Long>> removecmd)
Create a lease time collection.
|
static <E> ILeaseTimeSet<E> |
createLeaseTimeCollection(long leasetime,
ICommand<Tuple2<E,java.lang.Long>> removecmd,
boolean passive,
IDelayRunner timer,
boolean sync,
java.lang.Object mutex)
Create a lease time collection.
|
static <E> ILeaseTimeSet<E> |
createLeaseTimeCollection(long leasetime,
ICommand<Tuple2<E,java.lang.Long>> removecmd,
java.lang.Object mutex)
Create a lease time collection.
|
void |
dispose()
Release all resources.
|
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.
|
java.lang.Long |
getLeaseTime(E entry)
Get the leasetime.
|
int |
hashCode()
Get the 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) |
void |
setRemoveCommand(ICommand<Tuple2<E,java.lang.Long>> cmd)
Set the remove cmd.
|
int |
size() |
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
java.lang.String |
toString()
Get the string representation.
|
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 IDelayRunner timer
protected long leasetime
protected LeaseTimeSet.Checker checker
protected LeaseTimeSet()
protected LeaseTimeSet(long leasetime)
protected LeaseTimeSet(ICommand<Tuple2<E,java.lang.Long>> removecmd)
protected LeaseTimeSet(long leasetime, ICommand<Tuple2<E,java.lang.Long>> removecmd)
public LeaseTimeSet(long leasetime, ICommand<Tuple2<E,java.lang.Long>> removecmd, IDelayRunner timer)
public static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime)
public static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime, ICommand<Tuple2<E,java.lang.Long>> removecmd)
public static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime, ICommand<Tuple2<E,java.lang.Long>> removecmd, java.lang.Object mutex)
public static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime, ICommand<Tuple2<E,java.lang.Long>> removecmd, boolean passive, IDelayRunner timer, boolean sync, java.lang.Object mutex)
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()
public java.lang.Runnable doWaitFor(long delay, java.lang.Runnable step)
protected long getClockTime()
public long getLeaseTime()
public java.lang.Long getLeaseTime(E entry)
public void dispose()
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)