Search in sources :

Example 6 with StorageConsumptionCollectionHandlerEvent

use of com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionHandlerEvent in project cloudbreak by hortonworks.

the class StorageConsumptionCollectionHandler method executeOperation.

@Override
public Selectable executeOperation(HandlerEvent<StorageConsumptionCollectionHandlerEvent> event) throws Exception {
    StorageConsumptionCollectionHandlerEvent data = event.getData();
    Consumption consumption = data.getContext().getConsumption();
    String environmentCrn = consumption.getEnvironmentCrn();
    LOGGER.debug("Getting credential for environment with CRN [{}].", environmentCrn);
    Credential credential = credentialService.getCredentialByEnvCrn(environmentCrn);
    credentialConverter.convert(credential);
    Long resourceId = data.getResourceId();
    String resourceCrn = data.getResourceCrn();
    LOGGER.debug("Storage consumption collection started. resourceCrn: '{}'", resourceCrn);
    return StorageConsumptionCollectionEvent.builder().withResourceCrn(resourceCrn).withResourceId(resourceId).withSelector(SEND_CONSUMPTION_EVENT_EVENT.selector()).build();
}
Also used : StorageConsumptionCollectionHandlerEvent(com.sequenceiq.consumption.flow.consumption.storage.event.StorageConsumptionCollectionHandlerEvent) Consumption(com.sequenceiq.consumption.domain.Consumption) Credential(com.sequenceiq.consumption.dto.Credential)

Aggregations

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