public class CounterContext extends java.lang.Object implements IContext
Modifier and Type | Class and Description |
---|---|
static class |
CounterContext.ContextState
Helper class to work on contexts (works by iterating over them).
|
IContext.ContextRelationship
Constructor and Description |
---|
CounterContext() |
Modifier and Type | Method and Description |
---|---|
java.nio.ByteBuffer |
clearAllLocal(java.nio.ByteBuffer context)
Remove all the local of a context (but keep global).
|
java.nio.ByteBuffer |
createLocal(long count,
Allocator allocator)
Creates a counter context with a single local shard.
|
java.nio.ByteBuffer |
createRemote(CounterId id,
long clock,
long count,
Allocator allocator)
Creates a counter context with a single remote shard.
|
IContext.ContextRelationship |
diff(java.nio.ByteBuffer left,
java.nio.ByteBuffer right)
Determine the count relationship between two contexts.
|
boolean |
hasCounterId(java.nio.ByteBuffer context,
CounterId id)
Checks whether the provided context has a count for the provided
CounterId.
|
static CounterContext |
instance() |
java.nio.ByteBuffer |
markLocalToBeCleared(java.nio.ByteBuffer context)
Mark context to delete local references afterward.
|
java.nio.ByteBuffer |
merge(java.nio.ByteBuffer left,
java.nio.ByteBuffer right,
Allocator allocator)
Return a context w/ an aggregated count for each counter id.
|
boolean |
shouldClearLocal(java.nio.ByteBuffer context) |
java.lang.String |
toString(java.nio.ByteBuffer context)
Human-readable String from context.
|
long |
total(java.nio.ByteBuffer context)
Returns the aggregated count across all counter ids.
|
void |
updateDigest(java.security.MessageDigest message,
java.nio.ByteBuffer context)
Update a MessageDigest with the content of a context.
|
void |
validateContext(java.nio.ByteBuffer context) |
public static CounterContext instance()
public java.nio.ByteBuffer createLocal(long count, Allocator allocator)
public java.nio.ByteBuffer createRemote(CounterId id, long clock, long count, Allocator allocator)
public IContext.ContextRelationship diff(java.nio.ByteBuffer left, java.nio.ByteBuffer right)
public java.nio.ByteBuffer merge(java.nio.ByteBuffer left, java.nio.ByteBuffer right, Allocator allocator)
public java.lang.String toString(java.nio.ByteBuffer context)
public long total(java.nio.ByteBuffer context)
context
- a counter contextcontext
public boolean shouldClearLocal(java.nio.ByteBuffer context)
public java.nio.ByteBuffer markLocalToBeCleared(java.nio.ByteBuffer context)
context
- a counter contextpublic java.nio.ByteBuffer clearAllLocal(java.nio.ByteBuffer context)
context
- a counter contextcontext
where no shards are local.public void validateContext(java.nio.ByteBuffer context) throws MarshalException
MarshalException
public void updateDigest(java.security.MessageDigest message, java.nio.ByteBuffer context)
public boolean hasCounterId(java.nio.ByteBuffer context, CounterId id)
Copyright © 2014 The Apache Software Foundation