Search in sources :

Example 1 with TMultiplexedProcessor

use of org.apache.thrift.TMultiplexedProcessor in project alluxio by Alluxio.

the class DefaultAlluxioWorker method createThriftServer.

/**
   * Helper method to create a {@link org.apache.thrift.server.TThreadPoolServer} for handling
   * incoming RPC requests.
   *
   * @return a thrift server
   */
private TThreadPoolServer createThriftServer() {
    int minWorkerThreads = Configuration.getInt(PropertyKey.WORKER_BLOCK_THREADS_MIN);
    int maxWorkerThreads = Configuration.getInt(PropertyKey.WORKER_BLOCK_THREADS_MAX);
    TMultiplexedProcessor processor = new TMultiplexedProcessor();
    registerServices(processor, mBlockWorker.getServices());
    registerServices(processor, mFileSystemWorker.getServices());
    // register additional workers for RPC service
    for (Worker worker : mAdditionalWorkers) {
        registerServices(processor, worker.getServices());
    }
    // Return a TTransportFactory based on the authentication type
    TTransportFactory tTransportFactory;
    try {
        tTransportFactory = mTransportProvider.getServerTransportFactory();
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
    TThreadPoolServer.Args args = new TThreadPoolServer.Args(mThriftServerSocket).minWorkerThreads(minWorkerThreads).maxWorkerThreads(maxWorkerThreads).processor(processor).transportFactory(tTransportFactory).protocolFactory(new TBinaryProtocol.Factory(true, true));
    if (Configuration.getBoolean(PropertyKey.TEST_MODE)) {
        args.stopTimeoutVal = 0;
    } else {
        args.stopTimeoutVal = Constants.THRIFT_STOP_TIMEOUT_SECONDS;
    }
    return new TThreadPoolServer(args);
}
Also used : TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TMultiplexedProcessor(org.apache.thrift.TMultiplexedProcessor) BlockWorker(alluxio.worker.block.BlockWorker) DefaultBlockWorker(alluxio.worker.block.DefaultBlockWorker) DefaultFileSystemWorker(alluxio.worker.file.DefaultFileSystemWorker) FileSystemWorker(alluxio.worker.file.FileSystemWorker) TTransportFactory(org.apache.thrift.transport.TTransportFactory) IOException(java.io.IOException) TThreadPoolServer(org.apache.thrift.server.TThreadPoolServer)

Example 2 with TMultiplexedProcessor

use of org.apache.thrift.TMultiplexedProcessor in project airavata by apache.

the class ProfileServiceServer method start.

public void start() throws Exception {
    try {
        setStatus(ServerStatus.STARTING);
        final int serverPort = Integer.parseInt(ServerSettings.getProfileServiceServerPort());
        final String serverHost = ServerSettings.getProfileServiceServerHost();
        // create multiple processors for each profile-service
        UserProfileService.Processor userProfileProcessor = new UserProfileService.Processor(new UserProfileServiceHandler());
        TenantProfileService.Processor teneantProfileProcessor = new TenantProfileService.Processor(new TenantProfileServiceHandler());
        IamAdminServices.Processor iamAdminServicesProcessor = new IamAdminServices.Processor(new IamAdminServicesHandler());
        // create a multiplexed processor
        TMultiplexedProcessor profileServiceProcessor = new TMultiplexedProcessor();
        profileServiceProcessor.registerProcessor(profile_user_cpiConstants.USER_PROFILE_CPI_NAME, userProfileProcessor);
        profileServiceProcessor.registerProcessor(profile_tenant_cpiConstants.TENANT_PROFILE_CPI_NAME, teneantProfileProcessor);
        profileServiceProcessor.registerProcessor(iam_admin_services_cpiConstants.IAM_ADMIN_SERVICES_CPI_NAME, iamAdminServicesProcessor);
        TServerTransport serverTransport;
        if (serverHost == null) {
            serverTransport = new TServerSocket(serverPort);
        } else {
            InetSocketAddress inetSocketAddress = new InetSocketAddress(serverHost, serverPort);
            serverTransport = new TServerSocket(inetSocketAddress);
        }
        TThreadPoolServer.Args options = new TThreadPoolServer.Args(serverTransport);
        options.minWorkerThreads = 30;
        server = new TThreadPoolServer(options.processor(profileServiceProcessor));
        new Thread() {

            public void run() {
                server.serve();
                setStatus(ServerStatus.STOPPED);
                logger.info("Profile Service Server Stopped.");
            }
        }.start();
        new Thread() {

            public void run() {
                while (!server.isServing()) {
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        break;
                    }
                }
                if (server.isServing()) {
                    setStatus(ServerStatus.STARTED);
                    logger.info("Starting Profile Service Server on Port " + serverPort);
                    logger.info("Listening to Profile Service Server clients ....");
                }
            }
        }.start();
    } catch (TTransportException e) {
        setStatus(ServerStatus.FAILED);
        throw new Exception("Error while starting the Profile Service Server", e);
    }
}
Also used : TenantProfileService(org.apache.airavata.service.profile.tenant.cpi.TenantProfileService) UserProfileServiceHandler(org.apache.airavata.service.profile.handlers.UserProfileServiceHandler) TMultiplexedProcessor(org.apache.thrift.TMultiplexedProcessor) InetSocketAddress(java.net.InetSocketAddress) UserProfileService(org.apache.airavata.service.profile.user.cpi.UserProfileService) TMultiplexedProcessor(org.apache.thrift.TMultiplexedProcessor) TTransportException(org.apache.thrift.transport.TTransportException) TServerTransport(org.apache.thrift.transport.TServerTransport) TTransportException(org.apache.thrift.transport.TTransportException) TServerSocket(org.apache.thrift.transport.TServerSocket) IamAdminServices(org.apache.airavata.service.profile.iam.admin.services.cpi.IamAdminServices) IamAdminServicesHandler(org.apache.airavata.service.profile.handlers.IamAdminServicesHandler) TenantProfileServiceHandler(org.apache.airavata.service.profile.handlers.TenantProfileServiceHandler) TThreadPoolServer(org.apache.thrift.server.TThreadPoolServer)

