All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.airavata.testsuite.multitenantedairavata.AiravataClient Maven / Gradle / Ivy

There is a newer version: 0.16
Show newest version
/*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
*/

package org.apache.airavata.testsuite.multitenantedairavata;

import org.apache.airavata.api.Airavata;
import org.apache.airavata.api.client.AiravataClientFactory;
import org.apache.airavata.model.error.AiravataClientConnectException;
import org.apache.airavata.testsuite.multitenantedairavata.utils.PropertyFileType;
import org.apache.airavata.testsuite.multitenantedairavata.utils.PropertyReader;
import org.apache.airavata.testsuite.multitenantedairavata.utils.TestFrameworkConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AiravataClient {
    private static Airavata.Client airavataClient;
    private PropertyReader propertyReader;
    private final static Logger logger = LoggerFactory.getLogger(AiravataClient.class);

    private static AiravataClient ourInstance = new AiravataClient();

    public static AiravataClient getInstance() {
        return ourInstance;
    }

    private AiravataClient() {
        propertyReader = new PropertyReader();
    }

    public Airavata.Client getAiravataClient() throws Exception{
        try {
            String airavataHost = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.THRIFT_SERVER_HOST, PropertyFileType.AIRAVATA_CLIENT);
            int airavataport = Integer.valueOf(propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.THRIFT_SERVER_PORT, PropertyFileType.AIRAVATA_CLIENT));
            airavataClient = AiravataClientFactory.createAiravataClient(airavataHost, airavataport);
            return airavataClient;
        } catch (AiravataClientConnectException e) {
            logger.error("Error while creating airavata client instance", e);
            throw new Exception("Error while creating airavata client instance", e);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy