Search in sources :

Example 1 with AcquireMinaSshdServiceResponse

use of com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementProto.AcquireMinaSshdServiceResponse in project cloudbreak by hortonworks.

the class MinaSshdManagementClient method acquireMinaSshdService.

/**
 * Wraps call to acquireMinaSshdService.
 *
 * @param requestId the request ID for the request
 * @param accountId the account ID
 * @return the minasshd service
 * @throws CcmException if an exception occurs
 */
public MinaSshdService acquireMinaSshdService(String requestId, String accountId) throws CcmException {
    checkNotNull(requestId, "requestId should not be null.");
    checkNotNull(accountId, "accountId should not be null.");
    MinaSshdManagementBlockingStub blockingStub = newStub(requestId);
    AcquireMinaSshdServiceRequest.Builder requestBuilder = AcquireMinaSshdServiceRequest.newBuilder().setAccountId(accountId);
    try {
        LOGGER.debug("Calling acquireMinaSshdService with requestId: {}, accountId: {}", requestId, accountId);
        AcquireMinaSshdServiceResponse response = blockingStub.acquireMinaSshdService(requestBuilder.build());
        if (response == null) {
            throw new CcmException("Got null response from MinaSshdManagementService acquireMinaSshdService gRPC call", false);
        } else {
            MinaSshdService minaSshdService = response.getMinaSshdService();
            if (minaSshdService == null) {
                throw new CcmException("Got null minasshd service in MinaSshdManagementService acquireMinaSshdService gRPC response", false);
            } else {
                return minaSshdService;
            }
        }
    } catch (StatusRuntimeException e) {
        String message = "MinaSshdManagementService acquireMinaSshdService gRPC call failed: " + e.getMessage();
        Status status = e.getStatus();
        Status.Code code = status.getCode();
        boolean retryable = GrpcUtil.isRetryable(code);
        LOGGER.debug("Got status code: {}, retryable: {}", code, retryable);
        throw new CcmException(message, e, retryable);
    }
}
Also used : Status(io.grpc.Status) CcmException(com.sequenceiq.cloudbreak.ccm.exception.CcmException) AcquireMinaSshdServiceRequest(com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementProto.AcquireMinaSshdServiceRequest) StatusRuntimeException(io.grpc.StatusRuntimeException) MinaSshdManagementBlockingStub(com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementGrpc.MinaSshdManagementBlockingStub) AcquireMinaSshdServiceResponse(com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementProto.AcquireMinaSshdServiceResponse) MinaSshdService(com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementProto.MinaSshdService)

Aggregations

MinaSshdManagementBlockingStub (com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementGrpc.MinaSshdManagementBlockingStub)1 AcquireMinaSshdServiceRequest (com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementProto.AcquireMinaSshdServiceRequest)1 AcquireMinaSshdServiceResponse (com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementProto.AcquireMinaSshdServiceResponse)1 MinaSshdService (com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementProto.MinaSshdService)1 CcmException (com.sequenceiq.cloudbreak.ccm.exception.CcmException)1 Status (io.grpc.Status)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1