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);
}
}
}
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);
}
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;
}
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();
}
}
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;
}
}
Aggregations