Search in sources :

Example 1 with StopTelemetryRequest

use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.stoptelemetry.StopTelemetryRequest in project cloudbreak by hortonworks.

the class FreeIpaDownscaleActions method stopTelemetryAction.

@Bean(name = "DOWNSCALE_STOP_TELEMETRY_STATE")
public Action<?, ?> stopTelemetryAction() {
    return new AbstractDownscaleAction<>(StackEvent.class) {

        @Override
        protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
            Stack stack = context.getStack();
            stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Stopping telemetry");
            List<String> repairInstanceIds = getInstanceIds(variables);
            StopTelemetryRequest stopTelemetryRequest = new StopTelemetryRequest(stack.getId(), repairInstanceIds);
            sendEvent(context, stopTelemetryRequest.selector(), stopTelemetryRequest);
        }
    };
}
Also used : StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) StopTelemetryRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.stoptelemetry.StopTelemetryRequest) Map(java.util.Map) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Example 2 with StopTelemetryRequest

use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.stoptelemetry.StopTelemetryRequest in project cloudbreak by hortonworks.

the class StopTelemetryHandler method accept.

@Override
public void accept(Event<StopTelemetryRequest> event) {
    StopTelemetryRequest request = event.getData();
    LOGGER.info("Stop telemetry agents gracefully (if needed)...");
    telemetryAgentService.stopTelemetryAgent(request.getResourceId(), request.getInstanceIds());
    StopTelemetryResponse response = new StopTelemetryResponse(request.getResourceId());
    eventBus.notify(EventSelectorUtil.selector(StopTelemetryResponse.class), new Event<>(event.getHeaders(), response));
}
Also used : StopTelemetryResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.stoptelemetry.StopTelemetryResponse) StopTelemetryRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.stoptelemetry.StopTelemetryRequest)

Example 3 with StopTelemetryRequest

use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.stoptelemetry.StopTelemetryRequest in project cloudbreak by hortonworks.

the class StopTelemetryHandlerTest method testCallsTelemetryAgentService.

@Test
void testCallsTelemetryAgentService() {
    List<String> instanceIds = List.of("i-1");
    StopTelemetryRequest request = new StopTelemetryRequest(1L, instanceIds);
    underTest.accept(new Event<>(request));
    verify(telemetryAgentService, times(1)).stopTelemetryAgent(1L, instanceIds);
    verify(eventBus).notify(eq("STOPTELEMETRYRESPONSE"), ArgumentMatchers.<Event>any());
}
Also used : StopTelemetryRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.stoptelemetry.StopTelemetryRequest) Test(org.junit.jupiter.api.Test)

Aggregations

StopTelemetryRequest (com.sequenceiq.freeipa.flow.freeipa.downscale.event.stoptelemetry.StopTelemetryRequest)3 Stack (com.sequenceiq.freeipa.entity.Stack)1 StopTelemetryResponse (com.sequenceiq.freeipa.flow.freeipa.downscale.event.stoptelemetry.StopTelemetryResponse)1 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)1 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)1 Map (java.util.Map)1 Test (org.junit.jupiter.api.Test)1 Bean (org.springframework.context.annotation.Bean)1