}
@Test
public void testAddComputeResource (){
try {
ComputeResource computeResource = appcatalog.getComputeResource();
ComputeResourceDescription description = new ComputeResourceDescription();
description.setHostName("localhost");
description.setResourceDescription("test compute resource");
Set<String> ipdaresses = new HashSet<String>();
ipdaresses.add("222.33.43.444");
ipdaresses.add("23.344.44.454");
description.setIpAddresses(ipdaresses);
Set<String> aliases = new HashSet<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);
System.out.println("**********Resource name ************* : " + host.getHostName());
}
SSHJobSubmission sshJobSubmission = computeResource.getSSHJobSubmission(sshsubmissionId);
System.out.println("**********SSH Submission resource job manager ************* : " + sshJobSubmission.getResourceJobManager().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(AbstractResource.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);