Search in sources :

Example 1 with ListMinaSshdServicesResponse

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

the class MinaSshdManagementClient method listMinaSshdServices.

/**
 * Wraps calls to listMinaSshdServices with an account ID.
 *
 * @param requestId  the request ID for the request
 * @param accountId  the account ID
 * @param serviceIds the minasshd services to list. if null or empty then all minasshd services will be listed
 * @return the list of minasshd services
 */
public List<MinaSshdService> listMinaSshdServices(String requestId, String accountId, List<String> serviceIds) throws CcmException {
    checkNotNull(requestId, "requestId should not be null.");
    checkNotNull(accountId, "accountId should not be null.");
    List<MinaSshdService> groups = new ArrayList<>();
    MinaSshdManagementBlockingStub minaSshdManagementBlockingStub = newStub(requestId);
    ListMinaSshdServicesRequest.Builder requestBuilder = ListMinaSshdServicesRequest.newBuilder().setAccountId(accountId).setPageSize(minaSshdManagementClientConfig.getListMinaSshdServicesPageSize());
    if (serviceIds != null && !serviceIds.isEmpty()) {
        requestBuilder.addAllId(serviceIds);
    }
    ListMinaSshdServicesResponse response;
    do {
        try {
            LOGGER.debug("Calling listMinaSshdServices with requestId: {}, accountId: {}, serviceIds: [{}]", requestId, accountId, serviceIds);
            response = minaSshdManagementBlockingStub.listMinaSshdServices(requestBuilder.build());
            if (response == null) {
                throw new CcmException("Got null response from MinaSshdManagementService listMinaSshdServices gRPC call", false);
            } else {
                List<MinaSshdService> minaSshdServices = response.getMinaSshdServiceList();
                if (minaSshdServices == null) {
                    throw new CcmException("Got null minasshd services in MinaSshdManagementService listMinaSshdServices gRPC response", false);
                } else {
                    groups.addAll(minaSshdServices);
                }
            }
        } catch (StatusRuntimeException e) {
            String message = "MinaSshdManagementService listMinaSshdServices 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);
        }
        requestBuilder.setPageToken(response.getNextPageToken());
    } while (response.hasNextPageToken());
    return groups;
}
Also used : ListMinaSshdServicesResponse(com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementProto.ListMinaSshdServicesResponse) Status(io.grpc.Status) CcmException(com.sequenceiq.cloudbreak.ccm.exception.CcmException) ArrayList(java.util.ArrayList) ListMinaSshdServicesRequest(com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementProto.ListMinaSshdServicesRequest) StatusRuntimeException(io.grpc.StatusRuntimeException) MinaSshdManagementBlockingStub(com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementGrpc.MinaSshdManagementBlockingStub) MinaSshdService(com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementProto.MinaSshdService)

Aggregations

MinaSshdManagementBlockingStub (com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementGrpc.MinaSshdManagementBlockingStub)1 ListMinaSshdServicesRequest (com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementProto.ListMinaSshdServicesRequest)1 ListMinaSshdServicesResponse (com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementProto.ListMinaSshdServicesResponse)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 ArrayList (java.util.ArrayList)1