use of org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference in project airavata by apache.
the class GwyResourceProfileImpl method getAllGatewayProfiles.
@Override
public List<GatewayResourceProfile> getAllGatewayProfiles() throws AppCatalogException {
try {
List<GatewayResourceProfile> gatewayResourceProfileList = new ArrayList<GatewayResourceProfile>();
GatewayProfileResource profileResource = new GatewayProfileResource();
List<AppCatalogResource> resourceList = profileResource.getAll();
if (resourceList != null && !resourceList.isEmpty()) {
for (AppCatalogResource resource : resourceList) {
GatewayProfileResource gatewayProfileResource = (GatewayProfileResource) resource;
List<ComputeResourcePreference> computeResourcePreferences = getAllComputeResourcePreferences(gatewayProfileResource.getGatewayID());
List<StoragePreference> dataStoragePreferences = getAllStoragePreferences(gatewayProfileResource.getGatewayID());
GatewayResourceProfile gatewayResourceProfile = AppCatalogThriftConversion.getGatewayResourceProfile(gatewayProfileResource, computeResourcePreferences, dataStoragePreferences);
gatewayResourceProfileList.add(gatewayResourceProfile);
}
}
return gatewayResourceProfileList;
} catch (Exception e) {
logger.error("Error while retrieving gateway ids...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference in project airavata by apache.
the class GwyResourceProfileImpl method getGatewayProfile.
@Override
public GatewayResourceProfile getGatewayProfile(String gatewayId) throws AppCatalogException {
try {
GatewayProfileResource resource = new GatewayProfileResource();
GatewayProfileResource gwresource = (GatewayProfileResource) resource.get(gatewayId);
ComputeHostPreferenceResource prefResource = new ComputeHostPreferenceResource();
List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.ComputeResourcePreferenceConstants.GATEWAY_ID, gatewayId);
List<ComputeResourcePreference> computeResourcePreferences = AppCatalogThriftConversion.getComputeResourcePreferences(computePrefList);
List<StoragePreference> dataStoragePreferences = getAllStoragePreferences(gatewayId);
return AppCatalogThriftConversion.getGatewayResourceProfile(gwresource, computeResourcePreferences, dataStoragePreferences);
} catch (Exception e) {
logger.error("Error while retrieving gateway profile...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference in project airavata by apache.
the class GwyResourceProfileImpl method addGatewayResourceProfile.
@Override
public String addGatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile gatewayProfile) throws AppCatalogException {
try {
GatewayProfileResource profileResource = new GatewayProfileResource();
if (!gatewayProfile.getGatewayID().equals("")) {
profileResource.setGatewayID(gatewayProfile.getGatewayID());
}
if (gatewayProfile.getCredentialStoreToken() != null) {
profileResource.setCredentialStoreToken(gatewayProfile.getCredentialStoreToken());
}
if (gatewayProfile.getIdentityServerTenant() != null) {
profileResource.setIdentityServerTenant(gatewayProfile.getIdentityServerTenant());
}
if (gatewayProfile.getIdentityServerPwdCredToken() != null) {
profileResource.setIdentityServerPwdCredToken(gatewayProfile.getIdentityServerPwdCredToken());
}
profileResource.setGatewayID(gatewayProfile.getGatewayID());
profileResource.save();
List<ComputeResourcePreference> computeResourcePreferences = gatewayProfile.getComputeResourcePreferences();
if (computeResourcePreferences != null && !computeResourcePreferences.isEmpty()) {
for (ComputeResourcePreference preference : computeResourcePreferences) {
ComputeHostPreferenceResource resource = new ComputeHostPreferenceResource();
resource.setGatewayProfile(profileResource);
resource.setResourceId(preference.getComputeResourceId());
ComputeResourceResource computeHostResource = new ComputeResourceResource();
resource.setComputeHostResource((ComputeResourceResource) computeHostResource.get(preference.getComputeResourceId()));
resource.setGatewayId(profileResource.getGatewayID());
resource.setOverrideByAiravata(preference.isOverridebyAiravata());
resource.setLoginUserName(preference.getLoginUserName());
resource.setResourceCSToken(preference.getResourceSpecificCredentialStoreToken());
resource.setUsageReportingGatewayId(preference.getUsageReportingGatewayId());
if (preference.getPreferredJobSubmissionProtocol() != null) {
resource.setPreferredJobProtocol(preference.getPreferredJobSubmissionProtocol().toString());
}
if (preference.getPreferredDataMovementProtocol() != null) {
resource.setPreferedDMProtocol(preference.getPreferredDataMovementProtocol().toString());
}
resource.setBatchQueue(preference.getPreferredBatchQueue());
resource.setProjectNumber(preference.getAllocationProjectNumber());
resource.setScratchLocation(preference.getScratchLocation());
resource.setQualityOfService(preference.getQualityOfService());
resource.setReservation(preference.getReservation());
if (preference.getReservationStartTime() > 0) {
resource.setReservationStartTime(AiravataUtils.getTime(preference.getReservationStartTime()));
}
if (preference.getReservationEndTime() > 0) {
resource.setReservationEndTime(AiravataUtils.getTime(preference.getReservationEndTime()));
}
resource.setSshAccountProvisioner(preference.getSshAccountProvisioner());
if (preference.getSshAccountProvisionerConfig() != null && !preference.getSshAccountProvisionerConfig().isEmpty()) {
Map<String, String> sshAccountProvisionerConfigurationsCopy = new HashMap<>(preference.getSshAccountProvisionerConfig());
resource.setSshAccountProvisionerConfigurations(sshAccountProvisionerConfigurationsCopy);
}
resource.setSshAccountProvisionerAdditionalInfo(preference.getSshAccountProvisionerAdditionalInfo());
resource.save();
}
}
List<StoragePreference> dataStoragePreferences = gatewayProfile.getStoragePreferences();
if (dataStoragePreferences != null && !dataStoragePreferences.isEmpty()) {
for (StoragePreference storagePreference : dataStoragePreferences) {
StoragePreferenceResource resource = new StoragePreferenceResource();
resource.setStorageResourceId(storagePreference.getStorageResourceId());
resource.setGatewayId(profileResource.getGatewayID());
resource.setFsRootLocation(storagePreference.getFileSystemRootLocation());
resource.setLoginUserName(storagePreference.getLoginUserName());
resource.setResourceCSToken(storagePreference.getResourceSpecificCredentialStoreToken());
resource.setGatewayProfile(profileResource);
resource.save();
}
}
return profileResource.getGatewayID();
} catch (Exception e) {
logger.error("Error while saving gateway profile...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference in project airavata by apache.
the class OrchestratorUtils method getScratchLocation.
public static String getScratchLocation(OrchestratorContext context, ProcessModel processModel, String gatewayId) throws RegistryException, AiravataException {
try {
ComputeResourcePreference computeResourcePreference = getComputeResourcePreference(context, gatewayId, processModel.getComputeResourceId());
ComputationalResourceSchedulingModel processResourceSchedule = processModel.getProcessResourceSchedule();
if (processModel.isUseUserCRPref()) {
UsrResourceProfile userResourceProfile = getUserResourceProfile(context);
UserComputeResourcePreference userComputeResourcePreference = userResourceProfile.getUserComputeResourcePreference(processModel.getUserName(), gatewayId, processModel.getComputeResourceId());
if (isValid(userComputeResourcePreference.getScratchLocation())) {
return userComputeResourcePreference.getScratchLocation();
} else if (isValid(processResourceSchedule.getOverrideScratchLocation())) {
logger.warn("User computer resource preference doesn't have valid scratch location, using computer " + "resource scheduling scratch location " + processResourceSchedule.getOverrideScratchLocation());
return processResourceSchedule.getOverrideScratchLocation();
} else if (isValid(computeResourcePreference.getScratchLocation())) {
logger.warn("Either User computer resource preference or computer resource scheduling doesn't have " + "valid scratch location, using gateway computer resource preference scratch location" + computeResourcePreference.getScratchLocation());
return computeResourcePreference.getScratchLocation();
} else {
throw new AiravataException("Scratch location is not found");
}
} else {
if (isValid(processResourceSchedule.getOverrideScratchLocation())) {
return processResourceSchedule.getOverrideScratchLocation();
} else if (isValid(computeResourcePreference.getScratchLocation())) {
logger.warn("Process compute resource scheduling doesn't have valid scratch location, " + "using gateway computer resource preference scratch location" + computeResourcePreference.getScratchLocation());
return computeResourcePreference.getScratchLocation();
} else {
throw new AiravataException("Scratch location is not found");
}
}
} catch (AppCatalogException e) {
logger.error("Error occurred while initializing app catalog to fetch scratch location", e);
throw new RegistryException("Error occurred while initializing app catalog to fetch scratch location", e);
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference in project airavata by apache.
the class OrchestratorUtils method getPrefferredDataMovementInterface.
public static DataMovementInterface getPrefferredDataMovementInterface(OrchestratorContext context, ProcessModel processModel, String gatewayId) throws RegistryException {
try {
String resourceHostId = processModel.getComputeResourceId();
ComputeResourcePreference resourcePreference = getComputeResourcePreference(context, processModel, gatewayId);
DataMovementProtocol preferredDataMovementProtocol = resourcePreference.getPreferredDataMovementProtocol();
ComputeResourceDescription resourceDescription = context.getRegistry().getAppCatalog().getComputeResource().getComputeResource(resourceHostId);
List<DataMovementInterface> dataMovementInterfaces = resourceDescription.getDataMovementInterfaces();
if (dataMovementInterfaces != null && !dataMovementInterfaces.isEmpty()) {
for (DataMovementInterface dataMovementInterface : dataMovementInterfaces) {
if (preferredDataMovementProtocol != null) {
if (preferredDataMovementProtocol.toString().equals(dataMovementInterface.getDataMovementProtocol().toString())) {
return dataMovementInterface;
}
}
}
} else {
throw new RegistryException("Compute resource should have at least one data movement interface defined...");
}
} catch (AppCatalogException e) {
throw new RegistryException("Error occurred while retrieving data from app catalog", e);
}
return null;
}
Aggregations