Search in sources :

Example 1 with AiravataSystemException

use of org.apache.airavata.model.error.AiravataSystemException in project airavata by apache.

the class AiravataAPIServer method startAiravataServer.

public void startAiravataServer(Airavata.Processor<Airavata.Iface> airavataAPIServer) throws AiravataSystemException {
    try {
        final String serverHost = ServerSettings.getSetting(Constants.API_SERVER_HOST, null);
        if (!ServerSettings.isTLSEnabled()) {
            final int serverPort = Integer.parseInt(ServerSettings.getSetting(Constants.API_SERVER_PORT, "8930"));
            TServerTransport serverTransport;
            if (ServerSettings.isAPIServerTLSEnabled()) {
                logger.info("Starting API Server with TLS Security..");
                String keystore = ServerSettings.getApiServerKeystore();
                String keystorePWD = ServerSettings.getApiServerKeystorePasswd();
                TSSLTransportFactory.TSSLTransportParameters tlsParams = new TSSLTransportFactory.TSSLTransportParameters();
                tlsParams.setKeyStore(keystore, keystorePWD);
                serverTransport = TSSLTransportFactory.getServerSocket(serverPort, 10000, InetAddress.getByName(serverHost), tlsParams);
            } else {
                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 = Integer.parseInt(ServerSettings.getSetting(Constants.API_SERVER_MIN_THREADS, "50"));
            server = new TThreadPoolServer(options.processor(airavataAPIServer));
            new Thread() {

                public void run() {
                    server.serve();
                    setStatus(ServerStatus.STOPPED);
                    logger.info("Airavata API 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 Airavata API Server on Port " + serverPort);
                        logger.info("Listening to Airavata Clients ....");
                    }
                }
            }.start();
            logger.info("Started API Server ....");
        } else {
            /**
             ********start thrift server over TLS*****************
             */
            TSSLTransportFactory.TSSLTransportParameters TLSParams = new TSSLTransportFactory.TSSLTransportParameters();
            TLSParams.setKeyStore(ServerSettings.getKeyStorePath(), ServerSettings.getKeyStorePassword());
            TServerSocket TLSServerTransport = TSSLTransportFactory.getServerSocket(ServerSettings.getTLSServerPort(), ServerSettings.getTLSClientTimeout(), InetAddress.getByName(serverHost), TLSParams);
            TThreadPoolServer.Args settings = new TThreadPoolServer.Args(TLSServerTransport);
            settings.minWorkerThreads = Integer.parseInt(ServerSettings.getSetting(Constants.API_SERVER_MIN_THREADS, "50"));
            TLSServer = new TThreadPoolServer(settings.processor(airavataAPIServer));
            new Thread() {

                public void run() {
                    TLSServer.serve();
                    setStatus(ServerStatus.STOPPED);
                    logger.info("Airavata API Server over TLS Stopped.");
                }
            }.start();
            new Thread() {

                public void run() {
                    while (!TLSServer.isServing()) {
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            break;
                        }
                    }
                    if (TLSServer.isServing()) {
                        setStatus(ServerStatus.STARTED);
                    }
                }
            }.start();
            logger.info("API server started over TLS on Port: " + ServerSettings.getTLSServerPort() + " ...");
        }
        /*perform any security related initialization at the server startup, according to the underlying security
             manager implementation being used.*/
        AiravataSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
        securityManager.initializeSecurityInfra();
    } catch (TTransportException e) {
        logger.error(e.getMessage(), e);
        setStatus(ServerStatus.FAILED);
        logger.error("Failed to start API server ...");
        throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
    } catch (ApplicationSettingsException e) {
        logger.error(e.getMessage(), e);
        throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
    } catch (UnknownHostException e) {
        logger.error(e.getMessage(), e);
        throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
    } catch (AiravataSecurityException e) {
        logger.error(e.getMessage(), e);
        throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
    }
}
Also used : ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) UnknownHostException(java.net.UnknownHostException) InetSocketAddress(java.net.InetSocketAddress) AiravataSecurityManager(org.apache.airavata.service.security.AiravataSecurityManager) TTransportException(org.apache.thrift.transport.TTransportException) TSSLTransportFactory(org.apache.thrift.transport.TSSLTransportFactory) TServerTransport(org.apache.thrift.transport.TServerTransport) TServerSocket(org.apache.thrift.transport.TServerSocket) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException) TThreadPoolServer(org.apache.thrift.server.TThreadPoolServer) AiravataSecurityException(org.apache.airavata.security.AiravataSecurityException)

Example 2 with AiravataSystemException

use of org.apache.airavata.model.error.AiravataSystemException in project airavata by apache.

the class ExperimentExecution method getApplicationMap.

protected Map<String, Map<String, String>> getApplicationMap(Map<String, String> tokenMap) throws Exception {
    appInterfaceMap = new HashMap<String, Map<String, String>>();
    try {
        if (tokenMap != null && !tokenMap.isEmpty()) {
            for (String gatewayId : tokenMap.keySet()) {
                Map<String, String> allApplicationInterfaceNames = airavata.getAllApplicationInterfaceNames(authzToken, gatewayId);
                appInterfaceMap.put(gatewayId, allApplicationInterfaceNames);
            }
        }
    } catch (AiravataSystemException e) {
        logger.error("Error while getting application interfaces", e);
        throw new Exception("Error while getting application interfaces", e);
    } catch (InvalidRequestException e) {
        logger.error("Error while getting application interfaces", e);
        throw new Exception("Error while getting application interfaces", e);
    } catch (AiravataClientException e) {
        logger.error("Error while getting application interfaces", e);
        throw new Exception("Error while getting application interfaces", e);
    } catch (TException e) {
        logger.error("Error while getting application interfaces", e);
        throw new Exception("Error while getting application interfaces", e);
    }
    return appInterfaceMap;
}
Also used : TException(org.apache.thrift.TException) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) TException(org.apache.thrift.TException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException)

Example 3 with AiravataSystemException

use of org.apache.airavata.model.error.AiravataSystemException in project airavata by apache.

the class GatewayRegister method createGateway.

public void createGateway() throws Exception {
    try {
        // read gateway count from properties file
        List<GatewayResourceProfile> gateReourceProfiles = airavata.getAllGatewayResourceProfiles(authzToken);
        for (GatewayResourceProfile gatewayResourceProfile : gateReourceProfiles) {
            if (gatewayResourceProfile.getGatewayID().equals(properties.getGname())) {
                createProject(gatewayResourceProfile.getGatewayID());
                return;
            }
        }
        String genericGatewayName = properties.getGname();
        String genericGatewayDomain = properties.getGdomain();
        Gateway gateway = new Gateway();
        String gatewayId = genericGatewayName;
        gateway.setGatewayId(gatewayId);
        gateway.setGatewayName(gatewayId);
        gateway.setDomain(gatewayId + genericGatewayDomain);
        gateway.setGatewayApprovalStatus(GatewayApprovalStatus.APPROVED);
        airavata.addGateway(authzToken, gateway);
        String token = airavata.generateAndRegisterSSHKeys(authzToken, gatewayId, testUser, testUser, CredentialOwnerType.USER);
        GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
        gatewayResourceProfile.setCredentialStoreToken(token);
        gatewayResourceProfile.setGatewayID(gatewayId);
        airavata.registerGatewayResourceProfile(authzToken, gatewayResourceProfile);
        createProject(gatewayId);
    } catch (AiravataSystemException e) {
        logger.error("Error while creating airavata client instance", e);
        throw new Exception("Error while creating airavata client instance", e);
    } catch (InvalidRequestException e) {
        logger.error("Invalid request for airavata client instance", e);
        throw new Exception("Invalid request for airavata client instance", e);
    } catch (AiravataClientException e) {
        logger.error("Error while creating airavata client instance", e);
        throw new Exception("Error while creating airavata client instance", e);
    } catch (TException e) {
        logger.error("Error while communicating with airavata client ", e);
        throw new Exception("Error while communicating with airavata client", e);
    }
}
Also used : TException(org.apache.thrift.TException) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) Gateway(org.apache.airavata.model.workspace.Gateway) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) CredentialStoreException(org.apache.airavata.credential.store.store.CredentialStoreException) TException(org.apache.thrift.TException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException)

Example 4 with AiravataSystemException

use of org.apache.airavata.model.error.AiravataSystemException in project airavata by apache.

the class CreateLaunchExperimentUS3 method createUS3ExperimentForTrestles.

