public abstract class GridStreamerWindowAdapter<E> extends Object implements GridLifecycleAware, GridStreamerWindow<E>, GridStreamerWindowMBean
| Constructor and Description |
|---|
GridStreamerWindowAdapter() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
checkConfiguration()
Check window configuration.
|
void |
clearEvicted()
Clears all evicted entries.
|
E |
dequeue()
Dequeues last element from windows.
|
Collection<E> |
dequeue(int cnt)
Dequeues up to
cnt elements from window. |
protected abstract Collection<E> |
dequeue0(int cnt)
Dequeues up to cnt elements from window.
|
Collection<E> |
dequeueAll()
Dequeues all elements from window.
|
boolean |
enqueue(E... evts)
Adds events to window.
|
boolean |
enqueue(E evt)
Adds single event to window.
|
protected abstract boolean |
enqueue0(E evt)
Adds event to window.
|
boolean |
enqueueAll(Collection<E> evts)
Adds all events to window.
|
String |
getClassName()
Gets window class name.
|
int |
getEvictionQueueSize()
Gets estimate for window eviction queue size.
|
GridPredicate<Object> |
getFilter()
Gets optional event filter.
|
String |
getName()
Gets window name.
|
int |
getSize()
Gets current window size.
|
<K,V> GridStreamerIndex<E,K,V> |
index()
Gets default index, if default index is not configured then
IllegalArgumentException will be thrown. |
<K,V> GridStreamerIndex<E,K,V> |
index(String name)
Gets index by name, if not index with such name was configured then
IllegalArgumentException will be thrown. |
Collection<GridStreamerIndex<E,?,?>> |
indexes()
Gets all indexes configured for this window.
|
GridStreamerIndexProvider<E,?,?>[] |
indexProviders()
Get array of index providers.
|
Iterator<E> |
iterator() |
protected abstract GridStreamerWindowIterator<E> |
iterator0()
Returns an iterator over a set of elements of type T without check for iteration limit.
|
String |
name()
Gets window name.
|
E |
pollEvicted()
If window supports eviction, this method will return next evicted element.
|
Collection<E> |
pollEvicted(int cnt)
If window supports eviction, this method will return up to
cnt evicted elements. |
protected abstract Collection<E> |
pollEvicted0(int cnt)
If window supports eviction, this method will return up to cnt evicted elements.
|
Collection<E> |
pollEvictedAll()
If window supports eviction, this method will return all available evicted elements.
|
Collection<E> |
pollEvictedBatch()
If window supports batch eviction, this method will poll next evicted batch from window.
|
protected abstract Collection<E> |
pollEvictedBatch0()
If window supports batch eviction, this method will poll next evicted batch from window.
|
void |
reset()
Resets window.
|
protected abstract void |
reset0()
Reset routine.
|
void |
setFilter(GridPredicate<Object> filter)
Sets event filter.
|
void |
setIndexes(GridStreamerIndexProvider<E,?,?>... idxs)
Set indexes.
|
void |
setName(String name)
Sets window name.
|
Collection<E> |
snapshot(boolean includeEvicted)
Create window snapshot.
|
void |
start()
Starts grid component, called on grid start.
|
void |
stop()
Stops grid component, called on grid shutdown.
|
protected abstract void |
stop0()
Dispose window.
|
protected void |
updateIndexes(E evt,
boolean rmv)
Update indexes.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitevictionQueueSize, sizepublic String getClassName()
getClassName in interface GridStreamerWindowMBeanpublic int getSize()
getSize in interface GridStreamerWindowMBeanpublic int getEvictionQueueSize()
getEvictionQueueSize in interface GridStreamerWindowMBeanpublic String name()
name in interface GridStreamerWindow<E>public String getName()
getName in interface GridStreamerWindowMBeanprotected abstract GridStreamerWindowIterator<E> iterator0()
public boolean enqueue(E evt) throws GridException
enqueue in interface GridStreamerWindow<E>evt - Event to add.True if event was added.GridException - If index update failed.public boolean enqueue(E... evts) throws GridException
enqueue in interface GridStreamerWindow<E>evts - Events to add.GridException - If index update failed.public boolean enqueueAll(Collection<E> evts) throws GridException
enqueueAll in interface GridStreamerWindow<E>evts - Collection of events to add.True if all events were added, false if at
least 1 event was skipped.GridException - If index update failed.protected abstract boolean enqueue0(E evt)
evt - Event.True if event added.public E dequeue() throws GridException
null if window is empty.dequeue in interface GridStreamerWindow<E>GridException - If index update failed.public Collection<E> dequeueAll() throws GridException
dequeueAll in interface GridStreamerWindow<E>GridException - If index update failed.public Collection<E> dequeue(int cnt) throws GridException
cnt elements from window. If current window size is less than cnt,
will dequeue all elements from window.dequeue in interface GridStreamerWindow<E>cnt - Count to dequeue.GridException - If index update failed.protected abstract Collection<E> dequeue0(int cnt)
cnt - Count.public E pollEvicted() throws GridException
pollEvicted in interface GridStreamerWindow<E>null if eviction queue is empty or if
window does not support eviction.GridException - If index update failed.public Collection<E> pollEvictedAll() throws GridException
pollEvictedAll in interface GridStreamerWindow<E>GridException - If index update failed.public Collection<E> pollEvicted(int cnt) throws GridException
cnt evicted elements.pollEvicted in interface GridStreamerWindow<E>cnt - Number of elements to evict.GridException - If index update failed.protected abstract Collection<E> pollEvicted0(int cnt)
cnt - Count.public Collection<E> pollEvictedBatch() throws GridException
pollEvictedBatch in interface GridStreamerWindow<E>GridException - If index update failed.protected abstract Collection<E> pollEvictedBatch0()
public final void start()
throws GridException
start in interface GridLifecycleAwareGridException - If failed.public final void reset()
reset in interface GridStreamerWindow<E>protected abstract void checkConfiguration()
throws GridException
GridException - If failed.protected abstract void reset0()
public void stop()
stop in interface GridLifecycleAwareprotected abstract void stop0()
public Collection<E> snapshot(boolean includeEvicted)
snapshot in interface GridStreamerWindow<E>includeEvicted - Whether to include evicted entries or not.public void setName(String name)
name - Window name.@Nullable public GridPredicate<Object> getFilter()
public void setFilter(@Nullable GridPredicate<Object> filter)
filter - Event filter.public <K,V> GridStreamerIndex<E,K,V> index()
IllegalArgumentException will be thrown.index in interface GridStreamerWindow<E>K - Type of the index key.V - Type of the index value.public <K,V> GridStreamerIndex<E,K,V> index(@Nullable String name)
IllegalArgumentException will be thrown.index in interface GridStreamerWindow<E>K - Type of the index key.V - Type of the index value.name - Name of the index, if null then analogous to GridStreamerWindow.index().public Collection<GridStreamerIndex<E,?,?>> indexes()
indexes in interface GridStreamerWindow<E>public GridStreamerIndexProvider<E,?,?>[] indexProviders()
public void setIndexes(GridStreamerIndexProvider<E,?,?>... idxs) throws IllegalArgumentException
idxs - Indexes.IllegalArgumentException - If some index names are not unique.public void clearEvicted()
throws GridException
clearEvicted in interface GridStreamerWindow<E>GridException - If index update failed.protected void updateIndexes(E evt, boolean rmv) throws GridException
evt - Event.rmv - Remove flag.GridException - If index update failed.Copyright © 2014. All rights reserved.