Search in sources :

Example 6 with StorageResourceDescription

use of org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription in project airavata by apache.

the class AppCatalogThriftConversion method getStorageDescription.

public static StorageResourceDescription getStorageDescription(StorageResourceResource resource) throws AppCatalogException {
    StorageResourceDescription description = new StorageResourceDescription();
    description.setStorageResourceId(resource.getStorageResourceId());
    description.setHostName(resource.getHostName());
    description.setStorageResourceDescription(resource.getResourceDescription());
    description.setEnabled(resource.isEnabled());
    StorageInterfaceResource interfaceResource = new StorageInterfaceResource();
    interfaceResource.setStorageResourceId(resource.getStorageResourceId());
    List<AppCatalogResource> resources = interfaceResource.get(AppCatAbstractResource.StorageResourceConstants.RESOURCE_ID, resource.getStorageResourceId());
    if (resources != null && !resources.isEmpty()) {
        description.setDataMovementInterfaces(getDataMovementInterfacesForStorageResource(resources));
    }
    return description;
}
Also used : StorageResourceDescription(org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription)

Example 7 with StorageResourceDescription

use of org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription in project airavata by apache.

the class RegistryServerHandler method getStorageResource.

/**
 * Fetch the given Storage Resource.
 *
 * @param storageResourceId The identifier for the requested storage resource
 * @return storageResourceDescription
 * Storage Resource Object created from the datamodel..
 */
