Search in sources :

Example 1 with ComputeResourcePreference

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();
    }
}
Also used : ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)

Example 2 with ComputeResourcePreference

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;
}
Also used : ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)

Example 3 with 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);
    }
}
Also used : ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)

Example 4 with ComputeResourcePreference

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;
    }
}
Also used : UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)

Example 5 with ComputeResourcePreference

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;
    }
}
Also used : UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException)

Aggregations

ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)30 GatewayResourceProfile (org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)10 UserComputeResourcePreference (org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference)10 TException (org.apache.thrift.TException)10 AiravataException (org.apache.airavata.common.exception.AiravataException)5 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)5 ComputeResourceDescription (org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)5 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)5 StoragePreference (org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference)4 RegistryService (org.apache.airavata.registry.api.RegistryService)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 CredentialStoreException (org.apache.airavata.credential.store.exception.CredentialStoreException)3 JobSubmissionInterface (org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface)3 AuthzToken (org.apache.airavata.model.security.AuthzToken)3 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)3 ApplicationDeploymentDescription (org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)2 ApplicationInterfaceDescription (org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription)2 LaunchValidationException (org.apache.airavata.model.error.LaunchValidationException)2 ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)2