Package jadex.commons.collection
Class LeaseTimeSet<E>
- java.lang.Object
- 
- jadex.commons.collection.LeaseTimeSet<E>
 
- 
- All Implemented Interfaces:
- ILeaseTimeSet<E>,- java.lang.Iterable<E>,- java.util.Collection<E>
 
 public class LeaseTimeSet<E> extends java.lang.Object implements ILeaseTimeSet<E> Collection that remove elements after a lease time automatically.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description classLeaseTimeSet.CheckerThe checker for removing entries.static classLeaseTimeSet.SynchronizedLeaseTimeCollection<E>Synchronized lease time collection.
 - 
Field SummaryFields Modifier and Type Field Description protected LeaseTimeSet.CheckercheckerThe current checker.protected java.util.PriorityQueue<E>entriesThe entries.protected longleasetimeThe leasetime.static longNONEConstant for no leasetime.protected ICommand<Tuple2<E,java.lang.Long>>removecmdThe cleaner.protected IDelayRunnertimerThe timer.protected java.util.Map<E,Tuple2<java.lang.Long,java.lang.Long>>timesThe timestamps.static longUNSETConstant for unset leasetime (use global default otherwise no leasetime).
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedLeaseTimeSet()Create a new lease time handling object.protectedLeaseTimeSet(long leasetime)Create a new lease time handling object.protectedLeaseTimeSet(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.protectedLeaseTimeSet(ICommand<Tuple2<E,java.lang.Long>> removecmd)Create a new lease time handling object.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E e)booleanadd(E e, long leasetime)Add a new entry.booleanaddAll(java.util.Collection<? extends E> c)voidcheckStale()Start removing discovered proxies.voidclear()booleancontains(java.lang.Object o)booleancontainsAll(java.util.Collection<?> c)static <E> ILeaseTimeSet<E>createLeaseTimeCollection(long leasetime)Create a lease time collection.static <E> ILeaseTimeSet<E>createLeaseTimeCollection(long leasetime, boolean passive, 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)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.voiddispose()Release all resources.java.lang.RunnabledoWaitFor(long delay, java.lang.Runnable step)Overriden wait for to not use platform clock.booleanequals(java.lang.Object o)protected longgetClockTime()Get the current time.protected java.lang.LonggetExpirationTime(long leasetime)Get the expiration time.longgetLeaseTime()Get the leasetime.java.lang.LonggetLeaseTime(E entry)Get the leasetime.inthashCode()Get the hashcode.booleanisEmpty()java.util.Iterator<E>iterator()static voidmain(java.lang.String[] args)Main for testing.booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection<?> c)booleanretainAll(java.util.Collection<?> c)voidsetRemoveCommand(ICommand<Tuple2<E,java.lang.Long>> cmd)Set the remove cmd.intsize()java.lang.Object[]toArray()<T> T[]toArray(T[] a)java.lang.StringtoString()Get the string representation.voidtouch(E e)Update the timestamp of e.voidtouch(E e, long leasetime)Update the timestamp of e.booleanupdate(E e)Add a new entry or update an existing entry.booleanupdate(E e, long leasetime)Add a new entry or update an existing entry.- 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
- 
 
- 
- 
- 
Field Detail- 
NONEpublic static final long NONE Constant for no leasetime.- See Also:
- Constant Field Values
 
 - 
UNSETpublic static final long UNSET Constant for unset leasetime (use global default otherwise no leasetime).- See Also:
- Constant Field Values
 
 - 
entriesprotected java.util.PriorityQueue<E> entries The entries.
 - 
timerprotected IDelayRunner timer The timer.
 - 
leasetimeprotected long leasetime The leasetime.
 - 
checkerprotected LeaseTimeSet.Checker checker The current checker.
 
- 
 - 
Constructor Detail- 
LeaseTimeSetprotected LeaseTimeSet() Create a new lease time handling object.
 - 
LeaseTimeSetprotected LeaseTimeSet(long leasetime) Create a new lease time handling object.
 - 
LeaseTimeSetprotected LeaseTimeSet(ICommand<Tuple2<E,java.lang.Long>> removecmd) Create a new lease time handling object.
 - 
LeaseTimeSetprotected LeaseTimeSet(long leasetime, ICommand<Tuple2<E,java.lang.Long>> removecmd)Create a new lease time handling object.
 - 
LeaseTimeSetpublic LeaseTimeSet(long leasetime, ICommand<Tuple2<E,java.lang.Long>> removecmd, IDelayRunner timer)Create a new lease time handling object.
 
- 
 - 
Method Detail- 
createLeaseTimeCollectionpublic static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime) Create a lease time collection.
 - 
