Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Reiner Jung
committed
Oct 15, 2018
1 parent
8e6029c
commit ea61ddd
Showing
20 changed files
with
2,143 additions
and
9 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
adaptation/src/main/java/org/iobserve/adaptation/stages/ComposedActionComputation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/*************************************************************************** | ||
* Copyright (C) 2018 iObserve Project (https://www.iobserve-devops.net) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
***************************************************************************/ | ||
package org.iobserve.adaptation.stages; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import teetime.stage.basic.AbstractTransformation; | ||
|
||
import org.iobserve.adaptation.data.AdaptationData; | ||
import org.iobserve.adaptation.data.graph.HostComponentAllocationGraph; | ||
import org.iobserve.planning.systemadaptation.SystemAdaptation; | ||
import org.iobserve.planning.systemadaptation.SystemadaptationFactory; | ||
import org.kie.api.KieServices; | ||
import org.kie.api.command.Command; | ||
import org.kie.api.command.KieCommands; | ||
import org.kie.api.runtime.KieContainer; | ||
import org.kie.api.runtime.StatelessKieSession; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Receives an AdaptationData record containing the runtime model graph as well as the redeployment | ||
* model graph. Inserts both graphs into the drools rule engine and receives a | ||
* {@link SystemAdaptation} model containing a list of composed (high-level) adaptation actions | ||
* which is passed to the output port. | ||
* | ||
* @author Lars Bluemke | ||
* | ||
*/ | ||
public class ComposedActionComputation extends AbstractTransformation<AdaptationData, SystemAdaptation> { | ||
// Logger is invoked from drools rule file | ||
public static final Logger LOGGER = LoggerFactory.getLogger(ComposedActionComputation.class); | ||
|
||
private final KieServices kieServices = KieServices.Factory.get(); | ||
private final KieContainer kContainer = this.kieServices.getKieClasspathContainer(); | ||
private final StatelessKieSession kSession = this.kContainer.newStatelessKieSession(); | ||
private final KieCommands kieCommands = this.kieServices.getCommands(); | ||
|
||
@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); | ||
} | ||
|
||
private void addToWorkingMemoryInserts(final List<Command<?>> inserts, final Set<?> graphComponents) { | ||
for (final Object component : graphComponents) { | ||
inserts.add(this.kieCommands.newInsert(component)); | ||
} | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...ain/java/org/iobserve/adaptation/stages/transformations/AllocateAction2AtomicActions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/*************************************************************************** | ||
* Copyright (C) 2018 iObserve Project (https://www.iobserve-devops.net) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
***************************************************************************/ | ||
package org.iobserve.adaptation.stages.transformations; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.iobserve.adaptation.executionplan.AtomicAction; | ||
import org.iobserve.adaptation.executionplan.AtomicActionFactory; | ||
import org.iobserve.planning.systemadaptation.AllocateAction; | ||
|
||
/** | ||
* Creates the necessary atomic actions to execute an allocation. | ||
* | ||
* @author Lars Bluemke | ||
* | ||
*/ | ||
public class AllocateAction2AtomicActions implements IComposed2AtomicAction<AllocateAction> { | ||
|
||
@Override | ||
public List<AtomicAction> transform(final AllocateAction allocateAction) { | ||
final List<AtomicAction> atomicActions = new ArrayList<>(); | ||
|
||
// Allocate Node | ||
atomicActions.add(AtomicActionFactory.generateAllocateNodeAction(allocateAction.getTargetResourceContainer())); | ||
|
||
// Connect Node | ||
atomicActions.add(AtomicActionFactory.generateConnectNodeAction(allocateAction.getTargetResourceContainer(), | ||
allocateAction.getTargetLinkingResources())); | ||
|
||
return atomicActions; | ||
} | ||
|
||
} |
74 changes: 74 additions & 0 deletions
74
...a/org/iobserve/adaptation/stages/transformations/ChangeComponentAction2AtomicActions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/*************************************************************************** | ||
* Copyright (C) 2018 iObserve Project (https://www.iobserve-devops.net) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
***************************************************************************/ | ||
package org.iobserve.adaptation.stages.transformations; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.iobserve.adaptation.executionplan.AtomicAction; | ||
import org.iobserve.adaptation.executionplan.AtomicActionFactory; | ||
import org.iobserve.planning.systemadaptation.ChangeRepositoryComponentAction; | ||
|
||
/** | ||
* Creates the necessary atomic actions to execute a change repository component action. | ||
* | ||
* @author Lars Bluemke | ||
* | ||
*/ | ||
public class ChangeComponentAction2AtomicActions implements IComposed2AtomicAction<ChangeRepositoryComponentAction> { | ||
|
||
@Override | ||
public List<AtomicAction> transform(final ChangeRepositoryComponentAction changeComponentAction) { | ||
final List<AtomicAction> atomicActions = new ArrayList<>(); | ||
|
||
// Deploy new component instance | ||
atomicActions.add( | ||
AtomicActionFactory.generateDeployComponentAction(changeComponentAction.getTargetAllocationContext())); | ||
|
||
// Migrate state | ||
atomicActions.add(AtomicActionFactory.generateMigrateComponentStateAction( | ||
changeComponentAction.getSourceAllocationContext(), | ||
changeComponentAction.getTargetAllocationContext())); | ||
|
||
// Connect replication | ||
atomicActions.add( | ||
AtomicActionFactory.generateConnectComponentAction(changeComponentAction.getTargetAllocationContext(), | ||
changeComponentAction.getTargetProvidingAllocationContexts(), | ||
changeComponentAction.getTargetRequiringAllocationContexts())); | ||
|
||
// Block incoming requests | ||
atomicActions.add(AtomicActionFactory.generateBlockRequestsToComponentAction( | ||
changeComponentAction.getSourceAllocationContext(), | ||
changeComponentAction.getTargetRequiringAllocationContexts())); | ||
|
||
// Finish running transactions | ||
atomicActions.add( | ||
AtomicActionFactory.generateFinishComponentAction(changeComponentAction.getSourceAllocationContext())); | ||
|
||
// Disconnect component instance | ||
atomicActions.add(AtomicActionFactory.generateDisconnectComponentAction( | ||
changeComponentAction.getSourceAllocationContext(), | ||
changeComponentAction.getTargetProvidingAllocationContexts(), | ||
changeComponentAction.getTargetRequiringAllocationContexts())); | ||
|
||
// Undeploy component instance | ||
atomicActions.add(AtomicActionFactory | ||
.generateUndeployComponentAction(changeComponentAction.getSourceAllocationContext())); | ||
|
||
return atomicActions; | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
...n/java/org/iobserve/adaptation/stages/transformations/DeallocateAction2AtomicActions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*************************************************************************** | ||
* Copyright (C) 2018 iObserve Project (https://www.iobserve-devops.net) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
***************************************************************************/ | ||
package org.iobserve.adaptation.stages.transformations; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.iobserve.adaptation.executionplan.AtomicAction; | ||
import org.iobserve.adaptation.executionplan.AtomicActionFactory; | ||
import org.iobserve.planning.systemadaptation.DeallocateAction; | ||
|
||
/** | ||
* Creates the necessary atomic actions to execute a deallocation. | ||
* | ||
* @author Lars Bluemke | ||
* | ||
*/ | ||
public class DeallocateAction2AtomicActions implements IComposed2AtomicAction<DeallocateAction> { | ||
|
||
@Override | ||
public List<AtomicAction> transform(final DeallocateAction deallocateAction) { | ||
final List<AtomicAction> atomicActions = new ArrayList<>(); | ||
|
||
// Disconnect Node | ||
atomicActions.add(AtomicActionFactory.generateDisonnectNodeAction(deallocateAction.getTargetResourceContainer(), | ||
deallocateAction.getTargetLinkingResources())); | ||
|
||
// Deallocate Node | ||
atomicActions | ||
.add(AtomicActionFactory.generateDeallocateNodeAction(deallocateAction.getTargetResourceContainer())); | ||
|
||
return atomicActions; | ||
} | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
.../java/org/iobserve/adaptation/stages/transformations/DereplicateAction2AtomicActions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/*************************************************************************** | ||
* Copyright (C) 2018 iObserve Project (https://www.iobserve-devops.net) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
***************************************************************************/ | ||
package org.iobserve.adaptation.stages.transformations; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.iobserve.adaptation.executionplan.AtomicAction; | ||
import org.iobserve.adaptation.executionplan.AtomicActionFactory; | ||
import org.iobserve.planning.systemadaptation.DereplicateAction; | ||
|
||
/** | ||
* Creates the necessary atomic actions to execute a dereplication. | ||
* | ||
* @author Lars Bluemke | ||
* | ||
*/ | ||
public class DereplicateAction2AtomicActions implements IComposed2AtomicAction<DereplicateAction> { | ||
|
||
@Override | ||
public List<AtomicAction> transform(final DereplicateAction dereplicateAction) { | ||
final List<AtomicAction> atomicActions = new ArrayList<>(); | ||
|
||
// Block incoming requests | ||
atomicActions.add(AtomicActionFactory.generateBlockRequestsToComponentAction( | ||
dereplicateAction.getTargetAllocationContext(), | ||
dereplicateAction.getTargetRequiringAllocationContexts())); | ||
|
||
// Finish running transactions | ||
atomicActions | ||
.add(AtomicActionFactory.generateFinishComponentAction(dereplicateAction.getTargetAllocationContext())); | ||
|
||
// Disconnect component instance | ||
atomicActions.add( | ||
AtomicActionFactory.generateDisconnectComponentAction(dereplicateAction.getTargetAllocationContext(), | ||
dereplicateAction.getTargetProvidingAllocationContexts(), | ||
dereplicateAction.getTargetRequiringAllocationContexts())); | ||
|
||
// Undeploy component instance | ||
atomicActions.add( | ||
AtomicActionFactory.generateUndeployComponentAction(dereplicateAction.getTargetAllocationContext())); | ||
|
||
return atomicActions; | ||
} | ||
|
||
} |
70 changes: 70 additions & 0 deletions
70
...main/java/org/iobserve/adaptation/stages/transformations/MigrateAction2AtomicActions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/*************************************************************************** | ||
* Copyright (C) 2018 iObserve Project (https://www.iobserve-devops.net) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
***************************************************************************/ | ||
package org.iobserve.adaptation.stages.transformations; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.iobserve.adaptation.executionplan.AtomicAction; | ||
import org.iobserve.adaptation.executionplan.AtomicActionFactory; | ||
import org.iobserve.planning.systemadaptation.MigrateAction; | ||
|
||
/** | ||
* Creates the necessary atomic actions to execute a migration. | ||
* | ||
* @author Lars Bluemke | ||
* | ||
*/ | ||
public class MigrateAction2AtomicActions implements IComposed2AtomicAction<MigrateAction> { | ||
|
||
@Override | ||
public List<AtomicAction> transform(final MigrateAction migrateAction) { | ||
final List<AtomicAction> atomicActions = new ArrayList<>(); | ||
|
||
// Deploy new component instance | ||
atomicActions | ||
.add(AtomicActionFactory.generateDeployComponentAction(migrateAction.getTargetAllocationContext())); | ||
|
||
// Migrate state | ||
atomicActions.add(AtomicActionFactory.generateMigrateComponentStateAction( | ||
migrateAction.getSourceAllocationContext(), migrateAction.getTargetAllocationContext())); | ||
|
||
// Connect replication | ||
atomicActions.add(AtomicActionFactory.generateConnectComponentAction(migrateAction.getTargetAllocationContext(), | ||
migrateAction.getTargetProvidingAllocationContexts(), | ||
migrateAction.getTargetRequiringAllocationContexts())); | ||
|
||
// Block incoming requests | ||
atomicActions.add(AtomicActionFactory.generateBlockRequestsToComponentAction( | ||
migrateAction.getSourceAllocationContext(), migrateAction.getSourceRequiringAllocationContexts())); | ||
|
||
// Finish running transactions | ||
atomicActions | ||
.add(AtomicActionFactory.generateFinishComponentAction(migrateAction.getSourceAllocationContext())); | ||
|
||
// Disconnect component instance | ||
atomicActions.add(AtomicActionFactory.generateDisconnectComponentAction( | ||
migrateAction.getSourceAllocationContext(), migrateAction.getSourceProvidingAllocationContexts(), | ||
migrateAction.getSourceRequiringAllocationContexts())); | ||
|
||
// Undeploy component instance | ||
atomicActions | ||
.add(AtomicActionFactory.generateUndeployComponentAction(migrateAction.getSourceAllocationContext())); | ||
|
||
return atomicActions; | ||
} | ||
|
||
} |
Oops, something went wrong.