use of org.apache.airavata.model.security.AuthzToken in project airavata by apache.
the class SingleAppIntegrationTestBase method monitorJob.
// monitoring the job
protected void monitorJob(final String expId) {
Thread monitor = (new Thread() {
public void run() {
authzToken = new AuthzToken("empty token");
long previousUpdateTime = -1;
ExperimentStatus experimentStatus = null;
do {
try {
experimentStatus = airavataClient.getExperimentStatus(authzToken, expId);
if (previousUpdateTime != experimentStatus.getTimeOfStateChange()) {
previousUpdateTime = experimentStatus.getTimeOfStateChange();
log.info(expId + " : " + experimentStatus.getState().toString() + " [" + new Date(previousUpdateTime).toString() + "]");
}
Thread.sleep(2000);
} catch (Exception e) {
log.error("Thread interrupted", e);
}
Assert.assertFalse(experimentStatus.getState().equals(ExperimentState.FAILED));
} while (!experimentStatus.getState().equals(ExperimentState.COMPLETED));
}
});
monitor.start();
try {
monitor.join();
} catch (InterruptedException e) {
log.error("Thread interrupted..", e.getMessage());
}
}
use of org.apache.airavata.model.security.AuthzToken in project airavata by apache.
the class SingleAppIntegrationTestBase method launchExperiment.
protected void launchExperiment(String expId) throws ExperimentNotFoundException, AiravataSystemException, InvalidRequestException, TException {
authzToken = new AuthzToken("empty token");
getClient().launchExperiment(authzToken, expId, "testToken");
}
use of org.apache.airavata.model.security.AuthzToken in project airavata by apache.
the class SecurityInterceptor method invoke.
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
// obtain the authz token from the input parameters
AuthzToken authzToken = (AuthzToken) invocation.getArguments()[0];
// authorize the API call
HashMap<String, String> metaDataMap = new HashMap();
metaDataMap.put(Constants.API_METHOD_NAME, invocation.getMethod().getName());
authorize(authzToken, metaDataMap);
// set the user identity info in a thread local to be used in downstream execution.
IdentityContext.set(authzToken);
// let the method call procees upon successful authorization
Object returnObj = invocation.proceed();
// clean the identity context before the method call returns
IdentityContext.unset();
return returnObj;
}
use of org.apache.airavata.model.security.AuthzToken in project airavata by apache.
the class CreateLaunchExperiment method createExperimentForStampedeAmber.
public static String createExperimentForStampedeAmber(Airavata.Client client) throws TException {
try {
List<InputDataObjectType> exInputs = client.getApplicationInputs(new AuthzToken(""), amberAppId);
// }
for (InputDataObjectType inputDataObjectType : exInputs) {
if (inputDataObjectType.getName().equalsIgnoreCase("Heat_Restart_File")) {
inputDataObjectType.setValue("file://ogce@stampede.xsede.org:/scratch/01437/ogce/gta-work-dirs/PROCESS_e0610a6c-5778-4a69-a004-f440e29194af/02_Heat.rst");
} else if (inputDataObjectType.getName().equalsIgnoreCase("Production_Control_File")) {
inputDataObjectType.setValue("file://ogce@stampede.xsede.org:/scratch/01437/ogce/gta-work-dirs/PROCESS_e0610a6c-5778-4a69-a004-f440e29194af/03_Prod.in");
} else if (inputDataObjectType.getName().equalsIgnoreCase("Parameter_Topology_File")) {
inputDataObjectType.setValue("file://ogce@stampede.xsede.org:/scratch/01437/ogce/gta-work-dirs/PROCESS_e0610a6c-5778-4a69-a004-f440e29194af/prmtop");
}
}
List<OutputDataObjectType> exOut = client.getApplicationOutputs(new AuthzToken(""), amberAppId);
Project project = ProjectModelUtil.createProject("default", "admin", "test project");
String projectId = client.createProject(new AuthzToken(""), DEFAULT_GATEWAY, project);
ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(DEFAULT_GATEWAY, projectId, "admin", "sshEchoExperiment", "SimpleEchoBR", amberAppId, exInputs);
simpleExperiment.setExperimentOutputs(exOut);
Map<String, String> computeResources = airavataClient.getAvailableAppInterfaceComputeResources(new AuthzToken(""), amberAppId);
if (computeResources != null && computeResources.size() != 0) {
for (String id : computeResources.keySet()) {
String resourceName = computeResources.get(id);
if (resourceName.equals(stampedeHostName)) {
ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 4, 1, 1, "normal", 20, 1);
UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
userConfigurationData.setAiravataAutoSchedule(false);
userConfigurationData.setOverrideManualScheduledParams(false);
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);
}
return null;
}
use of org.apache.airavata.model.security.AuthzToken in project airavata by apache.
the class CreateLaunchExperiment method createMPIExperimentForFSD.
public static String createMPIExperimentForFSD(Airavata.Client client) throws TException {
try {
List<InputDataObjectType> exInputs = client.getApplicationInputs(new AuthzToken(""), mpiAppId);
for (InputDataObjectType inputDataObjectType : exInputs) {
if (inputDataObjectType.getName().equalsIgnoreCase("Sample_Input")) {
inputDataObjectType.setValue("");
}
}
List<OutputDataObjectType> exOut = client.getApplicationOutputs(new AuthzToken(""), mpiAppId);
ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(DEFAULT_GATEWAY, "default", "admin", "mpiExperiment", "HelloMPI", mpiAppId, null);
simpleExperiment.setExperimentOutputs(exOut);
Map<String, String> computeResources = airavataClient.getAvailableAppInterfaceComputeResources(new AuthzToken(""), mpiAppId);
if (computeResources != null && computeResources.size() != 0) {
for (String id : computeResources.keySet()) {
String resourceName = computeResources.get(id);
if (resourceName.equals(unicoreHostName)) {
ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 2, 1, 2, "normal", 30, 1048576);
UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
userConfigurationData.setAiravataAutoSchedule(false);
userConfigurationData.setOverrideManualScheduledParams(false);
userConfigurationData.setComputationalResourceScheduling(scheduling);
userConfigurationData.setGenerateCert(false);
userConfigurationData.setUserDN("");
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);
}
return null;
}
Aggregations