use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.
the class AnalysisMain method createConfiguration.
@Override
protected AnalysisConfiguration createConfiguration(final Configuration configuration) throws ConfigurationException {
/**
* Configure model handling.
*/
// old model providers without neo4j
final PCMModelHandler modelFileHandler = new PCMModelHandler(this.modelInitDirectory);
final ICorrespondence correspondenceModel = modelFileHandler.getCorrespondenceModel();
/**
* initialize neo4j graphs.
*/
final GraphLoader graphLoader = new GraphLoader(this.modelDatabaseDirectory);
Graph repositoryModelGraph = graphLoader.initializeRepositoryModelGraph(modelFileHandler.getRepositoryModel());
Graph resourceEnvironmentGraph = graphLoader.initializeResourceEnvironmentModelGraph(modelFileHandler.getResourceEnvironmentModel());
Graph allocationModelGraph = graphLoader.initializeAllocationModelGraph(modelFileHandler.getAllocationModel());
Graph systemModelGraph = graphLoader.initializeSystemModelGraph(modelFileHandler.getSystemModel());
Graph usageModelGraph = graphLoader.initializeUsageModelGraph(modelFileHandler.getUsageModel());
/**
* load neo4j graphs.
*/
repositoryModelGraph = graphLoader.createRepositoryModelGraph();
resourceEnvironmentGraph = graphLoader.createResourceEnvironmentModelGraph();
allocationModelGraph = graphLoader.createAllocationModelGraph();
systemModelGraph = graphLoader.createSystemModelGraph();
usageModelGraph = graphLoader.createUsageModelGraph();
/**
* new graphModelProvider.
*/
final IModelProvider<Repository> repositoryModelProvider = new ModelProvider<>(repositoryModelGraph);
final IModelProvider<ResourceEnvironment> resourceEnvironmentModelProvider = new ModelProvider<>(resourceEnvironmentGraph);
final IModelProvider<Allocation> allocationModelProvider = new ModelProvider<>(allocationModelGraph);
final IModelProvider<org.palladiosimulator.pcm.system.System> systemModelProvider = new ModelProvider<>(systemModelGraph);
final IModelProvider<UsageModel> usageModelProvider = new ModelProvider<>(usageModelGraph);
// get systemId
final org.palladiosimulator.pcm.system.System systemModel = systemModelProvider.readOnlyRootComponent(org.palladiosimulator.pcm.system.System.class);
final String systemId = systemModel.getId();
try {
/**
* URLs for sending updates to the deployment visualization.
*/
// TODO this should be moved to the visualization sinks
final String[] sinks = configuration.getStringArrayProperty(ConfigurationKeys.CONTAINER_MANAGEMENT_SINK, ",");
if (sinks.length > 0) {
final InitializeDeploymentVisualization deploymentVisualization = new InitializeDeploymentVisualization(this.containerManagementVisualizationBaseUrl, systemId, allocationModelProvider, systemModelProvider, resourceEnvironmentModelProvider);
deploymentVisualization.initialize();
}
return new AnalysisConfiguration(configuration, repositoryModelProvider, resourceEnvironmentModelProvider, allocationModelProvider, systemModelProvider, usageModelProvider, correspondenceModel);
} catch (final MalformedURLException e) {
AbstractServiceMain.LOGGER.debug("URL construction for deployment visualization failed.", e);
return null;
} catch (final IOException e) {
AbstractServiceMain.LOGGER.debug("Deployment visualization could not connect to visualization service.", e);
return null;
}
}
use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.
the class AssemblyContextActionFactory method generateAllocateAction.
/**
* Create an allocation action.
*
* @param runtimeNode
* node to be allocated
* @param reDeploymentNode
* node to be deployed
* @return returns the allocation action
*/
public static AllocateAction generateAllocateAction(final ComponentNode runtimeNode, final ComponentNode reDeploymentNode) {
final SystemadaptationFactory factory = SystemadaptationFactory.eINSTANCE;
final AllocateAction action = factory.createAllocateAction();
// Allcotaion has no runtime component
// AssemblyContextActionFactory.setSourceAssemblyContext(action,
// runtimeNode.getAssemblyContextID());
final org.palladiosimulator.pcm.system.System reDeplSystem = ActionFactory.getRedeploymentModels().getSystemModel();
action.setSourceAssemblyContext(ActionFactory.getAssemblyContext(reDeploymentNode.getAssemblyContextID(), reDeplSystem));
final Allocation reDeplAllocation = ActionFactory.getRedeploymentModels().getAllocationModel();
action.setNewAllocationContext(ActionFactory.getAllocationContext(reDeploymentNode.getAllocationContextID(), reDeplAllocation));
return action;
}
use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.
the class ModelGenerationFactory method generateAndSaveAllocation.
private static Allocation generateAndSaveAllocation(final URI outputLocation, final System systemModel, final ResourceEnvironment resEnvModel) {
final AllocationGeneration allocationGen = new AllocationGeneration(systemModel, resEnvModel);
final Allocation allocationModel = allocationGen.generateAllocation();
final AllocationModelHandler allocationModelProvider = new AllocationModelHandler();
final URI allocationModelURI = URI.createFileURI(outputLocation.toFileString() + File.separator + resEnvModel.getEntityName() + ".allocation");
allocationModelProvider.save(allocationModelURI, allocationModel);
return allocationModel;
}
use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.
the class ModelModificationFactory method createNewModel.
/**
* Create a new model.
*
* @param commandLine
* command line parameters
* @throws InitializationException
* when handler do not initialize
* @throws IOException
* on io errors
*/
public static void createNewModel(final CommandLine commandLine) throws InitializationException, IOException {
ModelModificationFactory.LOGGER.info("Modifying model!");
final URI inputModels = URI.createFileURI(commandLine.getOptionValue("i"));
final URI outputLocation = URI.createFileURI(commandLine.getOptionValue("o"));
ModelModificationFactory.LOGGER.info("Copying models to new location.");
PCMModelHandler modelProviders = new PCMModelHandler(new File(inputModels.toFileString()));
final URI copyURI = ModelModificationFactory.copyRepoToOutput(outputLocation, modelProviders);
modelProviders = new PCMModelHandler(new File(copyURI.toFileString()));
final Allocation allocationModel = modelProviders.getAllocationModel();
final ResourceEnvironment resourceEnvironmentModel = modelProviders.getResourceEnvironmentModel();
final System systemModel = modelProviders.getSystemModel();
final Repository repositoryModel = modelProviders.getRepositoryModel();
final ResourceEnvironmentModification resEnvMod = new ResourceEnvironmentModification(resourceEnvironmentModel);
ModelModificationFactory.LOGGER.info("Terminating Server");
final List<ResourceContainer> terminatedResourceContainers = resEnvMod.modifyResEnvTerminate(Integer.parseInt(commandLine.getOptionValue("ac")));
ModelModificationFactory.LOGGER.info("Acquiring Server");
resEnvMod.modifyResEnvAcquire(Integer.parseInt(commandLine.getOptionValue("ac")));
ModelModificationFactory.LOGGER.info("Fixing Allocation after terminating");
AllocationModification allocMod = new AllocationModification(allocationModel, systemModel, resourceEnvironmentModel);
final int terminationMigrations = allocMod.modifyAllocationFixTerminations(terminatedResourceContainers);
ModelModificationFactory.LOGGER.info("Deallocating Components");
final SystemModification sysMod = new SystemModification(systemModel, repositoryModel);
final List<AssemblyContext> deallocatedACs = sysMod.modifySystemDeallocations(Integer.parseInt(commandLine.getOptionValue("de")));
ModelModificationFactory.LOGGER.info("Fixing Allocation after deallocating");
allocMod = new AllocationModification(allocationModel, systemModel, resourceEnvironmentModel);
allocMod.modifyAllocationFixDeallocations(deallocatedACs);
// LOG.info("Exchanging Components");
// sysMod.modifySystem_ChangeComp(Integer.parseInt(commandLine.getOptionValue("cr")));
ModelModificationFactory.LOGGER.info("Allocating new Components");
final List<AssemblyContext> allocatedACs = sysMod.modifySystemAllocate(Integer.parseInt(commandLine.getOptionValue("al")));
ModelModificationFactory.LOGGER.info("Creating Allocation for new components");
allocMod = new AllocationModification(allocationModel, systemModel, resourceEnvironmentModel);
allocMod.modifyAllocationFixAllocations(allocatedACs);
ModelModificationFactory.LOGGER.info("Creating migrations");
allocMod = new AllocationModification(allocationModel, systemModel, resourceEnvironmentModel);
final int totalMigrations = Integer.parseInt(commandLine.getOptionValue("al"));
// allocationMigrations
final int migrationsToPerform = totalMigrations - terminationMigrations;
if (migrationsToPerform > 0) {
ModelModificationFactory.LOGGER.info("Migrations to Perform: {}", migrationsToPerform);
allocMod.modifyAllocationMigrate(migrationsToPerform);
} else {
ModelModificationFactory.LOGGER.info(String.format("All migrations (%d) are already perfomed by Server-Termination (%d)!", totalMigrations, migrationsToPerform));
}
ModelModificationFactory.LOGGER.info("Saving models!");
modelProviders.save(outputLocation);
ModelModificationFactory.LOGGER.info("Modification done!");
}
use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.
the class SerializePcmModelStage method execute.
@Override
protected void execute(final EObject model) throws Exception {
final ResourceSet resourceSet = model.eResource().getResourceSet();
final String filePathPrefix = this.modelDirectory.getAbsolutePath() + File.separator + this.modelName;
final String filePath;
if (model instanceof Allocation) {
filePath = filePathPrefix + "." + AllocationPackage.eNAME;
new FileModelHandler<Allocation>(resourceSet, AllocationPackage.eINSTANCE).save(URI.createFileURI(filePath), (Allocation) model);
} else if (model instanceof CloudProfile) {
filePath = filePathPrefix + "." + CloudprofilePackage.eNAME;
new FileModelHandler<CloudProfile>(resourceSet, CloudprofilePackage.eINSTANCE).save(URI.createFileURI(filePath), (CloudProfile) model);
} else if (model instanceof CostRepository) {
filePath = filePathPrefix + "." + costPackage.eNAME;
new FileModelHandler<CostRepository>(resourceSet, costPackage.eINSTANCE).save(URI.createFileURI(filePath), (CostRepository) model);
} else if (model instanceof DecisionSpace) {
filePath = filePathPrefix + "." + designdecisionPackage.eNAME;
new FileModelHandler<DecisionSpace>(resourceSet, designdecisionPackage.eINSTANCE).save(URI.createFileURI(filePath), (DecisionSpace) model);
} else if (model instanceof QMLDeclarations) {
filePath = filePathPrefix + "." + QMLDeclarationsPackage.eNAME;
new FileModelHandler<QMLDeclarations>(resourceSet, QMLDeclarationsPackage.eINSTANCE).save(URI.createFileURI(filePath), (QMLDeclarations) model);
} else if (model instanceof Repository) {
filePath = filePathPrefix + "." + RepositoryPackage.eNAME;
new FileModelHandler<Repository>(resourceSet, RepositoryPackage.eINSTANCE).save(URI.createFileURI(filePath), (Repository) model);
} else if (model instanceof ResourceEnvironment) {
filePath = filePathPrefix + "." + ResourceenvironmentPackage.eNAME;
new FileModelHandler<ResourceEnvironment>(resourceSet, ResourceenvironmentPackage.eINSTANCE).save(URI.createFileURI(filePath), (ResourceEnvironment) model);
} else if (model instanceof System) {
filePath = filePathPrefix + "." + SystemPackage.eNAME;
new FileModelHandler<System>(resourceSet, SystemPackage.eINSTANCE).save(URI.createFileURI(filePath), (System) model);
} else if (model instanceof UsageModel) {
filePath = filePathPrefix + UsagemodelPackage.eNAME;
new FileModelHandler<UsageModel>(resourceSet, UsagemodelPackage.eINSTANCE).save(URI.createFileURI(filePath), (UsageModel) model);
} else {
throw new IllegalArgumentException("The EObject passed to this stage must be a PCM model!");
}
this.getOutputPort().send(new File(filePath));
}
Aggregations