use of alluxio.security.authentication.AuthenticatedChannelClientDriver 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);
}
}
Aggregations