Brian O'Connor

Chaning IntentStore.isMaster to take a key

Change-Id: I2d04a6aa7418e06137b0688bcb4e3af060a02b63
......@@ -82,6 +82,10 @@ public interface IntentService {
*/
List<Intent> getInstallableIntents(Key intentKey);
default boolean isLocal(Key intentKey) {
return true;
}
/**
* Adds the specified listener for intent events.
*
......
......@@ -106,11 +106,11 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> {
* Checks to see whether the calling instance is the master for processing
* this intent, or more specifically, the key contained in this intent.
*
* @param intent intent to check
* @param intentKey intentKey to check
* @return true if master; false, otherwise
*/
//TODO better name
default boolean isMaster(Intent intent) { //FIXME remove default when impl.
default boolean isMaster(Key intentKey) { //FIXME remove default when impl.
return true;
}
}
......
......@@ -201,6 +201,11 @@ public class IntentManager
}
@Override
public boolean isLocal(Key intentKey) {
return store.isMaster(intentKey);
}
@Override
public void addListener(IntentListener listener) {
listenerRegistry.addListener(listener);
}
......
......@@ -276,8 +276,8 @@ public class GossipIntentStore
}
@Override
public boolean isMaster(Intent intent) {
return partitionService.isMine(intent.key());
public boolean isMaster(Key intentKey) {
return partitionService.isMine(intentKey);
}
private void notifyDelegateIfNotNull(IntentEvent event) {
......@@ -308,7 +308,7 @@ public class GossipIntentStore
// The pending intents map has been updated. If we are master for
// this intent's partition, notify the Manager that it should do
// some work.
if (isMaster(event.value().intent())) {
if (isMaster(event.value().intent().key())) {
if (delegate != null) {
delegate.process(copyData(event.value()));
}
......
......@@ -252,7 +252,7 @@ public class SimpleIntentStore
}
@Override
public boolean isMaster(Intent intent) {
public boolean isMaster(Key intentKey) {
return true;
}
}
......
......@@ -124,9 +124,4 @@ public class SimpleIntentStore
notifyDelegate(IntentEvent.getEvent(data));
}
@Override
public boolean isMaster(Intent intent) {
return true;
}
}
......