use of org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference in project airavata by apache.
the class AiravataIT method testComputeResource.
@org.testng.annotations.Test(priority = 2)
public void testComputeResource() {
try {
logger.info("testComputeResource() -> Creating test compute resource......");
computeResourceProperties = setup.getComputeResourceRegister().addComputeResources();
Assert.assertNotNull(computeResourceProperties);
Assert.assertNotNull(computeResourceProperties.getComputeResourceId());
Assert.assertNotNull(computeResourceProperties.getJobSubmissionId());
ComputeResourceDescription computeResourceDescription = setup.getComputeResourceRegister().getComputeResource(computeResourceProperties.getComputeResourceId());
Assert.assertNotNull(computeResourceDescription.getHostName(), HOST_NAME);
Assert.assertNotNull(computeResourceDescription.getResourceDescription(), HOST_DESC);
LOCALSubmission localSubmission = setup.getComputeResourceRegister().getLocalSubmission(computeResourceProperties.getJobSubmissionId());
Assert.assertEquals(localSubmission.getResourceJobManager().getResourceJobManagerType(), ResourceJobManagerType.FORK);
Assert.assertEquals(localSubmission.getSecurityProtocol(), SecurityProtocol.LOCAL);
Assert.assertEquals(localSubmission.getResourceJobManager().getPushMonitoringEndpoint(), null);
Assert.assertEquals(localSubmission.getResourceJobManager().getJobManagerBinPath(), "");
Assert.assertEquals(localSubmission.getResourceJobManager().getJobManagerCommands().get(JobManagerCommand.SUBMISSION), JOB_MANAGER_COMMAND);
setup.getComputeResourceRegister().registerGatewayResourceProfile(computeResourceProperties.getComputeResourceId());
ComputeResourcePreference computeResourcePreference = setup.getComputeResourceRegister().getGatewayComputeResourcePreference(properties.getGname(), computeResourceProperties.getComputeResourceId());
Assert.assertEquals(computeResourcePreference.getAllocationProjectNumber(), ALLOCATION_PROJECT_NUMBER);
Assert.assertEquals(computeResourcePreference.getPreferredBatchQueue(), BATCH_QUEUE);
Assert.assertEquals(computeResourcePreference.getPreferredDataMovementProtocol(), DataMovementProtocol.LOCAL);
Assert.assertEquals(computeResourcePreference.getPreferredJobSubmissionProtocol(), JobSubmissionProtocol.LOCAL);
Assert.assertEquals(computeResourcePreference.getScratchLocation(), TestFrameworkConstants.SCRATCH_LOCATION);
Assert.assertEquals(computeResourcePreference.getLoginUserName(), LOGIN_USER);
logger.info("testComputeResource() -> Created test compute resource." + computeResourceProperties.toString());
} catch (Exception e) {
logger.error("Error occured while testComputeResource", e);
Assert.fail();
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference in project airavata by apache.
the class ComputeResourceRegister method createComputeResourcePreference.
public ComputeResourcePreference createComputeResourcePreference(String computeResourceId, String allocationProjectNumber, boolean overridebyAiravata, String preferredBatchQueue, JobSubmissionProtocol preferredJobSubmissionProtocol, DataMovementProtocol preferredDataMovementProtocol, String scratchLocation, String loginUserName) {
ComputeResourcePreference computeResourcePreference = new ComputeResourcePreference();
computeResourcePreference.setComputeResourceId(computeResourceId);
computeResourcePreference.setOverridebyAiravata(overridebyAiravata);
computeResourcePreference.setAllocationProjectNumber(allocationProjectNumber);
computeResourcePreference.setPreferredBatchQueue(preferredBatchQueue);
computeResourcePreference.setPreferredDataMovementProtocol(preferredDataMovementProtocol);
computeResourcePreference.setPreferredJobSubmissionProtocol(preferredJobSubmissionProtocol);
computeResourcePreference.setScratchLocation(scratchLocation);
computeResourcePreference.setLoginUserName(loginUserName);
return computeResourcePreference;
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference in project airavata by apache.
the class GFacUtils method getPreferredJobSubmissionProtocol.
public static JobSubmissionProtocol getPreferredJobSubmissionProtocol(ProcessContext context) throws AppCatalogException {
try {
GwyResourceProfile gatewayProfile = context.getAppCatalog().getGatewayProfile();
String resourceHostId = context.getComputeResourceDescription().getComputeResourceId();
ComputeResourcePreference preference = gatewayProfile.getComputeResourcePreference(context.getGatewayId(), resourceHostId);
return preference.getPreferredJobSubmissionProtocol();
} catch (AppCatalogException e) {
log.error("Error occurred while initializing app catalog", e);
throw new AppCatalogException("Error occurred while initializing app catalog", e);
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference in project airavata by apache.
the class RegistryServerHandler method updateGatewayComputeResourcePreference.
/**
* Update a Compute Resource Preference to a registered gateway profile.
*
* @param gatewayID The identifier for the gateway profile to be updated.
* @param computeResourceId Preferences related to a particular compute resource
* @param computeResourcePreference The ComputeResourcePreference object to be updated to the resource profile.
* @return status
* Returns a success/failure of the updation.
*/
@Override
public boolean updateGatewayComputeResourcePreference(String gatewayID, String computeResourceId, ComputeResourcePreference computeResourcePreference) throws RegistryServiceException, TException {
try {
if (!isGatewayExistInternal(gatewayID)) {
logger.error("Gateway does not exist.Please provide a valid gateway id...");
throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
}
appCatalog = RegistryFactory.getAppCatalog();
GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile();
GatewayResourceProfile profile = gatewayProfile.getGatewayProfile(gatewayID);
List<ComputeResourcePreference> computeResourcePreferences = profile.getComputeResourcePreferences();
ComputeResourcePreference preferenceToRemove = null;
for (ComputeResourcePreference preference : computeResourcePreferences) {
if (preference.getComputeResourceId().equals(computeResourceId)) {
preferenceToRemove = preference;
break;
}
}
if (preferenceToRemove != null) {
profile.getComputeResourcePreferences().remove(preferenceToRemove);
}
profile.getComputeResourcePreferences().add(computeResourcePreference);
gatewayProfile.updateGatewayResourceProfile(gatewayID, profile);
logger.debug("Airavata updated compute resource preference with gateway id : " + gatewayID + " and for compute resource id : " + computeResourceId);
return true;
} catch (AppCatalogException e) {
logger.error(gatewayID, "Error while reading gateway compute resource preference...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while updating gateway compute resource preference. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference in project airavata by apache.
the class RegistryServerHandler method getGatewayComputeResourcePreference.
/**
* Fetch a Compute Resource Preference of a registered gateway profile.
*
* @param gatewayID The identifier for the gateway profile to be requested
* @param computeResourceId Preferences related to a particular compute resource
* @return computeResourcePreference
* Returns the ComputeResourcePreference object.
*/
@Override
public ComputeResourcePreference getGatewayComputeResourcePreference(String gatewayID, String computeResourceId) throws RegistryServiceException, TException {
try {
if (!isGatewayExistInternal(gatewayID)) {
logger.error("Gateway does not exist.Please provide a valid gateway id...");
throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
}
appCatalog = RegistryFactory.getAppCatalog();
GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile();
ComputeResource computeResource = appCatalog.getComputeResource();
if (!gatewayProfile.isGatewayResourceProfileExists(gatewayID)) {
logger.error(gatewayID, "Given gateway profile does not exist in the system. Please provide a valid gateway id...");
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Given gateway profile does not exist in the system. Please provide a valid gateway id...");
throw exception;
}
if (!computeResource.isComputeResourceExists(computeResourceId)) {
logger.error(computeResourceId, "Given compute resource does not exist in the system. Please provide a valid compute resource id...");
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Given compute resource does not exist in the system. Please provide a valid compute resource id...");
throw exception;
}
ComputeResourcePreference computeResourcePreference = gatewayProfile.getComputeResourcePreference(gatewayID, computeResourceId);
logger.debug("Airavata retrieved gateway compute resource preference with gateway id : " + gatewayID + " and for compute resoruce id : " + computeResourceId);
return computeResourcePreference;
} catch (AppCatalogException e) {
logger.error(gatewayID, "Error while reading gateway compute resource preference...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while reading gateway compute resource preference. More info : " + e.getMessage());
throw exception;
}
}
Aggregations