Search in sources :

Example 1 with StorageConsumptionCollectionEvent

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)));
}
Also used : Promise(reactor.rx.Promise) StorageConsumptionCollectionEvent(com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionEvent) Event(reactor.bus.Event) StorageConsumptionCollectionEvent(com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionEvent)

Example 2 with StorageConsumptionCollectionEvent

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);
        }
    };
}
Also used : StorageConsumptionCollectionHandlerEvent(com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionHandlerEvent) ConsumptionContext(com.sequenceiq.consumption.flow.consumption.ConsumptionContext) StorageConsumptionCollectionEvent(com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 3 with StorageConsumptionCollectionEvent

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);
        }
    };
}
Also used : ConsumptionContext(com.sequenceiq.consumption.flow.consumption.ConsumptionContext) StorageConsumptionCollectionEvent(com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 4 with StorageConsumptionCollectionEvent

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);
        }
    };
}
Also used : ConsumptionContext(com.sequenceiq.consumption.flow.consumption.ConsumptionContext) StorageConsumptionCollectionEvent(com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 5 with StorageConsumptionCollectionEvent

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);
        }
    };
}
Also used : StorageConsumptionCollectionHandlerEvent(com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionHandlerEvent) ConsumptionContext(com.sequenceiq.consumption.flow.consumption.ConsumptionContext) StorageConsumptionCollectionEvent(com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Aggregations

StorageConsumptionCollectionEvent (com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionEvent)7 ConsumptionContext (com.sequenceiq.consumption.flow.consumption.ConsumptionContext)5 StorageConsumptionCollectionHandlerEvent (com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionHandlerEvent)4 Map (java.util.Map)4 Bean (org.springframework.context.annotation.Bean)4 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)2 Test (org.junit.jupiter.api.Test)2 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 Consumption (com.sequenceiq.consumption.domain.Consumption)1 Event (reactor.bus.Event)1 Promise (reactor.rx.Promise)1