Ray Milkey
Committed by Brian O'Connor

Removed deprecated classes/interfaces

IntentBatchLeaderEvent
IntentBatchListener
IntentBatchService

Change-Id: I712f0eb0b26d9bfaa820a14022c1dd30943fab27
...@@ -56,7 +56,6 @@ import org.onosproject.net.host.HostService; ...@@ -56,7 +56,6 @@ import org.onosproject.net.host.HostService;
56 import org.onosproject.net.intent.Constraint; 56 import org.onosproject.net.intent.Constraint;
57 import org.onosproject.net.intent.HostToHostIntent; 57 import org.onosproject.net.intent.HostToHostIntent;
58 import org.onosproject.net.intent.Intent; 58 import org.onosproject.net.intent.Intent;
59 -import org.onosproject.net.intent.IntentBatchService;
60 import org.onosproject.net.intent.IntentService; 59 import org.onosproject.net.intent.IntentService;
61 import org.slf4j.Logger; 60 import org.slf4j.Logger;
62 61
...@@ -103,9 +102,6 @@ public class DemoInstaller implements DemoAPI { ...@@ -103,9 +102,6 @@ public class DemoInstaller implements DemoAPI {
103 protected MastershipService mastershipService; 102 protected MastershipService mastershipService;
104 103
105 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 104 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
106 - protected IntentBatchService intentBatchService;
107 -
108 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
109 protected ClusterService clusterService; 105 protected ClusterService clusterService;
110 106
111 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 107 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
......
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.net.intent;
17 -
18 -import org.onosproject.core.ApplicationId;
19 -import org.onosproject.event.AbstractEvent;
20 -
21 -/**
22 - * A class to represent an intent related event.
23 - */
24 -@Deprecated
25 -public class IntentBatchLeaderEvent extends AbstractEvent<IntentBatchLeaderEvent.Type, ApplicationId> {
26 -
27 - public enum Type {
28 - /**
29 - * Signifies that this instance has become the leader for the given application id.
30 - */
31 - ELECTED,
32 -
33 - /**
34 - * Signifies that instance is no longer the leader for a given application id.
35 - */
36 - BOOTED
37 - }
38 -
39 - /**
40 - * Creates an event of a given type and for the specified appId and the
41 - * current time.
42 - *
43 - * @param type event type
44 - * @param appId subject appId
45 - * @param time time the event created in milliseconds since start of epoch
46 - */
47 - public IntentBatchLeaderEvent(Type type, ApplicationId appId, long time) {
48 - super(type, appId, time);
49 - }
50 -
51 - /**
52 - * Creates an event of a given type and for the specified appId and the
53 - * current time.
54 - *
55 - * @param type event type
56 - * @param appId subject appId
57 - */
58 - public IntentBatchLeaderEvent(Type type, ApplicationId appId) {
59 - super(type, appId);
60 - }
61 -
62 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.net.intent;
17 -
18 -import org.onosproject.event.EventListener;
19 -
20 -/**
21 - * Listener for {@link org.onosproject.net.intent.IntentEvent intent events}.
22 - */
23 -@Deprecated
24 -public interface IntentBatchListener extends EventListener<IntentBatchLeaderEvent> {
25 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.net.intent;
17 -
18 -import org.onosproject.core.ApplicationId;
19 -
20 -/**
21 - * Service for tracking and delegating batches of intent operations.
22 - */
23 -@Deprecated
24 -public interface IntentBatchService {
25 -
26 - /**
27 - * Return true if this instance is the local leader for batch
28 - * processing a given application id.
29 - *
30 - * @param applicationId an application id
31 - * @return true if this instance is the local leader for batch
32 - */
33 - boolean isLocalLeader(ApplicationId applicationId);
34 -
35 - /**
36 - * Sets the batch service delegate.
37 - *
38 - * @param delegate delegate to apply
39 - */
40 - void setDelegate(IntentBatchDelegate delegate);
41 -
42 - /**
43 - * Unsets the batch service delegate.
44 - *
45 - * @param delegate delegate to unset
46 - */
47 - void unsetDelegate(IntentBatchDelegate delegate);
48 -
49 - /**
50 - * Adds the specified listener for intent batch leadership events.
51 - *
52 - * @param listener listener to be added
53 - */
54 - void addListener(IntentBatchListener listener);
55 -
56 - /**
57 - * Removes the specified listener for intent batch leadership events.
58 - *
59 - * @param listener listener to be removed
60 - */
61 - void removeListener(IntentBatchListener listener);
62 -}
...@@ -29,9 +29,6 @@ import org.onosproject.event.Event; ...@@ -29,9 +29,6 @@ import org.onosproject.event.Event;
29 import org.onosproject.net.Link; 29 import org.onosproject.net.Link;
30 import org.onosproject.net.LinkKey; 30 import org.onosproject.net.LinkKey;
31 import org.onosproject.net.NetworkResource; 31 import org.onosproject.net.NetworkResource;
32 -import org.onosproject.net.intent.IntentBatchLeaderEvent;
33 -import org.onosproject.net.intent.IntentBatchListener;
34 -import org.onosproject.net.intent.IntentBatchService;
35 import org.onosproject.net.intent.IntentId; 32 import org.onosproject.net.intent.IntentId;
36 import org.onosproject.net.intent.IntentService; 33 import org.onosproject.net.intent.IntentService;
37 import org.onosproject.net.link.LinkEvent; 34 import org.onosproject.net.link.LinkEvent;
...@@ -80,23 +77,18 @@ public class ObjectiveTracker implements ObjectiveTrackerService { ...@@ -80,23 +77,18 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
80 @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY) 77 @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY)
81 protected IntentService intentService; 78 protected IntentService intentService;
82 79
83 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
84 - protected IntentBatchService batchService;
85 -
86 private ExecutorService executorService = 80 private ExecutorService executorService =
87 newSingleThreadExecutor(namedThreads("onos-flowtracker")); 81 newSingleThreadExecutor(namedThreads("onos-flowtracker"));
88 82
89 private TopologyListener listener = new InternalTopologyListener(); 83 private TopologyListener listener = new InternalTopologyListener();
90 private LinkResourceListener linkResourceListener = 84 private LinkResourceListener linkResourceListener =
91 new InternalLinkResourceListener(); 85 new InternalLinkResourceListener();
92 - private final LeadershipListener leaderListener = new LeadershipListener();
93 private TopologyChangeDelegate delegate; 86 private TopologyChangeDelegate delegate;
94 87
95 @Activate 88 @Activate
96 public void activate() { 89 public void activate() {
97 topologyService.addListener(listener); 90 topologyService.addListener(listener);
98 resourceManager.addListener(linkResourceListener); 91 resourceManager.addListener(linkResourceListener);
99 - batchService.addListener(leaderListener);
100 log.info("Started"); 92 log.info("Started");
101 } 93 }
102 94
...@@ -104,7 +96,6 @@ public class ObjectiveTracker implements ObjectiveTrackerService { ...@@ -104,7 +96,6 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
104 public void deactivate() { 96 public void deactivate() {
105 topologyService.removeListener(listener); 97 topologyService.removeListener(listener);
106 resourceManager.removeListener(linkResourceListener); 98 resourceManager.removeListener(linkResourceListener);
107 - batchService.removeListener(leaderListener);
108 log.info("Stopped"); 99 log.info("Stopped");
109 } 100 }
110 101
...@@ -265,22 +256,4 @@ public class ObjectiveTracker implements ObjectiveTrackerService { ...@@ -265,22 +256,4 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
265 } 256 }
266 }); 257 });
267 } 258 }
268 -
269 - private class LeadershipListener implements IntentBatchListener {
270 - @Override
271 - public void event(IntentBatchLeaderEvent event) {
272 - log.debug("leadership event: {}", event);
273 - ApplicationId appId = event.subject();
274 - switch (event.type()) {
275 - case ELECTED:
276 - updateTrackedResources(appId, true);
277 - break;
278 - case BOOTED:
279 - updateTrackedResources(appId, false);
280 - break;
281 - default:
282 - break;
283 - }
284 - }
285 - }
286 } 259 }
......
...@@ -26,17 +26,13 @@ import org.junit.After; ...@@ -26,17 +26,13 @@ import org.junit.After;
26 import org.junit.Before; 26 import org.junit.Before;
27 import org.junit.Test; 27 import org.junit.Test;
28 import org.onlab.junit.TestUtils; 28 import org.onlab.junit.TestUtils;
29 +import org.onlab.junit.TestUtils.TestUtilsException;
29 import org.onosproject.core.IdGenerator; 30 import org.onosproject.core.IdGenerator;
30 import org.onosproject.event.Event; 31 import org.onosproject.event.Event;
31 import org.onosproject.net.Link; 32 import org.onosproject.net.Link;
32 -import org.onosproject.net.LinkKey;
33 -import org.onosproject.net.NetTestTools;
34 import org.onosproject.net.NetworkResource; 33 import org.onosproject.net.NetworkResource;
35 import org.onosproject.net.intent.Intent; 34 import org.onosproject.net.intent.Intent;
36 -import org.onosproject.net.intent.IntentBatchLeaderEvent;
37 -import org.onosproject.net.intent.IntentBatchListener;
38 import org.onosproject.net.intent.IntentId; 35 import org.onosproject.net.intent.IntentId;
39 -import org.onosproject.net.intent.IntentService;
40 import org.onosproject.net.intent.MockIdGenerator; 36 import org.onosproject.net.intent.MockIdGenerator;
41 import org.onosproject.net.link.LinkEvent; 37 import org.onosproject.net.link.LinkEvent;
42 import org.onosproject.net.resource.LinkResourceEvent; 38 import org.onosproject.net.resource.LinkResourceEvent;
...@@ -45,20 +41,15 @@ import org.onosproject.net.topology.Topology; ...@@ -45,20 +41,15 @@ import org.onosproject.net.topology.Topology;
45 import org.onosproject.net.topology.TopologyEvent; 41 import org.onosproject.net.topology.TopologyEvent;
46 import org.onosproject.net.topology.TopologyListener; 42 import org.onosproject.net.topology.TopologyListener;
47 43
48 -import com.google.common.collect.ImmutableList;
49 import com.google.common.collect.ImmutableSet; 44 import com.google.common.collect.ImmutableSet;
50 import com.google.common.collect.Lists; 45 import com.google.common.collect.Lists;
51 -import com.google.common.collect.SetMultimap;
52 46
53 import static org.easymock.EasyMock.createMock; 47 import static org.easymock.EasyMock.createMock;
54 -import static org.easymock.EasyMock.expect;
55 -import static org.easymock.EasyMock.replay;
56 import static org.hamcrest.MatcherAssert.assertThat; 48 import static org.hamcrest.MatcherAssert.assertThat;
57 import static org.hamcrest.Matchers.equalTo; 49 import static org.hamcrest.Matchers.equalTo;
58 import static org.hamcrest.Matchers.hasSize; 50 import static org.hamcrest.Matchers.hasSize;
59 import static org.hamcrest.Matchers.is; 51 import static org.hamcrest.Matchers.is;
60 import static org.onosproject.net.NetTestTools.link; 52 import static org.onosproject.net.NetTestTools.link;
61 -import org.onlab.junit.TestUtils.TestUtilsException;
62 53
63 /** 54 /**
64 * Tests for the objective tracker. 55 * Tests for the objective tracker.
...@@ -71,7 +62,6 @@ public class ObjectiveTrackerTest { ...@@ -71,7 +62,6 @@ public class ObjectiveTrackerTest {
71 private List<Event> reasons; 62 private List<Event> reasons;
72 private TopologyListener listener; 63 private TopologyListener listener;
73 private LinkResourceListener linkResourceListener; 64 private LinkResourceListener linkResourceListener;
74 - private IntentBatchListener leaderListener;
75 private IdGenerator mockGenerator; 65 private IdGenerator mockGenerator;
76 66
77 /** 67 /**
...@@ -88,7 +78,6 @@ public class ObjectiveTrackerTest { ...@@ -88,7 +78,6 @@ public class ObjectiveTrackerTest {
88 reasons = new LinkedList<>(); 78 reasons = new LinkedList<>();
89 listener = TestUtils.getField(tracker, "listener"); 79 listener = TestUtils.getField(tracker, "listener");
90 linkResourceListener = TestUtils.getField(tracker, "linkResourceListener"); 80 linkResourceListener = TestUtils.getField(tracker, "linkResourceListener");
91 - leaderListener = TestUtils.getField(tracker, "leaderListener");
92 mockGenerator = new MockIdGenerator(); 81 mockGenerator = new MockIdGenerator();
93 Intent.bindIdGenerator(mockGenerator); 82 Intent.bindIdGenerator(mockGenerator);
94 } 83 }
...@@ -123,32 +112,6 @@ public class ObjectiveTrackerTest { ...@@ -123,32 +112,6 @@ public class ObjectiveTrackerTest {
123 } 112 }
124 113
125 /** 114 /**
126 - * Mock compilable intent class.
127 - */
128 - private static class MockIntent extends Intent {
129 -
130 - public MockIntent(Collection<NetworkResource> resources) {
131 - super(NetTestTools.APP_ID, resources);
132 - }
133 -
134 - }
135 -
136 - /**
137 - * Mock installable intent class.
138 - */
139 - private static class MockInstallableIntent extends Intent {
140 - public MockInstallableIntent(Collection<NetworkResource> resources) {
141 - super(NetTestTools.APP_ID, resources);
142 - }
143 -
144 - @Override
145 - public boolean isInstallable() {
146 - return true;
147 - }
148 -
149 - }
150 -
151 - /**
152 * Tests an event with no associated reasons. 115 * Tests an event with no associated reasons.
153 * 116 *
154 * @throws InterruptedException if the latch wait fails. 117 * @throws InterruptedException if the latch wait fails.
...@@ -271,52 +234,4 @@ public class ObjectiveTrackerTest { ...@@ -271,52 +234,4 @@ public class ObjectiveTrackerTest {
271 assertThat(delegate.compileAllFailedFromEvent, is(true)); 234 assertThat(delegate.compileAllFailedFromEvent, is(true));
272 } 235 }
273 236
274 - /**
275 - * Tests leadership events.
276 - *
277 - * @throws InterruptedException if the latch wait fails.
278 - */
279 - @Test
280 - public void testLeaderEvents() throws Exception {
281 -
282 - final Link link = link("src", 1, "dst", 2);
283 - final List<NetworkResource> resources = ImmutableList.of(link);
284 -
285 - final List<Intent> intents = new LinkedList<>();
286 - final List<Intent> installableIntents = new LinkedList<>();
287 - installableIntents.add(new MockInstallableIntent(resources));
288 - intents.add(new MockIntent(resources));
289 -
290 - final SetMultimap<LinkKey, IntentId> intentsByLink =
291 - TestUtils.getField(tracker, "intentsByLink");
292 - assertThat(intentsByLink.size(), is(0));
293 -
294 - final IntentService mockIntentManager = createMock(IntentService.class);
295 - expect(mockIntentManager
296 - .getIntents())
297 - .andReturn(intents)
298 - .anyTimes();
299 - expect(mockIntentManager
300 - .getIntent(IntentId.valueOf(0x0)))
301 - .andReturn(intents.get(0))
302 - .anyTimes();
303 - expect(mockIntentManager
304 - .getInstallableIntents(IntentId.valueOf(0x1)))
305 - .andReturn(installableIntents)
306 - .anyTimes();
307 - replay(mockIntentManager);
308 - tracker.bindIntentService(mockIntentManager);
309 -
310 - final IntentBatchLeaderEvent electedEvent = new IntentBatchLeaderEvent(
311 - IntentBatchLeaderEvent.Type.ELECTED, NetTestTools.APP_ID);
312 - leaderListener.event(electedEvent);
313 - assertThat(intentsByLink.size(), is(1));
314 -
315 - final IntentBatchLeaderEvent bootedEvent = new IntentBatchLeaderEvent(
316 - IntentBatchLeaderEvent.Type.BOOTED, NetTestTools.APP_ID);
317 - leaderListener.event(bootedEvent);
318 - assertThat(intentsByLink.size(), is(0));
319 -
320 - tracker.unbindIntentService(mockIntentManager);
321 - }
322 } 237 }
......