Search in sources :

Example 16 with DirectBuffer

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);
}
Also used : DirectBuffer(org.agrona.DirectBuffer)

Example 17 with DirectBuffer

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());
        }
    }));
}
Also used : TaskSubscriptionRequest(io.zeebe.broker.task.processor.TaskSubscriptionRequest) ActorControl(io.zeebe.util.sched.ActorControl) ActorFuture(io.zeebe.util.sched.future.ActorFuture) BrokerEventMetadata(io.zeebe.protocol.impl.BrokerEventMetadata) TaskSubscription(io.zeebe.broker.task.processor.TaskSubscription) ControlMessageType(io.zeebe.protocol.clientapi.ControlMessageType) TaskSubscriptionManager(io.zeebe.broker.task.TaskSubscriptionManager) ServerOutput(io.zeebe.transport.ServerOutput) TaskSubscriptionRequest(io.zeebe.broker.task.processor.TaskSubscriptionRequest) BufferUtil.cloneBuffer(io.zeebe.util.buffer.BufferUtil.cloneBuffer) DirectBuffer(org.agrona.DirectBuffer) TaskSubscription(io.zeebe.broker.task.processor.TaskSubscription)

Example 18 with DirectBuffer

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;
            }
        }
    }
}
Also used : DirectBuffer(org.agrona.DirectBuffer) Long2BytesZbMapEntry(io.zeebe.map.iterator.Long2BytesZbMapEntry)

Example 19 with DirectBuffer

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;
}
Also used : DirectBuffer(org.agrona.DirectBuffer)

Example 20 with DirectBuffer

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;
}
Also used : DirectBuffer(org.agrona.DirectBuffer)

Aggregations

DirectBuffer (org.agrona.DirectBuffer)102 Header (io.aeron.logbuffer.Header)18 MutableDirectBuffer (org.agrona.MutableDirectBuffer)16 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)15 File (java.io.File)14 MappedByteBuffer (java.nio.MappedByteBuffer)11 Test (org.junit.Test)11 MediaDriver (io.aeron.driver.MediaDriver)10 CountersReader (org.agrona.concurrent.status.CountersReader)10 ClusteredService (io.aeron.cluster.service.ClusteredService)8 Publication (io.aeron.Publication)7 ClientSession (io.aeron.cluster.service.ClientSession)7 ExpandableArrayBuffer (org.agrona.ExpandableArrayBuffer)7 ThreadingMode (io.aeron.driver.ThreadingMode)6 FragmentHandler (io.aeron.logbuffer.FragmentHandler)6 ByteBuffer (java.nio.ByteBuffer)6 ClusteredServiceContainer (io.aeron.cluster.service.ClusteredServiceContainer)5 InterruptAfter (io.aeron.test.InterruptAfter)5 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)5 LogBufferDescriptor (io.aeron.logbuffer.LogBufferDescriptor)4