use of io.zeebe.broker.workflow.data.DeploymentEvent in project zeebe by zeebe-io.
the class DeploymentDistributedProcessor method updateState.
@Override
public void updateState(TypedEvent<DeploymentEvent> event) {
final DeploymentEvent deploymentEvent = event.getValue();
final long deploymentKey = event.getKey();
if (deploymentEvent.getState() == CREATED) {
pendingDeployments.remove(deploymentKey);
timer.onDeploymentResolved(deploymentKey);
removePendingWorkflowsOfDeployment(deploymentKey);
}
}
use of io.zeebe.broker.workflow.data.DeploymentEvent in project zeebe by zeebe-io.
the class ClientApiMessageHandler method initEventTypeMap.
private void initEventTypeMap() {
eventsByType.put(EventType.DEPLOYMENT_EVENT, new DeploymentEvent());
eventsByType.put(EventType.TASK_EVENT, new TaskEvent());
eventsByType.put(EventType.WORKFLOW_INSTANCE_EVENT, new WorkflowInstanceEvent());
eventsByType.put(EventType.SUBSCRIBER_EVENT, new TopicSubscriberEvent());
eventsByType.put(EventType.SUBSCRIPTION_EVENT, new TopicSubscriptionEvent());
eventsByType.put(EventType.TOPIC_EVENT, new TopicEvent());
}
use of io.zeebe.broker.workflow.data.DeploymentEvent in project zeebe by zeebe-io.
the class CreateDeploymentStreamProcessorTest method createDeployment.
protected DeploymentEvent createDeployment(WorkflowDefinition workflow) {
final DeploymentEvent event = new DeploymentEvent();
event.setState(DeploymentState.CREATE);
event.setTopicName(STREAM_NAME);
event.resources().add().setResourceName(BufferUtil.wrapString("foo.bpmn")).setResourceType(ResourceType.BPMN_XML).setResource(BufferUtil.wrapString(Bpmn.convertToString(workflow)));
return event;
}
use of io.zeebe.broker.workflow.data.DeploymentEvent in project zeebe by zeebe-io.
the class DeploymentCreateProcessor method writeEvent.
@Override
public long writeEvent(TypedEvent<DeploymentEvent> event, TypedStreamWriter writer) {
final DeploymentEvent deploymentEvent = event.getValue();
if (deploymentEvent.getState() == REJECTED) {
return writer.writeFollowupEvent(event.getKey(), deploymentEvent);
} else {
final TypedBatchWriter batch = writer.newBatch();
batch.addFollowUpEvent(event.getKey(), deploymentEvent, addRequestMetadata(event));
final DeployedWorkflowIterator deployedWorkflowIterator = deploymentResourceIterator.getDeployedWorkflows();
while (deployedWorkflowIterator.hasNext()) {
final DeployedWorkflow deployedWorkflow = deployedWorkflowIterator.next();
workflowEvent.setState(WorkflowState.CREATE).setBpmnProcessId(deployedWorkflow.getBpmnProcessId()).setVersion(deployedWorkflow.getVersion()).setBpmnXml(deployedWorkflowIterator.getDeploymentResource().getResource()).setDeploymentKey(event.getKey());
batch.addNewEvent(workflowEvent);
}
return batch.write();
}
}
use of io.zeebe.broker.workflow.data.DeploymentEvent 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);
}
Aggregations