Search in sources :

Example 11 with AlluxioStatusException

use of alluxio.exception.status.AlluxioStatusException in project alluxio by Alluxio.

the class AbstractClient method connect.

/**
 * Connects with the remote.
 */
@Override
public synchronized void connect() throws AlluxioStatusException {
    if (mConnected) {
        return;
    }
    disconnect();
    Preconditions.checkState(!mClosed, "Client is closed, will not try to connect.");
    IOException lastConnectFailure = null;
    RetryPolicy retryPolicy = mRetryPolicySupplier.get();
    while (retryPolicy.attempt()) {
        if (mClosed) {
            throw new FailedPreconditionException("Failed to connect: client has been closed");
        }
        // failover).
        try {
            mAddress = getAddress();
        } catch (UnavailableException e) {
            LOG.debug("Failed to determine {} rpc address ({}): {}", getServiceName(), retryPolicy.getAttemptCount(), e.toString());
            continue;
        }
        try {
            beforeConnect();
            LOG.debug("Alluxio client (version {}) is trying to connect with {} @ {}", RuntimeConstants.VERSION, getServiceName(), mAddress);
            mChannel = GrpcChannelBuilder.newBuilder(GrpcServerAddress.create(mAddress), mContext.getClusterConf()).setSubject(mContext.getSubject()).setClientType(getServiceName()).build();
            // Create stub for version service on host
            mVersionService = ServiceVersionClientServiceGrpc.newBlockingStub(mChannel);
            mConnected = true;
            afterConnect();
            checkVersion(getServiceVersion());
            LOG.debug("Alluxio client (version {}) is connected with {} @ {}", RuntimeConstants.VERSION, getServiceName(), mAddress);
            return;
        } catch (IOException e) {
            LOG.debug("Failed to connect ({}) with {} @ {}", retryPolicy.getAttemptCount(), getServiceName(), mAddress, e);
            lastConnectFailure = e;
            if (e instanceof UnauthenticatedException) {
                // If there has been a failure in opening GrpcChannel, it's possible because
                // the authentication credential has expired. Relogin.
                mContext.getUserState().relogin();
            }
            if (e instanceof NotFoundException) {
                // service is not found in the server, skip retry
                break;
            }
        }
    }
    if (mChannel != null) {
        mChannel.shutdown();
    }
    if (mAddress == null) {
        throw new UnavailableException(String.format("Failed to determine address for %s after %s attempts", getServiceName(), retryPolicy.getAttemptCount()));
    }
    /*
     * Throw as-is if {@link UnauthenticatedException} occurred.
     */
    if (lastConnectFailure instanceof UnauthenticatedException) {
        throw (AlluxioStatusException) lastConnectFailure;
    }
    if (lastConnectFailure instanceof NotFoundException) {
        throw new NotFoundException(lastConnectFailure.getMessage(), new ServiceNotFoundException(lastConnectFailure.getMessage(), lastConnectFailure));
    }
    throw new UnavailableException(String.format("Failed to connect to master (%s) after %s attempts." + "Please check if Alluxio master is currently running on \"%s\". Service=\"%s\"", mAddress, retryPolicy.getAttemptCount(), mAddress, getServiceName()), lastConnectFailure);
}
Also used : UnauthenticatedException(alluxio.exception.status.UnauthenticatedException) ServiceNotFoundException(alluxio.exception.ServiceNotFoundException) FailedPreconditionException(alluxio.exception.status.FailedPreconditionException) UnavailableException(alluxio.exception.status.UnavailableException) NotFoundException(alluxio.exception.status.NotFoundException) ServiceNotFoundException(alluxio.exception.ServiceNotFoundException) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) IOException(java.io.IOException) RetryPolicy(alluxio.retry.RetryPolicy)

Example 12 with AlluxioStatusException

use of alluxio.exception.status.AlluxioStatusException in project alluxio by Alluxio.

the class GetPinnedFileIdsBench method cleanup.

@Override
public void cleanup() throws Exception {
    // skip cleanup in job worker as the test files are to be cleaned up by the client
    if (mBaseParameters.mDistributed) {
        LOG.info("Skipping cleanup in distributed execution");
    } else {
        AlluxioURI baseUri = new AlluxioURI(mParameters.mBasePath);
        try (CloseableResource<FileSystemMasterClient> client = mFileSystemContext.acquireMasterClientResource()) {
            LOG.info("Deleting test directory {}", baseUri);
            client.get().delete(baseUri, DeletePOptions.newBuilder().setRecursive(true).build());
        } catch (AlluxioStatusException e) {
            LOG.warn("Failed to delete test directory {}, manual cleanup needed", baseUri, e);
        }
    }
    super.cleanup();
}
Also used : FileSystemMasterClient(alluxio.client.file.FileSystemMasterClient) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) AlluxioURI(alluxio.AlluxioURI)

Example 13 with AlluxioStatusException

use of alluxio.exception.status.AlluxioStatusException in project alluxio by Alluxio.

the class RestUtilsTest method errorResponse.

