Committed by
Ray Milkey
Remove unused IntentStore write APIs.
All write operations now come through the batchWrite API. Change-Id: I982c5f785bf108dc2c9716db5ed744882d88aa55
Showing
5 changed files
with
4 additions
and
247 deletions
| ... | @@ -56,23 +56,6 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { | ... | @@ -56,23 +56,6 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { |
| 56 | IntentState getIntentState(IntentId intentId); | 56 | IntentState getIntentState(IntentId intentId); |
| 57 | 57 | ||
| 58 | /** | 58 | /** |
| 59 | - * Sets the state of the specified intent to the new state. | ||
| 60 | - * | ||
| 61 | - * @param intent intent whose state is to be changed | ||
| 62 | - * @param newState new state | ||
| 63 | - */ | ||
| 64 | - void setState(Intent intent, IntentState newState); | ||
| 65 | - | ||
| 66 | - /** | ||
| 67 | - * Sets the installable intents which resulted from compilation of the | ||
| 68 | - * specified original intent. | ||
| 69 | - * | ||
| 70 | - * @param intentId original intent identifier | ||
| 71 | - * @param installableIntents compiled installable intents | ||
| 72 | - */ | ||
| 73 | - void setInstallableIntents(IntentId intentId, List<Intent> installableIntents); | ||
| 74 | - | ||
| 75 | - /** | ||
| 76 | * Returns the list of the installable events associated with the specified | 59 | * Returns the list of the installable events associated with the specified |
| 77 | * original intent. | 60 | * original intent. |
| 78 | * | 61 | * |
| ... | @@ -82,14 +65,6 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { | ... | @@ -82,14 +65,6 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { |
| 82 | List<Intent> getInstallableIntents(IntentId intentId); | 65 | List<Intent> getInstallableIntents(IntentId intentId); |
| 83 | 66 | ||
| 84 | /** | 67 | /** |
| 85 | - * Removes any installable intents which resulted from compilation of the | ||
| 86 | - * specified original intent. | ||
| 87 | - * | ||
| 88 | - * @param intentId original intent identifier | ||
| 89 | - */ | ||
| 90 | - void removeInstalledIntents(IntentId intentId); | ||
| 91 | - | ||
| 92 | - /** | ||
| 93 | * Execute writes in a batch. | 68 | * Execute writes in a batch. |
| 94 | * If the specified BatchWrite is empty, write will not be executed. | 69 | * If the specified BatchWrite is empty, write will not be executed. |
| 95 | * | 70 | * | ... | ... |
| ... | @@ -116,10 +116,7 @@ public class DistributedIntentStore | ... | @@ -116,10 +116,7 @@ public class DistributedIntentStore |
| 116 | // TODO make this configurable | 116 | // TODO make this configurable |
| 117 | private boolean onlyLogTransitionError = true; | 117 | private boolean onlyLogTransitionError = true; |
| 118 | 118 | ||
| 119 | - private Timer setInstallableIntentsTimer; | ||
| 120 | private Timer getInstallableIntentsTimer; | 119 | private Timer getInstallableIntentsTimer; |
| 121 | - private Timer removeInstalledIntentsTimer; | ||
| 122 | - private Timer setStateTimer; | ||
| 123 | private Timer getIntentCountTimer; | 120 | private Timer getIntentCountTimer; |
| 124 | private Timer getIntentsTimer; | 121 | private Timer getIntentsTimer; |
| 125 | private Timer getIntentTimer; | 122 | private Timer getIntentTimer; |
| ... | @@ -132,10 +129,7 @@ public class DistributedIntentStore | ... | @@ -132,10 +129,7 @@ public class DistributedIntentStore |
| 132 | 129 | ||
| 133 | @Activate | 130 | @Activate |
| 134 | public void activate() { | 131 | public void activate() { |
| 135 | - setInstallableIntentsTimer = createResponseTimer("setInstallableIntents"); | ||
| 136 | getInstallableIntentsTimer = createResponseTimer("getInstallableIntents"); | 132 | getInstallableIntentsTimer = createResponseTimer("getInstallableIntents"); |
| 137 | - removeInstalledIntentsTimer = createResponseTimer("removeInstalledIntents"); | ||
| 138 | - setStateTimer = createResponseTimer("setState"); | ||
| 139 | getIntentCountTimer = createResponseTimer("getIntentCount"); | 133 | getIntentCountTimer = createResponseTimer("getIntentCount"); |
| 140 | getIntentsTimer = createResponseTimer("getIntents"); | 134 | getIntentsTimer = createResponseTimer("getIntents"); |
| 141 | getIntentTimer = createResponseTimer("getIntent"); | 135 | getIntentTimer = createResponseTimer("getIntent"); |
| ... | @@ -242,94 +236,6 @@ public class DistributedIntentStore | ... | @@ -242,94 +236,6 @@ public class DistributedIntentStore |
| 242 | } | 236 | } |
| 243 | 237 | ||
| 244 | @Override | 238 | @Override |
| 245 | - public void setState(Intent intent, IntentState state) { | ||
| 246 | - Context timer = startTimer(setStateTimer); | ||
| 247 | - try { | ||
| 248 | - final IntentId id = intent.id(); | ||
| 249 | - IntentEvent.Type evtType = null; | ||
| 250 | - final IntentState prevParking; | ||
| 251 | - boolean transitionedToParking = true; | ||
| 252 | - boolean updated; | ||
| 253 | - | ||
| 254 | - // parking state transition | ||
| 255 | - switch (state) { | ||
| 256 | - case INSTALL_REQ: | ||
| 257 | - prevParking = states.get(id); | ||
| 258 | - if (prevParking == null) { | ||
| 259 | - updated = states.putIfAbsent(id, INSTALL_REQ); | ||
| 260 | - verify(updated, "Conditional replace %s => %s failed", prevParking, INSTALL_REQ); | ||
| 261 | - } else { | ||
| 262 | - verify(prevParking == WITHDRAWN, | ||
| 263 | - "Illegal state transition attempted from %s to INSTALL_REQ", | ||
| 264 | - prevParking); | ||
| 265 | - updated = states.replace(id, prevParking, INSTALL_REQ); | ||
| 266 | - verify(updated, "Conditional replace %s => %s failed", prevParking, INSTALL_REQ); | ||
| 267 | - } | ||
| 268 | - evtType = IntentEvent.Type.INSTALL_REQ; | ||
| 269 | - break; | ||
| 270 | - | ||
| 271 | - case INSTALLED: | ||
| 272 | - prevParking = states.get(id); | ||
| 273 | - verify(PRE_INSTALLED.contains(prevParking), | ||
| 274 | - "Illegal state transition attempted from %s to INSTALLED", | ||
| 275 | - prevParking); | ||
| 276 | - updated = states.replace(id, prevParking, INSTALLED); | ||
| 277 | - verify(updated, "Conditional replace %s => %s failed", prevParking, INSTALLED); | ||
| 278 | - evtType = IntentEvent.Type.INSTALLED; | ||
| 279 | - break; | ||
| 280 | - | ||
| 281 | - case FAILED: | ||
| 282 | - prevParking = states.get(id); | ||
| 283 | - updated = states.replace(id, prevParking, FAILED); | ||
| 284 | - verify(updated, "Conditional replace %s => %s failed", prevParking, FAILED); | ||
| 285 | - evtType = IntentEvent.Type.FAILED; | ||
| 286 | - break; | ||
| 287 | - | ||
| 288 | - case WITHDRAWN: | ||
| 289 | - prevParking = states.get(id); | ||
| 290 | - verify(PRE_WITHDRAWN.contains(prevParking), | ||
| 291 | - "Illegal state transition attempted from %s to WITHDRAWN", | ||
| 292 | - prevParking); | ||
| 293 | - updated = states.replace(id, prevParking, WITHDRAWN); | ||
| 294 | - verify(updated, "Conditional replace %s => %s failed", prevParking, WITHDRAWN); | ||
| 295 | - evtType = IntentEvent.Type.WITHDRAWN; | ||
| 296 | - break; | ||
| 297 | - | ||
| 298 | - default: | ||
| 299 | - transitionedToParking = false; | ||
| 300 | - prevParking = null; | ||
| 301 | - break; | ||
| 302 | - } | ||
| 303 | - if (transitionedToParking) { | ||
| 304 | - log.debug("Parking State change: {} {}=>{}", id, prevParking, state); | ||
| 305 | - // remove instance local state | ||
| 306 | - transientStates.remove(id); | ||
| 307 | - } else { | ||
| 308 | - // Update instance local state, which includes non-parking state transition | ||
| 309 | - final IntentState prevTransient = transientStates.put(id, state); | ||
| 310 | - log.debug("Transient State change: {} {}=>{}", id, prevTransient, state); | ||
| 311 | - } | ||
| 312 | - | ||
| 313 | - if (evtType != null) { | ||
| 314 | - notifyDelegate(new IntentEvent(evtType, intent)); | ||
| 315 | - } | ||
| 316 | - return; | ||
| 317 | - } finally { | ||
| 318 | - stopTimer(timer); | ||
| 319 | - } | ||
| 320 | - } | ||
| 321 | - | ||
| 322 | - @Override | ||
| 323 | - public void setInstallableIntents(IntentId intentId, List<Intent> result) { | ||
| 324 | - Context timer = startTimer(setInstallableIntentsTimer); | ||
| 325 | - try { | ||
| 326 | - installable.put(intentId, result); | ||
| 327 | - } finally { | ||
| 328 | - stopTimer(timer); | ||
| 329 | - } | ||
| 330 | - } | ||
| 331 | - | ||
| 332 | - @Override | ||
| 333 | public List<Intent> getInstallableIntents(IntentId intentId) { | 239 | public List<Intent> getInstallableIntents(IntentId intentId) { |
| 334 | Context timer = startTimer(getInstallableIntentsTimer); | 240 | Context timer = startTimer(getInstallableIntentsTimer); |
| 335 | try { | 241 | try { |
| ... | @@ -339,16 +245,6 @@ public class DistributedIntentStore | ... | @@ -339,16 +245,6 @@ public class DistributedIntentStore |
| 339 | } | 245 | } |
| 340 | } | 246 | } |
| 341 | 247 | ||
| 342 | - @Override | ||
| 343 | - public void removeInstalledIntents(IntentId intentId) { | ||
| 344 | - Context timer = startTimer(removeInstalledIntentsTimer); | ||
| 345 | - try { | ||
| 346 | - installable.remove(intentId); | ||
| 347 | - } finally { | ||
| 348 | - stopTimer(timer); | ||
| 349 | - } | ||
| 350 | - } | ||
| 351 | - | ||
| 352 | protected String strIntentId(IntentId key) { | 248 | protected String strIntentId(IntentId key) { |
| 353 | return keyCache.getUnchecked(key); | 249 | return keyCache.getUnchecked(key); |
| 354 | } | 250 | } | ... | ... |
| ... | @@ -186,11 +186,6 @@ public class GossipIntentStore | ... | @@ -186,11 +186,6 @@ public class GossipIntentStore |
| 186 | return null; | 186 | return null; |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | - @Override | ||
| 190 | - public void setState(Intent intent, IntentState newState) { | ||
| 191 | - // TODO implement | ||
| 192 | - } | ||
| 193 | - | ||
| 194 | private IntentEvent setStateInternal(IntentId intentId, IntentState newState, Timestamp timestamp) { | 189 | private IntentEvent setStateInternal(IntentId intentId, IntentState newState, Timestamp timestamp) { |
| 195 | switch (newState) { | 190 | switch (newState) { |
| 196 | case WITHDRAW_REQ: | 191 | case WITHDRAW_REQ: |
| ... | @@ -225,12 +220,6 @@ public class GossipIntentStore | ... | @@ -225,12 +220,6 @@ public class GossipIntentStore |
| 225 | } | 220 | } |
| 226 | } | 221 | } |
| 227 | 222 | ||
| 228 | - @Override | ||
| 229 | - public void setInstallableIntents(IntentId intentId, | ||
| 230 | - List<Intent> installableIntents) { | ||
| 231 | - // TODO implement | ||
| 232 | - } | ||
| 233 | - | ||
| 234 | private void setInstallableIntentsInternal(IntentId intentId, | 223 | private void setInstallableIntentsInternal(IntentId intentId, |
| 235 | List<Intent> installableIntents, | 224 | List<Intent> installableIntents, |
| 236 | Timestamp timestamp) { | 225 | Timestamp timestamp) { |
| ... | @@ -253,11 +242,6 @@ public class GossipIntentStore | ... | @@ -253,11 +242,6 @@ public class GossipIntentStore |
| 253 | } | 242 | } |
| 254 | 243 | ||
| 255 | @Override | 244 | @Override |
| 256 | - public void removeInstalledIntents(IntentId intentId) { | ||
| 257 | - // TODO implement | ||
| 258 | - } | ||
| 259 | - | ||
| 260 | - @Override | ||
| 261 | public List<BatchWrite.Operation> batchWrite(BatchWrite batch) { | 245 | public List<BatchWrite.Operation> batchWrite(BatchWrite batch) { |
| 262 | 246 | ||
| 263 | List<IntentEvent> events = Lists.newArrayList(); | 247 | List<IntentEvent> events = Lists.newArrayList(); | ... | ... |
| ... | @@ -101,10 +101,7 @@ public class HazelcastIntentStore | ... | @@ -101,10 +101,7 @@ public class HazelcastIntentStore |
| 101 | 101 | ||
| 102 | private boolean onlyLogTransitionError = true; | 102 | private boolean onlyLogTransitionError = true; |
| 103 | 103 | ||
| 104 | - private Timer setInstallableIntentsTimer; | ||
| 105 | private Timer getInstallableIntentsTimer; | 104 | private Timer getInstallableIntentsTimer; |
| 106 | - private Timer removeInstalledIntentsTimer; | ||
| 107 | - private Timer setStateTimer; | ||
| 108 | private Timer getIntentCountTimer; | 105 | private Timer getIntentCountTimer; |
| 109 | private Timer getIntentsTimer; | 106 | private Timer getIntentsTimer; |
| 110 | private Timer getIntentTimer; | 107 | private Timer getIntentTimer; |
| ... | @@ -128,10 +125,7 @@ public class HazelcastIntentStore | ... | @@ -128,10 +125,7 @@ public class HazelcastIntentStore |
| 128 | public void activate() { | 125 | public void activate() { |
| 129 | localIntents = new ConcurrentHashMap<>(); | 126 | localIntents = new ConcurrentHashMap<>(); |
| 130 | 127 | ||
| 131 | - setInstallableIntentsTimer = createResponseTimer("setInstallableIntents"); | ||
| 132 | getInstallableIntentsTimer = createResponseTimer("getInstallableIntents"); | 128 | getInstallableIntentsTimer = createResponseTimer("getInstallableIntents"); |
| 133 | - removeInstalledIntentsTimer = createResponseTimer("removeInstalledIntents"); | ||
| 134 | - setStateTimer = createResponseTimer("setState"); | ||
| 135 | getIntentCountTimer = createResponseTimer("getIntentCount"); | 129 | getIntentCountTimer = createResponseTimer("getIntentCount"); |
| 136 | getIntentsTimer = createResponseTimer("getIntents"); | 130 | getIntentsTimer = createResponseTimer("getIntents"); |
| 137 | getIntentTimer = createResponseTimer("getIntent"); | 131 | getIntentTimer = createResponseTimer("getIntent"); |
| ... | @@ -257,86 +251,6 @@ public class HazelcastIntentStore | ... | @@ -257,86 +251,6 @@ public class HazelcastIntentStore |
| 257 | } | 251 | } |
| 258 | 252 | ||
| 259 | @Override | 253 | @Override |
| 260 | - public void setState(Intent intent, IntentState state) { | ||
| 261 | - Context timer = startTimer(setStateTimer); | ||
| 262 | - try { | ||
| 263 | - final IntentId id = intent.id(); | ||
| 264 | - IntentEvent.Type type = null; | ||
| 265 | - final IntentState prevParking; | ||
| 266 | - boolean transientStateChangeOnly = false; | ||
| 267 | - | ||
| 268 | - // parking state transition | ||
| 269 | - switch (state) { | ||
| 270 | - case INSTALL_REQ: | ||
| 271 | - prevParking = states.get(id); | ||
| 272 | - if (prevParking == null) { | ||
| 273 | - IntentState existing = states.putIfAbsent(id, INSTALL_REQ); | ||
| 274 | - verify(existing == null, "Conditional replace %s => %s failed", prevParking, INSTALL_REQ); | ||
| 275 | - } else { | ||
| 276 | - verify(PRE_INSTALLED.contains(prevParking), | ||
| 277 | - "Illegal state transition attempted from %s to INSTALL_REQ", | ||
| 278 | - prevParking); | ||
| 279 | - boolean updated = states.replace(id, prevParking, INSTALL_REQ); | ||
| 280 | - verify(updated, "Conditional replace %s => %s failed", prevParking, INSTALL_REQ); | ||
| 281 | - } | ||
| 282 | - type = IntentEvent.Type.INSTALL_REQ; | ||
| 283 | - break; | ||
| 284 | - case INSTALLED: | ||
| 285 | - prevParking = states.replace(id, INSTALLED); | ||
| 286 | - verify(prevParking == INSTALL_REQ, | ||
| 287 | - "Illegal state transition attempted from %s to INSTALLED", | ||
| 288 | - prevParking); | ||
| 289 | - type = IntentEvent.Type.INSTALLED; | ||
| 290 | - break; | ||
| 291 | - case FAILED: | ||
| 292 | - prevParking = states.replace(id, FAILED); | ||
| 293 | - type = IntentEvent.Type.FAILED; | ||
| 294 | - break; | ||
| 295 | - case WITHDRAW_REQ: | ||
| 296 | - prevParking = states.replace(id, WITHDRAW_REQ); | ||
| 297 | - verify(PRE_WITHDRAWN.contains(prevParking), | ||
| 298 | - "Illegal state transition attempted from %s to WITHDRAW_REQ", | ||
| 299 | - prevParking); | ||
| 300 | - type = IntentEvent.Type.WITHDRAW_REQ; | ||
| 301 | - break; | ||
| 302 | - case WITHDRAWN: | ||
| 303 | - prevParking = states.replace(id, WITHDRAWN); | ||
| 304 | - verify(prevParking == WITHDRAW_REQ, | ||
| 305 | - "Illegal state transition attempted from %s to WITHDRAWN", | ||
| 306 | - prevParking); | ||
| 307 | - type = IntentEvent.Type.WITHDRAWN; | ||
| 308 | - break; | ||
| 309 | - default: | ||
| 310 | - transientStateChangeOnly = true; | ||
| 311 | - prevParking = null; | ||
| 312 | - break; | ||
| 313 | - } | ||
| 314 | - if (!transientStateChangeOnly) { | ||
| 315 | - log.debug("Parking State change: {} {}=>{}", id, prevParking, state); | ||
| 316 | - } | ||
| 317 | - // Update instance local state, which includes non-parking state transition | ||
| 318 | - final IntentState prevTransient = transientStates.put(id, state); | ||
| 319 | - log.debug("Transient State change: {} {}=>{}", id, prevTransient, state); | ||
| 320 | - | ||
| 321 | - if (type != null) { | ||
| 322 | - notifyDelegate(new IntentEvent(type, intent)); | ||
| 323 | - } | ||
| 324 | - } finally { | ||
| 325 | - stopTimer(timer); | ||
| 326 | - } | ||
| 327 | - } | ||
| 328 | - | ||
| 329 | - @Override | ||
| 330 | - public void setInstallableIntents(IntentId intentId, List<Intent> result) { | ||
| 331 | - Context timer = startTimer(setInstallableIntentsTimer); | ||
| 332 | - try { | ||
| 333 | - installable.put(intentId, result); | ||
| 334 | - } finally { | ||
| 335 | - stopTimer(timer); | ||
| 336 | - } | ||
| 337 | - } | ||
| 338 | - | ||
| 339 | - @Override | ||
| 340 | public List<Intent> getInstallableIntents(IntentId intentId) { | 254 | public List<Intent> getInstallableIntents(IntentId intentId) { |
| 341 | Context timer = startTimer(getInstallableIntentsTimer); | 255 | Context timer = startTimer(getInstallableIntentsTimer); |
| 342 | try { | 256 | try { |
| ... | @@ -347,16 +261,6 @@ public class HazelcastIntentStore | ... | @@ -347,16 +261,6 @@ public class HazelcastIntentStore |
| 347 | } | 261 | } |
| 348 | 262 | ||
| 349 | @Override | 263 | @Override |
| 350 | - public void removeInstalledIntents(IntentId intentId) { | ||
| 351 | - Context timer = startTimer(removeInstalledIntentsTimer); | ||
| 352 | - try { | ||
| 353 | - installable.remove(intentId); | ||
| 354 | - } finally { | ||
| 355 | - stopTimer(timer); | ||
| 356 | - } | ||
| 357 | - } | ||
| 358 | - | ||
| 359 | - @Override | ||
| 360 | public List<Operation> batchWrite(BatchWrite batch) { | 264 | public List<Operation> batchWrite(BatchWrite batch) { |
| 361 | if (batch.isEmpty()) { | 265 | if (batch.isEmpty()) { |
| 362 | return Collections.emptyList(); | 266 | return Collections.emptyList(); | ... | ... |
| ... | @@ -101,8 +101,7 @@ public class SimpleIntentStore | ... | @@ -101,8 +101,7 @@ public class SimpleIntentStore |
| 101 | return states.get(id); | 101 | return states.get(id); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | - @Override | 104 | + private void setState(Intent intent, IntentState state) { |
| 105 | - public void setState(Intent intent, IntentState state) { | ||
| 106 | IntentId id = intent.id(); | 105 | IntentId id = intent.id(); |
| 107 | states.put(id, state); | 106 | states.put(id, state); |
| 108 | IntentEvent.Type type = null; | 107 | IntentEvent.Type type = null; |
| ... | @@ -131,8 +130,7 @@ public class SimpleIntentStore | ... | @@ -131,8 +130,7 @@ public class SimpleIntentStore |
| 131 | } | 130 | } |
| 132 | } | 131 | } |
| 133 | 132 | ||
| 134 | - @Override | 133 | + private void setInstallableIntents(IntentId intentId, List<Intent> result) { |
| 135 | - public void setInstallableIntents(IntentId intentId, List<Intent> result) { | ||
| 136 | installable.put(intentId, result); | 134 | installable.put(intentId, result); |
| 137 | } | 135 | } |
| 138 | 136 | ||
| ... | @@ -141,10 +139,10 @@ public class SimpleIntentStore | ... | @@ -141,10 +139,10 @@ public class SimpleIntentStore |
| 141 | return installable.get(intentId); | 139 | return installable.get(intentId); |
| 142 | } | 140 | } |
| 143 | 141 | ||
| 144 | - @Override | 142 | + private void removeInstalledIntents(IntentId intentId) { |
| 145 | - public void removeInstalledIntents(IntentId intentId) { | ||
| 146 | installable.remove(intentId); | 143 | installable.remove(intentId); |
| 147 | } | 144 | } |
| 145 | + | ||
| 148 | /** | 146 | /** |
| 149 | * Execute writes in a batch. | 147 | * Execute writes in a batch. |
| 150 | * | 148 | * | ... | ... |
-
Please register or login to post a comment