diff --git a/apps/demo/src/main/java/org/onosproject/demo/DemoInstaller.java b/apps/demo/src/main/java/org/onosproject/demo/DemoInstaller.java index 86d9837610..8323229105 100644 --- a/apps/demo/src/main/java/org/onosproject/demo/DemoInstaller.java +++ b/apps/demo/src/main/java/org/onosproject/demo/DemoInstaller.java @@ -56,7 +56,6 @@ import org.onosproject.net.host.HostService; import org.onosproject.net.intent.Constraint; import org.onosproject.net.intent.HostToHostIntent; import org.onosproject.net.intent.Intent; -import org.onosproject.net.intent.IntentBatchService; import org.onosproject.net.intent.IntentService; import org.slf4j.Logger; @@ -102,9 +101,6 @@ public class DemoInstaller implements DemoAPI { @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected MastershipService mastershipService; - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected IntentBatchService intentBatchService; - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected ClusterService clusterService; diff --git a/core/api/src/main/java/org/onosproject/net/intent/IntentBatchLeaderEvent.java b/core/api/src/main/java/org/onosproject/net/intent/IntentBatchLeaderEvent.java deleted file mode 100644 index 793653cdea..0000000000 --- a/core/api/src/main/java/org/onosproject/net/intent/IntentBatchLeaderEvent.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2014 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.net.intent; - -import org.onosproject.core.ApplicationId; -import org.onosproject.event.AbstractEvent; - -/** - * A class to represent an intent related event. - */ -@Deprecated -public class IntentBatchLeaderEvent extends AbstractEvent { - - public enum Type { - /** - * Signifies that this instance has become the leader for the given application id. - */ - ELECTED, - - /** - * Signifies that instance is no longer the leader for a given application id. - */ - BOOTED - } - - /** - * Creates an event of a given type and for the specified appId and the - * current time. - * - * @param type event type - * @param appId subject appId - * @param time time the event created in milliseconds since start of epoch - */ - public IntentBatchLeaderEvent(Type type, ApplicationId appId, long time) { - super(type, appId, time); - } - - /** - * Creates an event of a given type and for the specified appId and the - * current time. - * - * @param type event type - * @param appId subject appId - */ - public IntentBatchLeaderEvent(Type type, ApplicationId appId) { - super(type, appId); - } - -} diff --git a/core/api/src/main/java/org/onosproject/net/intent/IntentBatchListener.java b/core/api/src/main/java/org/onosproject/net/intent/IntentBatchListener.java deleted file mode 100644 index 5365e29471..0000000000 --- a/core/api/src/main/java/org/onosproject/net/intent/IntentBatchListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2014 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.net.intent; - -import org.onosproject.event.EventListener; - -/** - * Listener for {@link org.onosproject.net.intent.IntentEvent intent events}. - */ -@Deprecated -public interface IntentBatchListener extends EventListener { -} diff --git a/core/api/src/main/java/org/onosproject/net/intent/IntentBatchService.java b/core/api/src/main/java/org/onosproject/net/intent/IntentBatchService.java deleted file mode 100644 index 1401833bf4..0000000000 --- a/core/api/src/main/java/org/onosproject/net/intent/IntentBatchService.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2014 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.net.intent; - -import org.onosproject.core.ApplicationId; - -/** - * Service for tracking and delegating batches of intent operations. - */ -@Deprecated -public interface IntentBatchService { - - /** - * Return true if this instance is the local leader for batch - * processing a given application id. - * - * @param applicationId an application id - * @return true if this instance is the local leader for batch - */ - boolean isLocalLeader(ApplicationId applicationId); - - /** - * Sets the batch service delegate. - * - * @param delegate delegate to apply - */ - void setDelegate(IntentBatchDelegate delegate); - - /** - * Unsets the batch service delegate. - * - * @param delegate delegate to unset - */ - void unsetDelegate(IntentBatchDelegate delegate); - - /** - * Adds the specified listener for intent batch leadership events. - * - * @param listener listener to be added - */ - void addListener(IntentBatchListener listener); - - /** - * Removes the specified listener for intent batch leadership events. - * - * @param listener listener to be removed - */ - void removeListener(IntentBatchListener listener); -} diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java b/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java index 0a36d1c217..aabcc28d1c 100644 --- a/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java +++ b/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java @@ -29,9 +29,6 @@ import org.onosproject.event.Event; import org.onosproject.net.Link; import org.onosproject.net.LinkKey; import org.onosproject.net.NetworkResource; -import org.onosproject.net.intent.IntentBatchLeaderEvent; -import org.onosproject.net.intent.IntentBatchListener; -import org.onosproject.net.intent.IntentBatchService; import org.onosproject.net.intent.IntentId; import org.onosproject.net.intent.IntentService; import org.onosproject.net.link.LinkEvent; @@ -80,23 +77,18 @@ public class ObjectiveTracker implements ObjectiveTrackerService { @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY) protected IntentService intentService; - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected IntentBatchService batchService; - private ExecutorService executorService = newSingleThreadExecutor(namedThreads("onos-flowtracker")); private TopologyListener listener = new InternalTopologyListener(); private LinkResourceListener linkResourceListener = new InternalLinkResourceListener(); - private final LeadershipListener leaderListener = new LeadershipListener(); private TopologyChangeDelegate delegate; @Activate public void activate() { topologyService.addListener(listener); resourceManager.addListener(linkResourceListener); - batchService.addListener(leaderListener); log.info("Started"); } @@ -104,7 +96,6 @@ public class ObjectiveTracker implements ObjectiveTrackerService { public void deactivate() { topologyService.removeListener(listener); resourceManager.removeListener(linkResourceListener); - batchService.removeListener(leaderListener); log.info("Stopped"); } @@ -265,22 +256,4 @@ public class ObjectiveTracker implements ObjectiveTrackerService { } }); } - - private class LeadershipListener implements IntentBatchListener { - @Override - public void event(IntentBatchLeaderEvent event) { - log.debug("leadership event: {}", event); - ApplicationId appId = event.subject(); - switch (event.type()) { - case ELECTED: - updateTrackedResources(appId, true); - break; - case BOOTED: - updateTrackedResources(appId, false); - break; - default: - break; - } - } - } } diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java index cf89098173..02d206a935 100644 --- a/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java +++ b/core/net/src/test/java/org/onosproject/net/intent/impl/ObjectiveTrackerTest.java @@ -26,17 +26,13 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onlab.junit.TestUtils; +import org.onlab.junit.TestUtils.TestUtilsException; import org.onosproject.core.IdGenerator; import org.onosproject.event.Event; import org.onosproject.net.Link; -import org.onosproject.net.LinkKey; -import org.onosproject.net.NetTestTools; import org.onosproject.net.NetworkResource; import org.onosproject.net.intent.Intent; -import org.onosproject.net.intent.IntentBatchLeaderEvent; -import org.onosproject.net.intent.IntentBatchListener; import org.onosproject.net.intent.IntentId; -import org.onosproject.net.intent.IntentService; import org.onosproject.net.intent.MockIdGenerator; import org.onosproject.net.link.LinkEvent; import org.onosproject.net.resource.LinkResourceEvent; @@ -45,20 +41,15 @@ import org.onosproject.net.topology.Topology; import org.onosproject.net.topology.TopologyEvent; import org.onosproject.net.topology.TopologyListener; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; -import com.google.common.collect.SetMultimap; import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.onosproject.net.NetTestTools.link; -import org.onlab.junit.TestUtils.TestUtilsException; /** * Tests for the objective tracker. @@ -71,7 +62,6 @@ public class ObjectiveTrackerTest { private List reasons; private TopologyListener listener; private LinkResourceListener linkResourceListener; - private IntentBatchListener leaderListener; private IdGenerator mockGenerator; /** @@ -88,7 +78,6 @@ public class ObjectiveTrackerTest { reasons = new LinkedList<>(); listener = TestUtils.getField(tracker, "listener"); linkResourceListener = TestUtils.getField(tracker, "linkResourceListener"); - leaderListener = TestUtils.getField(tracker, "leaderListener"); mockGenerator = new MockIdGenerator(); Intent.bindIdGenerator(mockGenerator); } @@ -122,32 +111,6 @@ public class ObjectiveTrackerTest { } } - /** - * Mock compilable intent class. - */ - private static class MockIntent extends Intent { - - public MockIntent(Collection resources) { - super(NetTestTools.APP_ID, resources); - } - - } - - /** - * Mock installable intent class. - */ - private static class MockInstallableIntent extends Intent { - public MockInstallableIntent(Collection resources) { - super(NetTestTools.APP_ID, resources); - } - - @Override - public boolean isInstallable() { - return true; - } - - } - /** * Tests an event with no associated reasons. * @@ -271,52 +234,4 @@ public class ObjectiveTrackerTest { assertThat(delegate.compileAllFailedFromEvent, is(true)); } - /** - * Tests leadership events. - * - * @throws InterruptedException if the latch wait fails. - */ - @Test - public void testLeaderEvents() throws Exception { - - final Link link = link("src", 1, "dst", 2); - final List resources = ImmutableList.of(link); - - final List intents = new LinkedList<>(); - final List installableIntents = new LinkedList<>(); - installableIntents.add(new MockInstallableIntent(resources)); - intents.add(new MockIntent(resources)); - - final SetMultimap intentsByLink = - TestUtils.getField(tracker, "intentsByLink"); - assertThat(intentsByLink.size(), is(0)); - - final IntentService mockIntentManager = createMock(IntentService.class); - expect(mockIntentManager - .getIntents()) - .andReturn(intents) - .anyTimes(); - expect(mockIntentManager - .getIntent(IntentId.valueOf(0x0))) - .andReturn(intents.get(0)) - .anyTimes(); - expect(mockIntentManager - .getInstallableIntents(IntentId.valueOf(0x1))) - .andReturn(installableIntents) - .anyTimes(); - replay(mockIntentManager); - tracker.bindIntentService(mockIntentManager); - - final IntentBatchLeaderEvent electedEvent = new IntentBatchLeaderEvent( - IntentBatchLeaderEvent.Type.ELECTED, NetTestTools.APP_ID); - leaderListener.event(electedEvent); - assertThat(intentsByLink.size(), is(1)); - - final IntentBatchLeaderEvent bootedEvent = new IntentBatchLeaderEvent( - IntentBatchLeaderEvent.Type.BOOTED, NetTestTools.APP_ID); - leaderListener.event(bootedEvent); - assertThat(intentsByLink.size(), is(0)); - - tracker.unbindIntentService(mockIntentManager); - } }