Search in sources :

Example 6 with AlluxioStatusException

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

the class GrpcChannelBuilder method build.

/**
 * Creates an authenticated channel of type {@link GrpcChannel}.
 *
 * @return the built {@link GrpcChannel}
 */
public GrpcChannel build() throws AlluxioStatusException {
    // Acquire a connection from the pool.
    GrpcConnection connection = GrpcConnectionPool.INSTANCE.acquireConnection(mChannelKey, mConfiguration);
    try {
        AuthenticatedChannelClientDriver authDriver = null;
        if (mAuthenticateChannel) {
            // Create channel authenticator based on provided content.
            ChannelAuthenticator channelAuthenticator = new ChannelAuthenticator(connection, mParentSubject, mAuthType, mConfiguration);
            // Authenticate a new logical channel.
            channelAuthenticator.authenticate();
            // Acquire authentication driver.
            authDriver = channelAuthenticator.getAuthenticationDriver();
        }
        // Return a wrapper over logical channel.
        return new GrpcChannel(connection, authDriver);
    } catch (Throwable t) {
        try {
            connection.close();
        } catch (Exception e) {
            throw new RuntimeException("Failed to release the connection. " + mChannelKey.toStringShort(), e);
        }
        // Pretty print unavailable cases.
        if (t instanceof UnavailableException) {
            throw new UnavailableException(String.format("Failed to connect to remote server %s. %s", mChannelKey.getServerAddress(), mChannelKey.toStringShort()), t.getCause());
        }
        throw AlluxioStatusException.fromThrowable(t);
    }
}
Also used : ChannelAuthenticator(alluxio.security.authentication.ChannelAuthenticator) UnavailableException(alluxio.exception.status.UnavailableException) AuthenticatedChannelClientDriver(alluxio.security.authentication.AuthenticatedChannelClientDriver) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) UnavailableException(alluxio.exception.status.UnavailableException)

Example 7 with AlluxioStatusException

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

the class RpcPortHealthCheckClient method isServing.

@Override
public boolean isServing() {
    RetryPolicy retry = mRetryPolicySupplier.get();
    while (retry.attempt()) {
        try {
            LOG.debug("Checking whether {} is listening for RPCs", mNodeAddress);
            NetworkAddressUtils.pingService(mNodeAddress, mServiceType, mConf, mUserState);
            LOG.debug("Successfully connected to {}", mNodeAddress);
            return true;
        } catch (UnavailableException e) {
            LOG.debug("Failed to connect to {} on attempt #{}", mNodeAddress, retry.getAttemptCount());
        } catch (AlluxioStatusException e) {
            throw new RuntimeException(e);
        }
    }
    return false;
}
Also used : UnavailableException(alluxio.exception.status.UnavailableException) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) RetryPolicy(alluxio.retry.RetryPolicy)

Example 8 with AlluxioStatusException

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

the class GetPinnedFileIdsBench method prepare.

@Override
public void prepare() throws Exception {
    // The task ID is different for local and cluster executions
    // So including that in the log can help associate the log to the run
    LOG.info("Task ID is {}", mBaseParameters.mId);
    // done once, so skip preparation when running in job worker
    if (mBaseParameters.mDistributed) {
        LOG.info("Skipping preparation in distributed execution");
        return;
    }
    AlluxioURI baseUri = new AlluxioURI(mParameters.mBasePath);
    try (CloseableResource<alluxio.client.file.FileSystemMasterClient> client = mFileSystemContext.acquireMasterClientResource()) {
        LOG.info("Creating temporary directory {} for benchmark", baseUri);
        client.get().createDirectory(baseUri, CreateDirectoryPOptions.newBuilder().setAllowExists(true).build());
    }
    int numFiles = mParameters.mNumFiles;
    int fileNameLength = (int) Math.ceil(Math.max(8, Math.log10(numFiles)));
    CompletableFuture<Void>[] futures = new CompletableFuture[numFiles];
    LOG.info("Generating {} pinned test files at the master", numFiles);
    for (int i = 0; i < numFiles; i++) {
        AlluxioURI fileUri = baseUri.join(CommonUtils.randomAlphaNumString(fileNameLength));
        CompletableFuture<Void> future = CompletableFuture.supplyAsync((Supplier<Void>) () -> {
            try (CloseableResource<FileSystemMasterClient> client = mFileSystemContext.acquireMasterClientResource()) {
                client.get().createFile(fileUri, CreateFilePOptions.newBuilder().setBlockSizeBytes(mConf.getBytes(PropertyKey.USER_BLOCK_SIZE_BYTES_DEFAULT)).build());
                client.get().setAttribute(fileUri, SetAttributePOptions.newBuilder().setPinned(true).build());
            } catch (AlluxioStatusException e) {
                LOG.warn("Exception during file creation of {}", fileUri, e);
            }
            return null;
        }, getPool());
        futures[i] = (future);
    }
    CompletableFuture.allOf(futures).join();
    LOG.info("Test files generated");
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) CloseableResource(alluxio.resource.CloseableResource) FileSystemMasterClient(alluxio.client.file.FileSystemMasterClient) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) AlluxioURI(alluxio.AlluxioURI)

