Search in sources :

Example 1 with HostComponentAllocationGraph

use of org.iobserve.adaptation.data.graph.HostComponentAllocationGraph in project iobserve-analysis by research-iobserve.

the class ModelGraphCreator method execute.

@Override
protected void execute(final AdaptationData adaptationData) throws Exception {
    final HostComponentAllocationGraphFactory runtimeFactory = new HostComponentAllocationGraphFactory();
    final HostComponentAllocationGraphFactory redeploymentFactory = new HostComponentAllocationGraphFactory();
    final File runtimeModelDir = adaptationData.getRuntimeModelDir();
    final File redeploymentModelDir = adaptationData.getReDeploymentModelDir();
    final HostComponentAllocationGraph runtimeModelGraph = runtimeFactory.buildGraph(new ModelImporter(runtimeModelDir), ModelGraphRevision.RUNTIME);
    final HostComponentAllocationGraph redeploymentModelGraph = redeploymentFactory.buildGraph(new ModelImporter(redeploymentModelDir), ModelGraphRevision.REDEPLOYMENT);
    adaptationData.setRuntimeGraph(runtimeModelGraph);
    adaptationData.setReDeploymentGraph(redeploymentModelGraph);
    this.getOutputPort().send(adaptationData);
}
Also used : ModelImporter(org.iobserve.model.ModelImporter) HostComponentAllocationGraph(org.iobserve.adaptation.data.graph.HostComponentAllocationGraph) HostComponentAllocationGraphFactory(org.iobserve.adaptation.data.graph.HostComponentAllocationGraphFactory) File(java.io.File)

Example 2 with HostComponentAllocationGraph

use of org.iobserve.adaptation.data.graph.HostComponentAllocationGraph in project iobserve-analysis by research-iobserve.

the class ModelComparer method execute.

@Override
protected void execute(final URI element) throws Exception {
    boolean equalGraphs = false;
    if (this.baseAdaptationData != null) {
        // TODO finish
        final ModelImporter modelProviders = new ModelImporter(new File(element.toFileString()));
        final HostComponentAllocationGraphFactory graphFactory = new HostComponentAllocationGraphFactory();
        final HostComponentAllocationGraph runtimeGraph = graphFactory.buildGraph(modelProviders, ModelGraphRevision.RUNTIME);
        if (runtimeGraph.equals(this.baseAdaptationData.getReDeploymentGraph()) && this.baseAdaptationData.getReDeploymentGraph().equals(runtimeGraph)) {
            equalGraphs = true;
            SystemEvaluation.disableEvaluation();
        }
    }
    this.outputPort.send(Boolean.valueOf(equalGraphs));
}
Also used : ModelImporter(org.iobserve.model.ModelImporter) HostComponentAllocationGraph(org.iobserve.adaptation.data.graph.HostComponentAllocationGraph) HostComponentAllocationGraphFactory(org.iobserve.adaptation.data.graph.HostComponentAllocationGraphFactory) File(java.io.File)

Example 3 with HostComponentAllocationGraph

use of org.iobserve.adaptation.data.graph.HostComponentAllocationGraph in project iobserve-analysis by research-iobserve.

the class ComposedActionComputationTest method createAdaptationData.

private AdaptationData createAdaptationData() throws Exception {
    final AdaptationData adaptationData = new AdaptationData();
    final HostComponentAllocationGraphFactory graphFactory = new HostComponentAllocationGraphFactory();
    final HostComponentAllocationGraph runtimeModelGraph = graphFactory.buildGraph(this.runtimeModel.getSystem(), this.runtimeModel.getResEnvironment(), this.runtimeModel.getAllocation(), ModelGraphRevision.RUNTIME);
    final HostComponentAllocationGraph redeploymentModelGraph = graphFactory.buildGraph(this.redeploymentModel.getSystem(), this.redeploymentModel.getResEnvironment(), this.redeploymentModel.getAllocation(), ModelGraphRevision.REDEPLOYMENT);
    adaptationData.setRuntimeGraph(runtimeModelGraph);
    adaptationData.setReDeploymentGraph(redeploymentModelGraph);
    return adaptationData;
}
Also used : HostComponentAllocationGraph(org.iobserve.adaptation.data.graph.HostComponentAllocationGraph) HostComponentAllocationGraphFactory(org.iobserve.adaptation.data.graph.HostComponentAllocationGraphFactory) AdaptationData(org.iobserve.adaptation.data.AdaptationData)

Example 4 with HostComponentAllocationGraph

use of org.iobserve.adaptation.data.graph.HostComponentAllocationGraph in project iobserve-analysis by research-iobserve.

the class ComposedActionComputation method execute.

@Override
protected void execute(final AdaptationData adaptationData) throws Exception {
    final HostComponentAllocationGraph runtimeGraph = adaptationData.getRuntimeGraph();
    final HostComponentAllocationGraph redeploymentGraph = adaptationData.getReDeploymentGraph();
    final List<Command<?>> workingMemoryInserts = new ArrayList<>();
    final SystemAdaptation systemAdaptationModel = SystemadaptationFactory.eINSTANCE.createSystemAdaptation();
    // Add system adaptation model (its list of actions will be filled with by the rule engine)
    workingMemoryInserts.add(this.kieCommands.newInsert(systemAdaptationModel));
    // Add component nodes and deployment nodes of runtime and redeployment model graph
    this.addToWorkingMemoryInserts(workingMemoryInserts, runtimeGraph.getComponents());
    this.addToWorkingMemoryInserts(workingMemoryInserts, runtimeGraph.getServers());
    this.addToWorkingMemoryInserts(workingMemoryInserts, redeploymentGraph.getComponents());
    this.addToWorkingMemoryInserts(workingMemoryInserts, redeploymentGraph.getServers());
    // Execute rule engine which will add actions to composedAdaptationActions
    this.kSession.execute(this.kieCommands.newBatchExecution(workingMemoryInserts));
    this.outputPort.send(systemAdaptationModel);
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) HostComponentAllocationGraph(org.iobserve.adaptation.data.graph.HostComponentAllocationGraph) Command(org.kie.api.command.Command) ArrayList(java.util.ArrayList)

Aggregations

HostComponentAllocationGraph (org.iobserve.adaptation.data.graph.HostComponentAllocationGraph)4 HostComponentAllocationGraphFactory (org.iobserve.adaptation.data.graph.HostComponentAllocationGraphFactory)3 File (java.io.File)2 ModelImporter (org.iobserve.model.ModelImporter)2 ArrayList (java.util.ArrayList)1 AdaptationData (org.iobserve.adaptation.data.AdaptationData)1 SystemAdaptation (org.iobserve.planning.systemadaptation.SystemAdaptation)1 Command (org.kie.api.command.Command)1