Skip to content

Commit

Permalink
Merge branch 'feature/more-gt-embedding-action' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkratz committed Sep 4, 2021
2 parents db62a0e + 01e21d2 commit 3b65798
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 37 deletions.
30 changes: 0 additions & 30 deletions network.model.rules.vnet/src/gt/emoflon/EmoflonGtVnet.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,14 @@
import java.util.function.BiConsumer;
import org.eclipse.collections.impl.map.mutable.UnifiedMap;
import org.emoflon.ibex.gt.api.GraphTransformationMatch;
import facade.ModelFacade;
import gt.IncrementalPatternMatcher;
import gt.PatternMatchingConfig;
import gt.PatternMatchingDelta;
import gt.emoflon.apps.EmoflonGtVnetHiPEApp;
import model.Element;
import model.Link;
import model.Node;
import model.Root;
import model.SubstrateElement;
import model.SubstrateServer;
import model.VirtualElement;
import model.VirtualNetwork;
import model.VirtualServer;
import model.VirtualSwitch;
import network.model.rules.vnet.api.VnetAPI;
import network.model.rules.vnet.api.VnetApp;
import network.model.rules.vnet.api.matches.VnetToServerMatch;
Expand Down Expand Up @@ -95,29 +88,6 @@ public void apply(final VirtualElement virt, final SubstrateElement sub, final b
final GraphTransformationMatch<?, ?> match = tupleToGtMatch.get(new Tuple(virt, sub));
if (match instanceof VnetToServerMatch) {
api.vnetToServer().apply((VnetToServerMatch) match, doUpdate);

// TODO: Currently, all virtual elements have to be embedded manually
embedElements((VirtualNetwork) virt, (SubstrateServer) sub);
}
}

