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);
}
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);
}
}
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();
}
Aggregations