Example 3 with TMultiplexedProcessor

use of org.apache.thrift.TMultiplexedProcessor in project alluxio by Alluxio.

the class DefaultAlluxioMaster method startServingRPCServer.

protected void startServingRPCServer() {
    // set up multiplexed thrift processors
    TMultiplexedProcessor processor = new TMultiplexedProcessor();
    registerServices(processor, mBlockMaster.getServices());
    registerServices(processor, mFileSystemMaster.getServices());
    if (LineageUtils.isLineageEnabled()) {
        registerServices(processor, mLineageMaster.getServices());
    }
    // register additional masters for RPC service
    for (Master master : mAdditionalMasters) {
        registerServices(processor, master.getServices());
    }
    // register meta services
    processor.registerProcessor(Constants.META_MASTER_SERVICE_NAME, new MetaMasterClientService.Processor<>(new MetaMasterClientServiceHandler(this)));
    // Return a TTransportFactory based on the authentication type
    TTransportFactory transportFactory;
    try {
        transportFactory = mTransportProvider.getServerTransportFactory();
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
    // create master thrift service with the multiplexed processor.
    Args args = new TThreadPoolServer.Args(mTServerSocket).maxWorkerThreads(mMaxWorkerThreads).minWorkerThreads(mMinWorkerThreads).processor(processor).transportFactory(transportFactory).protocolFactory(new TBinaryProtocol.Factory(true, true));
    if (Configuration.getBoolean(PropertyKey.TEST_MODE)) {
        args.stopTimeoutVal = 0;
    } else {
        args.stopTimeoutVal = Constants.THRIFT_STOP_TIMEOUT_SECONDS;
    }
    mMasterServiceServer = new TThreadPoolServer(args);
    // start thrift rpc server
    mIsServing = true;
    mStartTimeMs = System.currentTimeMillis();
    mMasterServiceServer.serve();
}
Also used : BlockMaster(alluxio.master.block.BlockMaster) FileSystemMaster(alluxio.master.file.FileSystemMaster) LineageMaster(alluxio.master.lineage.LineageMaster) MetaMasterClientService(alluxio.thrift.MetaMasterClientService) Args(org.apache.thrift.server.TThreadPoolServer.Args) Args(org.apache.thrift.server.TThreadPoolServer.Args) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TMultiplexedProcessor(org.apache.thrift.TMultiplexedProcessor) TTransportFactory(org.apache.thrift.transport.TTransportFactory) IOException(java.io.IOException) TThreadPoolServer(org.apache.thrift.server.TThreadPoolServer)

Aggregations

TMultiplexedProcessor (org.apache.thrift.TMultiplexedProcessor)3 TThreadPoolServer (org.apache.thrift.server.TThreadPoolServer)3 IOException (java.io.IOException)2 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)2 TTransportFactory (org.apache.thrift.transport.TTransportFactory)2 BlockMaster (alluxio.master.block.BlockMaster)1 FileSystemMaster (alluxio.master.file.FileSystemMaster)1 LineageMaster (alluxio.master.lineage.LineageMaster)1 MetaMasterClientService (alluxio.thrift.MetaMasterClientService)1 BlockWorker (alluxio.worker.block.BlockWorker)1 DefaultBlockWorker (alluxio.worker.block.DefaultBlockWorker)1 DefaultFileSystemWorker (alluxio.worker.file.DefaultFileSystemWorker)1 FileSystemWorker (alluxio.worker.file.FileSystemWorker)1 InetSocketAddress (java.net.InetSocketAddress)1 IamAdminServicesHandler (org.apache.airavata.service.profile.handlers.IamAdminServicesHandler)1 TenantProfileServiceHandler (org.apache.airavata.service.profile.handlers.TenantProfileServiceHandler)1 UserProfileServiceHandler (org.apache.airavata.service.profile.handlers.UserProfileServiceHandler)1 IamAdminServices (org.apache.airavata.service.profile.iam.admin.services.cpi.IamAdminServices)1 TenantProfileService (org.apache.airavata.service.profile.tenant.cpi.TenantProfileService)1 UserProfileService (org.apache.airavata.service.profile.user.cpi.UserProfileService)1