Example 9 with AlluxioStatusException

use of alluxio.exception.status.AlluxioStatusException in project presto by prestodb.

the class AlluxioHiveMetastore method getPartitionNamesByParts.

/**
 * return a list of partition names by which the values of each partition is at least
 * contained which the {@code parts} argument
 *
 * @param databaseName database name
 * @param tableName    table name
 * @param parts        list of values which returned partitions should contain
 * @return optionally, a list of strings where each entry is in the form of {key}={value}
 */
public Optional<List<String>> getPartitionNamesByParts(MetastoreContext metastoreContext, String databaseName, String tableName, List<String> parts) {
    try {
        List<PartitionInfo> partitionInfos = AlluxioProtoUtils.toPartitionInfoList(client.readTable(databaseName, tableName, Constraint.getDefaultInstance()));
        // TODO also check for database name equality
        partitionInfos = partitionInfos.stream().filter(p -> p.getTableName().equals(tableName)).filter(partition -> {
            List<String> values = partition.getValuesList();
            if (values.size() != parts.size()) {
                return false;
            }
            for (int i = 0; i < values.size(); i++) {
                String constraintPart = parts.get(i);
                if (!constraintPart.isEmpty() && !values.get(i).equals(constraintPart)) {
                    return false;
                }
            }
            return true;
        }).collect(toImmutableList());
        List<String> partitionNames = partitionInfos.stream().map(PartitionInfo::getPartitionName).collect(toImmutableList());
        return Optional.of(partitionNames);
    } catch (AlluxioStatusException e) {
        throw new PrestoException(HIVE_METASTORE_ERROR, e);
    }
}
Also used : ColumnStatisticsInfo(alluxio.grpc.table.ColumnStatisticsInfo) Table(com.facebook.presto.hive.metastore.Table) NotFoundException(com.facebook.presto.spi.NotFoundException) Column(com.facebook.presto.hive.metastore.Column) Database(com.facebook.presto.hive.metastore.Database) PartitionWithStatistics(com.facebook.presto.hive.metastore.PartitionWithStatistics) HiveMetastore(com.facebook.presto.hive.metastore.thrift.HiveMetastore) PrestoPrincipal(com.facebook.presto.spi.security.PrestoPrincipal) Inject(com.google.inject.Inject) HiveType(com.facebook.presto.hive.HiveType) MetastoreContext(com.facebook.presto.hive.metastore.MetastoreContext) HiveColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics) PrestoException(com.facebook.presto.spi.PrestoException) MetastoreUtil.convertPredicateToParts(com.facebook.presto.hive.metastore.MetastoreUtil.convertPredicateToParts) Function(java.util.function.Function) Partition(com.facebook.presto.hive.metastore.Partition) Duration(io.airlift.units.Duration) OptionalLong(java.util.OptionalLong) MetastoreUtil(com.facebook.presto.hive.metastore.MetastoreUtil) MetastoreUtil.getHiveBasicStatistics(com.facebook.presto.hive.metastore.MetastoreUtil.getHiveBasicStatistics) SchemaTableName(com.facebook.presto.spi.SchemaTableName) HIVE_METASTORE_ERROR(com.facebook.presto.hive.HiveErrorCode.HIVE_METASTORE_ERROR) ImmutableList(com.google.common.collect.ImmutableList) ExtendedHiveMetastore(com.facebook.presto.hive.metastore.ExtendedHiveMetastore) TableMasterClient(alluxio.client.table.TableMasterClient) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) Constraint(alluxio.grpc.table.Constraint) HiveBasicStatistics(com.facebook.presto.hive.HiveBasicStatistics) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) Type(com.facebook.presto.common.type.Type) PartitionNameWithVersion(com.facebook.presto.hive.metastore.PartitionNameWithVersion) ImmutableMap(com.google.common.collect.ImmutableMap) PrincipalPrivileges(com.facebook.presto.hive.metastore.PrincipalPrivileges) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Set(java.util.Set) Domain(com.facebook.presto.common.predicate.Domain) PartitionInfo(alluxio.grpc.table.layout.hive.PartitionInfo) List(java.util.List) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) TableNotFoundException(com.facebook.presto.spi.TableNotFoundException) RoleGrant(com.facebook.presto.spi.security.RoleGrant) ColumnStatisticType(com.facebook.presto.spi.statistics.ColumnStatisticType) PartitionStatistics(com.facebook.presto.hive.metastore.PartitionStatistics) Optional(java.util.Optional) HivePrivilegeInfo(com.facebook.presto.hive.metastore.HivePrivilegeInfo) Collections(java.util.Collections) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) PrestoException(com.facebook.presto.spi.PrestoException) PartitionInfo(alluxio.grpc.table.layout.hive.PartitionInfo) Constraint(alluxio.grpc.table.Constraint)

