Search in sources :

Example 46 with TTransportException

use of org.apache.thrift.transport.TTransportException in project airavata by apache.

the class TestSSLClient method invoke.

private void invoke() {
    // TTransport transport;
    try {
        // TSSLTransportFactory.TSSLTransportParameters params =
        // new TSSLTransportFactory.TSSLTransportParameters();
        // String keystorePath = ServerSettings.getCredentialStoreThriftServerKeyStorePath();
        // String keystorePWD = ServerSettings.getCredentialStoreThriftServerKeyStorePassword();
        // params.setTrustStore(keystorePath, keystorePWD);
        final int serverPort = Integer.parseInt(ServerSettings.getCredentialStoreServerPort());
        final String serverHost = ServerSettings.getCredentialStoreServerHost();
        TTransport transport = new TSocket(serverHost, serverPort);
        transport.open();
        TProtocol protocol = new TBinaryProtocol(transport);
        // transport = TSSLTransportFactory.getClientSocket(serverHost, serverPort, 10000, params);
        // TProtocol protocol = new TBinaryProtocol(transport);
        CredentialStoreService.Client client = new CredentialStoreService.Client(protocol);
        testSSHCredential(client);
        testCertificateCredential(client);
        transport.close();
    } catch (TTransportException e) {
        e.printStackTrace();
    } catch (ApplicationSettingsException e) {
        e.printStackTrace();
    }
}
Also used : ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TProtocol(org.apache.thrift.protocol.TProtocol) TTransportException(org.apache.thrift.transport.TTransportException) TTransport(org.apache.thrift.transport.TTransport) CredentialStoreService(org.apache.airavata.credential.store.cpi.CredentialStoreService) TSocket(org.apache.thrift.transport.TSocket)

Example 47 with TTransportException

use of org.apache.thrift.transport.TTransportException in project airavata by apache.

the class CredentialStoreServer method start.

@Override
public void start() throws Exception {
    try {
        setStatus(ServerStatus.STARTING);
        final int serverPort = Integer.parseInt(ServerSettings.getCredentialStoreServerPort());
        final String serverHost = ServerSettings.getCredentialStoreServerHost();
        CredentialStoreService.Processor processor = new CredentialStoreService.Processor(new CredentialStoreServerHandler());
        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(processor));
        new Thread() {

            public void run() {
                server.serve();
                setStatus(ServerStatus.STOPPED);
                logger.info("Credential store 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 Credential store Server on Port " + serverPort);
                    logger.info("Listening to Credential store clients ....");
                }
            }
        }.start();
    } catch (TTransportException e) {
        setStatus(ServerStatus.FAILED);
        throw new Exception("Error while starting the credential store service", e);
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) TTransportException(org.apache.thrift.transport.TTransportException) TServerTransport(org.apache.thrift.transport.TServerTransport) TTransportException(org.apache.thrift.transport.TTransportException) TServerSocket(org.apache.thrift.transport.TServerSocket) TThreadPoolServer(org.apache.thrift.server.TThreadPoolServer) CredentialStoreService(org.apache.airavata.credential.store.cpi.CredentialStoreService)

Example 48 with TTransportException

use of org.apache.thrift.transport.TTransportException in project airavata by apache.

the class RegistryAPIServer method StartRegistryServer.

