Package org.jgroups.protocols
Class COUNTER
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.COUNTER
- All Implemented Interfaces:
Lifecycle
Protocol which is used by
CounterService to provide a distributed atomic counter- Since:
- 3.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static classstatic classprotected classprivate static classprotected static classprotected static classprotected static classprotected static classprotected static classprotected classprotected static interfaceprivate static classprotected static enumprotected static classprivate static classprivate static classprotected static enumprotected static classprotected static classprivate static classprivate static classCOUNTER.UpdateFunctionRequest<T extends Streamable>private static classCOUNTER.UpdateFunctionResponse<T extends Streamable>protected static classprivate static classCOUNTER.UpdateResult<T extends Streamable>protected static classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionBackup coordinators.protected booleanprotected AddressThe address of the cluster coordinator.protected final Map<String, COUNTER.VersionedValue> protected booleanSet to true during reconciliation process, will cause all requests to be discardedprotected intprotected final Map<Owner, COUNTER.RequestCompletableFuture<?>> protected COUNTER.ReconciliationTaskprotected Future<?> protected longprotected static final byteprivate static final AtomicLongprivate static final COUNTER.RequestType[]protected static final byteprivate static final COUNTER.ResponseType[]protected longprivate TPprotected ViewFields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, stack, stats, up_prot -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteCounter(String name) Sent asynchronously - we don't wait for an ackprivate CompletionStage<COUNTER.CounterImpl> doGetOrCreateCounter(String name, long initial_value) An event is to be sent down the stack.protected static Stringbooleanprotected COUNTER.VersionedValuegetCounter(String name) intgetOrCreateAsyncCounter(String name, long initial_value) getOrCreateCounter(String name, long initial_value) Deprecated.protected OwnergetOwner()getView()private voidhandleReconcileResponse(COUNTER.ReconcileResponse rsp, Address sender) protected voidhandleResponse(COUNTER.Response rsp, Address sender) protected voidhandleView(View view) voidinit()Called after a protocol has been created and before the protocol is started.private voidlogSending(Address dst, Object data) protected static long[]readReconciliationLongs(DataInput in, int len) protected static String[]readReconciliationNames(DataInput in, int len) protected static COUNTER.Requestprotected static ByteArrayprotected static COUNTER.Response<?> protected static ByteArrayresponseToBuffer(COUNTER.Response<?> rsp) protected voidprotected voidsendCounterNotFoundExceptionResponse(Address dest, Owner owner, String counter_name) protected voidsendRequest(Address dest, COUNTER.Request req) private <T> CompletableFuture<T> sendRequestToCoordinator(Owner owner, COUNTER.Request request) protected voidsendResponse(Address dest, COUNTER.Response<?> rsp) setBypassBundling(boolean bypass_bundling) setNumberOfBackups(int num_backups) private booleanprotected voidprotected voidprotected static ByteArraystreamableToBuffer(byte req_or_rsp, byte type, Streamable obj) private voidtraceResending(COUNTER.Request request) An event was received from the protocol below.A single message was received.protected voidupdateBackups(String name, long[] versionedValue) private <T> TupdateCounter(COUNTER.ResponseData<T> responseData) protected static voidwriteReconciliation(DataOutput out, String[] names, long[] values, long[] versions) Methods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, destroy, down, down, enableStats, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, policies, providedDownServices, providedUpServices, removePolicy, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, start, statsEnabled, stop, toString, up
-
Field Details
-
REQUEST_ID_GENERATOR
-
REQUEST_TYPES_CACHED
-
RESPONSE_TYPES_CACHED
-
bypass_bundling
protected boolean bypass_bundling -
timeout
protected long timeout -
reconciliation_timeout
protected long reconciliation_timeout -
num_backups
protected int num_backups -
discard_requests
protected boolean discard_requestsSet to true during reconciliation process, will cause all requests to be discarded -
view
-
coord
The address of the cluster coordinator. Updated on view changes -
backup_coords
Backup coordinators. Only created if num_backups > 0 and coord=true -
reconciliation_task_future
-
reconciliation_task
-
counters
-
pending_requests
-
REQUEST
protected static final byte REQUEST- See Also:
-
RESPONSE
protected static final byte RESPONSE- See Also:
-
transport
-
-
Constructor Details
-
COUNTER
public COUNTER()
-
-
Method Details
-
getBypassBundling
public boolean getBypassBundling() -
setBypassBundling
-
getNumberOfBackups
public int getNumberOfBackups() -
setNumberOfBackups
-
getView
-
getBackupCoords
-
init
Description copied from class:ProtocolCalled after a protocol has been created and before the protocol is started. Attributes are already set. Other protocols are not yet connected and events cannot yet be sent. -
getOrCreateCounter
Deprecated. -
getOrCreateAsyncCounter
-
doGetOrCreateCounter
-
deleteCounter
Sent asynchronously - we don't wait for an ack -
down
Description copied from class:ProtocolAn event is to be sent down the stack. A protocol may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the protocol may need to add a header to it (or do nothing at all) before sending it down the stack usingdown_prot.down(). -
up
Description copied from class:ProtocolAn event was received from the protocol below. Usually the current protocol will want to examine the event type and - depending on its type - perform some computation (e.g. removing headers from a MSG event type, or updating the internal membership list when receiving a VIEW_CHANGE event). Finally, the event is either a) discarded, or b) an event is sent down the stack usingdown_prot.down()or c) the event (or another event) is sent up the stack usingup_prot.up(). -
up
Description copied from class:ProtocolA single message was received. Protocols may examine the message and do something (e.g. add a header) with it before passing it up. -
getCounter
-
handleResponse
-
handleReconcileResponse
-
printCounters
-
dumpPendingRequests
-
handleView
-
getOwner
-
updateBackups
-
sendRequest
-
sendResponse
-
send
-
logSending
-
sendCounterNotFoundExceptionResponse
-
updateCounter
-
requestToBuffer
- Throws:
Exception
-
responseToBuffer
- Throws:
Exception
-
streamableToBuffer
protected static ByteArray streamableToBuffer(byte req_or_rsp, byte type, Streamable obj) throws Exception - Throws:
Exception
-
requestFromDataInput
- Throws:
Exception
-
responseFromDataInput
- Throws:
Exception
-
startReconciliationTask
protected void startReconciliationTask() -
stopReconciliationTask
protected void stopReconciliationTask() -
writeReconciliation
protected static void writeReconciliation(DataOutput out, String[] names, long[] values, long[] versions) throws IOException - Throws:
IOException
-
readReconciliationNames
- Throws:
IOException
-
readReconciliationLongs
- Throws:
IOException
-
dump
-
sendRequestToCoordinator
-
skipRequest
private boolean skipRequest() -
traceResending
-