Search in sources :

Example 1 with HubAuthenticationInterceptor

use of alluxio.hub.manager.rpc.interceptor.HubAuthenticationInterceptor in project alluxio by Alluxio.

the class ManagerProcessContext method getHostedAsyncStub.

private HostedManagerServiceGrpc.HostedManagerServiceStub getHostedAsyncStub() {
    AlluxioConfiguration modifiedConfig = getConfWithHubTlsEnabled();
    LOG.debug("Connecting to hosted hub with TLS enabled={}", modifiedConfig.getBoolean(PropertyKey.NETWORK_TLS_ENABLED));
    if (mHostedAsyncSub == null) {
        InetSocketAddress addr = NetworkAddressUtils.getConnectAddress(NetworkAddressUtils.ServiceType.HUB_HOSTED_RPC, modifiedConfig);
        try {
            GrpcChannel channel = RpcClient.createChannel(addr, modifiedConfig);
            channel.intercept(new HubAuthenticationInterceptor(HubAuthentication.newBuilder().setApiKey(modifiedConfig.getString(PropertyKey.HUB_AUTHENTICATION_API_KEY)).setSecretKey(modifiedConfig.getString(PropertyKey.HUB_AUTHENTICATION_SECRET_KEY)).build()));
            mHostedAsyncSub = HostedManagerServiceGrpc.newStub(channel);
        } catch (AlluxioStatusException e) {
            LOG.error("Error connecting to hosted hub {}", e);
        }
    }
    return mHostedAsyncSub;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) HubAuthenticationInterceptor(alluxio.hub.manager.rpc.interceptor.HubAuthenticationInterceptor) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) GrpcChannel(alluxio.grpc.GrpcChannel)

Aggregations

AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)1 AlluxioStatusException (alluxio.exception.status.AlluxioStatusException)1 GrpcChannel (alluxio.grpc.GrpcChannel)1 HubAuthenticationInterceptor (alluxio.hub.manager.rpc.interceptor.HubAuthenticationInterceptor)1 InetSocketAddress (java.net.InetSocketAddress)1