use of org.apache.airavata.registry.cpi.ComputeResource in project airavata by apache.
the class UserResourceProfileTest method userProfileTest.
@Test
public void userProfileTest() throws Exception {
UsrResourceProfile userProfile = appcatalog.getUserResourceProfile();
UserResourceProfile uf = new UserResourceProfile();
ComputeResource computeRs = appcatalog.getComputeResource();
ComputeResourceDescription cm1 = new ComputeResourceDescription();
cm1.setHostName("localhost");
cm1.setResourceDescription("test compute host");
String hostId1 = computeRs.addComputeResource(cm1);
ComputeResourceDescription cm2 = new ComputeResourceDescription();
cm2.setHostName("localhost");
cm2.setResourceDescription("test compute host");
String hostId2 = computeRs.addComputeResource(cm2);
UserComputeResourcePreference preference1 = new UserComputeResourcePreference();
preference1.setComputeResourceId(hostId1);
preference1.setPreferredBatchQueue("queue1");
preference1.setScratchLocation("/tmp");
preference1.setAllocationProjectNumber("project1");
UserComputeResourcePreference preference2 = new UserComputeResourcePreference();
preference2.setComputeResourceId(hostId2);
preference2.setPreferredBatchQueue("queue2");
preference2.setScratchLocation("/tmp");
preference2.setAllocationProjectNumber("project2");
UserStoragePreference storagePreference = new UserStoragePreference();
storagePreference.setStorageResourceId("st3");
storagePreference.setLoginUserName("Anuj");
storagePreference.setFileSystemRootLocation("/home/Anuj/scratch/");
List<UserComputeResourcePreference> list = new ArrayList<UserComputeResourcePreference>();
list.add(preference1);
list.add(preference2);
List<UserStoragePreference> stList = new ArrayList<>();
stList.add(storagePreference);
uf.setUserComputeResourcePreferences(list);
uf.setGatewayID("airavataPGA");
uf.setUserId("Anuj");
uf.setUserStoragePreferences(stList);
// Check if UserResourceProfile exists (should not exist)
// This tests the mechanism that PGA will use to figure out if a user doesn't already have a UserResourceProfile
UserResourceProfile checkUserResourceProfile = userProfile.getUserResourceProfile(uf.getUserId(), uf.getGatewayID());
assertNotNull(checkUserResourceProfile.getUserId());
assertNotNull(checkUserResourceProfile.getGatewayID());
assertTrue(checkUserResourceProfile.isIsNull());
String gwId = userProfile.addUserResourceProfile(uf);
UserResourceProfile retrievedProfile = null;
// This test is to check whether an existing user can add more compute preferences - AIRAVATA-2245
System.out.println("*********Start Airavata-2245************");
ComputeResource computeRs1 = appcatalog.getComputeResource();
ComputeResourceDescription cm12 = new ComputeResourceDescription();
cm12.setHostName("localhost123");
cm12.setResourceDescription("test compute host");
String hostId12 = computeRs1.addComputeResource(cm12);
UserComputeResourcePreference preference12 = new UserComputeResourcePreference();
preference12.setComputeResourceId(hostId12);
preference12.setPreferredBatchQueue("queue112");
preference12.setScratchLocation("/tmp21");
preference12.setAllocationProjectNumber("project12");
List<UserComputeResourcePreference> list12 = new ArrayList<UserComputeResourcePreference>();
list12.add(preference12);
UserResourceProfile uf12 = new UserResourceProfile();
uf12.setUserComputeResourcePreferences(list12);
uf12.setGatewayID("airavataPGA");
uf12.setUserId("Anuj");
String gwId12 = userProfile.addUserResourceProfile(uf12);
System.out.println("*******End Airavata-2245******* : success");
// retrievedProfile = userProfile.getUserResourceProfile("hello",uf.getGatewayID());
if (userProfile.isUserResourceProfileExists(uf.getUserId(), uf.getGatewayID())) {
retrievedProfile = userProfile.getUserResourceProfile(uf.getUserId(), uf.getGatewayID());
assertFalse(retrievedProfile.isIsNull());
System.out.println("gateway ID :" + retrievedProfile.getGatewayID());
System.out.println("user ID : " + retrievedProfile.getUserId());
System.out.println("compute resource size : " + retrievedProfile.getUserComputeResourcePreferencesSize());
}
if (retrievedProfile != null) {
List<UserComputeResourcePreference> preferences = userProfile.getAllUserComputeResourcePreferences(retrievedProfile.getUserId(), retrievedProfile.getGatewayID());
System.out.println("compute preferences size : " + preferences.size());
if (preferences != null && !preferences.isEmpty()) {
for (UserComputeResourcePreference cm : preferences) {
System.out.println("******** host id ********* : " + cm.getComputeResourceId());
System.out.println(cm.getPreferredBatchQueue());
// this statement will remove all the compute resources created
System.out.println("Compute Preference removed : " + userProfile.removeUserComputeResourcePreferenceFromGateway(retrievedProfile.getUserId(), retrievedProfile.getGatewayID(), cm.getComputeResourceId()));
}
}
List<UserStoragePreference> storagePreferences = userProfile.getAllUserStoragePreferences(retrievedProfile.getUserId(), retrievedProfile.getGatewayID());
System.out.println("storage preferences size : " + storagePreferences.size());
if (storagePreferences != null && !storagePreferences.isEmpty()) {
for (UserStoragePreference cm : storagePreferences) {
System.out.println("******** storage id ********* : " + cm.getStorageResourceId());
System.out.println(cm.getFileSystemRootLocation());
// this statement will remove all the compute resources created
System.out.println("Storage Preference removed : " + userProfile.removeUserDataStoragePreferenceFromGateway(retrievedProfile.getUserId(), retrievedProfile.getGatewayID(), cm.getStorageResourceId()));
}
}
// remove the user resource profile created.
System.out.println("User Resource profile removed : " + userProfile.removeUserResourceProfile(retrievedProfile.getUserId(), retrievedProfile.getGatewayID()));
} else {
System.out.println("User resource profile is null");
}
assertTrue("App interface saved successfully", retrievedProfile != null);
}
use of org.apache.airavata.registry.cpi.ComputeResource in project airavata by apache.
the class ComputeAppCatalogExperimentCatResourceTest method testAddComputeResource.
@Test
public void testAddComputeResource() {
try {
ComputeResource computeResource = appcatalog.getComputeResource();
ComputeResourceDescription description = new ComputeResourceDescription();
description.setHostName("localhost");
description.setResourceDescription("test compute resource");
List<String> ipdaresses = new ArrayList<String>();
ipdaresses.add("222.33.43.444");
ipdaresses.add("23.344.44.454");
description.setIpAddresses(ipdaresses);
// List<String> aliases = new ArrayList<String>();
// aliases.add("test.alias1");
// aliases.add("test.alias2");
// description.setHostAliases(aliases);
String sshsubmissionId = addSSHJobSubmission();
System.out.println("**** SSH Submission id ****** :" + sshsubmissionId);
// String gsiSSHsubmissionId = addGSISSHJobSubmission();
// System.out.println("**** GSISSH Submission id ****** :" + gsiSSHsubmissionId);
// String globusSubmissionId = addGlobusJobSubmission();
// System.out.println("**** Globus Submission id ****** :" + globusSubmissionId);
JobSubmissionInterface sshSubmissionInt = new JobSubmissionInterface();
sshSubmissionInt.setJobSubmissionInterfaceId(sshsubmissionId);
sshSubmissionInt.setPriorityOrder(1);
sshSubmissionInt.setJobSubmissionProtocol(JobSubmissionProtocol.SSH);
// JobSubmissionInterface globusSubInt = new JobSubmissionInterface();
// globusSubInt.setJobSubmissionInterfaceId(globusSubmissionId);
// globusSubInt.setPriorityOrder(2);
// globusSubInt.setJobSubmissionProtocol(JobSubmissionProtocol.GLOBUS);
List<JobSubmissionInterface> interfaceList = new ArrayList<JobSubmissionInterface>();
interfaceList.add(sshSubmissionInt);
// interfaceList.add(globusSubInt);
description.setJobSubmissionInterfaces(interfaceList);
String scpDataMoveId = addSCPDataMovement();
System.out.println("**** SCP DataMoveId****** :" + scpDataMoveId);
String gridFTPDataMoveId = addGridFTPDataMovement();
System.out.println("**** grid FTP DataMoveId****** :" + gridFTPDataMoveId);
List<DataMovementInterface> dataMovementInterfaces = new ArrayList<DataMovementInterface>();
DataMovementInterface scpInterface = new DataMovementInterface();
scpInterface.setDataMovementInterfaceId(scpDataMoveId);
scpInterface.setDataMovementProtocol(DataMovementProtocol.SCP);
scpInterface.setPriorityOrder(1);
DataMovementInterface gridFTPMv = new DataMovementInterface();
gridFTPMv.setDataMovementInterfaceId(gridFTPDataMoveId);
gridFTPMv.setDataMovementProtocol(DataMovementProtocol.GridFTP);
gridFTPMv.setPriorityOrder(2);
description.setDataMovementInterfaces(dataMovementInterfaces);
BatchQueue batchQueue1 = new BatchQueue();
batchQueue1.setQueueName("queue1");
batchQueue1.setQueueDescription("que1Desc1");
batchQueue1.setMaxRunTime(10);
batchQueue1.setMaxNodes(4);
batchQueue1.setMaxJobsInQueue(1);
BatchQueue batchQueue2 = new BatchQueue();
batchQueue2.setQueueName("queue2");
batchQueue2.setQueueDescription("que1Desc2");
batchQueue2.setMaxRunTime(10);
batchQueue2.setMaxNodes(4);
batchQueue2.setMaxJobsInQueue(1);
List<BatchQueue> batchQueueList = new ArrayList<BatchQueue>();
batchQueueList.add(batchQueue1);
batchQueueList.add(batchQueue2);
description.setBatchQueues(batchQueueList);
Map<FileSystems, String> fileSysMap = new HashMap<FileSystems, String>();
fileSysMap.put(FileSystems.HOME, "/home");
fileSysMap.put(FileSystems.SCRATCH, "/tmp");
description.setFileSystems(fileSysMap);
String resourceId = computeResource.addComputeResource(description);
System.out.println("**********Resource id ************* : " + resourceId);
ComputeResourceDescription host = null;
if (computeResource.isComputeResourceExists(resourceId)) {
host = computeResource.getComputeResource(resourceId);
List<BatchQueue> batchQueues = host.getBatchQueues();
for (BatchQueue queue : batchQueues) {
System.out.println("%%%%%%%%%%%%%%%% queue description : %%%%%%%%%%%%%%%%%%% : " + queue.getQueueDescription());
}
List<String> hostAliases = host.getHostAliases();
if (hostAliases != null && !hostAliases.isEmpty()) {
for (String alias : hostAliases) {
System.out.println("%%%%%%%%%%%%%%%% alias value : %%%%%%%%%%%%%%%%%%% : " + alias);
}
}
host.addToHostAliases("abc");
computeResource.updateComputeResource(resourceId, host);
List<String> hostAliases1 = computeResource.getComputeResource(resourceId).getHostAliases();
for (String alias : hostAliases1) {
System.out.println("%%%%%%%%%%%%%%%% alias value : %%%%%%%%%%%%%%%%%%% : " + alias);
}
System.out.println("**********Resource name ************* : " + host.getHostName());
}
SSHJobSubmission sshJobSubmission = computeResource.getSSHJobSubmission(sshsubmissionId);
System.out.println("**********SSH Submission resource job manager ************* : " + sshJobSubmission.getResourceJobManager().toString());
System.out.println("**********Monitor mode ************* : " + sshJobSubmission.getMonitorMode().toString());
// GlobusJobSubmission globusJobSubmission = computeResource.get(globusSubmissionId);
// System.out.println("**********Globus Submission resource job manager ************* : " + globusJobSubmission.getResourceJobManager().toString());
SCPDataMovement scpDataMovement = computeResource.getSCPDataMovement(scpDataMoveId);
System.out.println("**********SCP Data Move Security protocol ************* : " + scpDataMovement.getSecurityProtocol().toString());
GridFTPDataMovement gridFTPDataMovement = computeResource.getGridFTPDataMovement(gridFTPDataMoveId);
System.out.println("**********GRID FTP Data Move Security protocol ************* : " + gridFTPDataMovement.getSecurityProtocol().toString());
description.setHostName("localhost2");
computeResource.updateComputeResource(resourceId, description);
if (computeResource.isComputeResourceExists(resourceId)) {
host = computeResource.getComputeResource(resourceId);
System.out.println("**********Updated Resource name ************* : " + host.getHostName());
}
Map<String, String> cfilters = new HashMap<String, String>();
cfilters.put(AppCatAbstractResource.ComputeResourceConstants.HOST_NAME, "localhost2");
List<ComputeResourceDescription> computeResourceList = computeResource.getComputeResourceList(cfilters);
System.out.println("**********Size of compute resources ************* : " + computeResourceList.size());
List<ComputeResourceDescription> allComputeResourceList = computeResource.getAllComputeResourceList();
System.out.println("**********Size of all compute resources ************* : " + allComputeResourceList.size());
Map<String, String> allComputeResourceIdList = computeResource.getAllComputeResourceIdList();
System.out.println("**********Size of all compute resources ids ************* : " + allComputeResourceIdList.size());
// Map<String, String> globusfilters = new HashMap<String, String>();
// globusfilters.put(AbstractResource.GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER, ResourceJobManager.PBS.toString());
// List<GlobusJobSubmission> gList = computeResource.getGlobusJobSubmissionList(globusfilters);
// System.out.println("**********Size of globus jobs ************* : " + gList.size());
// Map<String, String> sshfilters = new HashMap<String, String>();
// sshfilters.put(AbstractResource.SSHSubmissionConstants.RESOURCE_JOB_MANAGER, ResourceJobManager.PBS.toString());
// List<SSHJobSubmission> sshList = computeResource.getSS(sshfilters);
// System.out.println("**********Size of SSH jobs ************* : " + sshList.size());
// Map<String, String> gsishfilters = new HashMap<String, String>();
// gsishfilters.put(AbstractResource.GSISSHSubmissionConstants.RESOURCE_JOB_MANAGER, ResourceJobManager.PBS.toString());
// List<GSISSHJobSubmission> gsisshList = computeResource.getGSISSHJobSubmissionList(gsishfilters);
// System.out.println("**********Size of GSISSH jobs ************* : " + gsisshList.size());
// Map<String, String> scpfilters = new HashMap<String, String>();
// scpfilters.put(AbstractResource.SCPDataMovementConstants.SECURITY_PROTOCOL, SecurityProtocol.SSH_KEYS.toString());
// List<SCPDataMovement> scpDataMovementList = computeResource.getSCPDataMovementList(scpfilters);
// System.out.println("**********Size of SCP DM list ************* : " + scpDataMovementList.size());
//
// Map<String, String> ftpfilters = new HashMap<String, String>();
// ftpfilters.put(AbstractResource.GridFTPDataMovementConstants.SECURITY_PROTOCOL, SecurityProtocol.SSH_KEYS.toString());
// List<GridFTPDataMovement> ftpDataMovementList = computeResource.getGridFTPDataMovementList(ftpfilters);
// System.out.println("**********Size of FTP DM list ************* : " + ftpDataMovementList.size());
assertTrue("Compute resource save successfully", host != null);
} catch (AppCatalogException e) {
logger.error(e.getMessage(), e);
}
}
use of org.apache.airavata.registry.cpi.ComputeResource in project airavata by apache.
the class GatewayProfileTest method gatewayProfileTest.
@Test
public void gatewayProfileTest() throws Exception {
GwyResourceProfile gatewayProfile = appcatalog.getGatewayProfile();
GatewayResourceProfile gf = new GatewayResourceProfile();
ComputeResource computeRs = appcatalog.getComputeResource();
ComputeResourceDescription cm1 = new ComputeResourceDescription();
cm1.setHostName("localhost");
cm1.setResourceDescription("test compute host");
String hostId1 = computeRs.addComputeResource(cm1);
ComputeResourceDescription cm2 = new ComputeResourceDescription();
cm2.setHostName("localhost");
cm2.setResourceDescription("test compute host");
String hostId2 = computeRs.addComputeResource(cm2);
ComputeResourcePreference preference1 = new ComputeResourcePreference();
preference1.setComputeResourceId(hostId1);
preference1.setOverridebyAiravata(true);
preference1.setPreferredJobSubmissionProtocol(JobSubmissionProtocol.SSH);
preference1.setPreferredDataMovementProtocol(DataMovementProtocol.SCP);
preference1.setPreferredBatchQueue("queue1");
preference1.setScratchLocation("/tmp");
preference1.setAllocationProjectNumber("project1");
ComputeResourcePreference preference2 = new ComputeResourcePreference();
preference2.setComputeResourceId(hostId2);
preference2.setOverridebyAiravata(true);
preference2.setPreferredJobSubmissionProtocol(JobSubmissionProtocol.LOCAL);
preference2.setPreferredDataMovementProtocol(DataMovementProtocol.GridFTP);
preference2.setPreferredBatchQueue("queue2");
preference2.setScratchLocation("/tmp");
preference2.setAllocationProjectNumber("project2");
List<ComputeResourcePreference> list = new ArrayList<ComputeResourcePreference>();
list.add(preference1);
list.add(preference2);
gf.setComputeResourcePreferences(list);
gf.setGatewayID("testGateway");
String gwId = gatewayProfile.addGatewayResourceProfile(gf);
GatewayResourceProfile retrievedProfile = null;
if (gatewayProfile.isGatewayResourceProfileExists(gwId)) {
retrievedProfile = gatewayProfile.getGatewayProfile(gwId);
System.out.println("************ gateway id ************** :" + retrievedProfile.getGatewayID());
}
List<ComputeResourcePreference> preferences = gatewayProfile.getAllComputeResourcePreferences(gwId);
System.out.println("compute preferences size : " + preferences.size());
if (preferences != null && !preferences.isEmpty()) {
for (ComputeResourcePreference cm : preferences) {
System.out.println("******** host id ********* : " + cm.getComputeResourceId());
System.out.println(cm.getPreferredBatchQueue());
System.out.println(cm.getPreferredDataMovementProtocol());
System.out.println(cm.getPreferredJobSubmissionProtocol());
}
}
assertTrue("App interface saved successfully", retrievedProfile != null);
}
Aggregations