public class Dispatcher extends Actor implements AutoCloseable
| Modifier and Type | Field and Description |
|---|---|
protected String[] |
defaultSubscriptionNames |
protected boolean |
isClosed |
protected LogBufferAppender |
logAppender |
protected LogBuffer |
logBuffer |
protected int |
logWindowLength |
protected int |
maxFrameLength |
protected MetricsManager |
metricsManager |
protected int |
mode |
static int |
MODE_PIPELINE |
static int |
MODE_PUB_SUB |
protected String |
name |
protected int |
partitionSize |
protected AtomicPosition |
publisherLimit |
protected AtomicPosition |
publisherPosition |
protected Subscription[] |
subscriptions |
| Constructor and Description |
|---|
Dispatcher(LogBuffer logBuffer,
LogBufferAppender logAppender,
AtomicPosition publisherLimit,
AtomicPosition publisherPosition,
int logWindowLength,
String[] subscriptionNames,
int mode,
String name,
MetricsManager metricsManager) |
| Modifier and Type | Method and Description |
|---|---|
long |
claim(ClaimedFragmentBatch batch,
int fragmentCount,
int batchLength)
Claim a batch of fragments on the buffer with the given length.
|
long |
claim(ClaimedFragment claim,
int length)
Claim a fragment of the buffer with the given length.
|
long |
claim(ClaimedFragment claim,
int length,
int streamId)
Claim a fragment of the buffer with the given length and stream id.
|
void |
close() |
ActorFuture<Void> |
closeAsync() |
void |
closeSubscription(Subscription subscriptionToClose)
Close the given subscription.
|
ActorFuture<Void> |
closeSubscriptionAsync(Subscription subscriptionToClose)
Close the given subscription asynchronously.
|
protected AtomicPosition |
determineLimit(int subscriptionId) |
protected void |
doCloseSubscription(Subscription subscriptionToClose) |
protected Subscription |
doOpenSubscription(String subscriptionName,
ActorCondition onConsumption) |
protected void |
ensureUniqueSubscriptionName(String subscriptionName) |
protected Subscription |
findSubscriptionByName(String subscriptionName) |
LogBuffer |
getLogBuffer() |
int |
getMaxFrameLength() |
String |
getName() |
long |
getPublisherLimit() |
long |
getPublisherPosition() |
int |
getSubscriberCount() |
Subscription |
getSubscription(String subscriptionName) |
ActorFuture<Subscription> |
getSubscriptionAsync(String subscriptionName) |
boolean |
isClosed() |
protected Subscription |
newSubscription(int subscriptionId,
String subscriptionName,
ActorCondition onConsumption) |
long |
offer(org.agrona.DirectBuffer msg)
Writes the given message to the buffer.
|
long |
offer(org.agrona.DirectBuffer msg,
int streamId)
Writes the given message to the buffer with the given stream id.
|
long |
offer(org.agrona.DirectBuffer msg,
int start,
int length)
Writes the given part of the message to the buffer.
|
long |
offer(org.agrona.DirectBuffer msg,
int start,
int length,
int streamId)
Writes the given part of the message to the buffer with the given stream id.
|
protected void |
onActorClosing() |
protected void |
onActorStarted() |
protected void |
openDefaultSubscriptions() |
Subscription |
openSubscription(String subscriptionName)
Creates a new subscription with the given name.
|
ActorFuture<Subscription> |
openSubscriptionAsync(String subscriptionName)
Creates a new subscription with the given name asynchronously.
|
String |
toString() |
int |
updatePublisherLimit() |
protected long |
updatePublisherPosition(int activePartitionId,
int newOffset) |
onActorClosed, onActorCloseRequested, onActorStarting, wrappublic static final int MODE_PUB_SUB
public static final int MODE_PIPELINE
protected final LogBuffer logBuffer
protected final LogBufferAppender logAppender
protected final MetricsManager metricsManager
protected final AtomicPosition publisherLimit
protected final AtomicPosition publisherPosition
protected final String[] defaultSubscriptionNames
protected Subscription[] subscriptions
protected final int maxFrameLength
protected final int partitionSize
protected int logWindowLength
protected final String name
protected final int mode
protected volatile boolean isClosed
public Dispatcher(LogBuffer logBuffer, LogBufferAppender logAppender, AtomicPosition publisherLimit, AtomicPosition publisherPosition, int logWindowLength, String[] subscriptionNames, int mode, String name, MetricsManager metricsManager)
protected void onActorStarted()
onActorStarted in class Actorprotected void onActorClosing()
onActorClosing in class Actorprotected void openDefaultSubscriptions()
public long offer(org.agrona.DirectBuffer msg)
public long offer(org.agrona.DirectBuffer msg,
int streamId)
public long offer(org.agrona.DirectBuffer msg,
int start,
int length)
public long offer(org.agrona.DirectBuffer msg,
int start,
int length,
int streamId)
public long claim(ClaimedFragment claim, int length)
ClaimedFragment.getBuffer()
to write the message and finish the operation using ClaimedFragment.commit() or ClaimedFragment.abort(). Note that the claim operation can fail if the publisher limit or the
buffer partition size is reached.public long claim(ClaimedFragment claim, int length, int streamId)
ClaimedFragment.getBuffer() to write the message and finish the operation using ClaimedFragment.commit() or ClaimedFragment.abort(). Note that the claim operation can
fail if the publisher limit or the buffer partition size is reached.public long claim(ClaimedFragmentBatch batch, int fragmentCount, int batchLength)
#nextFragment(int,
int) to add a new fragment to the batch. Write the fragment message using #getBuffer()
and #getFragmentOffset() to get the buffer offset of this fragment. Complete the whole
batch operation by calling either #commit() or #abort(). Note that the claim
operation can fail if the publisher limit or the buffer partition size is reached.protected long updatePublisherPosition(int activePartitionId,
int newOffset)
public int updatePublisherLimit()
public Subscription openSubscription(String subscriptionName)
IllegalStateException - public ActorFuture<Subscription> openSubscriptionAsync(String subscriptionName)
public ActorFuture<Subscription> getSubscriptionAsync(String subscriptionName)
public Subscription getSubscription(String subscriptionName)
protected Subscription doOpenSubscription(String subscriptionName, ActorCondition onConsumption)
protected void ensureUniqueSubscriptionName(String subscriptionName)
protected Subscription newSubscription(int subscriptionId, String subscriptionName, ActorCondition onConsumption)
protected AtomicPosition determineLimit(int subscriptionId)
public void closeSubscription(Subscription subscriptionToClose)
IllegalStateException - if the dispatcher runs in pipeline-mode.public ActorFuture<Void> closeSubscriptionAsync(Subscription subscriptionToClose)
protected void doCloseSubscription(Subscription subscriptionToClose)
protected Subscription findSubscriptionByName(String subscriptionName)
public boolean isClosed()
public void close()
close in interface AutoCloseablepublic ActorFuture<Void> closeAsync()
public LogBuffer getLogBuffer()
public int getMaxFrameLength()
public long getPublisherPosition()
public long getPublisherLimit()
public int getSubscriberCount()
Copyright © 2017–2018 camunda services GmbH. All rights reserved.