Class OortLong

All Implemented Interfaces:

public class OortLong extends org.eclipse.jetty.util.component.AbstractLifeCycle

A shared atomic long made of an internal AtomicLong and of an internal OortObject<Long>.

This class exposes an API similar to that of AtomicLong, and for every successful update of the local value of the internal AtomicLong, it broadcast the local value via the internal OortObject to other nodes.

This class can be seen as the counterpart of OortPrimaryLong.

Where the OortPrimaryLong instance in each node has an internal AtomicLong, but only the one in the "primary" node has a non-zero value, the instance of this class in each node has an internal AtomicLong that has its own value.

Where in OortPrimaryLong updates are always sent to the "primary" node, in this class updates are always local, and then broadcast to the other nodes in the cluster.

Where in OortPrimaryLong each node has to send a message to the "primary" node to retrieve the total value, in this class the total value can be obtained from the internal OortObject without network communication with other nodes.

Where OortPrimaryLong trades less memory (one long per node) for larger latencies (every operation on non-primary nodes requires sending a message to the primary node), this class trades more memory (N longs per node - where N is the number of nodes) for smaller latencies (operations do not require messaging).

See Also: