Search in sources :

Example 51 with TTransportException

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);
    }
}
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 52 with TTransportException

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());
    }
}
Also used : TMultiplexedProtocol(org.apache.thrift.protocol.TMultiplexedProtocol) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) IamAdminServicesException(org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException) TProtocol(org.apache.thrift.protocol.TProtocol) TTransportException(org.apache.thrift.transport.TTransportException) TTransport(org.apache.thrift.transport.TTransport) TSocket(org.apache.thrift.transport.TSocket)

Example 53 with TTransportException

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());
    }
}
Also used : TMultiplexedProtocol(org.apache.thrift.protocol.TMultiplexedProtocol) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TenantProfileServiceException(org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException) TProtocol(org.apache.thrift.protocol.TProtocol) TTransportException(org.apache.thrift.transport.TTransportException) TTransport(org.apache.thrift.transport.TTransport) TSocket(org.apache.thrift.transport.TSocket)

Example 54 with TTransportException

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 + " ...");
    }
}
Also used : TServerSocket(org.apache.thrift.transport.TServerSocket) InetSocketAddress(java.net.InetSocketAddress) TTransportException(org.apache.thrift.transport.TTransportException) TThreadPoolServer(org.apache.thrift.server.TThreadPoolServer) TServerTransport(org.apache.thrift.transport.TServerTransport)

Example 55 with TTransportException

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;
    }
}
Also used : TTransportException(org.apache.thrift.transport.TTransportException)

Aggregations

TTransportException (org.apache.thrift.transport.TTransportException)165 TTransport (org.apache.thrift.transport.TTransport)43 TException (org.apache.thrift.TException)42 Test (org.junit.Test)39 IOException (java.io.IOException)38 TSocket (org.apache.thrift.transport.TSocket)38 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)29 TProtocol (org.apache.thrift.protocol.TProtocol)26 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)24 TServerSocket (org.apache.thrift.transport.TServerSocket)15 ArrayList (java.util.ArrayList)13 TFramedTransport (org.apache.thrift.transport.TFramedTransport)13 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)11 HostAndPort (org.apache.accumulo.core.util.HostAndPort)10 InetSocketAddress (java.net.InetSocketAddress)9 AccumuloException (org.apache.accumulo.core.client.AccumuloException)9 Function (org.apache.hadoop.hive.metastore.api.Function)9 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)8 ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)8 Partition (org.apache.hadoop.hive.metastore.api.Partition)8