Chaning IntentStore.isMaster to take a key
Change-Id: I2d04a6aa7418e06137b0688bcb4e3af060a02b63
Showing
6 changed files
with
15 additions
and
11 deletions
| ... | @@ -82,6 +82,10 @@ public interface IntentService { | ... | @@ -82,6 +82,10 @@ public interface IntentService { |
| 82 | */ | 82 | */ |
| 83 | List<Intent> getInstallableIntents(Key intentKey); | 83 | List<Intent> getInstallableIntents(Key intentKey); |
| 84 | 84 | ||
| 85 | + default boolean isLocal(Key intentKey) { | ||
| 86 | + return true; | ||
| 87 | + } | ||
| 88 | + | ||
| 85 | /** | 89 | /** |
| 86 | * Adds the specified listener for intent events. | 90 | * Adds the specified listener for intent events. |
| 87 | * | 91 | * | ... | ... |
| ... | @@ -106,11 +106,11 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { | ... | @@ -106,11 +106,11 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { |
| 106 | * Checks to see whether the calling instance is the master for processing | 106 | * Checks to see whether the calling instance is the master for processing |
| 107 | * this intent, or more specifically, the key contained in this intent. | 107 | * this intent, or more specifically, the key contained in this intent. |
| 108 | * | 108 | * |
| 109 | - * @param intent intent to check | 109 | + * @param intentKey intentKey to check |
| 110 | * @return true if master; false, otherwise | 110 | * @return true if master; false, otherwise |
| 111 | */ | 111 | */ |
| 112 | //TODO better name | 112 | //TODO better name |
| 113 | - default boolean isMaster(Intent intent) { //FIXME remove default when impl. | 113 | + default boolean isMaster(Key intentKey) { //FIXME remove default when impl. |
| 114 | return true; | 114 | return true; |
| 115 | } | 115 | } |
| 116 | } | 116 | } | ... | ... |
| ... | @@ -201,6 +201,11 @@ public class IntentManager | ... | @@ -201,6 +201,11 @@ public class IntentManager |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | @Override | 203 | @Override |
| 204 | + public boolean isLocal(Key intentKey) { | ||
| 205 | + return store.isMaster(intentKey); | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + @Override | ||
| 204 | public void addListener(IntentListener listener) { | 209 | public void addListener(IntentListener listener) { |
| 205 | listenerRegistry.addListener(listener); | 210 | listenerRegistry.addListener(listener); |
| 206 | } | 211 | } | ... | ... |
| ... | @@ -276,8 +276,8 @@ public class GossipIntentStore | ... | @@ -276,8 +276,8 @@ public class GossipIntentStore |
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | @Override | 278 | @Override |
| 279 | - public boolean isMaster(Intent intent) { | 279 | + public boolean isMaster(Key intentKey) { |
| 280 | - return partitionService.isMine(intent.key()); | 280 | + return partitionService.isMine(intentKey); |
| 281 | } | 281 | } |
| 282 | 282 | ||
| 283 | private void notifyDelegateIfNotNull(IntentEvent event) { | 283 | private void notifyDelegateIfNotNull(IntentEvent event) { |
| ... | @@ -308,7 +308,7 @@ public class GossipIntentStore | ... | @@ -308,7 +308,7 @@ public class GossipIntentStore |
| 308 | // The pending intents map has been updated. If we are master for | 308 | // The pending intents map has been updated. If we are master for |
| 309 | // this intent's partition, notify the Manager that it should do | 309 | // this intent's partition, notify the Manager that it should do |
| 310 | // some work. | 310 | // some work. |
| 311 | - if (isMaster(event.value().intent())) { | 311 | + if (isMaster(event.value().intent().key())) { |
| 312 | if (delegate != null) { | 312 | if (delegate != null) { |
| 313 | delegate.process(copyData(event.value())); | 313 | delegate.process(copyData(event.value())); |
| 314 | } | 314 | } | ... | ... |
| ... | @@ -252,7 +252,7 @@ public class SimpleIntentStore | ... | @@ -252,7 +252,7 @@ public class SimpleIntentStore |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | @Override | 254 | @Override |
| 255 | - public boolean isMaster(Intent intent) { | 255 | + public boolean isMaster(Key intentKey) { |
| 256 | return true; | 256 | return true; |
| 257 | } | 257 | } |
| 258 | } | 258 | } | ... | ... |
| ... | @@ -124,9 +124,4 @@ public class SimpleIntentStore | ... | @@ -124,9 +124,4 @@ public class SimpleIntentStore |
| 124 | notifyDelegate(IntentEvent.getEvent(data)); | 124 | notifyDelegate(IntentEvent.getEvent(data)); |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | - | ||
| 128 | - @Override | ||
| 129 | - public boolean isMaster(Intent intent) { | ||
| 130 | - return true; | ||
| 131 | - } | ||
| 132 | } | 127 | } | ... | ... |
-
Please register or login to post a comment