PARENT_KEY
- A key type to NormalGroup which contains multiple slots and is
group-committed.CHILD_KEY
- A key type to slot in NormalGroup which can contain a value ready to commit.FULL_KEY
- A key type to DelayedGroup which contains a single slot and is
singly-committed.EMIT_PARENT_KEY
- A parent-key type that Emitter can interpret.EMIT_FULL_KEY
- A full-key type that Emitter can interpret.V
- A value type to be set to a slot.@ThreadSafe
public class GroupCommitter<PARENT_KEY,CHILD_KEY,FULL_KEY,EMIT_PARENT_KEY,EMIT_FULL_KEY,V>
extends java.lang.Object
implements java.io.Closeable
Constructor and Description |
---|
GroupCommitter(java.lang.String label,
GroupCommitConfig config,
GroupCommitKeyManipulator<PARENT_KEY,CHILD_KEY,FULL_KEY,EMIT_PARENT_KEY,EMIT_FULL_KEY> keyManipulator) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the resources.
|
void |
ready(FULL_KEY fullKey,
V value)
Marks the slot associated with the specified key READY and then, waits until the group which
contains the slot is emitted.
|
void |
remove(FULL_KEY fullKey)
Removes the slot from the group.
|
FULL_KEY |
reserve(CHILD_KEY childKey)
Reserves a new slot in the current
NormalGroup . |
void |
setEmitter(Emittable<EMIT_PARENT_KEY,EMIT_FULL_KEY,V> emitter)
Set an emitter which contains implementation to emit values.
|
public GroupCommitter(java.lang.String label, GroupCommitConfig config, GroupCommitKeyManipulator<PARENT_KEY,CHILD_KEY,FULL_KEY,EMIT_PARENT_KEY,EMIT_FULL_KEY> keyManipulator)
label
- A label used for thread name.config
- A configuration.keyManipulator
- A key manipulator that contains logics how to treat keys.public void setEmitter(Emittable<EMIT_PARENT_KEY,EMIT_FULL_KEY,V> emitter)
GroupCommitter
and Emittable
can be different. That's why this API exists.emitter
- An emitter.public FULL_KEY reserve(CHILD_KEY childKey)
NormalGroup
. The slot may be moved to a DelayedGroup
later.childKey
- A child key.public void ready(FULL_KEY fullKey, V value) throws GroupCommitException
fullKey
- A full key associated with the slot already reserved with reserve(CHILD_KEY)
.value
- A value to be set to the slot. It will be committed with other values contained in
slots of the same group.GroupCommitException
- when group commit failspublic void remove(FULL_KEY fullKey)
ready(FULL_KEY, V)
won't be called for it.fullKey
- A full key to specify the slot.public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable