use of org.agrona.DirectBuffer in project zeebe by zeebe-io.
the class DeploymentValidatedProcessor method updateState.
@Override
public void updateState(TypedEvent<DeploymentEvent> event) {
final long deploymentKey = event.getKey();
final DirectBuffer topicName = event.getValue().getTopicName();
pendingDeployments.put(deploymentKey, event.getPosition(), topicName);
timer.onDeploymentValidated(deploymentKey);
}
use of org.agrona.DirectBuffer in project zeebe by zeebe-io.
the class AddTaskSubscriptionHandler method handle.
@Override
public void handle(final ActorControl actor, final int partitionId, final DirectBuffer buffer, final BrokerEventMetadata eventMetada) {
final TaskSubscriptionRequest request = new TaskSubscriptionRequest();
request.wrap(cloneBuffer(buffer));
final long requestId = eventMetada.getRequestId();
final int requestStreamId = eventMetada.getRequestStreamId();
final TaskSubscription taskSubscription = new TaskSubscription(partitionId, request.getLockTaskType(), request.getLockDuration(), request.getLockOwner(), requestStreamId);
taskSubscription.setCredits(request.getCredits());
final ActorFuture<Void> future = manager.addSubscription(taskSubscription);
actor.runOnCompletion(future, ((aVoid, throwable) -> {
if (throwable == null) {
final long subscriberKey = taskSubscription.getSubscriberKey();
request.setSubscriberKey(subscriberKey);
sendResponse(actor, requestStreamId, requestId, request);
} else {
sendErrorResponse(actor, requestStreamId, requestId, "Cannot add task subscription. %s", throwable.getMessage());
}
}));
}
use of org.agrona.DirectBuffer in project zeebe by zeebe-io.
the class TaskExpireLockStreamProcessor method timeOutTasks.
private void timeOutTasks() {
final Iterator<Long2BytesZbMapEntry> iterator = expirationMap.iterator();
while (iterator.hasNext()) {
final Long2BytesZbMapEntry entry = iterator.next();
final DirectBuffer value = entry.getValue();
final long eventPosition = value.getLong(0);
final long lockExpirationTime = value.getLong(SIZE_OF_LONG);
if (lockExpired(lockExpirationTime)) {
// TODO: would be nicer to have a consumable channel for timed-out timers
// that we can stop consuming/yield on backpressure
final boolean success = streamWriter.tryWriteTaskEvent(eventPosition, TaskState.EXPIRE_LOCK);
if (!success) {
return;
}
}
}
}
use of org.agrona.DirectBuffer in project zeebe by zeebe-io.
the class ActivityInstanceMap method wrapActivityInstanceKey.
public ActivityInstanceMap wrapActivityInstanceKey(long key) {
final DirectBuffer result = map.get(key);
if (result != null) {
this.buffer.putBytes(0, result, 0, result.capacity());
}
this.isRead = result != null;
this.key = key;
return this;
}
use of org.agrona.DirectBuffer in project zeebe by zeebe-io.
the class PayloadCache method getPayload.
public DirectBuffer getPayload(long workflowInstanceKey) {
DirectBuffer payload = null;
final long position = map.get(workflowInstanceKey, -1L);
if (position > 0) {
payload = cache.get(position);
}
return payload == null ? WorkflowInstanceEvent.NO_PAYLOAD : payload;
}
Aggregations