Search in sources :

Example 71 with DirectBuffer

use of org.agrona.DirectBuffer in project zeebe by zeebe-io.

the class DeploymentCreateProcessor method assignVersionToWorkflows.

private void assignVersionToWorkflows(final DeploymentResourceIterator resourceIterator, final DirectBuffer topicName, final WorkflowDefinition definition) {
    for (Workflow workflow : definition.getWorkflows()) {
        if (workflow.isExecutable()) {
            final DirectBuffer bpmnProcessId = workflow.getBpmnProcessId();
            final int latestVersion = workflowVersions.getLatestVersion(topicName, bpmnProcessId, 0);
            resourceIterator.addDeployedWorkflow().setBpmnProcessId(bpmnProcessId).setVersion(latestVersion + 1);
        }
    }
}
Also used : DirectBuffer(org.agrona.DirectBuffer) DeployedWorkflow(io.zeebe.broker.workflow.data.DeployedWorkflow) Workflow(io.zeebe.model.bpmn.instance.Workflow)

Example 72 with DirectBuffer

use of org.agrona.DirectBuffer in project zeebe by zeebe-io.

the class DeploymentCreateProcessor method processEvent.

@Override
public void processEvent(TypedEvent<DeploymentEvent> event) {
    final DeploymentEvent deploymentEvent = event.getValue();
    final DirectBuffer topicName = deploymentEvent.getTopicName();
    boolean success = false;
    if (isTopicCreated(topicName)) {
        if (hasPendingDeploymentForTopic(topicName)) {
            // reject deployment if a previous deployment is not completed yet
            // -- otherwise, we could run into problems with the workflow versions when the previous deployment is rejected
            LOG.info("Cannot create deployment: pending deployment found for topic with name '{}'.", bufferAsString(topicName));
        } else {
            success = readAndValidateWorkflows(deploymentEvent);
        }
    } else {
        LOG.info("Cannot create deployment: no topic found with name '{}'.", bufferAsString(topicName));
    }
    deploymentEvent.setState(success ? VALIDATED : REJECTED);
}
Also used : DirectBuffer(org.agrona.DirectBuffer) DeploymentEvent(io.zeebe.broker.workflow.data.DeploymentEvent)

Example 73 with DirectBuffer

use of org.agrona.DirectBuffer in project zeebe by zeebe-io.

the class DeploymentCreateProcessor method transformWorkflowResource.

private boolean transformWorkflowResource(final DeploymentResource deploymentResource, final WorkflowDefinition definition) {
    if (deploymentResource.getResourceType() != ResourceType.BPMN_XML) {
        final DirectBuffer bpmnXml = wrapString(bpmn.convertToString(definition));
        deploymentResource.setResource(bpmnXml);
        return true;
    }
    return false;
}
Also used : DirectBuffer(org.agrona.DirectBuffer)

Example 74 with DirectBuffer

use of org.agrona.DirectBuffer in project zeebe by zeebe-io.

the class RemoteWorkflowsManager method onRequestSuccessful.

private void onRequestSuccessful(ClientResponse request) {
    try {
        final DirectBuffer responseBuffer = request.getResponseBuffer();
        createResponse.wrap(responseBuffer, 0, responseBuffer.capacity());
        final long workflowKey = createResponse.getWorkflowKey();
        final int partitionId = createResponse.getPartitionId();
        final long deploymentKey = createResponse.getDeploymentKey();
        final PendingWorkflow pendingWorkflow = pendingWorkflows.get(workflowKey, partitionId);
        if (pendingWorkflow != null && pendingWorkflow.getState() == PendingWorkflows.STATE_CREATE) {
            // ignore response if pending workflow or deployment is already processed
            pendingWorkflows.put(workflowKey, partitionId, PendingWorkflows.STATE_CREATED, deploymentKey);
        }
        if (isDeploymentDistributed(deploymentKey)) {
            final PendingDeployment pendingDeployment = pendingDeployments.get(deploymentKey);
            writer.writeDeploymentEvent(pendingDeployment.getDeploymentEventPosition(), DeploymentState.DISTRIBUTED);
        }
    } finally {
        request.close();
    }
}
Also used : DirectBuffer(org.agrona.DirectBuffer) PendingDeployment(io.zeebe.broker.system.deployment.data.PendingDeployments.PendingDeployment) PendingWorkflow(io.zeebe.broker.system.deployment.data.PendingWorkflows.PendingWorkflow)

Example 75 with DirectBuffer

use of org.agrona.DirectBuffer in project zeebe by zeebe-io.

the class PendingWorkflows method get.

public PendingWorkflow get(long workflowKey, int partitionId) {
    keyBuffer.putLong(WORKFLOW_KEY_OFFSET, workflowKey, BYTE_ORDER);
    keyBuffer.putInt(PARTITION_ID_OFFSET, partitionId, BYTE_ORDER);
    final DirectBuffer currentValue = map.get(keyBuffer);
    if (currentValue != null) {
        pendingWorkflow.wrap(keyBuffer, currentValue);
        return pendingWorkflow;
    } else {
        return null;
    }
}
Also used : DirectBuffer(org.agrona.DirectBuffer)

Aggregations

DirectBuffer (org.agrona.DirectBuffer)116 Header (io.aeron.logbuffer.Header)21 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)21 MutableDirectBuffer (org.agrona.MutableDirectBuffer)20 File (java.io.File)19 MediaDriver (io.aeron.driver.MediaDriver)18 CountersReader (org.agrona.concurrent.status.CountersReader)15 ThreadingMode (io.aeron.driver.ThreadingMode)12 FragmentHandler (io.aeron.logbuffer.FragmentHandler)12 MappedByteBuffer (java.nio.MappedByteBuffer)12 ClusteredService (io.aeron.cluster.service.ClusteredService)10 InterruptAfter (io.aeron.test.InterruptAfter)10 Test (org.junit.jupiter.api.Test)10 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 Publication (io.aeron.Publication)9 ClientSession (io.aeron.cluster.service.ClientSession)9 ClusteredServiceContainer (io.aeron.cluster.service.ClusteredServiceContainer)8 Assertions (org.junit.jupiter.api.Assertions)8 Mockito.mock (org.mockito.Mockito.mock)8