Search in sources :

Example 16 with AlluxioStatusException

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

the class AuthenticatedChannelClientDriver method waitUntilChannelAuthenticated.

private void waitUntilChannelAuthenticated(long timeoutMs) throws AlluxioStatusException {
    try {
        // Wait until authentication status changes.
        mChannelAuthenticatedFuture.get(timeoutMs, TimeUnit.MILLISECONDS);
        mChannelAuthenticated = true;
    } catch (InterruptedException ie) {
        Thread.currentThread().interrupt();
        throw AlluxioStatusException.fromThrowable(ie);
    } catch (ExecutionException e) {
        AlluxioStatusException statExc = AlluxioStatusException.fromThrowable(e.getCause());
        // Unimplemented is returned if server doesn't provide authentication service.
        if (statExc.getStatusCode() == Status.Code.UNIMPLEMENTED) {
            throw new UnauthenticatedException("Authentication is disabled on target server.");
        }
        throw statExc;
    } catch (TimeoutException e) {
        throw new UnavailableException(e);
    }
}
Also used : UnauthenticatedException(alluxio.exception.status.UnauthenticatedException) UnavailableException(alluxio.exception.status.UnavailableException) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 17 with AlluxioStatusException

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

the class MasterJournalContext method waitForJournalFlush.

/**
 * Waits for the flush counter to be flushed to the journal. If the counter is
 * {@link #INVALID_FLUSH_COUNTER}, this is a noop.
 */
private void waitForJournalFlush() throws UnavailableException {
    if (mFlushCounter == INVALID_FLUSH_COUNTER) {
        // Check this before the precondition.
        return;
    }
    RetryPolicy retry = new TimeoutRetry(FLUSH_RETRY_TIMEOUT_MS, FLUSH_RETRY_INTERVAL_MS);
    while (retry.attempt()) {
        try {
            mAsyncJournalWriter.flush(mFlushCounter);
            return;
        } catch (NotLeaderException | JournalClosedException e) {
            throw new UnavailableException(String.format("Failed to complete request: %s", e.getMessage()), e);
        } catch (AlluxioStatusException e) {
            // written already
            if (e.getStatus().equals(Status.CANCELLED)) {
                LOG.warn("Journal flush interrupted because the RPC was cancelled. ", e);
            } else {
                LOG.warn("Journal flush failed. retrying...", e);
            }
        } catch (IOException e) {
            if (e instanceof AlluxioStatusException && ((AlluxioStatusException) e).getStatusCode() == Status.Code.CANCELLED) {
                throw new UnavailableException(String.format("Failed to complete request: %s", e.getMessage()), e);
            }
            LOG.warn("Journal flush failed. retrying...", e);
        } catch (Throwable e) {
            ProcessUtils.fatalError(LOG, e, "Journal flush failed");
        }
    }
    ProcessUtils.fatalError(LOG, "Journal flush failed after %d attempts", retry.getAttemptCount());
}
Also used : NotLeaderException(org.apache.ratis.protocol.exceptions.NotLeaderException) JournalClosedException(alluxio.exception.JournalClosedException) UnavailableException(alluxio.exception.status.UnavailableException) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) TimeoutRetry(alluxio.retry.TimeoutRetry) IOException(java.io.IOException) RetryPolicy(alluxio.retry.RetryPolicy)

Example 18 with AlluxioStatusException

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

the class AsyncJournalWriter method flush.

/**
 * Submits a ticket to flush thread and waits until ticket is served.
 *
 * If the specified counter is already flushed, this is essentially a no-op.
 *
 * @param targetCounter the counter to flush
 */
public void flush(final long targetCounter) throws IOException, JournalClosedException {
    // Return if flushed.
    if (targetCounter <= mFlushCounter.get()) {
        return;
    }
    // Submit the ticket for flush thread to process.
    FlushTicket ticket = new FlushTicket(targetCounter);
    mTicketSet.add(ticket);
    try {
        // Give a permit for flush thread to run.
        mFlushSemaphore.release();
        // Wait on the ticket until completed.
        ticket.waitCompleted();
    } catch (InterruptedException ie) {
        // Interpret interruption as cancellation.
        throw new AlluxioStatusException(Status.CANCELLED.withCause(ie));
    } catch (Throwable e) {
        // Filter, journal specific exception codes.
        if (e instanceof IOException) {
            throw (IOException) e;
        }
        if (e instanceof JournalClosedException) {
            throw (JournalClosedException) e;
        }
        // Not expected. throw internal error.
        throw new AlluxioStatusException(Status.INTERNAL.withCause(e));
    } finally {
        /*
       * Client can only try to reacquire the permit it has given
       * because the permit may or may not have been used by the flush thread.
       */
        mFlushSemaphore.tryAcquire();
    }
}
Also used : JournalClosedException(alluxio.exception.JournalClosedException) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) IOException(java.io.IOException)

Example 19 with AlluxioStatusException

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

the class BlockReadHandler method handleStreamEndingException.

/**
 * Handles any exception which should abort the client's read request.
 *
 * @param status the type of {@link Status} exception which should be returned to the user
 */
private void handleStreamEndingException(Status status) {
    Long sessionId = mContext.getRequest() == null ? -1 : mContext.getRequest().getSessionId();
    LogUtils.warnWithException(LOG, "Error occurred while handling read. sessionId: {}. Ending " + "stream", sessionId, status);
    AlluxioStatusException statusExc = AlluxioStatusException.from(status);
    try (LockResource lr = new LockResource(mLock)) {
        if (mContext == null) {
            mContext = createRequestContext(alluxio.grpc.ReadRequest.newBuilder().build());
        }
        setError(new Error(statusExc, true));
    }
}
Also used : LockResource(alluxio.resource.LockResource) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException)

Example 20 with AlluxioStatusException

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

the class ChannelAuthenticator method authenticate.

/**
 * It builds an authenticated channel.
 *
 * @throws AlluxioStatusException
 */
public void authenticate() throws AlluxioStatusException {
    LOG.debug("Authenticating channel: {}. AuthType: {}", mChannelKey.toStringShort(), mAuthType);
    ChannelAuthenticationScheme authScheme = getChannelAuthScheme(mAuthType, mParentSubject, mChannelKey.getServerAddress().getSocketAddress());
    try {
        // Create client-side driver for establishing authenticated channel with the target.
        mAuthDriver = new AuthenticatedChannelClientDriver(createSaslClientHandler(mChannelKey.getServerAddress(), authScheme, mParentSubject), mChannelKey);
        // Initialize client-server authentication drivers.
        SaslAuthenticationServiceGrpc.SaslAuthenticationServiceStub serverStub = SaslAuthenticationServiceGrpc.newStub(mConnection.getChannel());
        StreamObserver<SaslMessage> requestObserver = serverStub.authenticate(mAuthDriver);
        mAuthDriver.setServerObserver(requestObserver);
        // Start authentication with the target. (This is blocking.)
        long authTimeout = mConfiguration.getMs(PropertyKey.NETWORK_CONNECTION_AUTH_TIMEOUT);
        mAuthDriver.startAuthenticatedChannel(authTimeout);
        // Intercept authenticated channel with channel-id injector.
        mConnection.interceptChannel(new ChannelIdInjector(mChannelKey.getChannelId()));
    } catch (Throwable t) {
        AlluxioStatusException e = AlluxioStatusException.fromThrowable(t);
        // Build a pretty message for authentication failure.
        String message = String.format("Channel authentication failed with code:%s. Channel: %s, AuthType: %s, Error: %s", e.getStatusCode().name(), mChannelKey.toStringShort(), mAuthType, e.toString());
        throw AlluxioStatusException.from(Status.fromCode(e.getStatusCode()).withDescription(message).withCause(t));
    }
}
Also used : ChannelAuthenticationScheme(alluxio.grpc.ChannelAuthenticationScheme) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) SaslMessage(alluxio.grpc.SaslMessage) SaslAuthenticationServiceGrpc(alluxio.grpc.SaslAuthenticationServiceGrpc)

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