Search in sources :

Example 1 with GrpcServerBuilder

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

the class GrpcSecurityTest method createServer.

private GrpcServer createServer(AuthType authType) {
    mConfiguration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, authType.name());
    InetSocketAddress bindAddress = new InetSocketAddress(NetworkAddressUtils.getLocalHostName((int) mConfiguration.getMs(PropertyKey.NETWORK_HOST_RESOLUTION_TIMEOUT_MS)), 0);
    UserState us = UserState.Factory.create(mConfiguration);
    GrpcServerBuilder serverBuilder = GrpcServerBuilder.forAddress(GrpcServerAddress.create("localhost", bindAddress), mConfiguration, us);
    return serverBuilder.build();
}
Also used : GrpcServerBuilder(alluxio.grpc.GrpcServerBuilder) UserState(alluxio.security.user.UserState) InetSocketAddress(java.net.InetSocketAddress)

Example 2 with GrpcServerBuilder

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

the class AlluxioMasterProcess method createRPCServer.

private GrpcServer createRPCServer() {
    // Create an executor for Master RPC server.
    mRPCExecutor = ExecutorServiceBuilder.buildExecutorService(ExecutorServiceBuilder.RpcExecutorHost.MASTER);
    MetricsSystem.registerGaugeIfAbsent(MetricKey.MASTER_RPC_QUEUE_LENGTH.getName(), mRPCExecutor::getRpcQueueLength);
    // Create underlying gRPC server.
    GrpcServerBuilder builder = GrpcServerBuilder.forAddress(GrpcServerAddress.create(mRpcConnectAddress.getHostName(), mRpcBindAddress), ServerConfiguration.global(), ServerUserState.global()).executor(mRPCExecutor).flowControlWindow((int) ServerConfiguration.getBytes(PropertyKey.MASTER_NETWORK_FLOWCONTROL_WINDOW)).keepAliveTime(ServerConfiguration.getMs(PropertyKey.MASTER_NETWORK_KEEPALIVE_TIME_MS), TimeUnit.MILLISECONDS).keepAliveTimeout(ServerConfiguration.getMs(PropertyKey.MASTER_NETWORK_KEEPALIVE_TIMEOUT_MS), TimeUnit.MILLISECONDS).permitKeepAlive(ServerConfiguration.getMs(PropertyKey.MASTER_NETWORK_PERMIT_KEEPALIVE_TIME_MS), TimeUnit.MILLISECONDS).maxInboundMessageSize((int) ServerConfiguration.getBytes(PropertyKey.MASTER_NETWORK_MAX_INBOUND_MESSAGE_SIZE));
    // Bind manifests of each Alluxio master to RPC server.
    for (Master master : mRegistry.getServers()) {
        registerServices(builder, master.getServices());
    }
    // Bind manifest of Alluxio JournalMaster service.
    // TODO(ggezer) Merge this with registerServices() logic.
    builder.addService(alluxio.grpc.ServiceType.JOURNAL_MASTER_CLIENT_SERVICE, new GrpcService(new JournalMasterClientServiceHandler(new DefaultJournalMaster(JournalDomain.MASTER, mJournalSystem))));
    // Builds a server that is not started yet.
    return builder.build();
}
Also used : GrpcServerBuilder(alluxio.grpc.GrpcServerBuilder) DefaultJournalMaster(alluxio.master.journal.DefaultJournalMaster) DefaultJournalMaster(alluxio.master.journal.DefaultJournalMaster) GrpcService(alluxio.grpc.GrpcService) JournalMasterClientServiceHandler(alluxio.master.journal.JournalMasterClientServiceHandler)

Example 3 with GrpcServerBuilder

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

the class GrpcDataServer method createServerBuilder.

private GrpcServerBuilder createServerBuilder(String hostName, SocketAddress bindAddress, ChannelType type) {
    // Create an executor for Worker RPC server.
    mRPCExecutor = ExecutorServiceBuilder.buildExecutorService(ExecutorServiceBuilder.RpcExecutorHost.WORKER);
    MetricsSystem.registerGaugeIfAbsent(MetricKey.WORKER_RPC_QUEUE_LENGTH.getName(), mRPCExecutor::getRpcQueueLength);
    // Create underlying gRPC server.
    GrpcServerBuilder builder = GrpcServerBuilder.forAddress(GrpcServerAddress.create(hostName, bindAddress), ServerConfiguration.global(), ServerUserState.global()).executor(mRPCExecutor);
    int bossThreadCount = ServerConfiguration.getInt(PropertyKey.WORKER_NETWORK_NETTY_BOSS_THREADS);
    // If number of worker threads is 0, Netty creates (#processors * 2) threads by default.
    int workerThreadCount = ServerConfiguration.getInt(PropertyKey.WORKER_NETWORK_NETTY_WORKER_THREADS);
    String dataServerEventLoopNamePrefix = "data-server-" + ((mSocketAddress instanceof DomainSocketAddress) ? "domain-socket" : "tcp-socket");
    mBossGroup = NettyUtils.createEventLoop(type, bossThreadCount, dataServerEventLoopNamePrefix + "-boss-%d", true);
    mWorkerGroup = NettyUtils.createEventLoop(type, workerThreadCount, dataServerEventLoopNamePrefix + "-worker-%d", true);
    Class<? extends ServerChannel> socketChannelClass = NettyUtils.getServerChannelClass(mSocketAddress instanceof DomainSocketAddress, ServerConfiguration.global());
    if (type == ChannelType.EPOLL) {
        builder.withChildOption(EpollChannelOption.EPOLL_MODE, EpollMode.LEVEL_TRIGGERED);
    }
    return builder.bossEventLoopGroup(mBossGroup).workerEventLoopGroup(mWorkerGroup).channelType(socketChannelClass).withChildOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT).withChildOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, (int) ServerConfiguration.getBytes(PropertyKey.WORKER_NETWORK_NETTY_WATERMARK_HIGH)).withChildOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, (int) ServerConfiguration.getBytes(PropertyKey.WORKER_NETWORK_NETTY_WATERMARK_LOW));
}
Also used : GrpcServerBuilder(alluxio.grpc.GrpcServerBuilder) DomainSocketAddress(io.netty.channel.unix.DomainSocketAddress)

