Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 1 | package net.onrc.onos.intent.runtime; |
| 2 | |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 3 | import static org.easymock.EasyMock.*; |
| 4 | |
Pavlin Radoslavov | 74986ce | 2014-02-20 13:17:20 -0800 | [diff] [blame] | 5 | import java.util.LinkedList; |
Brian O'Connor | 12861f7 | 2014-02-19 20:40:32 -0800 | [diff] [blame] | 6 | import java.util.List; |
| 7 | import java.util.Set; |
| 8 | |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 9 | import net.floodlightcontroller.core.module.FloodlightModuleContext; |
| 10 | import net.floodlightcontroller.core.module.FloodlightModuleException; |
| 11 | import net.onrc.onos.datagrid.IDatagridService; |
| 12 | import net.onrc.onos.datagrid.IEventChannel; |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 13 | import net.onrc.onos.datagrid.IEventChannelListener; |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 14 | import net.onrc.onos.intent.ConstrainedShortestPathIntent; |
Brian O'Connor | 12861f7 | 2014-02-19 20:40:32 -0800 | [diff] [blame] | 15 | import net.onrc.onos.intent.FlowEntry; |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 16 | import net.onrc.onos.intent.Intent; |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 17 | import net.onrc.onos.intent.Intent.IntentState; |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 18 | import net.onrc.onos.intent.IntentOperation.Operator; |
| 19 | import net.onrc.onos.intent.IntentOperationList; |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 20 | import net.onrc.onos.intent.MockNetworkGraph; |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 21 | import net.onrc.onos.intent.PathIntent; |
Toshio Koide | 4f30873 | 2014-02-18 15:19:48 -0800 | [diff] [blame] | 22 | import net.onrc.onos.intent.PathIntentMap; |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 23 | import net.onrc.onos.intent.ShortestPathIntent; |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 24 | import net.onrc.onos.intent.persist.PersistIntent; |
Toshio Koide | 798bc1b | 2014-02-20 14:02:40 -0800 | [diff] [blame] | 25 | import net.onrc.onos.ofcontroller.networkgraph.DeviceEvent; |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 26 | import net.onrc.onos.ofcontroller.networkgraph.INetworkGraphListener; |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 27 | import net.onrc.onos.ofcontroller.networkgraph.INetworkGraphService; |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 28 | import net.onrc.onos.ofcontroller.networkgraph.LinkEvent; |
Toshio Koide | 798bc1b | 2014-02-20 14:02:40 -0800 | [diff] [blame] | 29 | import net.onrc.onos.ofcontroller.networkgraph.NetworkGraph; |
Pavlin Radoslavov | 74986ce | 2014-02-20 13:17:20 -0800 | [diff] [blame] | 30 | import net.onrc.onos.ofcontroller.networkgraph.PortEvent; |
| 31 | import net.onrc.onos.ofcontroller.networkgraph.SwitchEvent; |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 32 | import net.onrc.onos.registry.controller.IControllerRegistryService; |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 33 | |
| 34 | import org.junit.After; |
| 35 | import org.junit.Before; |
| 36 | import org.junit.Test; |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 37 | import org.junit.runner.RunWith; |
| 38 | import org.powermock.api.easymock.PowerMock; |
| 39 | import org.powermock.core.classloader.annotations.PrepareForTest; |
| 40 | import org.powermock.modules.junit4.PowerMockRunner; |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 41 | |
| 42 | /** |
| 43 | * @author Toshio Koide (t-koide@onlab.us) |
| 44 | */ |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 45 | @RunWith(PowerMockRunner.class) |
| 46 | @PrepareForTest(PathCalcRuntimeModule.class) |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 47 | public class UseCaseTest { |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 48 | private NetworkGraph g; |
| 49 | private FloodlightModuleContext modContext; |
| 50 | private IDatagridService datagridService; |
| 51 | private INetworkGraphService networkGraphService; |
Toshio Koide | 798bc1b | 2014-02-20 14:02:40 -0800 | [diff] [blame] | 52 | private IControllerRegistryService controllerRegistryService; |
| 53 | private PersistIntent persistIntent; |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 54 | @SuppressWarnings("rawtypes") |
| 55 | private IEventChannel eventChannel; |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 56 | |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 57 | @SuppressWarnings("unchecked") |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 58 | @Before |
Nick Karanatsios | 8abe717 | 2014-02-19 20:31:48 -0800 | [diff] [blame] | 59 | public void setUp() throws Exception { |
Toshio Koide | ebdbb62 | 2014-02-12 20:28:38 -0800 | [diff] [blame] | 60 | MockNetworkGraph graph = new MockNetworkGraph(); |
| 61 | graph.createSampleTopology(); |
| 62 | g = graph; |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 63 | |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 64 | datagridService = createMock(IDatagridService.class); |
| 65 | networkGraphService = createMock(INetworkGraphService.class); |
| 66 | controllerRegistryService = createMock(IControllerRegistryService.class); |
| 67 | modContext = createMock(FloodlightModuleContext.class); |
| 68 | eventChannel = createMock(IEventChannel.class); |
Toshio Koide | 798bc1b | 2014-02-20 14:02:40 -0800 | [diff] [blame] | 69 | persistIntent = PowerMock.createMock(PersistIntent.class); |
| 70 | |
| 71 | PowerMock.expectNew(PersistIntent.class, |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 72 | anyObject(IControllerRegistryService.class), |
| 73 | anyObject(INetworkGraphService.class)).andReturn(persistIntent); |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 74 | |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 75 | expect(modContext.getServiceImpl(IDatagridService.class)) |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 76 | .andReturn(datagridService).once(); |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 77 | expect(modContext.getServiceImpl(INetworkGraphService.class)) |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 78 | .andReturn(networkGraphService).once(); |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 79 | expect(modContext.getServiceImpl(IControllerRegistryService.class)) |
Toshio Koide | 798bc1b | 2014-02-20 14:02:40 -0800 | [diff] [blame] | 80 | .andReturn(controllerRegistryService).once(); |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 81 | expect(persistIntent.getKey()).andReturn(1L).anyTimes(); |
| 82 | expect(persistIntent.persistIfLeader(eq(1L), |
| 83 | anyObject(IntentOperationList.class))).andReturn(true).anyTimes(); |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 84 | |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 85 | expect(networkGraphService.getNetworkGraph()).andReturn(g).anyTimes(); |
| 86 | networkGraphService.registerNetworkGraphListener(anyObject(INetworkGraphListener.class)); |
| 87 | expectLastCall(); |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 88 | |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 89 | expect(datagridService.createChannel("onos.pathintent", Long.class, IntentOperationList.class)) |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 90 | .andReturn(eventChannel).once(); |
| 91 | |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 92 | expect(datagridService.addListener( |
| 93 | eq("onos.pathintent_state"), |
| 94 | anyObject(IEventChannelListener.class), |
| 95 | eq(Long.class), |
| 96 | eq(IntentStateList.class))) |
| 97 | .andReturn(eventChannel).once(); |
| 98 | |
| 99 | replay(datagridService); |
| 100 | replay(networkGraphService); |
| 101 | replay(modContext); |
| 102 | replay(controllerRegistryService); |
Toshio Koide | 798bc1b | 2014-02-20 14:02:40 -0800 | [diff] [blame] | 103 | PowerMock.replay(persistIntent, PersistIntent.class); |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | @After |
| 107 | public void tearDown() { |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 108 | verify(datagridService); |
| 109 | verify(networkGraphService); |
| 110 | verify(modContext); |
| 111 | verify(controllerRegistryService); |
Toshio Koide | 798bc1b | 2014-02-20 14:02:40 -0800 | [diff] [blame] | 112 | PowerMock.verify(persistIntent, PersistIntent.class); |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 113 | } |
| 114 | |
Toshio Koide | 4f30873 | 2014-02-18 15:19:48 -0800 | [diff] [blame] | 115 | private void showResult(PathIntentMap intents) { |
| 116 | for (Intent intent: intents.getAllIntents()) { |
| 117 | PathIntent pathIntent = (PathIntent)intent; |
Toshio Koide | bf87566 | 2014-02-24 12:19:15 -0800 | [diff] [blame^] | 118 | System.out.println("Path intent:" + pathIntent); |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 119 | System.out.println("Parent intent: " + pathIntent.getParentIntent().toString()); |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 120 | } |
| 121 | } |
| 122 | |
| 123 | @Test |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 124 | public void createShortestPaths() throws FloodlightModuleException { |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 125 | // create shortest path intents |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 126 | IntentOperationList opList = new IntentOperationList(); |
| 127 | opList.add(Operator.ADD, new ShortestPathIntent("1", 1L, 20L, 1L, 4L, 20L, 4L)); |
| 128 | opList.add(Operator.ADD, new ShortestPathIntent("2", 2L, 20L, 2L, 6L, 20L, 5L)); |
| 129 | opList.add(Operator.ADD, new ShortestPathIntent("3", 4L, 20L, 3L, 8L, 20L, 6L)); |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 130 | |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 131 | // compile high-level intent operations into low-level intent operations (calculate paths) |
| 132 | PathCalcRuntimeModule runtime1 = new PathCalcRuntimeModule(); |
| 133 | runtime1.init(modContext); |
| 134 | runtime1.startUp(modContext); |
| 135 | IntentOperationList pathIntentOpList = runtime1.executeIntentOperations(opList); |
| 136 | |
Brian O'Connor | 7f8e301 | 2014-02-15 23:59:29 -0800 | [diff] [blame] | 137 | // compile low-level intents into flow entry installation plan |
Brian O'Connor | 488e5ed | 2014-02-20 19:50:01 -0800 | [diff] [blame] | 138 | PlanCalcRuntime runtime2 = new PlanCalcRuntime(); |
Brian O'Connor | 12861f7 | 2014-02-19 20:40:32 -0800 | [diff] [blame] | 139 | List<Set<FlowEntry>> plan = runtime2.computePlan(pathIntentOpList); |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 140 | |
| 141 | // show results |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 142 | showResult((PathIntentMap) runtime1.getPathIntents()); |
Brian O'Connor | 12861f7 | 2014-02-19 20:40:32 -0800 | [diff] [blame] | 143 | System.out.println(plan); |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | @Test |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 147 | public void createConstrainedShortestPaths() throws FloodlightModuleException { |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 148 | // create constrained shortest path intents |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 149 | IntentOperationList opList = new IntentOperationList(); |
| 150 | opList.add(Operator.ADD, new ConstrainedShortestPathIntent("1", 1L, 20L, 1L, 4L, 20L, 17L, 400.0)); |
| 151 | opList.add(Operator.ADD, new ConstrainedShortestPathIntent("2", 2L, 20L, 2L, 6L, 20L, 18L, 400.0)); |
| 152 | opList.add(Operator.ADD, new ConstrainedShortestPathIntent("3", 4L, 20L, 3L, 8L, 20L, 19L, 400.0)); |
| 153 | opList.add(Operator.ADD, new ConstrainedShortestPathIntent("4", 3L, 20L, 4L, 8L, 20L, 20L, 400.0)); |
| 154 | opList.add(Operator.ADD, new ConstrainedShortestPathIntent("5", 4L, 20L, 5L, 8L, 20L, 21L, 400.0)); |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 155 | |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 156 | // compile high-level intent operations into low-level intent operations (calculate paths) |
| 157 | PathCalcRuntimeModule runtime1 = new PathCalcRuntimeModule(); |
| 158 | runtime1.init(modContext); |
| 159 | runtime1.startUp(modContext); |
| 160 | IntentOperationList pathIntentOpList = runtime1.executeIntentOperations(opList); |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 161 | |
Brian O'Connor | 7f8e301 | 2014-02-15 23:59:29 -0800 | [diff] [blame] | 162 | // compile low-level intents into flow entry installation plan |
Brian O'Connor | 488e5ed | 2014-02-20 19:50:01 -0800 | [diff] [blame] | 163 | PlanCalcRuntime runtime2 = new PlanCalcRuntime(); |
Brian O'Connor | 12861f7 | 2014-02-19 20:40:32 -0800 | [diff] [blame] | 164 | List<Set<FlowEntry>> plan = runtime2.computePlan(pathIntentOpList); |
Brian O'Connor | 7f8e301 | 2014-02-15 23:59:29 -0800 | [diff] [blame] | 165 | |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 166 | // show results |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 167 | showResult((PathIntentMap) runtime1.getPathIntents()); |
Brian O'Connor | 12861f7 | 2014-02-19 20:40:32 -0800 | [diff] [blame] | 168 | System.out.println(plan); |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | @Test |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 172 | public void createMixedShortestPaths() throws FloodlightModuleException { |
| 173 | // create constrained & best effort shortest path intents |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 174 | IntentOperationList opList = new IntentOperationList(); |
| 175 | opList.add(Operator.ADD, new ConstrainedShortestPathIntent("1", 1L, 20L, 1L, 4L, 20L, 6L, 600.0)); |
| 176 | opList.add(Operator.ADD, new ConstrainedShortestPathIntent("2", 2L, 20L, 2L, 6L, 20L, 7L, 600.0)); |
| 177 | opList.add(Operator.ADD, new ShortestPathIntent("3", 4L, 20L, 3L, 8L, 20L, 8L)); |
| 178 | opList.add(Operator.ADD, new ShortestPathIntent("4", 4L, 20L, 4L, 8L, 20L, 9L)); |
| 179 | opList.add(Operator.ADD, new ConstrainedShortestPathIntent("5", 4L, 20L, 5L, 8L, 20L, 10L, 600.0)); |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 180 | |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 181 | // compile high-level intent operations into low-level intent operations (calculate paths) |
| 182 | PathCalcRuntimeModule runtime1 = new PathCalcRuntimeModule(); |
| 183 | runtime1.init(modContext); |
| 184 | runtime1.startUp(modContext); |
| 185 | IntentOperationList pathIntentOpList = runtime1.executeIntentOperations(opList); |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 186 | |
Brian O'Connor | 7f8e301 | 2014-02-15 23:59:29 -0800 | [diff] [blame] | 187 | // compile low-level intents into flow entry installation plan |
Brian O'Connor | 488e5ed | 2014-02-20 19:50:01 -0800 | [diff] [blame] | 188 | PlanCalcRuntime runtime2 = new PlanCalcRuntime(); |
Brian O'Connor | 12861f7 | 2014-02-19 20:40:32 -0800 | [diff] [blame] | 189 | List<Set<FlowEntry>> plan = runtime2.computePlan(pathIntentOpList); |
Brian O'Connor | 7f8e301 | 2014-02-15 23:59:29 -0800 | [diff] [blame] | 190 | |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 191 | // show results |
Toshio Koide | 27ffd41 | 2014-02-18 19:15:27 -0800 | [diff] [blame] | 192 | showResult((PathIntentMap) runtime1.getPathIntents()); |
Brian O'Connor | 12861f7 | 2014-02-19 20:40:32 -0800 | [diff] [blame] | 193 | System.out.println(plan); |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 194 | } |
Toshio Koide | d9fa2a8 | 2014-02-19 17:35:18 -0800 | [diff] [blame] | 195 | |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 196 | @Test |
| 197 | public void rerouteShortestPaths() throws FloodlightModuleException { |
Pavlin Radoslavov | 74986ce | 2014-02-20 13:17:20 -0800 | [diff] [blame] | 198 | List<SwitchEvent> addedSwitchEvents = new LinkedList<>(); |
| 199 | List<SwitchEvent> removedSwitchEvents = new LinkedList<>(); |
| 200 | List<PortEvent> addedPortEvents = new LinkedList<>(); |
| 201 | List<PortEvent> removedPortEvents = new LinkedList<>(); |
| 202 | List<LinkEvent> addedLinkEvents = new LinkedList<>(); |
| 203 | List<LinkEvent> removedLinkEvents = new LinkedList<>(); |
| 204 | List<DeviceEvent> addedDeviceEvents = new LinkedList<>(); |
| 205 | List<DeviceEvent> removedDeviceEvents = new LinkedList<>(); |
| 206 | |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 207 | // create shortest path intents |
| 208 | IntentOperationList opList = new IntentOperationList(); |
| 209 | opList.add(Operator.ADD, new ShortestPathIntent("1", 1L, 20L, 1L, 4L, 20L, 4L)); |
| 210 | opList.add(Operator.ADD, new ShortestPathIntent("2", 2L, 20L, 2L, 6L, 20L, 5L)); |
| 211 | opList.add(Operator.ADD, new ShortestPathIntent("3", 4L, 20L, 3L, 8L, 20L, 6L)); |
| 212 | |
| 213 | // compile high-level intent operations into low-level intent operations (calculate paths) |
| 214 | PathCalcRuntimeModule runtime1 = new PathCalcRuntimeModule(); |
| 215 | runtime1.init(modContext); |
| 216 | runtime1.startUp(modContext); |
| 217 | IntentOperationList pathIntentOpList = runtime1.executeIntentOperations(opList); |
| 218 | |
| 219 | // compile low-level intents into flow entry installation plan |
Brian O'Connor | 488e5ed | 2014-02-20 19:50:01 -0800 | [diff] [blame] | 220 | PlanCalcRuntime runtime2 = new PlanCalcRuntime(); |
Brian O'Connor | 12861f7 | 2014-02-19 20:40:32 -0800 | [diff] [blame] | 221 | List<Set<FlowEntry>> plan = runtime2.computePlan(pathIntentOpList); |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 222 | |
| 223 | // show results step1 |
| 224 | showResult((PathIntentMap) runtime1.getPathIntents()); |
Brian O'Connor | 12861f7 | 2014-02-19 20:40:32 -0800 | [diff] [blame] | 225 | System.out.println(plan); |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 226 | |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 227 | // TODO this state changes should be triggered by notification of plan module |
Toshio Koide | 066506e | 2014-02-20 19:52:09 -0800 | [diff] [blame] | 228 | IntentStateList states = new IntentStateList(); |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 229 | states.put("1", IntentState.INST_ACK); |
| 230 | states.put("2", IntentState.INST_ACK); |
| 231 | states.put("3", IntentState.INST_ACK); |
| 232 | runtime1.getHighLevelIntents().changeStates(states); |
Toshio Koide | bf87566 | 2014-02-24 12:19:15 -0800 | [diff] [blame^] | 233 | states.clear(); |
| 234 | states.put("1___0", IntentState.INST_ACK); |
| 235 | states.put("2___0", IntentState.INST_ACK); |
| 236 | states.put("3___0", IntentState.INST_ACK); |
| 237 | runtime1.getPathIntents().changeStates(states); |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 238 | |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 239 | // link down |
| 240 | ((MockNetworkGraph)g).removeLink(1L, 2L, 9L, 1L); // This link is used by the intent "1" |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 241 | ((MockNetworkGraph)g).removeLink(9L, 1L, 1L, 2L); |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 242 | LinkEvent linkEvent1 = new LinkEvent(1L, 2L, 9L, 1L); |
| 243 | LinkEvent linkEvent2 = new LinkEvent(9L, 1L, 1L, 2L); |
Pavlin Radoslavov | 74986ce | 2014-02-20 13:17:20 -0800 | [diff] [blame] | 244 | removedLinkEvents.clear(); |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 245 | removedLinkEvents.add(linkEvent1); |
| 246 | removedLinkEvents.add(linkEvent2); |
Toshio Koide | 798bc1b | 2014-02-20 14:02:40 -0800 | [diff] [blame] | 247 | runtime1.networkGraphEvents( |
| 248 | addedSwitchEvents, |
| 249 | removedSwitchEvents, |
| 250 | addedPortEvents, |
| 251 | removedPortEvents, |
| 252 | addedLinkEvents, |
| 253 | removedLinkEvents, |
| 254 | addedDeviceEvents, |
| 255 | removedDeviceEvents); |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 256 | System.out.println("Link goes down."); |
| 257 | |
| 258 | // show results step2 |
| 259 | showResult((PathIntentMap) runtime1.getPathIntents()); |
Brian O'Connor | 12861f7 | 2014-02-19 20:40:32 -0800 | [diff] [blame] | 260 | // TODO: show results of plan computation |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 261 | } |
Toshio Koide | c87810e | 2014-02-11 13:03:21 -0800 | [diff] [blame] | 262 | } |