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 |
clearAllDelta(java.nio.ByteBuffer context)
Remove all the delta of a context (i.e, set an empty header).
|
java.nio.ByteBuffer |
computeOldShardMerger(java.nio.ByteBuffer context,
java.util.List<CounterId.CounterIdRecord> oldIds,
long mergeBefore)
Compute a new context such that if applied to context yields the same
total but with old local counter ids nulified and there content merged to
the current localCounterId.
|
java.nio.ByteBuffer |
create(CounterId id,
long clock,
long value,
boolean isDelta) |
java.nio.ByteBuffer |
create(long value,
Allocator allocator)
Creates an initial counter context with an initial value for the local node.
|
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 |
markDeltaToBeCleared(java.nio.ByteBuffer context)
Mark context to delete delta 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.
|
java.nio.ByteBuffer |
removeOldShards(java.nio.ByteBuffer context,
int gcBefore)
Remove shards that have been canceled through computeOldShardMerger
since a time older than gcBefore.
|
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 create(long value, Allocator allocator)
value
- the value for this initial updateallocator
- public java.nio.ByteBuffer create(CounterId id, long clock, long value, boolean isDelta)
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 java.nio.ByteBuffer markDeltaToBeCleared(java.nio.ByteBuffer context)
context
- a counter contextpublic java.nio.ByteBuffer clearAllDelta(java.nio.ByteBuffer context)
context
- a counter contextcontext
where no count are a delta.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)
public java.nio.ByteBuffer computeOldShardMerger(java.nio.ByteBuffer context, java.util.List<CounterId.CounterIdRecord> oldIds, long mergeBefore)
public java.nio.ByteBuffer removeOldShards(java.nio.ByteBuffer context, int gcBefore)
Copyright © 2014 The Apache Software Foundation