E
- the element typepublic class OortList<E> extends OortContainer<List<E>>
A specialized oort object whose entity is a List
.
OortList
specializes OortObject
and allows optimized replication of elements
across the cluster: instead of replicating the whole list, that may be contain a lot of elements,
only elements that are added or removed are replicated.
Applications can use #addAndShare(Result, Object[])
and #removeAndShare(Result, Object[])
to broadcast changes related to elements, as well as OortObject.setAndShare(Object, Result)
to
change the whole list.
When one or more elements are changed, OortList.ElementListener
s are notified.
OortList.DeltaListener
converts whole list updates triggered by OortObject.setAndShare(Object, Result)
into events for OortList.ElementListener
s, giving applications a single listener type to implement
their business logic.
Modifier and Type | Class and Description |
---|---|
static class |
OortList.DeltaListener<E>
An implementation of
Listener that converts whole list events into OortList.ElementListener events. |
static interface |
OortList.ElementListener<E>
Listener for element events that update the entity list, either locally or remotely.
|
OortObject.Data<T>, OortObject.Factory<T>, OortObject.Info<T>, OortObject.Listener<T>, OortObject.Merger<T,R>, OortObject.Result<R>
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
ConfigurableServerChannel.Initializer.Persistent
Oort.CometListener.Event
OORT_OBJECTS_CHANNEL
Constructor and Description |
---|
OortList(Oort oort,
String name,
OortObject.Factory<List<E>> factory) |
Modifier and Type | Method and Description |
---|---|
void |
addAndShare(OortObject.Result<Boolean> callback,
E... elements)
Adds the given
elements to the local entity list,
and then broadcasts the addition to all nodes in the cluster. |
void |
addElementListener(OortList.ElementListener<E> listener) |
boolean |
contains(E element)
Returns whether the given
element is present in the local entity list of this node. |
protected boolean |
isItemUpdate(Map<String,Object> data) |
boolean |
isPresent(E element)
Returns whether the given
element is present in one of the entity lists of all nodes. |
protected void |
onItem(OortObject.Info<List<E>> info,
Map<String,Object> data) |
void |
removeAndShare(OortObject.Result<Boolean> callback,
E... elements)
Removes the given
elements to the local entity list,
and then broadcasts the removal to all nodes in the cluster. |
void |
removeElementListener(OortList.ElementListener<E> listener) |
void |
removeElementListeners() |
cometLeft, doStop, onObject
addListener, cometJoined, configureChannel, deserialize, doStart, dump, getChannelName, getFactory, getInfo, getInfoByObject, getInfos, getLocalSession, getName, getOort, iterator, merge, newInfo, notifyRemoved, notifyUpdated, pullInfo, pushInfo, removeListener, removeListeners, serialize, setAndShare, toString
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public OortList(Oort oort, String name, OortObject.Factory<List<E>> factory)
public void addElementListener(OortList.ElementListener<E> listener)
public void removeElementListener(OortList.ElementListener<E> listener)
public void removeElementListeners()
public boolean contains(E element)
element
is present in the local entity list of this node.
Differently from isPresent(Object)
, only the local entity list is scanned.element
- the element to test for presenceelement
is contained in the local entity list, false otherwisepublic boolean isPresent(E element)
element
is present in one of the entity lists of all nodes.
Differently from contains(Object)
entity lists of all nodes are scanned.element
- the element to test for presenceelement
is contained in one of the entity lists of all nodes, false otherwisepublic void addAndShare(OortObject.Result<Boolean> callback, E... elements)
Adds the given elements
to the local entity list,
and then broadcasts the addition to all nodes in the cluster.
Calling this method triggers notifications OortList.ElementListener
s,
both on this node and on remote nodes.
The element is guaranteed to be added not when this method returns,
but when the Result
parameter is notified.
callback
- the callback invoked with whether at least one of the elements was added to the local entity list
or null
if there is no interest in knowing whether elements were addedelements
- the elements to addpublic void removeAndShare(OortObject.Result<Boolean> callback, E... elements)
Removes the given elements
to the local entity list,
and then broadcasts the removal to all nodes in the cluster.
Calling this method triggers notifications OortList.ElementListener
s,
both on this node and on remote nodes.
The element is guaranteed to be removed not when this method returns,
but when the Result
parameter is notified.
callback
- the callback invoked with whether at least one of the elements was removed to the local entity list
or null
if there is no interest in knowing whether elements were removedelements
- the elements to removeprotected boolean isItemUpdate(Map<String,Object> data)
isItemUpdate
in class OortContainer<List<E>>
protected void onItem(OortObject.Info<List<E>> info, Map<String,Object> data)
onItem
in class OortContainer<List<E>>
Copyright © 2008–2024 The CometD Project. All rights reserved.