Example 4 with GrpcServerBuilder

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

the class AlluxioJobMasterProcess method createRPCServer.

private GrpcServer createRPCServer() {
    // Create underlying gRPC server.
    GrpcServerBuilder builder = GrpcServerBuilder.forAddress(GrpcServerAddress.create(mRpcConnectAddress.getHostName(), mRpcBindAddress), ServerConfiguration.global(), ServerUserState.global()).flowControlWindow((int) ServerConfiguration.getBytes(PropertyKey.JOB_MASTER_NETWORK_FLOWCONTROL_WINDOW)).keepAliveTime(ServerConfiguration.getMs(PropertyKey.JOB_MASTER_NETWORK_KEEPALIVE_TIME_MS), TimeUnit.MILLISECONDS).keepAliveTimeout(ServerConfiguration.getMs(PropertyKey.JOB_MASTER_NETWORK_KEEPALIVE_TIMEOUT_MS), TimeUnit.MILLISECONDS).permitKeepAlive(ServerConfiguration.getMs(PropertyKey.JOB_MASTER_NETWORK_PERMIT_KEEPALIVE_TIME_MS), TimeUnit.MILLISECONDS).maxInboundMessageSize((int) ServerConfiguration.getBytes(PropertyKey.JOB_MASTER_NETWORK_MAX_INBOUND_MESSAGE_SIZE));
    // Register job-master services.
    registerServices(builder, mJobMaster.getServices());
    // Bind manifest of Alluxio JournalMaster service.
    // TODO(ggezer) Merge this with registerServices() logic.
    builder.addService(alluxio.grpc.ServiceType.JOURNAL_MASTER_CLIENT_SERVICE, new GrpcService(new JournalMasterClientServiceHandler(new DefaultJournalMaster(JournalDomain.JOB_MASTER, mJournalSystem))));
    // Builds a server that is not started yet.
    return builder.build();
}
Also used : GrpcServerBuilder(alluxio.grpc.GrpcServerBuilder) DefaultJournalMaster(alluxio.master.journal.DefaultJournalMaster) GrpcService(alluxio.grpc.GrpcService) JournalMasterClientServiceHandler(alluxio.master.journal.JournalMasterClientServiceHandler)

Example 5 with GrpcServerBuilder

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

the class AlluxioJobWorkerProcess method startServingRPCServer.

private void startServingRPCServer() {
    try {
        if (mBindSocket != null) {
            // Socket opened for auto bind.
            // Close it.
            mBindSocket.close();
        }
        LOG.info("Starting gRPC server on address {}", mRpcConnectAddress);
        GrpcServerBuilder serverBuilder = GrpcServerBuilder.forAddress(GrpcServerAddress.create(mRpcConnectAddress.getHostName(), mRpcBindAddress), ServerConfiguration.global(), ServerUserState.global());
        for (Map.Entry<alluxio.grpc.ServiceType, GrpcService> serviceEntry : mJobWorker.getServices().entrySet()) {
            LOG.info("Registered service:{}", serviceEntry.getKey().name());
            serverBuilder.addService(serviceEntry.getValue());
        }
        mGrpcServer = serverBuilder.build().start();
        LOG.info("Started gRPC server on address {}", mRpcConnectAddress);
        // Wait until the server is shut down.
        mGrpcServer.awaitTermination();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : GrpcServerBuilder(alluxio.grpc.GrpcServerBuilder) GrpcService(alluxio.grpc.GrpcService) ServiceType(alluxio.util.network.NetworkAddressUtils.ServiceType) IOException(java.io.IOException) Map(java.util.Map)

Aggregations

GrpcServerBuilder (alluxio.grpc.GrpcServerBuilder)5 GrpcService (alluxio.grpc.GrpcService)3 DefaultJournalMaster (alluxio.master.journal.DefaultJournalMaster)2 JournalMasterClientServiceHandler (alluxio.master.journal.JournalMasterClientServiceHandler)2 UserState (alluxio.security.user.UserState)1 ServiceType (alluxio.util.network.NetworkAddressUtils.ServiceType)1 DomainSocketAddress (io.netty.channel.unix.DomainSocketAddress)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 Map (java.util.Map)1