Skip to content

Commit

Permalink
Merge branch 'master' into merge-prism_process
Browse files Browse the repository at this point in the history
  • Loading branch information
rsfzi committed Jan 9, 2025
2 parents da27f71 + 571f3d5 commit b133995
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 415 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<stringAttribute key="SimulationID" value="FT_LB_modelled"/>
<stringAttribute key="Simulator Type" value="MODELLED"/>
<setAttribute key="TransformationsActive">
<setEntry value="nodeRecovery"/>
<setEntry value="scaleIn"/>
<setEntry value="scaleOut"/>
</setAttribute>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,81 @@ modeltype PCM_STOEX uses 'http://sdq.ipd.uka.de/StochasticExpressions/2.2';
* transformation definition, while no name is needed for the output PCM modeltype. Note that OCL
* type and namespace notation are used in operational QVT (: and :: respectively).
*/
transformation unsetBranchProbabilityFailSave( in pcmAllocation : PCM_ALLOC ) {
transformation nodeRecovery( in pcmAllocation : PCM_ALLOC ) {

configuration property node1 : String; // node1 availability
configuration property node2 : String; // node2 availability


/**
* The main transformation.
* This is the entry point to the overall transformation.
*/
main() {

log('Transformation rule [nodeRecovery] ...');
if ((node1 != "available") or (node2 != "available")) {
log('Start node recovery ...');
if ((node1.toString() = 'available') and (node2.toString() != 'available')){
log("node1 : '" + node1.toString() + "', node2: '" + node2.toString() + "'");
var probBranch1 : Real = 1.0;
var probBranch2 : Real = 0.0;
pcmAllocation.rootObjects()[Allocation]->forAll(
allocation : Allocation |
setBranchProbabilities(allocation.allocationContexts_Allocation, probBranch1, probBranch2)
);
};
if ((node1 = "available") and (node2 = "available")){
log("node1 : '" + node1.toString() + "', node2: '" + node2.toString() + "'");
var probBranch1 : Real = 1.0;
var probBranch2 : Real = 0.0;
pcmAllocation.rootObjects()[Allocation]->forAll(
allocation : Allocation |
setBranchProbabilities(allocation.allocationContexts_Allocation, probBranch1, probBranch2)
);
};
if ((node1 != "available") and (node2 = "available")){
log("node1 : '" + node1.toString() + "', node2: '" + node2.toString() + "'");
var probBranch1 : Real = 0.0;
var probBranch2 : Real = 1.0;
pcmAllocation.rootObjects()[Allocation]->forAll(
allocation : Allocation |
setBranchProbabilities(allocation.allocationContexts_Allocation, probBranch1, probBranch2)
);
};
if ((node1 != "available") and (node2 != "available")){
log("node1 : '" + node1.toString() + "', node2: '" + node2.toString() + "'");
var probBranch1 : Real = 0.0;
var probBranch2 : Real = 0.0;
pcmAllocation.rootObjects()[Allocation]->forAll(
allocation : Allocation |
setBranchProbabilities(allocation.allocationContexts_Allocation, probBranch1, probBranch2)
);
};
log('Node recovery DONE.');
};

log('*** STARTED: Transformation rule [unsetBranchProbabilityFailSave] ...');
pcmAllocation.rootObjects()[Allocation]->forAll(
allocation : Allocation |
setBranchProbabilities(allocation.allocationContexts_Allocation)
);
log('*** DONE: Transformation rule [unsetBranchProbabilityFailSave]');
log('Transformation rule [unsetBranchProbabilityNode1] DONE.');
}


/**
* branchProbabilityProcessing Processing.
*/
helper setBranchProbabilities(allocationContexts : Set(AllocationContext)) : Boolean {
helper setBranchProbabilities(allocationContexts : Set(AllocationContext), in probBranch1 : Real, in probBranch2: Real) : Boolean {

allocationContexts->forEach(allocation){

if( allocation.assemblyContext_AllocationContext.id = "_6F6LYAEnEeS7FKokKTKFow" ) {
//log('Found load balancer: AC_LoadBalancer');
allocation.assemblyContext_AllocationContext.encapsulatedComponent__AssemblyContext.oclAsType(BasicComponent).serviceEffectSpecifications__BasicComponent->forEach(seff) {
if(seff.oclIsTypeOf(ResourceDemandingSEFF)) {
var branch1 : ProbabilisticBranchTransition = seff.allSubobjects()[ProbabilisticBranchTransition]->any(id="_ridTkAEoEeS7FKokKTKFow"); // entityName="delegateToServer1"
branch1.branchProbability := probBranch1;
log('Set branch1.branchProbability to ' + branch1.branchProbability.toString());
var branch2 : ProbabilisticBranchTransition = seff.allSubobjects()[ProbabilisticBranchTransition]->any(id="_tjFukAEoEeS7FKokKTKFow"); // entityName="delegateToServer2"
branch2.branchProbability := probBranch2;
log('Set branch2.branchProbability to ' + branch2.branchProbability.toString());
var branchFailSave : ProbabilisticBranchTransition = seff.allSubobjects()[ProbabilisticBranchTransition]->any(id="_fm8UkQFdEe-xm__qsFXqOw"); // entityName="failSavee"
branchFailSave.branchProbability := 0.0;
log('Set branchFailSave.branchProbability to ' + branchFailSave.branchProbability.toString());
Expand All @@ -70,6 +116,6 @@ transformation unsetBranchProbabilityFailSave( in pcmAllocation : PCM_ALLOC ) {
};

return false;
}
}

}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit b133995

Please sign in to comment.