@Override
public StorageResourceDescription getStorageResource(String storageResourceId) throws RegistryServiceException, TException {
    try {
        appCatalog = RegistryFactory.getAppCatalog();
        StorageResourceDescription storageResource = appCatalog.getStorageResource().getStorageResource(storageResourceId);
        logger.debug("Airavata retrieved storage resource with storage resource Id : " + storageResourceId);
        return storageResource;
    } catch (AppCatalogException e) {
        logger.error(storageResourceId, "Error while retrieving storage resource...", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while retrieving storage resource. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : StorageResourceDescription(org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException)

Example 8 with StorageResourceDescription

use of org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription in project airavata by apache.

the class AiravataServerHandler method getStorageResource.

/**
 * Fetch the given Storage Resource.
 *
 * @param authzToken
 * @param storageResourceId The identifier for the requested storage resource
 * @return storageResourceDescription
 * Storage Resource Object created from the datamodel..
 */
@Override
@SecurityCheck
public StorageResourceDescription getStorageResource(AuthzToken authzToken, String storageResourceId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
    RegistryService.Client regClient = registryClientPool.getResource();
    try {
        StorageResourceDescription result = regClient.getStorageResource(storageResourceId);
        registryClientPool.returnResource(regClient);
        return result;
    } catch (Exception e) {
        logger.error(storageResourceId, "Error while retrieving storage resource...", e);
        AiravataSystemException exception = new AiravataSystemException();
        exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
        exception.setMessage("Error while retrieving storage resource. More info : " + e.getMessage());
        registryClientPool.returnBrokenResource(regClient);
        throw exception;
    }
}
Also used : StorageResourceDescription(org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription) RegistryService(org.apache.airavata.registry.api.RegistryService) SharingRegistryService(org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) AiravataException(org.apache.airavata.common.exception.AiravataException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 9 with StorageResourceDescription

use of org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription in project airavata by apache.

the class GFacEngineImpl method populateProcessContext.

@Override
public ProcessContext populateProcessContext(String processId, String gatewayId, String tokenId) throws GFacException, CredentialStoreException {
    // NOTE: Process context gives precedence to data come with process Computer resources;
    ProcessContext processContext = null;
    ProcessContext.ProcessContextBuilder builder = new ProcessContext.ProcessContextBuilder(processId, gatewayId, tokenId);
    try {
        AppCatalog appCatalog = Factory.getDefaultAppCatalog();
        ExperimentCatalog expCatalog = Factory.getDefaultExpCatalog();
        ProcessModel processModel = (ProcessModel) expCatalog.get(ExperimentCatalogModelType.PROCESS, processId);
        builder.setAppCatalog(appCatalog).setExperimentCatalog(expCatalog).setCuratorClient(Factory.getCuratorClient()).setStatusPublisher(Factory.getStatusPublisher()).setProcessModel(processModel).setGatewayResourceProfile(appCatalog.getGatewayProfile().getGatewayProfile(gatewayId)).setGatewayComputeResourcePreference(appCatalog.getGatewayProfile().getComputeResourcePreference(gatewayId, processModel.getComputeResourceId())).setGatewayStorageResourcePreference(appCatalog.getGatewayProfile().getStoragePreference(gatewayId, processModel.getStorageResourceId()));
        processContext = builder.build();
        /* check point */
        checkpoint(processContext);
        if (processModel.isUseUserCRPref()) {
            setUserResourceProfile(gatewayId, processContext);
            setUserComputeResourcePreference(gatewayId, processContext);
        }
        String scratchLocation = processContext.getScratchLocation();
        String workingDirectory = scratchLocation + File.separator + processId + File.separator;
        StorageResourceDescription storageResource = appCatalog.getStorageResource().getStorageResource(processModel.getStorageResourceId());
        if (storageResource != null) {
            processContext.setStorageResource(storageResource);
        } else {
            // we need to fail the process which will fail the experiment
            processContext.setProcessStatus(new ProcessStatus(ProcessState.FAILED));
            GFacUtils.saveAndPublishProcessStatus(processContext);
            throw new GFacException("expId: " + processModel.getExperimentId() + ", processId: " + processId + ":- Couldn't find storage resource for storage resource id :" + processModel.getStorageResourceId());
        }
        /*            StorageResourceDescription storageResource = appCatalog.getStorageResource().getStorageResource(processModel.getStorageResourceId());
            if (storageResource != null){
                processContext.setStorageResource(storageResource);
            }*/
        processContext.setComputeResourceDescription(appCatalog.getComputeResource().getComputeResource(processContext.getComputeResourceId()));
        processContext.setApplicationDeploymentDescription(appCatalog.getApplicationDeployment().getApplicationDeployement(processModel.getApplicationDeploymentId()));
        ApplicationInterfaceDescription applicationInterface = appCatalog.getApplicationInterface().getApplicationInterface(processModel.getApplicationInterfaceId());
        processContext.setApplicationInterfaceDescription(applicationInterface);
        List<OutputDataObjectType> applicationOutputs = applicationInterface.getApplicationOutputs();
        if (applicationOutputs != null && !applicationOutputs.isEmpty()) {
            for (OutputDataObjectType outputDataObjectType : applicationOutputs) {
                if (outputDataObjectType.getType().equals(DataType.STDOUT)) {
                    if (outputDataObjectType.getValue() == null || outputDataObjectType.getValue().equals("")) {
                        outputDataObjectType.setValue(workingDirectory + applicationInterface.getApplicationName() + ".stdout");
                        processContext.setStdoutLocation(workingDirectory + applicationInterface.getApplicationName() + ".stdout");
                    } else {
                        processContext.setStdoutLocation(outputDataObjectType.getValue());
                    }
                }
                if (outputDataObjectType.getType().equals(DataType.STDERR)) {
                    if (outputDataObjectType.getValue() == null || outputDataObjectType.getValue().equals("")) {
                        String stderrLocation = workingDirectory + applicationInterface.getApplicationName() + ".stderr";
                        outputDataObjectType.setValue(stderrLocation);
                        processContext.setStderrLocation(stderrLocation);
                    } else {
                        processContext.setStderrLocation(outputDataObjectType.getValue());
                    }
                }
            }
        }
        expCatalog.update(ExperimentCatalogModelType.PROCESS, processModel, processId);
        processModel.setProcessOutputs(applicationOutputs);
        if (processContext.getJobSubmissionProtocol() == JobSubmissionProtocol.UNICORE) {
            // process monitor mode set in getResourceJobManager method, but unicore doesn't have resource job manager.
            // hence we set process monitor mode here.
            processContext.setMonitorMode(MonitorMode.FORK);
        } else {
            processContext.setResourceJobManager(getResourceJobManager(processContext));
            processContext.setJobSubmissionRemoteCluster(Factory.getJobSubmissionRemoteCluster(processContext));
            processContext.setDataMovementRemoteCluster(Factory.getDataMovementRemoteCluster(processContext));
        }
        String inputPath = ServerSettings.getLocalDataLocation();
        if (inputPath != null) {
            processContext.setLocalWorkingDir((inputPath.endsWith("/") ? inputPath : inputPath + "/") + processContext.getProcessId());
        }
        List<Object> jobModels = expCatalog.get(ExperimentCatalogModelType.JOB, "processId", processId);
        if (jobModels != null && !jobModels.isEmpty()) {
            if (jobModels.size() > 1) {
                log.warn("Process has more than one job model, take first one");
            }
            processContext.setJobModel(((JobModel) jobModels.get(0)));
        }
        return processContext;
    } catch (AppCatalogException e) {
        String msg = "App catalog access exception ";
        saveErrorModel(processContext, e, msg);
        updateProcessFailure(processContext, msg);
        throw new GFacException(msg, e);
    } catch (RegistryException e) {
        String msg = "Registry access exception";
        saveErrorModel(processContext, e, msg);
        updateProcessFailure(processContext, msg);
        throw new GFacException(msg, e);
    } catch (AiravataException e) {
        String msg = "Remote cluster initialization error";
        saveErrorModel(processContext, e, msg);
        updateProcessFailure(processContext, msg);
        throw new GFacException(msg, e);
    }
}
Also used : ProcessModel(org.apache.airavata.model.process.ProcessModel) ExperimentCatalog(org.apache.airavata.registry.cpi.ExperimentCatalog) ProcessStatus(org.apache.airavata.model.status.ProcessStatus) AppCatalog(org.apache.airavata.registry.cpi.AppCatalog) RegistryException(org.apache.airavata.registry.cpi.RegistryException) ProcessContext(org.apache.airavata.gfac.core.context.ProcessContext) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) StorageResourceDescription(org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription) GFacException(org.apache.airavata.gfac.core.GFacException) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) ApplicationInterfaceDescription(org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription) JobModel(org.apache.airavata.model.job.JobModel) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 10 with StorageResourceDescription

use of org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription in project airavata by apache.

the class AiravataIT method testStorageResource.

@org.testng.annotations.Test(priority = 3)
public void testStorageResource() {
    try {
        logger.info("testStorageResource() -> Creating test storage resource......");
        storageResource = setup.getStorageResourceRegister().addStorageResourceResource();
        ;
        Assert.assertNotNull(storageResource);
        StorageResourceDescription storageResourceDescription = setup.getStorageResourceRegister().getStorageResourceDescription(storageResource);
        Assert.assertNotNull(storageResourceDescription.getHostName(), HOST_NAME);
        Assert.assertNotNull(storageResourceDescription.getStorageResourceDescription(), HOST_DESC);
        setup.getStorageResourceRegister().registerGatewayStorageProfile(storageResource);
        StoragePreference storagePreference = setup.getStorageResourceRegister().getStoragePreference(properties.getGname(), storageResource);
        Assert.assertEquals(storagePreference.getLoginUserName(), LOGIN_USER);
        Assert.assertEquals(storagePreference.getFileSystemRootLocation(), TestFrameworkConstants.STORAGE_LOCATION);
        logger.info("testStorageResource() -> Created test storage resource. Storage Resource Id : " + storageResource);
    } catch (Exception e) {
        logger.error("Error occured while testStorageResource", e);
        Assert.fail();
    }
}
Also used : StorageResourceDescription(org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription) StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference)

Aggregations

StorageResourceDescription (org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription)12 GFacException (org.apache.airavata.gfac.core.GFacException)4 ProcessContext (org.apache.airavata.gfac.core.context.ProcessContext)4 Session (com.jcraft.jsch.Session)3 URI (java.net.URI)3 URISyntaxException (java.net.URISyntaxException)3 AiravataException (org.apache.airavata.common.exception.AiravataException)3 CredentialStoreException (org.apache.airavata.credential.store.store.CredentialStoreException)3 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)3 TException (org.apache.thrift.TException)3 JSchException (com.jcraft.jsch.JSchException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)2 AuthenticationInfo (org.apache.airavata.gfac.core.authentication.AuthenticationInfo)2 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)2 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)2 ErrorModel (org.apache.airavata.model.commons.ErrorModel)2 TaskStatus (org.apache.airavata.model.status.TaskStatus)2 DataStagingTaskModel (org.apache.airavata.model.task.DataStagingTaskModel)2