use of org.apache.thrift.transport.TTransportException 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.transport.TTransportException in project airavata by apache.
the class ProfileServiceClientFactory method createIamAdminServiceClient.
public static IamAdminServices.Client createIamAdminServiceClient(String serverHost, int serverPort) throws IamAdminServicesException {
try {
TTransport transport = new TSocket(serverHost, serverPort);
transport.open();
TProtocol protocol = new TBinaryProtocol(transport);
TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, iam_admin_services_cpiConstants.IAM_ADMIN_SERVICES_CPI_NAME);
return new IamAdminServices.Client(multiplexedProtocol);
} catch (TTransportException e) {
throw new IamAdminServicesException(e.getMessage());
}
}
use of org.apache.thrift.transport.TTransportException in project airavata by apache.
the class ProfileServiceClientFactory method createTenantProfileServiceClient.
public static TenantProfileService.Client createTenantProfileServiceClient(String serverHost, int serverPort) throws TenantProfileServiceException {
try {
TTransport transport = new TSocket(serverHost, serverPort);
transport.open();
TProtocol protocol = new TBinaryProtocol(transport);
TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, profile_tenant_cpiConstants.TENANT_PROFILE_CPI_NAME);
return new TenantProfileService.Client(multiplexedProtocol);
} catch (TTransportException e) {
throw new TenantProfileServiceException(e.getMessage());
}
}
use of org.apache.thrift.transport.TTransportException in project airavata by apache.
the class OrchestratorServer method StartOrchestratorServer.
public void StartOrchestratorServer(OrchestratorService.Processor<OrchestratorServerHandler> orchestratorServerHandlerProcessor) throws Exception {
final int serverPort = Integer.parseInt(ServerSettings.getSetting(Constants.ORCHESTRATOT_SERVER_PORT, "8940"));
try {
final String serverHost = ServerSettings.getSetting(Constants.ORCHESTRATOT_SERVER_HOST, null);
TServerTransport serverTransport;
if (serverHost == null) {
serverTransport = new TServerSocket(serverPort);
} else {
InetSocketAddress inetSocketAddress = new InetSocketAddress(serverHost, serverPort);
serverTransport = new TServerSocket(inetSocketAddress);
}
// server = new TSimpleServer(
// new TServer.Args(serverTransport).processor(orchestratorServerHandlerProcessor));
TThreadPoolServer.Args options = new TThreadPoolServer.Args(serverTransport);
options.minWorkerThreads = Integer.parseInt(ServerSettings.getSetting(Constants.ORCHESTRATOT_SERVER_MIN_THREADS, "30"));
server = new TThreadPoolServer(options.processor(orchestratorServerHandlerProcessor));
new Thread() {
public void run() {
server.serve();
setStatus(ServerStatus.STARTING);
logger.info("Starting Orchestrator Server ... ");
}
}.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("Started Orchestrator Server on Port " + serverPort + " ...");
}
}
}.start();
} catch (TTransportException e) {
logger.error(e.getMessage());
setStatus(ServerStatus.FAILED);
logger.error("Failed to start Orchestrator server on port " + serverPort + " ...");
}
}
use of org.apache.thrift.transport.TTransportException in project atlasdb by palantir.
the class CassandraRequestExceptionHandler method logAndThrowException.
@SuppressWarnings("unchecked")
private <K extends Exception> void logAndThrowException(int numberOfAttempts, Exception ex) throws K {
if (ex instanceof TTransportException && ex.getCause() != null && (ex.getCause().getClass() == SocketException.class)) {
log.warn(CONNECTION_FAILURE_MSG_WITH_EXCEPTION_INFO, SafeArg.of("numTries", numberOfAttempts), SafeArg.of("exceptionClass", ex.getClass().getTypeName()), UnsafeArg.of("exceptionMessage", ex.getMessage()));
String errorMsg = MessageFormatter.format(CONNECTION_FAILURE_MSG, numberOfAttempts).getMessage();
throw (K) new TTransportException(((TTransportException) ex).getType(), errorMsg, ex);
} else {
log.warn("Tried to connect to cassandra {} times. Exception message was: {} : {}", SafeArg.of("numTries", numberOfAttempts), SafeArg.of("exceptionClass", ex.getClass().getTypeName()), UnsafeArg.of("exceptionMessage", ex.getMessage()));
throw (K) ex;
}
}
Aggregations