Search in sources :

Example 1 with DeploymentEvent

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);
    }
}
Also used : DeploymentEvent(io.zeebe.broker.workflow.data.DeploymentEvent)

Example 2 with DeploymentEvent

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());
}
Also used : TopicEvent(io.zeebe.broker.system.log.TopicEvent) TopicSubscriptionEvent(io.zeebe.broker.event.processor.TopicSubscriptionEvent) TopicSubscriberEvent(io.zeebe.broker.event.processor.TopicSubscriberEvent) TaskEvent(io.zeebe.broker.task.data.TaskEvent) WorkflowInstanceEvent(io.zeebe.broker.workflow.data.WorkflowInstanceEvent) DeploymentEvent(io.zeebe.broker.workflow.data.DeploymentEvent)

Example 3 with DeploymentEvent

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;
}
Also used : DeploymentEvent(io.zeebe.broker.workflow.data.DeploymentEvent)

Example 4 with DeploymentEvent

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();
    }
}
Also used : TypedBatchWriter(io.zeebe.broker.logstreams.processor.TypedBatchWriter) DeployedWorkflow(io.zeebe.broker.workflow.data.DeployedWorkflow) DeploymentEvent(io.zeebe.broker.workflow.data.DeploymentEvent)

Example 5 with DeploymentEvent

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);
}
Also used : DirectBuffer(org.agrona.DirectBuffer) DeploymentEvent(io.zeebe.broker.workflow.data.DeploymentEvent)

Aggregations

DeploymentEvent (io.zeebe.broker.workflow.data.DeploymentEvent)6 TopicSubscriberEvent (io.zeebe.broker.event.processor.TopicSubscriberEvent)1 TopicSubscriptionEvent (io.zeebe.broker.event.processor.TopicSubscriptionEvent)1 TypedBatchWriter (io.zeebe.broker.logstreams.processor.TypedBatchWriter)1 TopicEvent (io.zeebe.broker.system.log.TopicEvent)1 TaskEvent (io.zeebe.broker.task.data.TaskEvent)1 DeployedWorkflow (io.zeebe.broker.workflow.data.DeployedWorkflow)1 WorkflowInstanceEvent (io.zeebe.broker.workflow.data.WorkflowInstanceEvent)1 DirectBuffer (org.agrona.DirectBuffer)1