createLeaseTimeCollectionpublic static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime, ICommand<Tuple2<E,java.lang.Long>> removecmd) Create a lease time collection.
 - 
createLeaseTimeCollectionpublic static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime, boolean passive, ICommand<Tuple2<E,java.lang.Long>> removecmd) Create a lease time collection.
 - 
createLeaseTimeCollectionpublic static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime, ICommand<Tuple2<E,java.lang.Long>> removecmd, java.lang.Object mutex) Create a lease time collection.
 - 
createLeaseTimeCollectionpublic 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.
 - 
setRemoveCommandpublic void setRemoveCommand(ICommand<Tuple2<E,java.lang.Long>> cmd) Set the remove cmd.- Specified by:
- setRemoveCommandin interface- ILeaseTimeSet<E>
 
 - 
sizepublic int size() - Specified by:
- sizein interface- java.util.Collection<E>
 
 - 
isEmptypublic boolean isEmpty() - Specified by:
- isEmptyin interface- java.util.Collection<E>
 
 - 
containspublic boolean contains(java.lang.Object o) - Specified by:
- containsin interface- java.util.Collection<E>
 
 - 
iteratorpublic java.util.Iterator<E> iterator() 
 - 
toArraypublic java.lang.Object[] toArray() - Specified by:
- toArrayin interface- java.util.Collection<E>
 
 - 
toArraypublic <T> T[] toArray(T[] a) - Specified by:
- toArrayin interface- java.util.Collection<E>
 
 - 
addpublic boolean add(E e, long leasetime) Description copied from interface:ILeaseTimeSetAdd a new entry.- Specified by:
- addin interface- ILeaseTimeSet<E>
- Parameters:
- e- The entry.
- leasetime- The leasetime.
- Returns:
- True, if new entry.
 
 - 
removepublic boolean remove(java.lang.Object o) - Specified by:
- removein interface- java.util.Collection<E>
 
 - 
containsAllpublic boolean containsAll(java.util.Collection<?> c) - Specified by:
- containsAllin interface- java.util.Collection<E>
 
 - 
addAllpublic boolean addAll(java.util.Collection<? extends E> c) - Specified by:
- addAllin interface- java.util.Collection<E>
 
 - 
removeAllpublic boolean removeAll(java.util.Collection<?> c) - Specified by:
- removeAllin interface- java.util.Collection<E>
 
 - 
retainAllpublic boolean retainAll(java.util.Collection<?> c) - Specified by:
- retainAllin interface- java.util.Collection<E>
 
 - 
clearpublic void clear() - Specified by:
- clearin interface- java.util.Collection<E>
 
 - 
equalspublic boolean equals(java.lang.Object o) - Specified by:
- equalsin interface- java.util.Collection<E>
- Overrides:
- equalsin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() Get the hashcode.- Specified by:
- hashCodein interface- java.util.Collection<E>
- Overrides:
- hashCodein class- java.lang.Object
 
 - 
updatepublic boolean update(E e) Add a new entry or update an existing entry.- Specified by:
- updatein interface- ILeaseTimeSet<E>
- Parameters:
- entry- The entry.
- Returns:
- True, if new entry.
 
 - 
updatepublic boolean update(E e, long leasetime) Add a new entry or update an existing entry.- Specified by:
- updatein interface- ILeaseTimeSet<E>
- Parameters:
- entry- The entry.
- Returns:
- True, if new entry.
 
 - 
touchpublic void touch(E e) Update the timestamp of e.- Specified by:
- touchin interface- ILeaseTimeSet<E>
- Parameters:
- entry- The entry.
 
 - 
touchpublic void touch(E e, long leasetime) Update the timestamp of e.- Specified by:
- touchin interface- ILeaseTimeSet<E>
- Parameters:
- entry- The entry.
 
 - 
getExpirationTimeprotected java.lang.Long getExpirationTime(long leasetime) Get the expiration time.- Parameters:
- leasetime-
- Returns:
 
 - 
checkStalepublic void checkStale() Start removing discovered proxies.
 - 
doWaitForpublic java.lang.Runnable doWaitFor(long delay, java.lang.Runnable step)Overriden wait for to not use platform clock.
 - 
getClockTimeprotected long getClockTime() Get the current time.
 - 
getLeaseTimepublic long getLeaseTime() Get the leasetime.
 - 
getLeaseTimepublic java.lang.Long getLeaseTime(E entry) Get the leasetime.
 - 
disposepublic void dispose() Release all resources.
 - 
toStringpublic java.lang.String toString() Get the string representation.- Overrides:
- toStringin class- java.lang.Object
 
 - 
mainpublic static void main(java.lang.String[] args) Main for testing.
 
- 
 
-