@Test
public void errorResponse() throws Exception {
    final Status status = Status.ALREADY_EXISTS;
    final String message = "error message";
    Response response = RestUtils.call(new RestUtils.RestCallable<Void>() {

        @Override
        public Void call() throws Exception {
            throw new AlluxioStatusException(status.withDescription(message));
        }
    }, ServerConfiguration.global());
    Assert.assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
    RestUtils.ErrorResponse errorResponse = (RestUtils.ErrorResponse) response.getEntity();
    Assert.assertEquals(status.getCode(), errorResponse.getStatusCode());
    Assert.assertEquals(message, errorResponse.getMessage());
}
Also used : Status(io.grpc.Status) Response(javax.ws.rs.core.Response) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) Test(org.junit.Test)

Example 14 with AlluxioStatusException

use of alluxio.exception.status.AlluxioStatusException in project alluxio by Alluxio.

the class ManagerProcessContext method getHostedAsyncStub.

private HostedManagerServiceGrpc.HostedManagerServiceStub getHostedAsyncStub() {
    AlluxioConfiguration modifiedConfig = getConfWithHubTlsEnabled();
    LOG.debug("Connecting to hosted hub with TLS enabled={}", modifiedConfig.getBoolean(PropertyKey.NETWORK_TLS_ENABLED));
    if (mHostedAsyncSub == null) {
        InetSocketAddress addr = NetworkAddressUtils.getConnectAddress(NetworkAddressUtils.ServiceType.HUB_HOSTED_RPC, modifiedConfig);
        try {
            GrpcChannel channel = RpcClient.createChannel(addr, modifiedConfig);
            channel.intercept(new HubAuthenticationInterceptor(HubAuthentication.newBuilder().setApiKey(modifiedConfig.getString(PropertyKey.HUB_AUTHENTICATION_API_KEY)).setSecretKey(modifiedConfig.getString(PropertyKey.HUB_AUTHENTICATION_SECRET_KEY)).build()));
            mHostedAsyncSub = HostedManagerServiceGrpc.newStub(channel);
        } catch (AlluxioStatusException e) {
            LOG.error("Error connecting to hosted hub {}", e);
        }
    }
    return mHostedAsyncSub;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) HubAuthenticationInterceptor(alluxio.hub.manager.rpc.interceptor.HubAuthenticationInterceptor) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) GrpcChannel(alluxio.grpc.GrpcChannel)

Example 15 with AlluxioStatusException

use of alluxio.exception.status.AlluxioStatusException in project alluxio by Alluxio.

the class PollingMasterInquireClient method getAddress.

@Nullable
private InetSocketAddress getAddress() {
    // Iterate over the masters and try to connect to each of their RPC ports.
    List<InetSocketAddress> addresses;
    if (mConfiguration.getBoolean(PropertyKey.USER_RPC_SHUFFLE_MASTERS_ENABLED)) {
        addresses = Lists.newArrayList(mConnectDetails.getAddresses());
        Collections.shuffle(addresses);
    } else {
        addresses = mConnectDetails.getAddresses();
    }
    for (InetSocketAddress address : addresses) {
        try {
            LOG.debug("Checking whether {} is listening for RPCs", address);
            pingMetaService(address);
            LOG.debug("Successfully connected to {}", address);
            return address;
        } catch (UnavailableException e) {
            LOG.debug("Failed to connect to {}", address);
            continue;
        } catch (DeadlineExceededException e) {
            LOG.debug("Timeout while connecting to {}", address);
            continue;
        } catch (CancelledException e) {
            LOG.debug("Cancelled while connecting to {}", address);
            continue;
        } catch (AlluxioStatusException e) {
            LOG.error("Error while connecting to {}. {}", address, e);
            // Breaking the loop on non filtered error.
            break;
        }
    }
    return null;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) CancelledException(alluxio.exception.status.CancelledException) UnavailableException(alluxio.exception.status.UnavailableException) DeadlineExceededException(alluxio.exception.status.DeadlineExceededException) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) Nullable(javax.annotation.Nullable)

Aggregations

AlluxioStatusException (alluxio.exception.status.AlluxioStatusException)20 UnavailableException (alluxio.exception.status.UnavailableException)9 IOException (java.io.IOException)5 TableMasterClient (alluxio.client.table.TableMasterClient)3 UnauthenticatedException (alluxio.exception.status.UnauthenticatedException)3 ColumnStatisticsInfo (alluxio.grpc.table.ColumnStatisticsInfo)3 Constraint (alluxio.grpc.table.Constraint)3 PartitionInfo (alluxio.grpc.table.layout.hive.PartitionInfo)3 RetryPolicy (alluxio.retry.RetryPolicy)3 Domain (com.facebook.presto.common.predicate.Domain)3 Type (com.facebook.presto.common.type.Type)3 HiveBasicStatistics (com.facebook.presto.hive.HiveBasicStatistics)3 HIVE_METASTORE_ERROR (com.facebook.presto.hive.HiveErrorCode.HIVE_METASTORE_ERROR)3 HiveType (com.facebook.presto.hive.HiveType)3 Column (com.facebook.presto.hive.metastore.Column)3 Database (com.facebook.presto.hive.metastore.Database)3 ExtendedHiveMetastore (com.facebook.presto.hive.metastore.ExtendedHiveMetastore)3 HiveColumnStatistics (com.facebook.presto.hive.metastore.HiveColumnStatistics)3 HivePrivilegeInfo (com.facebook.presto.hive.metastore.HivePrivilegeInfo)3 MetastoreContext (com.facebook.presto.hive.metastore.MetastoreContext)3