use of com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionEvent in project cloudbreak by hortonworks.
the class ConsumptionReactorFlowManager method triggerStorageConsumptionCollectionFlow.
public void triggerStorageConsumptionCollectionFlow(Consumption consumption, String userCrn) {
LOGGER.info("Storage consumption collection flow triggered for environment {} and location {}", consumption.getEnvironmentCrn(), consumption.getStorageLocation());
StorageConsumptionCollectionEvent event = StorageConsumptionCollectionEvent.builder().withResourceCrn(consumption.getResourceCrn()).withResourceId(consumption.getId()).withSelector(STORAGE_CONSUMPTION_COLLECTION_START_EVENT.event()).withAccepted(new Promise<>()).build();
eventSender.sendEvent(event, new Event.Headers(getFlowTriggerUsercrn(userCrn)));
}
use of com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionEvent in project cloudbreak by hortonworks.
the class StorageConsumptionCollectionActions method storageConsumptionCollectionAction.
@Bean(name = "STORAGE_CONSUMPTION_COLLECTION_STATE")
public Action<?, ?> storageConsumptionCollectionAction() {
return new AbstractStorageConsumptionCollectionAction<>(StorageConsumptionCollectionEvent.class) {
@Override
protected void doExecute(ConsumptionContext context, StorageConsumptionCollectionEvent payload, Map<Object, Object> variables) {
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into STORAGE_CONSUMPTION_COLLECTION_STATE. resourceCrn: '{}'", resourceCrn);
StorageConsumptionCollectionHandlerEvent event = new StorageConsumptionCollectionHandlerEvent(StorageConsumptionCollectionHandlerSelectors.STORAGE_CONSUMPTION_COLLECTION_HANDLER.selector(), payload.getResourceId(), resourceCrn, context);
sendEvent(context, event);
}
};
}
use of com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionEvent in project cloudbreak by hortonworks.
the class StorageConsumptionCollectionActions method finishedAction.
@Bean(name = "STORAGE_CONSUMPTION_COLLECTION_FINISHED_STATE")
public Action<?, ?> finishedAction() {
return new AbstractStorageConsumptionCollectionAction<>(StorageConsumptionCollectionEvent.class) {
@Override
protected void doExecute(ConsumptionContext context, StorageConsumptionCollectionEvent payload, Map<Object, Object> variables) {
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into STORAGE_CONSUMPTION_COLLECTION_FINISHED_STATE. resourceCrn: '{}'", resourceCrn);
StorageConsumptionCollectionEvent event = StorageConsumptionCollectionEvent.builder().withResourceId(payload.getResourceId()).withResourceCrn(resourceCrn).withSelector(StorageConsumptionCollectionStateSelectors.STORAGE_CONSUMPTION_COLLECTION_FINALIZED_EVENT.selector()).build();
sendEvent(context, event);
}
};
}
use of com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionEvent in project cloudbreak by hortonworks.
the class StorageConsumptionCollectionActions method failedAction.
@Bean(name = "STORAGE_CONSUMPTION_COLLECTION_FAILED_STATE")
public Action<?, ?> failedAction() {
return new AbstractStorageConsumptionCollectionAction<>(StorageConsumptionCollectionEvent.class) {
@Override
protected void doExecute(ConsumptionContext context, StorageConsumptionCollectionEvent payload, Map<Object, Object> variables) {
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into STORAGE_CONSUMPTION_COLLECTION_FAILED_STATE. resourceCrn: '{}'", resourceCrn);
StorageConsumptionCollectionEvent event = StorageConsumptionCollectionEvent.builder().withResourceId(payload.getResourceId()).withResourceCrn(resourceCrn).withSelector(StorageConsumptionCollectionStateSelectors.STORAGE_CONSUMPTION_COLLECTION_HANDLED_FAILED_EVENT.selector()).build();
sendEvent(context, event);
}
};
}
use of com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionEvent in project cloudbreak by hortonworks.
the class StorageConsumptionCollectionActions method sendConsumptionEventAction.
@Bean(name = "SEND_CONSUMPTION_EVENT_STATE")
public Action<?, ?> sendConsumptionEventAction() {
return new AbstractStorageConsumptionCollectionAction<>(StorageConsumptionCollectionEvent.class) {
@Override
protected void doExecute(ConsumptionContext context, StorageConsumptionCollectionEvent payload, Map<Object, Object> variables) {
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into SEND_CONSUMPTION_EVENT_STATE. resourceCrn: '{}'", resourceCrn);
StorageConsumptionCollectionHandlerEvent event = new StorageConsumptionCollectionHandlerEvent(StorageConsumptionCollectionHandlerSelectors.SEND_CONSUMPTION_EVENT_HANDLER.selector(), payload.getResourceId(), resourceCrn, context);
sendEvent(context, event);
}
};
}
Aggregations