Search in sources :

Example 1 with CdpNodeStatusMonitorClient

use of com.sequenceiq.node.health.client.CdpNodeStatusMonitorClient in project cloudbreak by hortonworks.

the class NodeStatusService method saltPing.

public RPCResponse<NodeStatusProto.SaltHealthReport> saltPing(Long stackId) {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    MDCBuilder.buildMdcContext(stack);
    LOGGER.debug("Retrieving salt ping report from the hosts of stack: {}", stack.getResourceCrn());
    try (CdpNodeStatusMonitorClient client = factory.getClient(stack, stack.getPrimaryGatewayInstance())) {
        return client.saltPing(false, false);
    } catch (CdpNodeStatusMonitorClientException e) {
        throw new CloudbreakServiceException("Could not get salt ping report from stack.");
    }
}
Also used : CdpNodeStatusMonitorClientException(com.sequenceiq.node.health.client.CdpNodeStatusMonitorClientException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) CdpNodeStatusMonitorClient(com.sequenceiq.node.health.client.CdpNodeStatusMonitorClient)

Example 2 with CdpNodeStatusMonitorClient

use of com.sequenceiq.node.health.client.CdpNodeStatusMonitorClient in project cloudbreak by hortonworks.

the class NodeStatusService method getSystemMetrics.

public RPCResponse<NodeStatusProto.NodeStatusReport> getSystemMetrics(Stack stack) {
    MDCBuilder.buildMdcContext(stack);
    LOGGER.debug("Retrieving system metrics report from the hosts of stack: {}", stack.getResourceCrn());
    try (CdpNodeStatusMonitorClient client = factory.getClient(stack, stack.getPrimaryGatewayInstance())) {
        return client.systemMetricsReport();
    } catch (CdpNodeStatusMonitorClientException e) {
        throw new CloudbreakServiceException("Could not get system metrics report from stack.");
    }
}
Also used : CdpNodeStatusMonitorClientException(com.sequenceiq.node.health.client.CdpNodeStatusMonitorClientException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CdpNodeStatusMonitorClient(com.sequenceiq.node.health.client.CdpNodeStatusMonitorClient)

Example 3 with CdpNodeStatusMonitorClient

use of com.sequenceiq.node.health.client.CdpNodeStatusMonitorClient in project cloudbreak by hortonworks.

the class NodeStatusService method getMeteringReport.

public RPCResponse<NodeStatusProto.NodeStatusReport> getMeteringReport(Stack stack) {
    MDCBuilder.buildMdcContext(stack);
    LOGGER.debug("Retrieving metering report from the hosts of stack: {}", stack.getResourceCrn());
    try (CdpNodeStatusMonitorClient client = factory.getClient(stack, stack.getPrimaryGatewayInstance())) {
        return client.nodeMeteringReport();
    } catch (CdpNodeStatusMonitorClientException e) {
        throw new CloudbreakServiceException("Could not get metering report from stack.");
    }
}
Also used : CdpNodeStatusMonitorClientException(com.sequenceiq.node.health.client.CdpNodeStatusMonitorClientException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CdpNodeStatusMonitorClient(com.sequenceiq.node.health.client.CdpNodeStatusMonitorClient)

Example 4 with CdpNodeStatusMonitorClient

use of com.sequenceiq.node.health.client.CdpNodeStatusMonitorClient in project cloudbreak by hortonworks.

the class CdpNodeStatusMonitorClientFactory method getClient.

public CdpNodeStatusMonitorClient getClient(Stack stack, InstanceMetaData instance) {
    final Optional<String> username;
    final Optional<String> password;
    if (stack.getCluster() != null && StringUtils.isNoneEmpty(stack.getCluster().getCdpNodeStatusMonitorUser(), stack.getCluster().getCdpNodeStatusMonitorPassword())) {
        username = Optional.of(stack.getCluster().getCdpNodeStatusMonitorUser());
        password = Optional.of(stack.getCluster().getCdpNodeStatusMonitorPassword());
    } else {
        username = Optional.empty();
        password = Optional.empty();
    }
    CdpNodeStatusMonitorClient client;
    if (clusterProxyService.isCreateConfigForClusterProxy(stack)) {
        client = buildClientForClusterProxy(stack, instance, username, password);
    } else {
        client = buildClientForDirectConnect(stack, instance, username, password);
    }
    return client;
}
Also used : CdpNodeStatusMonitorClient(com.sequenceiq.node.health.client.CdpNodeStatusMonitorClient)

Example 5 with CdpNodeStatusMonitorClient

use of com.sequenceiq.node.health.client.CdpNodeStatusMonitorClient in project cloudbreak by hortonworks.

the class CdpNodeStatusMonitorClientFactory method buildNodeStatusMonitorClient.

private CdpNodeStatusMonitorClient buildNodeStatusMonitorClient(HttpClientConfig clientConfig, int port, String basePath, Map<String, String> headers, Optional<String> username, Optional<String> password) {
    Client restClient;
    try {
        restClient = RestClientUtil.createClient(clientConfig.getServerCert(), clientConfig.getClientCert(), clientConfig.getClientKey(), connectionTimeoutMillis, readTimeoutMillis, restDebug);
    } catch (Exception e) {
        throw new CloudbreakServiceException("Unable to create client for node status checks", e);
    }
    URL url = null;
    try {
        url = getUrl(clientConfig, port, basePath);
    } catch (MalformedURLException e) {
        throw new CloudbreakServiceException("Unable to build url to check node status", e);
    }
    if (username.isPresent() && password.isPresent()) {
        return instantiateClient(headers, restClient, url, username, password);
    }
    return instantiateClient(headers, restClient, url);
}
Also used : MalformedURLException(java.net.MalformedURLException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Client(javax.ws.rs.client.Client) CdpNodeStatusMonitorClient(com.sequenceiq.node.health.client.CdpNodeStatusMonitorClient) MalformedURLException(java.net.MalformedURLException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) URL(java.net.URL)

Aggregations

CdpNodeStatusMonitorClient (com.sequenceiq.node.health.client.CdpNodeStatusMonitorClient)7 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)6 CdpNodeStatusMonitorClientException (com.sequenceiq.node.health.client.CdpNodeStatusMonitorClientException)5 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)2 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Client (javax.ws.rs.client.Client)1