Example 10 with AlluxioStatusException

use of alluxio.exception.status.AlluxioStatusException in project presto by prestodb.

the class AlluxioHiveMetastore method getPartitionsByNames.

@Override
public Map<String, Optional<Partition>> getPartitionsByNames(MetastoreContext metastoreContext, String databaseName, String tableName, List<String> partitionNames) {
    if (partitionNames.isEmpty()) {
        return ImmutableMap.of();
    }
    try {
        // Get all partitions
        List<PartitionInfo> partitionInfos = AlluxioProtoUtils.toPartitionInfoList(client.readTable(databaseName, tableName, Constraint.getDefaultInstance()));
        // TODO also check for database name equality
        partitionInfos = partitionInfos.stream().filter(p -> p.getTableName().equals(tableName)).collect(toImmutableList());
        return partitionInfos.stream().filter(p -> partitionNames.stream().anyMatch(p.getPartitionName()::equals)).collect(toImmutableMap(PartitionInfo::getPartitionName, partitionInfo -> Optional.of(AlluxioProtoUtils.fromProto(partitionInfo))));
    } catch (AlluxioStatusException e) {
        throw new PrestoException(HIVE_METASTORE_ERROR, e);
    }
}
Also used : ColumnStatisticsInfo(alluxio.grpc.table.ColumnStatisticsInfo) Table(com.facebook.presto.hive.metastore.Table) NotFoundException(com.facebook.presto.spi.NotFoundException) Column(com.facebook.presto.hive.metastore.Column) Database(com.facebook.presto.hive.metastore.Database) PartitionWithStatistics(com.facebook.presto.hive.metastore.PartitionWithStatistics) HiveMetastore(com.facebook.presto.hive.metastore.thrift.HiveMetastore) PrestoPrincipal(com.facebook.presto.spi.security.PrestoPrincipal) Inject(com.google.inject.Inject) HiveType(com.facebook.presto.hive.HiveType) MetastoreContext(com.facebook.presto.hive.metastore.MetastoreContext) HiveColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics) PrestoException(com.facebook.presto.spi.PrestoException) MetastoreUtil.convertPredicateToParts(com.facebook.presto.hive.metastore.MetastoreUtil.convertPredicateToParts) Function(java.util.function.Function) Partition(com.facebook.presto.hive.metastore.Partition) Duration(io.airlift.units.Duration) OptionalLong(java.util.OptionalLong) MetastoreUtil(com.facebook.presto.hive.metastore.MetastoreUtil) MetastoreUtil.getHiveBasicStatistics(com.facebook.presto.hive.metastore.MetastoreUtil.getHiveBasicStatistics) SchemaTableName(com.facebook.presto.spi.SchemaTableName) HIVE_METASTORE_ERROR(com.facebook.presto.hive.HiveErrorCode.HIVE_METASTORE_ERROR) ImmutableList(com.google.common.collect.ImmutableList) ExtendedHiveMetastore(com.facebook.presto.hive.metastore.ExtendedHiveMetastore) TableMasterClient(alluxio.client.table.TableMasterClient) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) Constraint(alluxio.grpc.table.Constraint) HiveBasicStatistics(com.facebook.presto.hive.HiveBasicStatistics) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) Type(com.facebook.presto.common.type.Type) PartitionNameWithVersion(com.facebook.presto.hive.metastore.PartitionNameWithVersion) ImmutableMap(com.google.common.collect.ImmutableMap) PrincipalPrivileges(com.facebook.presto.hive.metastore.PrincipalPrivileges) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Set(java.util.Set) Domain(com.facebook.presto.common.predicate.Domain) PartitionInfo(alluxio.grpc.table.layout.hive.PartitionInfo) List(java.util.List) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) TableNotFoundException(com.facebook.presto.spi.TableNotFoundException) RoleGrant(com.facebook.presto.spi.security.RoleGrant) ColumnStatisticType(com.facebook.presto.spi.statistics.ColumnStatisticType) PartitionStatistics(com.facebook.presto.hive.metastore.PartitionStatistics) Optional(java.util.Optional) HivePrivilegeInfo(com.facebook.presto.hive.metastore.HivePrivilegeInfo) Collections(java.util.Collections) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) PrestoException(com.facebook.presto.spi.PrestoException) PartitionInfo(alluxio.grpc.table.layout.hive.PartitionInfo)

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