Search in sources :

Example 1 with ConsumptionContext

use of com.sequenceiq.consumption.flow.consumption.ConsumptionContext 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 2 with ConsumptionContext

use of com.sequenceiq.consumption.flow.consumption.ConsumptionContext 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 3 with ConsumptionContext

use of com.sequenceiq.consumption.flow.consumption.ConsumptionContext 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 4 with ConsumptionContext

use of com.sequenceiq.consumption.flow.consumption.ConsumptionContext 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)

Example 5 with ConsumptionContext

use of com.sequenceiq.consumption.flow.consumption.ConsumptionContext in project cloudbreak by hortonworks.

the class AbstractStorageConsumptionCollectionActionTest method testCreateFlowContext.

@Test
public void testCreateFlowContext() {
    when(consumptionService.findConsumptionById(RESOURCE_ID)).thenReturn(consumption);
    ConsumptionContext ctx = underTest.createFlowContext(flowParameters, stateContext, new TestPayload());
    assertEquals(consumption, ctx.getConsumption());
}
Also used : ConsumptionContext(com.sequenceiq.consumption.flow.consumption.ConsumptionContext) Test(org.junit.jupiter.api.Test)

Aggregations

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