use of org.apache.airavata.model.error.AiravataClientException in project airavata by apache.
the class AiravataClientFactory method createAiravataClient.
public static Airavata.Client createAiravataClient(String serverHost, int serverPort) throws AiravataClientException {
try {
TTransport transport = new TSocket(serverHost, serverPort);
transport.open();
TProtocol protocol = new TBinaryProtocol(transport);
// TMultiplexedProtocol mp = new TMultiplexedProtocol(protocol, "APIServer");
return new Airavata.Client(protocol);
} catch (TTransportException e) {
AiravataClientException exception = new AiravataClientException();
exception.setParameter("Unable to connect to the server at " + serverHost + ":" + serverPort);
throw exception;
}
}
use of org.apache.airavata.model.error.AiravataClientException in project airavata by apache.
the class AiravataClientFactory method createAiravataSecureClient.
/**
* This method returns a Airavata Client that talks to the API Server exposed over TLS.
*
* @param serverHost
* @param serverPort
* @param trustStorePath
* @param trustStorePassword
* @param clientTimeOut
* @return
* @throws AiravataClientConnectException
*/
public static Airavata.Client createAiravataSecureClient(String serverHost, int serverPort, String trustStorePath, String trustStorePassword, int clientTimeOut) throws AiravataClientException {
try {
TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters();
params.setTrustStore(trustStorePath, trustStorePassword);
TSocket transport = TSSLTransportFactory.getClientSocket(serverHost, serverPort, clientTimeOut, params);
TProtocol protocol = new TBinaryProtocol(transport);
return new Airavata.Client(protocol);
} catch (TTransportException e) {
logger.error(e.getMessage(), e);
AiravataClientException clientError = new AiravataClientException();
clientError.setParameter("Unable to connect to the server at " + serverHost + ":" + serverPort);
throw clientError;
}
}
use of org.apache.airavata.model.error.AiravataClientException in project airavata by apache.
the class RegisterUS3Application method registerComputeHost.
public static String registerComputeHost(String hostName, String hostDesc, ResourceJobManagerType resourceJobManagerType, String monitoringEndPoint, String jobMangerBinPath, SecurityProtocol securityProtocol, int portNumber, String jobManagerCommand) throws TException {
ComputeResourceDescription computeResourceDescription = RegisterSampleApplicationsUtils.createComputeResourceDescription(hostName, hostDesc, null, null);
String computeResourceId = airavataClient.registerComputeResource(new AuthzToken(""), computeResourceDescription);
if (computeResourceId.isEmpty())
throw new AiravataClientException();
ResourceJobManager resourceJobManager = RegisterSampleApplicationsUtils.createResourceJobManager(resourceJobManagerType, monitoringEndPoint, jobMangerBinPath, null);
if (jobManagerCommand != null) {
Map<JobManagerCommand, String> jobManagerCommandStringMap = new HashMap<JobManagerCommand, String>();
jobManagerCommandStringMap.put(JobManagerCommand.SUBMISSION, jobManagerCommand);
resourceJobManager.setJobManagerCommands(jobManagerCommandStringMap);
}
SSHJobSubmission sshJobSubmission = new SSHJobSubmission();
sshJobSubmission.setResourceJobManager(resourceJobManager);
sshJobSubmission.setSecurityProtocol(securityProtocol);
sshJobSubmission.setSshPort(portNumber);
airavataClient.addSSHJobSubmissionDetails(new AuthzToken(""), computeResourceId, 1, sshJobSubmission);
SCPDataMovement scpDataMovement = new SCPDataMovement();
scpDataMovement.setSecurityProtocol(securityProtocol);
scpDataMovement.setSshPort(portNumber);
airavataClient.addSCPDataMovementDetails(new AuthzToken(""), computeResourceId, DMType.COMPUTE_RESOURCE, 1, scpDataMovement);
return computeResourceId;
}
use of org.apache.airavata.model.error.AiravataClientException in project airavata by apache.
the class RegisterUS3Application method updateComputeHost.
public static String updateComputeHost(String computeResourceId, String hostName, String hostDesc, ResourceJobManagerType resourceJobManagerType, String monitoringEndPoint, String jobMangerBinPath, SecurityProtocol securityProtocol, int portNumber, String jobManagerCommand) throws TException {
if (computeResourceId.isEmpty())
throw new AiravataClientException();
ResourceJobManager resourceJobManager = RegisterSampleApplicationsUtils.createResourceJobManager(resourceJobManagerType, monitoringEndPoint, jobMangerBinPath, null);
if (jobManagerCommand != null) {
Map<JobManagerCommand, String> jobManagerCommandStringMap = new HashMap<JobManagerCommand, String>();
jobManagerCommandStringMap.put(JobManagerCommand.SUBMISSION, jobManagerCommand);
resourceJobManager.setJobManagerCommands(jobManagerCommandStringMap);
}
SSHJobSubmission sshJobSubmission = new SSHJobSubmission();
sshJobSubmission.setResourceJobManager(resourceJobManager);
sshJobSubmission.setSecurityProtocol(securityProtocol);
sshJobSubmission.setSshPort(portNumber);
airavataClient.addSSHJobSubmissionDetails(new AuthzToken(""), computeResourceId, 1, sshJobSubmission);
ComputeResourceDescription computeResourceDescription = airavataClient.getComputeResource(new AuthzToken(""), computeResourceId);
computeResourceDescription.getJobSubmissionInterfacesIterator();
SCPDataMovement scpDataMovement = new SCPDataMovement();
scpDataMovement.setSecurityProtocol(securityProtocol);
scpDataMovement.setSshPort(portNumber);
airavataClient.addSCPDataMovementDetails(new AuthzToken(""), computeResourceId, DMType.COMPUTE_RESOURCE, 1, scpDataMovement);
return computeResourceId;
}
use of org.apache.airavata.model.error.AiravataClientException in project airavata by apache.
the class ExperimentExecution method getProjects.
protected Map<String, List<Project>> getProjects(Map<String, String> tokenMap) throws Exception {
projectsMap = new HashMap<String, List<Project>>();
try {
if (tokenMap != null && !tokenMap.isEmpty()) {
for (String gatewayId : tokenMap.keySet()) {
List<Project> allUserProjects = airavata.getUserProjects(authzToken, gatewayId, testUser, 5, 0);
projectsMap.put(gatewayId, allUserProjects);
}
}
} catch (AiravataSystemException e) {
logger.error("Error while getting all user projects", e);
throw new Exception("Error while getting all user projects", e);
} catch (InvalidRequestException e) {
logger.error("Error while getting all user projects", e);
throw new Exception("Error while getting all user projects", e);
} catch (AiravataClientException e) {
logger.error("Error while getting all user projects", e);
throw new Exception("Error while getting all user projects", e);
} catch (TException e) {
logger.error("Error while getting all user projects", e);
throw new Exception("Error while getting all user projects", e);
}
return projectsMap;
}
Aggregations