public static String createUS3ExperimentForTrestles(Airavata.Client client) throws AiravataSystemException, InvalidRequestException, AiravataClientException, TException {
    try {
        List<InputDataObjectType> exInputs = new ArrayList<InputDataObjectType>();
        InputDataObjectType input = new InputDataObjectType();
        input.setName("input");
        input.setType(DataType.URI);
        input.setValue("file:///home/sgg/chathuri/laptop_backup/airavata/ultrascan_input/hpcinput.tar");
        InputDataObjectType input1 = new InputDataObjectType();
        input1.setName("walltime");
        input1.setType(DataType.STRING);
        input1.setValue("-walltime=60");
        InputDataObjectType input2 = new InputDataObjectType();
        input2.setName("mgroupcount");
        input2.setType(DataType.STRING);
        input2.setValue("-mgroupcount=1");
        exInputs.add(input);
        exInputs.add(input1);
        exInputs.add(input2);
        List<OutputDataObjectType> exOut = new ArrayList<OutputDataObjectType>();
        OutputDataObjectType output = new OutputDataObjectType();
        output.setName("output");
        output.setType(DataType.URI);
        output.setValue("");
        // OutputDataObjectType output1 = new OutputDataObjectType();
        // output1.setName("stdout");
        // output1.setType(DataType.STDOUT);
        // output1.setValue("");
        // OutputDataObjectType output2 = new OutputDataObjectType();
        // output2.setName("stderr");
        // output2.setType(DataType.STDERR);
        // output2.setValue("");
        exOut.add(output);
        // exOut.add(output1);
        // exOut.add(output2);
        Project project = ProjectModelUtil.createProject("ultrascan", "ultrascan", "test project");
        String projectId = client.createProject(new AuthzToken(""), DEFAULT_GATEWAY, project);
        ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(DEFAULT_GATEWAY, projectId, "ultrascan", "US3ExperimentTrestles", "US3AppTrestles", "ultrascan_7ce6cd43-622c-44e0-87c5-fb7a6528c799", exInputs);
        simpleExperiment.setExperimentOutputs(exOut);
        ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling("trestles.sdsc.xsede.org_72b9181b-7156-4975-a386-ed98b4949496", 32, 1, 0, "shared", 30, 0);
        UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
        scheduling.setResourceHostId("trestles.sdsc.xsede.org_72b9181b-7156-4975-a386-ed98b4949496");
        userConfigurationData.setAiravataAutoSchedule(false);
        userConfigurationData.setOverrideManualScheduledParams(false);
        /*          AdvancedOutputDataHandling dataHandling = new AdvancedOutputDataHandling();
            dataHandling.setOutputDataDir("/home/sgg/chathuri/laptop_backup/airavata");
            userConfigurationData.setAdvanceOutputDataHandling(dataHandling);*/
        userConfigurationData.setComputationalResourceScheduling(scheduling);
        simpleExperiment.setUserConfigurationData(userConfigurationData);
        return client.createExperiment(new AuthzToken(""), DEFAULT_GATEWAY, simpleExperiment);
    } catch (AiravataSystemException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new AiravataSystemException(e);
    } catch (InvalidRequestException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new InvalidRequestException(e);
    } catch (AiravataClientException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new AiravataClientException(e);
    } catch (TException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new TException(e);
    }
}
Also used : TException(org.apache.thrift.TException) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ArrayList(java.util.ArrayList) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) Project(org.apache.airavata.model.workspace.Project) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) UserConfigurationDataModel(org.apache.airavata.model.experiment.UserConfigurationDataModel) AuthzToken(org.apache.airavata.model.security.AuthzToken) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)

Example 5 with AiravataSystemException

use of org.apache.airavata.model.error.AiravataSystemException in project airavata by apache.

the class WorkflowInterpreterLaunchWindow method initGUI.

private void initGUI() {
    this.parameterPanel = new GridPanel(true);
    GridPanel infoPanel = new GridPanel();
    this.instanceNameTextField = new XBayaTextField();
    XBayaLabel instanceNameLabel = new XBayaLabel("Experiment name", this.instanceNameTextField);
    infoPanel.add(instanceNameLabel);
    infoPanel.add(this.instanceNameTextField);
    token = new XBayaTextField("");
    JLabel tokenLabel = new JLabel("Token Id: ");
    infoPanel.add(tokenLabel);
    infoPanel.add(token);
    infoPanel.layout(2, 2, GridPanel.WEIGHT_NONE, 1);
    GridPanel mainPanel = new GridPanel();
    mainPanel.getContentPanel().setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    mainPanel.add(infoPanel);
    mainPanel.add(this.parameterPanel);
    mainPanel.layout(2, 1, 0, 0);
    JButton okButton = new JButton("Run");
    okButton.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            try {
                execute();
            } catch (AiravataClientConnectException e1) {
                e1.printStackTrace();
            } catch (InvalidRequestException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (AiravataClientException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (AiravataSystemException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (TException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            hide();
        }
    });
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(okButton);
    buttonPanel.add(cancelButton);
    buttonPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    this.dialog = new XBayaDialog(this.engine.getGUI(), "Launch  workflow", mainPanel, buttonPanel);
    this.dialog.setDefaultButton(okButton);
}
Also used : TException(org.apache.thrift.TException) JPanel(javax.swing.JPanel) XBayaDialog(org.apache.airavata.xbaya.ui.dialogs.XBayaDialog) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException) GridPanel(org.apache.airavata.xbaya.ui.widgets.GridPanel) AiravataClientConnectException(org.apache.airavata.model.error.AiravataClientConnectException) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) AbstractAction(javax.swing.AbstractAction) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Aggregations

AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)16 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)15 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)15 TException (org.apache.thrift.TException)15 ArrayList (java.util.ArrayList)6 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)6 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)6 ExperimentModel (org.apache.airavata.model.experiment.ExperimentModel)6 UserConfigurationDataModel (org.apache.airavata.model.experiment.UserConfigurationDataModel)6 ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)6 AuthzToken (org.apache.airavata.model.security.AuthzToken)6 Project (org.apache.airavata.model.workspace.Project)5 XBayaLabel (org.apache.airavata.xbaya.ui.widgets.XBayaLabel)4 XBayaTextField (org.apache.airavata.xbaya.ui.widgets.XBayaTextField)4 JLabel (javax.swing.JLabel)3 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)3 ActionEvent (java.awt.event.ActionEvent)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2