Search in sources :

Example 1 with GrpcServerAddress

use of alluxio.grpc.GrpcServerAddress in project alluxio by Alluxio.

the class FileSystemContext method acquireBlockWorkerClientInternal.

private CloseableResource<BlockWorkerClient> acquireBlockWorkerClientInternal(final WorkerNetAddress workerNetAddress, final ClientContext context, UserState userState) throws IOException {
    SocketAddress address = NetworkAddressUtils.getDataPortSocketAddress(workerNetAddress, context.getClusterConf());
    GrpcServerAddress serverAddress = GrpcServerAddress.create(workerNetAddress.getHost(), address);
    ClientPoolKey key = new ClientPoolKey(address, AuthenticationUserUtils.getImpersonationUser(userState.getSubject(), context.getClusterConf()));
    final ConcurrentHashMap<ClientPoolKey, BlockWorkerClientPool> poolMap = mBlockWorkerClientPoolMap;
    return new CloseableResource<BlockWorkerClient>(poolMap.computeIfAbsent(key, k -> new BlockWorkerClientPool(userState, serverAddress, context.getClusterConf().getInt(PropertyKey.USER_BLOCK_WORKER_CLIENT_POOL_MIN), context.getClusterConf().getInt(PropertyKey.USER_BLOCK_WORKER_CLIENT_POOL_MAX), context.getClusterConf())).acquire()) {

        // Save the reference to the original pool map.
        @Override
        public void closeResource() {
            releaseBlockWorkerClient(workerNetAddress, get(), context, poolMap);
        }
    };
}
Also used : CloseableResource(alluxio.resource.CloseableResource) BlockWorkerClientPool(alluxio.client.block.stream.BlockWorkerClientPool) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) GrpcServerAddress(alluxio.grpc.GrpcServerAddress)

Aggregations

BlockWorkerClientPool (alluxio.client.block.stream.BlockWorkerClientPool)1 GrpcServerAddress (alluxio.grpc.GrpcServerAddress)1 CloseableResource (alluxio.resource.CloseableResource)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1