Search in sources :

Example 1 with TenantProfileServiceHandler

use of org.apache.airavata.service.profile.handlers.TenantProfileServiceHandler 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)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 IamAdminServicesHandler (org.apache.airavata.service.profile.handlers.IamAdminServicesHandler)1 TenantProfileServiceHandler (org.apache.airavata.service.profile.handlers.TenantProfileServiceHandler)1 UserProfileServiceHandler (org.apache.airavata.service.profile.handlers.UserProfileServiceHandler)1 IamAdminServices (org.apache.airavata.service.profile.iam.admin.services.cpi.IamAdminServices)1 TenantProfileService (org.apache.airavata.service.profile.tenant.cpi.TenantProfileService)1 UserProfileService (org.apache.airavata.service.profile.user.cpi.UserProfileService)1 TMultiplexedProcessor (org.apache.thrift.TMultiplexedProcessor)1 TThreadPoolServer (org.apache.thrift.server.TThreadPoolServer)1 TServerSocket (org.apache.thrift.transport.TServerSocket)1 TServerTransport (org.apache.thrift.transport.TServerTransport)1 TTransportException (org.apache.thrift.transport.TTransportException)1