Madan Jampani
Committed by Gerrit Code Review

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
Showing 12 changed files with 58 additions and 58 deletions
......@@ -51,7 +51,7 @@ import org.onosproject.net.intent.IntentEvent;
import org.onosproject.net.intent.IntentListener;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.Key;
import org.onosproject.net.intent.PartitionService;
import org.onosproject.net.intent.IntentPartitionService;
import org.onosproject.net.intent.PointToPointIntent;
import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
import org.onosproject.store.cluster.messaging.MessageSubject;
......@@ -139,7 +139,7 @@ public class IntentPerfInstaller {
protected MastershipService mastershipService;
@Reference(cardinality = MANDATORY_UNARY)
protected PartitionService partitionService;
protected IntentPartitionService partitionService;
@Reference(cardinality = MANDATORY_UNARY)
protected ComponentConfigService configService;
......
......@@ -23,13 +23,13 @@ import org.onosproject.event.AbstractEvent;
*/
//TODO change String into a proper object type
@Beta
public class PartitionEvent extends AbstractEvent<PartitionEvent.Type, String> {
public class IntentPartitionEvent extends AbstractEvent<IntentPartitionEvent.Type, String> {
public enum Type {
LEADER_CHANGED
}
public PartitionEvent(Type type, String partition) {
public IntentPartitionEvent(Type type, String partition) {
super(type, partition);
}
}
......
......@@ -22,5 +22,5 @@ import org.onosproject.event.EventListener;
* Entity capable of receiving device partition-related events.
*/
@Beta
public interface PartitionEventListener extends EventListener<PartitionEvent> {
public interface IntentPartitionEventListener extends EventListener<IntentPartitionEvent> {
}
......
......@@ -20,11 +20,11 @@ import org.onosproject.cluster.NodeId;
import org.onosproject.event.ListenerService;
/**
* Service for interacting with the partition-to-instance assignments.
* Service for interacting with the intent partition-to-instance assignments.
*/
@Beta
public interface PartitionService
extends ListenerService<PartitionEvent, PartitionEventListener> {
public interface IntentPartitionService
extends ListenerService<IntentPartitionEvent, IntentPartitionEventListener> {
/**
* Returns whether the given intent key is in a partition owned by this
......
......@@ -18,9 +18,9 @@ package org.onosproject.net.intent;
import org.onosproject.cluster.NodeId;
/**
* Testing adapter for the partition service.
* Testing adapter for the IntentPartitionService.
*/
public class PartitionServiceAdapter implements PartitionService {
public class IntentPartitionServiceAdapter implements IntentPartitionService {
@Override
public boolean isMine(Key intentKey) {
return true;
......@@ -32,12 +32,12 @@ public class PartitionServiceAdapter implements PartitionService {
}
@Override
public void addListener(PartitionEventListener listener) {
public void addListener(IntentPartitionEventListener listener) {
}
@Override
public void removeListener(PartitionEventListener listener) {
public void removeListener(IntentPartitionEventListener listener) {
}
}
......
......@@ -33,9 +33,9 @@ import org.onosproject.cluster.NodeId;
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.onosproject.store.AbstractStore;
import org.slf4j.Logger;
......@@ -51,7 +51,7 @@ import static org.slf4j.LoggerFactory.getLogger;
@Service
public class SimpleClusterStore
extends AbstractStore<ClusterEvent, ClusterStoreDelegate>
implements ClusterStore, PartitionService {
implements ClusterStore, IntentPartitionService {
public static final IpAddress LOCALHOST = IpAddress.valueOf("127.0.0.1");
......@@ -64,21 +64,21 @@ public class SimpleClusterStore
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected EventDeliveryService eventDispatcher;
private ListenerRegistry<PartitionEvent, PartitionEventListener> listenerRegistry;
private ListenerRegistry<IntentPartitionEvent, IntentPartitionEventListener> listenerRegistry;
@Activate
public void activate() {
instance = new DefaultControllerNode(new NodeId("local"), LOCALHOST);
listenerRegistry = new ListenerRegistry<>();
eventDispatcher.addSink(PartitionEvent.class, listenerRegistry);
eventDispatcher.addSink(IntentPartitionEvent.class, listenerRegistry);
log.info("Started");
}
@Deactivate
public void deactivate() {
eventDispatcher.removeSink(PartitionEvent.class);
eventDispatcher.removeSink(IntentPartitionEvent.class);
log.info("Stopped");
}
......@@ -128,12 +128,12 @@ public class SimpleClusterStore
}
@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);
}
}
......
......@@ -45,9 +45,9 @@ import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentData;
import org.onosproject.net.intent.IntentService;
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.onosproject.net.link.LinkEvent;
import org.onosproject.net.newresource.ResourceEvent;
import org.onosproject.net.newresource.ResourceListener;
......@@ -116,7 +116,7 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
protected IntentService intentService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected PartitionService partitionService;
protected IntentPartitionService partitionService;
private ExecutorService executorService =
newSingleThreadExecutor(groupedThreads("onos/intent", "objectivetracker"));
......@@ -127,7 +127,7 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
private ResourceListener resourceListener = new InternalResourceListener();
private DeviceListener deviceListener = new InternalDeviceListener();
private HostListener hostListener = new InternalHostListener();
private PartitionEventListener partitionListener = new InternalPartitionListener();
private IntentPartitionEventListener partitionListener = new InternalPartitionListener();
private TopologyChangeDelegate delegate;
protected final AtomicBoolean updateScheduled = new AtomicBoolean(false);
......@@ -445,9 +445,9 @@ public class ObjectiveTracker implements ObjectiveTrackerService {
}
}
private final class InternalPartitionListener implements PartitionEventListener {
private final class InternalPartitionListener implements IntentPartitionEventListener {
@Override
public void event(PartitionEvent event) {
public void event(IntentPartitionEvent event) {
log.debug("got message {}", event.subject());
scheduleIntentUpdate(1);
}
......
......@@ -42,7 +42,7 @@ import org.onosproject.net.host.HostService;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.IntentExtensionService;
import org.onosproject.net.intent.IntentClockService;
import org.onosproject.net.intent.PartitionService;
import org.onosproject.net.intent.IntentPartitionService;
import org.onosproject.net.link.LinkAdminService;
import org.onosproject.net.link.LinkService;
import org.onosproject.net.packet.PacketService;
......@@ -193,7 +193,7 @@ public final class DefaultPolicyBuilder {
permSet.add(new ServicePermission(IntentService.class.getName(), ServicePermission.GET));
permSet.add(new ServicePermission(IntentClockService.class.getName(), ServicePermission.GET));
permSet.add(new ServicePermission(IntentExtensionService.class.getName(), ServicePermission.GET));
permSet.add(new ServicePermission(PartitionService.class.getName(), ServicePermission.GET));
permSet.add(new ServicePermission(IntentPartitionService.class.getName(), ServicePermission.GET));
permSet.add(new ServicePermission(LinkService.class.getName(), ServicePermission.GET));
permSet.add(new ServicePermission(LinkResourceService.class.getName(), ServicePermission.GET));
// permSet.add(new ServicePermission(LabelResourceService.class.getName(), ServicePermission.GET));
......@@ -262,7 +262,7 @@ public final class DefaultPolicyBuilder {
serviceDirectory.put(HOST_EVENT, ImmutableSet.of(
HostService.class.getName()));
serviceDirectory.put(INTENT_READ, ImmutableSet.of(
IntentService.class.getName(), PartitionService.class.getName(),
IntentService.class.getName(), IntentPartitionService.class.getName(),
IntentClockService.class.getName()));
serviceDirectory.put(INTENT_WRITE, ImmutableSet.of(
IntentService.class.getName()));
......
......@@ -35,7 +35,7 @@ import org.onosproject.net.intent.IntentState;
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 @@ public class GossipIntentStore
protected StorageService storageService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected PartitionService partitionService;
protected IntentPartitionService partitionService;
private final AtomicLong sequenceNumber = new AtomicLong(0);
......
......@@ -33,9 +33,9 @@ import org.onosproject.cluster.NodeId;
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 @@ import java.util.stream.Collectors;
*/
@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 @@ public class PartitionManager implements PartitionService {
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 @@ public class PartitionManager implements PartitionService {
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 class PartitionManager implements PartitionService {
public void deactivate() {
executor.shutdownNow();
eventDispatcher.removeSink(PartitionEvent.class);
eventDispatcher.removeSink(IntentPartitionEvent.class);
leadershipService.removeListener(leaderListener);
clusterService.removeListener(clusterListener);
}
......@@ -112,7 +112,7 @@ public class PartitionManager implements PartitionService {
* @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 @@ public class PartitionManager implements PartitionService {
}
@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 @@ public class PartitionManager implements PartitionService {
// 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()));
}
}
......
......@@ -30,7 +30,7 @@ import org.onosproject.net.intent.IntentData;
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 class GossipIntentStoreTest {
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);
......
......@@ -50,9 +50,9 @@ import static org.easymock.EasyMock.verify;
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 @@ public class PartitionManagerTest {
private LeadershipService leadershipService;
private LeadershipEventListener leaderListener;
private PartitionManager partitionManager;
private IntentPartitionManager partitionManager;
@Before
public void setUp() {
......@@ -76,13 +76,13 @@ public class PartitionManagerTest {
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 @@ public class PartitionManagerTest {
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 @@ public class PartitionManagerTest {
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 @@ public class PartitionManagerTest {
@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 @@ public class PartitionManagerTest {
@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 @@ public class PartitionManagerTest {
@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 @@ public class PartitionManagerTest {
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
......