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);
}
}
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;
}
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");
}
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);
}
}
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);
}
}
Aggregations