public void StartRegistryServer(RegistryService.Processor<RegistryServerHandler> orchestratorServerHandlerProcessor) throws Exception {
    // creating experiment catalog db
    logger.info("Initializing ExperimentCatalog DB");
    ExperimentCatalogInitUtil.initializeDB();
    // creating app catalog db
    logger.info("Initializing AppCatalog DB");
    AppCatalogInitUtil.initializeDB();
    // creating workflow catalog db
    logger.info("Initializing WorkflowCatalog DB");
    WorkflowCatalogInitUtil.initializeDB();
    // creating replica catalog db
    logger.info("Initializing ReplicaCatalog DB");
    ReplicaCatalogInitUtil.initializeDB();
    final int serverPort = Integer.parseInt(ServerSettings.getSetting(Constants.REGISTRY_SERVER_PORT, "8960"));
    try {
        final String serverHost = ServerSettings.getSetting(Constants.REGISTRY_SERVER_HOST, null);
        TServerTransport serverTransport;
        if (serverHost == null) {
            serverTransport = new TServerSocket(serverPort);
        } else {
            InetSocketAddress inetSocketAddress = new InetSocketAddress(serverHost, serverPort);
            serverTransport = new TServerSocket(inetSocketAddress);
        }
        // thrift server start
        TThreadPoolServer.Args options = new TThreadPoolServer.Args(serverTransport);
        options.minWorkerThreads = Integer.parseInt(ServerSettings.getSetting(Constants.REGISTRY_SERVER_MIN_THREADS, "30"));
        server = new TThreadPoolServer(options.processor(orchestratorServerHandlerProcessor));
        new Thread() {

            public void run() {
                server.serve();
                setStatus(ServerStatus.STARTING);
                logger.info("Starting Registry 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 Registry Server on Port " + serverPort + " ...");
                    // start db event handlers
                    if (!startDatabaseEventHandlers()) {
                        logger.error("Stopping Registry Server as DB event handlers failed to start!");
                        server.stop();
                    }
                }
            }
        }.start();
    } catch (TTransportException e) {
        logger.error(e.getMessage());
        setStatus(ServerStatus.FAILED);
        logger.error("Failed to start Registry 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 49 with TTransportException

use of org.apache.thrift.transport.TTransportException in project airavata by apache.

the class AuroraThriftClient method getJobList.

/**
 * Gets the job list.
 *
 * @param ownerRole the owner role
 * @return the job list
 * @throws Exception the exception
 */
public GetJobsResponseBean getJobList(String ownerRole) throws Exception {
    GetJobsResponseBean response = null;
    // try till we get response or scheduler connection not found
    while (response == null) {
        try {
            Response jobListResponse = this.readOnlySchedulerClient.getJobs(ownerRole);
            response = (GetJobsResponseBean) AuroraThriftClientUtil.getResponseBean(jobListResponse, ResponseResultType.GET_JOBS);
        } catch (Exception ex) {
            if (ex instanceof TTransportException) {
                // if re-connection success, retry command
                if (this.reconnectWithAuroraScheduler()) {
                    continue;
                }
            }
            logger.error(ex.getMessage(), ex);
            throw ex;
        }
    }
    return response;
}
Also used : Response(org.apache.airavata.cloud.aurora.client.sdk.Response) GetJobsResponseBean(org.apache.airavata.cloud.aurora.client.bean.GetJobsResponseBean) TTransportException(org.apache.thrift.transport.TTransportException) TTransportException(org.apache.thrift.transport.TTransportException)

Example 50 with TTransportException

use of org.apache.thrift.transport.TTransportException in project airavata by apache.

the class GfacServer method StartGfacServer.

public void StartGfacServer(GfacService.Processor<GfacServerHandler> gfacServerHandlerProcessor) throws Exception {
    final int serverPort = Integer.parseInt(ServerSettings.getGFacServerPort());
    try {
        final String serverHost = ServerSettings.getGfacServerHost();
        InetSocketAddress inetSocketAddress = new InetSocketAddress(serverHost, serverPort);
        TServerTransport serverTransport = new TServerSocket(inetSocketAddress);
        server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(gfacServerHandlerProcessor));
        new Thread() {

            public void run() {
                server.serve();
                setStatus(ServerStatus.STARTING);
                logger.info("Starting Gfac Server ...");
            }
        }.start();
        new Thread() {

            public void run() {
                while (!server.isServing()) {
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        break;
                    }
                }
                if (server.isServing()) {
                    setStatus(IServer.ServerStatus.STARTED);
                    logger.info("Started Gfac Server on Port " + serverPort + " ...");
                }
            }
        }.start();
    } catch (TTransportException e) {
        logger.error(e.getMessage());
        setStatus(IServer.ServerStatus.FAILED);
        logger.error("Failed to start Gfac 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)

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