/**
* FIXME: Remove this method after implementing whole embedding using GT.
*
* @param vnet Virtual network to embed.
* @param sub Substrate server to embed virtual network on.
*/
private void embedElements(final VirtualNetwork vnet, final SubstrateServer sub) {
for (final Node n : vnet.getNodes()) {
if (n instanceof VirtualServer) {
ModelFacade.getInstance().embedServerToServer(sub.getName(), n.getName());
} else if (n instanceof VirtualSwitch) {
ModelFacade.getInstance().embedSwitchToNode(sub.getName(), n.getName());
}
}

for (final Link l : vnet.getLinks()) {
ModelFacade.getInstance().embedLinkToServer(sub.getName(), l.getName());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ rule vnetToServer() {
}

substrateNode: SubstrateServer {
// .residualCpu := substrateNode.residualCpu - virtualNetwork.cpu
// .residualMemory := substrateNode.residualMemory - virtualNetwork.memory
// .residualStorage := substrateNode.residualStorage - virtualNetwork.storage
.residualCpu := substrateNode.residualCpu - virtualNetwork.cpu
.residualMemory := substrateNode.residualMemory - virtualNetwork.memory
.residualStorage := substrateNode.residualStorage - virtualNetwork.storage
++ -guestNetworks -> virtualNetwork
// TODO: All embedding of all virtual elements onto the substrate server
// Embedding of the virtual elements is done by the "virtualNetwork" block below
}

substrateNetwork: SubstrateNetwork {
Expand All @@ -26,7 +26,16 @@ rule vnetToServer() {

virtualNetwork: VirtualNetwork {
++ -hostServer -> substrateNode
// TODO: Embed all virtual elements onto the substrate server
// Embed all virtual elements onto the substrate server
forEach links->l <VirtualLink> {
++ substrateNode - guestLinks->l
}
forEach nodes->srv <VirtualServer> {
++ substrateNode - guestServers->srv
}
forEach nodes->sw <VirtualSwitch> {
++ substrateNode - guestSwitches->sw
}
}

# virtualNetwork.cpu <= substrateNode.residualCpu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ public void testPathLinkBandwidthDecrement() {
sNet.getPaths().forEach(p -> {
if (p.getHops() == 1) {
// Path itself
final SubstratePath sp = (SubstratePath) p;
final SubstratePath sp = p;
assertTrue(sp.getBandwidth() != sp.getResidualBandwidth());

// Links
sp.getLinks().forEach(l -> {
final SubstrateLink sl = (SubstrateLink) l;
final SubstrateLink sl = l;
assertTrue(sl.getBandwidth() != sl.getResidualBandwidth());
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package test.algorithms.pm.pipeline;

import java.util.Set;
import org.junit.jupiter.api.Disabled;
import algorithms.AlgorithmConfig;
import algorithms.AlgorithmConfig.Objective;
import algorithms.pm.VnePmMdvneAlgorithmPipelineTwoStagesRackA;
Expand All @@ -23,4 +24,11 @@ public void initAlgo(final SubstrateNetwork sNet, final Set<VirtualNetwork> vNet
algo = VnePmMdvneAlgorithmPipelineTwoStagesRackA.prepare(sNet, vNets);
}

@Override
@Disabled
public void testAllOnOneServer() {
// This test is disabled, because the pipeline stage rack A can not embed a virtual network onto
// a substrate server only (desired behavior).
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package test.algorithms.pm.pipeline;

import java.util.Set;
import org.junit.jupiter.api.Disabled;
import algorithms.AlgorithmConfig;
import algorithms.AlgorithmConfig.Objective;
import algorithms.pm.VnePmMdvneAlgorithmPipelineTwoStagesRackA;
Expand All @@ -23,4 +24,11 @@ public void initAlgo(final SubstrateNetwork sNet, final Set<VirtualNetwork> vNet
algo = VnePmMdvneAlgorithmPipelineTwoStagesRackA.prepare(sNet, vNets);
}

@Override
@Disabled
public void testAllOnOneServer() {
// This test is disabled, because the pipeline stage rack A can not embed a virtual network onto
// a substrate server only (desired behavior).
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package test.algorithms.pm.pipeline;

import java.util.Set;
import org.junit.jupiter.api.Disabled;
import algorithms.AlgorithmConfig;
import algorithms.AlgorithmConfig.Objective;
import algorithms.pm.VnePmMdvneAlgorithmPipelineTwoStagesRackA;
Expand All @@ -23,4 +24,19 @@ public void initAlgo(final SubstrateNetwork sNet, final Set<VirtualNetwork> vNet
algo = VnePmMdvneAlgorithmPipelineTwoStagesRackA.prepare(sNet, vNets);
}

@Override
@Disabled
public void testAllOnOneServer() {
// This test is disabled, because the pipeline stage rack A can not embed a virtual network onto
// a substrate server only (desired behavior).
}

@Override
public void testPreferenceOfFilledServers() {
// From the parent test case: Test expects that all virtual networks are placed on the same
// substrate server
// This test is disabled, because the pipeline stage rack A can not embed a virtual network onto
// a substrate server only (desired behavior).
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package test.algorithms.pm.pipeline;

import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import java.util.Set;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import algorithms.AlgorithmConfig;
import algorithms.AlgorithmConfig.Objective;
import algorithms.pm.VnePmMdvneAlgorithmPipelineTwoStagesRackA;
import model.Link;
import model.SubstrateLink;
import model.SubstrateNetwork;
import model.VirtualNetwork;
import test.algorithms.pm.VnePmMdvneAlgorithmTotalPathCostTest;
Expand All @@ -23,4 +31,64 @@ public void initAlgo(final SubstrateNetwork sNet, final Set<VirtualNetwork> vNet
algo = VnePmMdvneAlgorithmPipelineTwoStagesRackA.prepare(sNet, vNets);
}

@Override
@Disabled
public void testAllOnOneServer() {
// This test is disabled, because the pipeline stage rack A can not embed a virtual network onto
// a substrate server only (desired behavior).
}

@Test
@Override
public void testNoEmbeddingIfFullOneByOne() {
oneTierSetupTwoServers("virt", 2);
twoTierSetupFourServers("sub", 4);

// Patch the substrate links that connects servers with rack switches to hold a higher bandwidth
// value
final List<Link> slinks = facade.getAllLinksOfNetwork("sub");
slinks.stream().forEach(l -> {
if (l instanceof SubstrateLink && l.getBandwidth() == 1) {
final SubstrateLink sl = (SubstrateLink) l;
sl.setBandwidth(5);
sl.setResidualBandwidth(5);
}
});

// Normal test procedure continues here
facade.createAllPathsForNetwork("sub");

final SubstrateNetwork sNet = (SubstrateNetwork) facade.getNetworkById("sub");

// First three must succeed
initAlgo(sNet, Set.of((VirtualNetwork) facade.getNetworkById("virt")));
assertTrue(algo.execute());

facade.addNetworkToRoot("virt2", true);
oneTierSetupTwoServers("virt2", 2);

initAlgo(sNet, Set.of((VirtualNetwork) facade.getNetworkById("virt2")));
assertTrue(algo.execute());

facade.addNetworkToRoot("virt3", true);
oneTierSetupTwoServers("virt3", 2);

initAlgo(sNet, Set.of((VirtualNetwork) facade.getNetworkById("virt3")));
assertTrue(algo.execute());

facade.addNetworkToRoot("virt4", true);
oneTierSetupThreeServers("virt4", 2);

// Last one must not succeed
initAlgo(sNet, Set.of((VirtualNetwork) facade.getNetworkById("virt4")));
assertFalse(algo.execute());

checkAllElementsEmbeddedOnSubstrateNetwork(sNet,
Set.of((VirtualNetwork) facade.getNetworkById("virt"),
(VirtualNetwork) facade.getNetworkById("virt2"),
(VirtualNetwork) facade.getNetworkById("virt3")));
final VirtualNetwork vNet4 = (VirtualNetwork) facade.getNetworkById("virt4");
assertNull(vNet4.getHost());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public void dispose() {
}
super.dispose();
instance = null;

// Dispose also the first two stages
VnePmMdvneAlgorithmPipelineStageVnet.prepare(sNet, vNets).dispose();
VnePmMdvneAlgorithmPipelineStageRackA.prepare(sNet, vNets).dispose();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public void dispose() {
}
super.dispose();
instance = null;

// Dispose also the first two stages
VnePmMdvneAlgorithmPipelineStageVnet.prepare(sNet, vNets).dispose();
VnePmMdvneAlgorithmPipelineStageRackB.prepare(sNet, vNets).dispose();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public void dispose() {
}
super.dispose();
instance = null;

// Dispose also the first stage only
VnePmMdvneAlgorithmPipelineStageRackA.prepare(sNet, vNets).dispose();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public void dispose() {
}
super.dispose();
instance = null;

// Dispose also the first stage only
VnePmMdvneAlgorithmPipelineStageRackB.prepare(sNet, vNets).dispose();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public void dispose() {
}
super.dispose();
instance = null;

// Dispose also the first stage only
VnePmMdvneAlgorithmPipelineStageVnet.prepare(sNet, vNets).dispose();
}

@Override
Expand Down

0 comments on commit 3b65798

Please sign in to comment.