Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix perf example #53

Merged
merged 4 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading