Renaming Partition{Service, Manager, Event} to IntentPartition{Service, Manager, Event} to better disambiguate between another PartitionService that is responsible for managing datastore partitions
Change-Id: I74d311ae991fb241563a1475ea74a625d8069142
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java
index 1e5db99..77dbff1 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java
@@ -35,7 +35,7 @@
import org.onosproject.net.intent.IntentStore;
import org.onosproject.net.intent.IntentStoreDelegate;
import org.onosproject.net.intent.Key;
-import org.onosproject.net.intent.PartitionService;
+import org.onosproject.net.intent.IntentPartitionService;
import org.onosproject.store.AbstractStore;
import org.onosproject.store.service.MultiValuedTimestamp;
import org.onosproject.store.service.WallClockTimestamp;
@@ -83,7 +83,7 @@
protected StorageService storageService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected PartitionService partitionService;
+ protected IntentPartitionService partitionService;
private final AtomicLong sequenceNumber = new AtomicLong(0);
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionManager.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/IntentPartitionManager.java
similarity index 89%
rename from core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionManager.java
rename to core/store/dist/src/main/java/org/onosproject/store/intent/impl/IntentPartitionManager.java
index 09108d2..565c6cf 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionManager.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/IntentPartitionManager.java
@@ -33,9 +33,9 @@
import org.onosproject.event.EventDeliveryService;
import org.onosproject.event.ListenerRegistry;
import org.onosproject.net.intent.Key;
-import org.onosproject.net.intent.PartitionEvent;
-import org.onosproject.net.intent.PartitionEventListener;
-import org.onosproject.net.intent.PartitionService;
+import org.onosproject.net.intent.IntentPartitionEvent;
+import org.onosproject.net.intent.IntentPartitionEventListener;
+import org.onosproject.net.intent.IntentPartitionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,9 +52,9 @@
*/
@Component(immediate = true)
@Service
-public class PartitionManager implements PartitionService {
+public class IntentPartitionManager implements IntentPartitionService {
- private static final Logger log = LoggerFactory.getLogger(PartitionManager.class);
+ private static final Logger log = LoggerFactory.getLogger(IntentPartitionManager.class);
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected LeadershipService leadershipService;
@@ -74,7 +74,7 @@
private static final String ELECTION_PREFIX = "intent-partition-";
- private ListenerRegistry<PartitionEvent, PartitionEventListener> listenerRegistry;
+ private ListenerRegistry<IntentPartitionEvent, IntentPartitionEventListener> listenerRegistry;
private LeadershipEventListener leaderListener = new InternalLeadershipListener();
private ClusterEventListener clusterListener = new InternalClusterEventListener();
@@ -87,7 +87,7 @@
clusterService.addListener(clusterListener);
listenerRegistry = new ListenerRegistry<>();
- eventDispatcher.addSink(PartitionEvent.class, listenerRegistry);
+ eventDispatcher.addSink(IntentPartitionEvent.class, listenerRegistry);
for (int i = 0; i < NUM_PARTITIONS; i++) {
leadershipService.runForLeadership(getPartitionPath(i));
@@ -101,7 +101,7 @@
public void deactivate() {
executor.shutdownNow();
- eventDispatcher.removeSink(PartitionEvent.class);
+ eventDispatcher.removeSink(IntentPartitionEvent.class);
leadershipService.removeListener(leaderListener);
clusterService.removeListener(clusterListener);
}
@@ -112,7 +112,7 @@
* @param executor scheduled executor service for background tasks
* @return this PartitionManager
*/
- public PartitionManager withScheduledExecutor(ScheduledExecutorService executor) {
+ public IntentPartitionManager withScheduledExecutor(ScheduledExecutorService executor) {
this.executor = executor;
return this;
}
@@ -146,12 +146,12 @@
}
@Override
- public void addListener(PartitionEventListener listener) {
+ public void addListener(IntentPartitionEventListener listener) {
listenerRegistry.addListener(listener);
}
@Override
- public void removeListener(PartitionEventListener listener) {
+ public void removeListener(IntentPartitionEventListener listener) {
listenerRegistry.removeListener(listener);
}
@@ -226,7 +226,7 @@
// See if we need to let some partitions go
scheduleRebalance(0);
- eventDispatcher.post(new PartitionEvent(PartitionEvent.Type.LEADER_CHANGED,
+ eventDispatcher.post(new IntentPartitionEvent(IntentPartitionEvent.Type.LEADER_CHANGED,
leadership.topic()));
}
}
diff --git a/core/store/dist/src/test/java/org/onosproject/store/intent/impl/GossipIntentStoreTest.java b/core/store/dist/src/test/java/org/onosproject/store/intent/impl/GossipIntentStoreTest.java
index a74c3a2..7fed235 100644
--- a/core/store/dist/src/test/java/org/onosproject/store/intent/impl/GossipIntentStoreTest.java
+++ b/core/store/dist/src/test/java/org/onosproject/store/intent/impl/GossipIntentStoreTest.java
@@ -30,7 +30,7 @@
import org.onosproject.net.intent.IntentState;
import org.onosproject.net.intent.IntentTestsMocks;
import org.onosproject.net.intent.MockIdGenerator;
-import org.onosproject.net.intent.PartitionServiceAdapter;
+import org.onosproject.net.intent.IntentPartitionServiceAdapter;
import org.onosproject.store.service.TestStorageService;
import static org.hamcrest.Matchers.is;
@@ -52,7 +52,7 @@
public void setUp() {
intentStore = new GossipIntentStore();
intentStore.storageService = new TestStorageService();
- intentStore.partitionService = new PartitionServiceAdapter();
+ intentStore.partitionService = new IntentPartitionServiceAdapter();
intentStore.clusterService = new ClusterServiceAdapter();
idGenerator = new MockIdGenerator();
Intent.bindIdGenerator(idGenerator);
diff --git a/core/store/dist/src/test/java/org/onosproject/store/intent/impl/PartitionManagerTest.java b/core/store/dist/src/test/java/org/onosproject/store/intent/impl/IntentPartitionManagerTest.java
similarity index 93%
rename from core/store/dist/src/test/java/org/onosproject/store/intent/impl/PartitionManagerTest.java
rename to core/store/dist/src/test/java/org/onosproject/store/intent/impl/IntentPartitionManagerTest.java
index 61d1937..5ba0c7c 100644
--- a/core/store/dist/src/test/java/org/onosproject/store/intent/impl/PartitionManagerTest.java
+++ b/core/store/dist/src/test/java/org/onosproject/store/intent/impl/IntentPartitionManagerTest.java
@@ -50,9 +50,9 @@
import static org.junit.Assert.assertTrue;
/**
- * Unit tests for the PartitionManager class.
+ * Unit tests for the IntentPartitionManager class.
*/
-public class PartitionManagerTest {
+public class IntentPartitionManagerTest {
private final LeadershipEvent event
= new LeadershipEvent(LeadershipEvent.Type.LEADER_ELECTED,
@@ -68,7 +68,7 @@
private LeadershipService leadershipService;
private LeadershipEventListener leaderListener;
- private PartitionManager partitionManager;
+ private IntentPartitionManager partitionManager;
@Before
public void setUp() {
@@ -76,13 +76,13 @@
leadershipService.addListener(anyObject(LeadershipEventListener.class));
expectLastCall().andDelegateTo(new TestLeadershipService());
- for (int i = 0; i < PartitionManager.NUM_PARTITIONS; i++) {
+ for (int i = 0; i < IntentPartitionManager.NUM_PARTITIONS; i++) {
expect(leadershipService.runForLeadership(ELECTION_PREFIX + i))
.andReturn(CompletableFuture.completedFuture(null))
.times(1);
}
- partitionManager = new PartitionManager()
+ partitionManager = new IntentPartitionManager()
.withScheduledExecutor(new NullScheduledExecutor());
partitionManager.clusterService = new TestClusterService();
@@ -108,7 +108,7 @@
new Leadership(ELECTION_PREFIX + i, MY_NODE_ID, 0, 0));
}
- for (int i = numMine; i < PartitionManager.NUM_PARTITIONS; i++) {
+ for (int i = numMine; i < IntentPartitionManager.NUM_PARTITIONS; i++) {
expect(leadershipService.getLeader(ELECTION_PREFIX + i))
.andReturn(OTHER_NODE_ID).anyTimes();
@@ -129,7 +129,7 @@
leadershipService.addListener(anyObject(LeadershipEventListener.class));
- for (int i = 0; i < PartitionManager.NUM_PARTITIONS; i++) {
+ for (int i = 0; i < IntentPartitionManager.NUM_PARTITIONS; i++) {
expect(leadershipService.runForLeadership(ELECTION_PREFIX + i))
.andReturn(CompletableFuture.completedFuture(null))
.times(1);
@@ -179,7 +179,7 @@
@Test
public void testRebalanceScheduling() {
// We have all the partitions so we'll need to relinquish some
- setUpLeadershipService(PartitionManager.NUM_PARTITIONS);
+ setUpLeadershipService(IntentPartitionManager.NUM_PARTITIONS);
replay(leadershipService);
@@ -198,7 +198,7 @@
@Test
public void testRebalance() {
// We have all the partitions so we'll need to relinquish some
- setUpLeadershipService(PartitionManager.NUM_PARTITIONS);
+ setUpLeadershipService(IntentPartitionManager.NUM_PARTITIONS);
expect(leadershipService.withdraw(anyString()))
.andReturn(CompletableFuture.completedFuture(null))
@@ -221,7 +221,7 @@
@Test
public void testNoRebalance() {
// Partitions are already perfectly balanced among the two active instances
- setUpLeadershipService(PartitionManager.NUM_PARTITIONS / 2);
+ setUpLeadershipService(IntentPartitionManager.NUM_PARTITIONS / 2);
replay(leadershipService);
partitionManager.activate();
@@ -233,7 +233,7 @@
reset(leadershipService);
// We have a smaller share than we should
- setUpLeadershipService(PartitionManager.NUM_PARTITIONS / 2 - 1);
+ setUpLeadershipService(IntentPartitionManager.NUM_PARTITIONS / 2 - 1);
replay(leadershipService);
// trigger rebalance