Package jadex.collection
Class LeaseTimeSet<E>
java.lang.Object
jadex.collection.LeaseTimeSet<E>
- All Implemented Interfaces:
ILeaseTimeSet<E>,Iterable<E>,Collection<E>
Collection that remove elements after a lease time automatically.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassThe checker for removing entries.static classSynchronized lease time collection. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LeaseTimeSet<E>.CheckerThe current checker.protected PriorityQueue<E> The entries.protected longThe leasetime.static final longConstant for no leasetime.The cleaner.protected IDelayRunnerThe timer.The timestamps.static final longConstant for unset leasetime (use global default otherwise no leasetime). -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreate a new lease time handling object.protectedLeaseTimeSet(long leasetime) Create a new lease time handling object.protectedLeaseTimeSet(long leasetime, Consumer<jadex.common.Tuple2<E, Long>> removecmd) Create a new lease time handling object.LeaseTimeSet(long leasetime, Consumer<jadex.common.Tuple2<E, Long>> removecmd, IDelayRunner timer) Create a new lease time handling object.protectedLeaseTimeSet(Consumer<jadex.common.Tuple2<E, Long>> removecmd) Create a new lease time handling object. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanAdd a new entry.booleanaddAll(Collection<? extends E> c) voidStart removing discovered proxies.voidclear()booleanbooleancontainsAll(Collection<?> c) static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime) Create a lease time collection.static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime, boolean passive, Consumer<jadex.common.Tuple2<E, Long>> removecmd) Create a lease time collection.static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime, Consumer<jadex.common.Tuple2<E, Long>> removecmd) Create a lease time collection.static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime, Consumer<jadex.common.Tuple2<E, Long>> removecmd, boolean passive, IDelayRunner timer, boolean sync, Object mutex) Create a lease time collection.static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime, Consumer<jadex.common.Tuple2<E, Long>> removecmd, Object mutex) Create a lease time collection.voiddispose()Release all resources.Overriden wait for to not use platform clock.booleanprotected longGet the current time.protected LonggetExpirationTime(long leasetime) Get the expiration time.longGet the leasetime.getLeaseTime(E entry) Get the leasetime.inthashCode()Get the hashcode.booleanisEmpty()iterator()static voidMain for testing.booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) voidsetRemoveCommand(Consumer<jadex.common.Tuple2<E, Long>> cmd) Set the remove cmd.intsize()Object[]toArray()<T> T[]toArray(T[] a) toString()Get the string representation.voidUpdate the timestamp of e.voidUpdate the timestamp of e.booleanAdd a new entry or update an existing entry.booleanAdd a new entry or update an existing entry.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
NONE
public static final long NONEConstant for no leasetime.- See Also:
-
UNSET
public static final long UNSETConstant for unset leasetime (use global default otherwise no leasetime).- See Also:
-
entries
The entries. -
times
The timestamps. -
timer
The timer. -
leasetime
protected long leasetimeThe leasetime. -
checker
The current checker. -
removecmd
The cleaner.
-
-
Constructor Details
-
LeaseTimeSet
protected LeaseTimeSet()Create a new lease time handling object. -
LeaseTimeSet
protected LeaseTimeSet(long leasetime) Create a new lease time handling object. -
LeaseTimeSet
Create a new lease time handling object. -
LeaseTimeSet
Create a new lease time handling object. -
LeaseTimeSet
public LeaseTimeSet(long leasetime, Consumer<jadex.common.Tuple2<E, Long>> removecmd, IDelayRunner timer) Create a new lease time handling object.
-
-
Method Details
-
createLeaseTimeCollection
Create a lease time collection. -
createLeaseTimeCollection
public static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime, Consumer<jadex.common.Tuple2<E, Long>> removecmd) Create a lease time collection. -
createLeaseTimeCollection
public static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime, boolean passive, Consumer<jadex.common.Tuple2<E, Long>> removecmd) Create a lease time collection. -
createLeaseTimeCollection
public static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime, Consumer<jadex.common.Tuple2<E, Long>> removecmd, Object mutex) Create a lease time collection. -
createLeaseTimeCollection
public static <E> ILeaseTimeSet<E> createLeaseTimeCollection(long leasetime, Consumer<jadex.common.Tuple2<E, Long>> removecmd, boolean passive, IDelayRunner timer, boolean sync, Object mutex) Create a lease time collection. -
setRemoveCommand
Set the remove cmd.- Specified by:
setRemoveCommandin interfaceILeaseTimeSet<E>
-
size
public int size()- Specified by:
sizein interfaceCollection<E>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<E>
-
contains
- Specified by:
containsin interfaceCollection<E>
-
iterator
-
toArray
- Specified by:
toArrayin interfaceCollection<E>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<E>
-
add
- Specified by:
addin interfaceCollection<E>
-
add
Description copied from interface:ILeaseTimeSetAdd a new entry.- Specified by:
addin interfaceILeaseTimeSet<E>- Parameters:
e- The entry.leasetime- The leasetime.- Returns:
- True, if new entry.
-
remove
- Specified by:
removein interfaceCollection<E>
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>
-
addAll
- Specified by:
addAllin interfaceCollection<E>
-
removeAll
- Specified by:
removeAllin interfaceCollection<E>
-
retainAll
- Specified by:
retainAllin interfaceCollection<E>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E>
-
equals
- Specified by:
equalsin interfaceCollection<E>- Overrides:
equalsin classObject
-
hashCode
public int hashCode()Get the hashcode.- Specified by:
hashCodein interfaceCollection<E>- Overrides:
hashCodein classObject
-
update
Add a new entry or update an existing entry.- Specified by:
updatein interfaceILeaseTimeSet<E>- Parameters:
entry- The entry.- Returns:
- True, if new entry.
-
update
Add a new entry or update an existing entry.- Specified by:
updatein interfaceILeaseTimeSet<E>- Parameters:
entry- The entry.- Returns:
- True, if new entry.
-
touch
Update the timestamp of e.- Specified by:
touchin interfaceILeaseTimeSet<E>- Parameters:
entry- The entry.
-
touch
Update the timestamp of e.- Specified by:
touchin interfaceILeaseTimeSet<E>- Parameters:
entry- The entry.
-
getExpirationTime
Get the expiration time.- Parameters:
leasetime-- Returns:
-
checkStale
public void checkStale()Start removing discovered proxies. -
doWaitFor
Overriden wait for to not use platform clock. -
getClockTime
protected long getClockTime()Get the current time. -
getLeaseTime
public long getLeaseTime()Get the leasetime. -
getLeaseTime
Get the leasetime. -
dispose
public void dispose()Release all resources. -
toString
Get the string representation. -
main
Main for testing.
-