use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class ResourceContainerActionFactory method createAllocateAction.
/**
* Create an allocate action.
*
* @param reDeploymentServer
* the node where components can be deployed on
* @return the action
*/
public static AllocateAction createAllocateAction(final DeploymentNode reDeploymentServer) {
final AllocateAction action = SystemadaptationFactory.eINSTANCE.createAllocateAction();
final ResourceEnvironment redeploymentResourceEnvironment = ActionFactory.getRedeploymentModels().getResourceEnvironmentModel();
ResourceContainerActionFactory.initializeResourceContainerAction(action, reDeploymentServer, redeploymentResourceEnvironment);
return action;
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class AnalysisMain method createTeetimeConfiguration.
@Override
protected AnalysisConfiguration createTeetimeConfiguration() throws ConfigurationException {
/**
* Configure model handling.
*/
if (this.parameterConfiguration.isPcmFeature()) {
try {
final ModelImporter modelHandler = new ModelImporter(this.parameterConfiguration.getModelInitDirectory());
/**
* initialize neo4j graphs.
*/
final Neo4JModelResource<CorrespondenceModel> correspondenceModelResource = new Neo4JModelResource<>(CorrespondencePackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "correspondence"));
correspondenceModelResource.storeModelPartition(modelHandler.getCorrespondenceModel());
final Neo4JModelResource<Repository> repositoryModelResource = new Neo4JModelResource<>(RepositoryPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "repository"));
repositoryModelResource.storeModelPartition(modelHandler.getRepositoryModel());
final Neo4JModelResource<ResourceEnvironment> resourceEnvironmentModelResource = new Neo4JModelResource<>(ResourceenvironmentPackage.eINSTANCE, // add
new File(this.parameterConfiguration.getModelDatabaseDirectory(), "resourceenvironment"));
resourceEnvironmentModelResource.storeModelPartition(modelHandler.getResourceEnvironmentModel());
final Neo4JModelResource<System> systemModelResource = new Neo4JModelResource<>(SystemPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "system"));
systemModelResource.storeModelPartition(modelHandler.getSystemModel());
final Neo4JModelResource<Allocation> allocationModelResource = new Neo4JModelResource<>(AllocationPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "allocation"));
allocationModelResource.storeModelPartition(modelHandler.getAllocationModel());
final Neo4JModelResource<UsageModel> usageModelResource = new Neo4JModelResource<>(UsagemodelPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "usageModel"));
usageModelResource.storeModelPartition(modelHandler.getUsageModel());
final Neo4JModelResource<DataProtectionModel> privacyModelResource = new Neo4JModelResource<>(PrivacyPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "privacy"));
privacyModelResource.storeModelPartition(modelHandler.getPrivacyModel());
// get systemId
final System systemModel = systemModelResource.getModelRootNode(System.class, SystemPackage.Literals.SYSTEM);
this.kiekerConfiguration.setProperty(ConfigurationKeys.SYSTEM_ID, systemModel.getId());
return new AnalysisConfiguration(this.kiekerConfiguration, repositoryModelResource, resourceEnvironmentModelResource, systemModelResource, allocationModelResource, usageModelResource, correspondenceModelResource);
} catch (final IOException e) {
// TODO should be replaced by logger
// NOPMD
java.lang.System.err.println("Cannot load all models " + e.getLocalizedMessage());
// required
return null;
} catch (final DBException e) {
// TODO should be replaced by logger
// NOPMD
java.lang.System.err.println("Cannot store all models in DB " + e.getLocalizedMessage());
// required
return null;
}
} else {
return new AnalysisConfiguration(this.kiekerConfiguration);
}
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class SynthesizeAllocationEventStage method execute.
@Override
protected void execute(final PCMDeployedEvent event) throws EventConfigurationException, DBException {
if (event.getAssemblyContext() == null) {
throw new EventConfigurationException("Missing assembly context in PCMDeployedEvent");
}
this.logger.debug("event received assmeblyContext={} countryCode={} resourceContainer={} service={} url={}", event.getAssemblyContext().getEntityName(), event.getCountryCode(), event.getResourceContainer(), event.getService(), event.getUrl());
final ResourceEnvironment resourceEnvironment = this.resourceEnvironmentModelResource.getModelRootNode(ResourceEnvironment.class, ResourceenvironmentPackage.Literals.RESOURCE_ENVIRONMENT);
final Optional<ResourceContainer> resourceContainer = ResourceEnvironmentModelFactory.getResourceContainerByName(resourceEnvironment, event.getService());
if (resourceContainer.isPresent()) {
this.logger.debug("Resource container {} exists.", event.getService());
/**
* execution environment exists. Can deploy.
*/
event.setResourceContainer(resourceContainer.get());
this.deployedOutputPort.send(event);
} else {
this.logger.debug("Resource container {} missing, create allocation event", event.getService());
/**
* If the resource container with this serverName is not available, send an event to
* TAllocation (creating the resource container) and forward the deployment event to
* TDeployment (deploying on created resource container).
*/
this.allocationOutputPort.send(new ContainerAllocationEvent(SynthesizeAllocationEventStage.TIME_SOURCE.getTime(), event.getService()));
this.deployedRelayOutputPort.send(event);
}
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class NetworkLink method execute.
/**
* Execute this filter.
*
* @param event
* event to use
* @throws NodeLookupException
* @throws DBException
* on db errors
*/
@Override
protected void execute(final TraceMetadata event) throws NodeLookupException, DBException {
final ResourceEnvironment resourceEnvironment = this.resourceEnvironmentModelResource.getAndLockModelRootNode(ResourceEnvironment.class, ResourceenvironmentPackage.Literals.RESOURCE_ENVIRONMENT);
final System system = this.systemModelResource.getModelRootNode(System.class, SystemPackage.Literals.SYSTEM);
final Allocation allocation = this.allocationModelResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
NetworkLink.collectUnLinkedResourceContainer(resourceEnvironment).stream().forEach(unLinkedResCont -> {
NetworkLink.getAsmContextDeployedOnContainer(allocation, unLinkedResCont).stream().map(asmCtx -> NetworkLink.getConnectedAsmCtx(system, asmCtx)).map(listAsmCtxToConnect -> NetworkLink.collectResourceContainer(allocation, listAsmCtxToConnect)).map(listResContToConnectTo -> NetworkLink.getLinkingResources(resourceEnvironment, listResContToConnectTo)).flatMap(l -> l.stream()).collect(Collectors.toList()).stream().forEach(link -> link.getConnectedResourceContainers_LinkingResource().add(unLinkedResCont));
});
this.resourceEnvironmentModelResource.updatePartition(resourceEnvironment);
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class ModelHelper method fillResourceEnvironmentFromCloudProfile.
/**
* Creates resource containers and their associated costs from the cloud profile given in the
* model provider.
*
* The created resource containers are of the type {@link ResourceContainerCloud} and are
* connected via an Internet linking resource
* ({@link #getInternetLinkingResource(ResourceEnvironment)}. For every vm type in the cloud
* profile, this method creates one resource container representing an instance of this specific
* vm type. The model is saved after the creation of containers is completed.
*
* @param writeURI
* location where all files are stored
* @param modelHandler
* the model providers with an initialized resource environment, cost model and cloud
* profile
* @throws ModelHandlingErrorException
* model handling issue
*/
public static void fillResourceEnvironmentFromCloudProfile(final org.eclipse.emf.common.util.URI writeURI, final ModelImporter modelHandler) throws ModelHandlingErrorException {
final ResourceEnvironment environment = modelHandler.getResourceEnvironmentModel();
final CloudProfile cloudProfileModel = modelHandler.getCloudProfileModel();
final CostRepository costRepositoryModel = modelHandler.getCostModel();
for (final CloudProvider provider : cloudProfileModel.getCloudProviders()) {
for (final CloudResourceType cloudResource : provider.getCloudResources()) {
if (cloudResource instanceof VMType) {
final VMType cloudVM = (VMType) cloudResource;
ModelHelper.createResourceContainerFromVMType(environment, costRepositoryModel, cloudVM, cloudVM.getName());
}
}
}
new FileModelHandler<ResourceEnvironment>(ModelHelper.RESOURCE_SET, ResourceenvironmentPackage.eINSTANCE).save(writeURI.appendFileExtension(ResourceenvironmentPackage.eNAME), environment);
new FileModelHandler<CostRepository>(ModelHelper.RESOURCE_SET, costPackage.eINSTANCE).save(writeURI.appendFileExtension(costPackage.eNAME), costRepositoryModel);
}
Aggregations