Search in sources :

Example 1 with SdxCmDiagnosticsWaitRequest

use of com.sequenceiq.datalake.flow.diagnostics.event.SdxCmDiagnosticsWaitRequest in project cloudbreak by hortonworks.

the class SdxCmDiagnosticsCollectionHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<SdxCmDiagnosticsWaitRequest> event) {
    SdxCmDiagnosticsWaitRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Map<String, Object> properties = request.getProperties();
    Selectable response;
    try {
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        diagnosticsFlowService.waitForDiagnosticsCollection(sdxId, pollingConfig, request.getFlowIdentifier(), true);
        response = new SdxDiagnosticsSuccessEvent(sdxId, userId, properties);
        LOGGER.debug("SDX CM based diagnostics collection event finished");
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Polling exited before timeout for SDX (CM based diagnostic collection): {}. Cause: ", sdxId, userBreakException);
        response = new SdxCmDiagnosticsFailedEvent(sdxId, userId, properties, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Poller stopped for SDX (CM based diagnostic collection): {}", sdxId, pollerStoppedException);
        response = new SdxCmDiagnosticsFailedEvent(sdxId, userId, properties, new PollerStoppedException("Datalake CM based diagnostic collection timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Polling failed for stack (CM based diagnostic collection): {}", sdxId, exception);
        response = new SdxCmDiagnosticsFailedEvent(sdxId, userId, properties, exception);
    } catch (Exception anotherException) {
        LOGGER.error("Something wrong happened in CM based diagnostic collection wait phase", anotherException);
        response = new SdxCmDiagnosticsFailedEvent(sdxId, userId, properties, anotherException);
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollerStoppedException(com.dyngr.exception.PollerStoppedException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) SdxDiagnosticsSuccessEvent(com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsSuccessEvent) SdxCmDiagnosticsWaitRequest(com.sequenceiq.datalake.flow.diagnostics.event.SdxCmDiagnosticsWaitRequest) PollerStoppedException(com.dyngr.exception.PollerStoppedException) SdxCmDiagnosticsFailedEvent(com.sequenceiq.datalake.flow.diagnostics.event.SdxCmDiagnosticsFailedEvent)

Aggregations

PollerException (com.dyngr.exception.PollerException)1 PollerStoppedException (com.dyngr.exception.PollerStoppedException)1 UserBreakException (com.dyngr.exception.UserBreakException)1 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 SdxCmDiagnosticsFailedEvent (com.sequenceiq.datalake.flow.diagnostics.event.SdxCmDiagnosticsFailedEvent)1 SdxCmDiagnosticsWaitRequest (com.sequenceiq.datalake.flow.diagnostics.event.SdxCmDiagnosticsWaitRequest)1 SdxDiagnosticsSuccessEvent (com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsSuccessEvent)1 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)1