use of org.apache.airavata.service.profile.handlers.IamAdminServicesHandler 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);
}
}
Aggregations