Committed by
Brian O'Connor
Refactor: rename "ops" to "data"
Change-Id: I92fc471e545e880d90079923c47c405b29853ed2
Showing
1 changed file
with
18 additions
and
17 deletions
... | @@ -453,24 +453,24 @@ public class IntentManager | ... | @@ -453,24 +453,24 @@ public class IntentManager |
453 | private static final int TIMEOUT_PER_OP = 500; // ms | 453 | private static final int TIMEOUT_PER_OP = 500; // ms |
454 | protected static final int MAX_ATTEMPTS = 3; | 454 | protected static final int MAX_ATTEMPTS = 3; |
455 | 455 | ||
456 | - protected final Collection<IntentData> ops; | 456 | + protected final Collection<IntentData> data; |
457 | 457 | ||
458 | // future holding current FlowRuleBatch installation result | 458 | // future holding current FlowRuleBatch installation result |
459 | protected final long startTime = System.currentTimeMillis(); | 459 | protected final long startTime = System.currentTimeMillis(); |
460 | protected final long endTime; | 460 | protected final long endTime; |
461 | 461 | ||
462 | - private IntentBatchPreprocess(Collection<IntentData> ops, long endTime) { | 462 | + private IntentBatchPreprocess(Collection<IntentData> data, long endTime) { |
463 | - this.ops = checkNotNull(ops); | 463 | + this.data = checkNotNull(data); |
464 | this.endTime = endTime; | 464 | this.endTime = endTime; |
465 | } | 465 | } |
466 | 466 | ||
467 | - public IntentBatchPreprocess(Collection<IntentData> ops) { | 467 | + public IntentBatchPreprocess(Collection<IntentData> data) { |
468 | - this(ops, System.currentTimeMillis() + ops.size() * TIMEOUT_PER_OP); | 468 | + this(data, System.currentTimeMillis() + data.size() * TIMEOUT_PER_OP); |
469 | } | 469 | } |
470 | 470 | ||
471 | // FIXME compute reasonable timeouts | 471 | // FIXME compute reasonable timeouts |
472 | protected long calculateTimeoutLimit() { | 472 | protected long calculateTimeoutLimit() { |
473 | - return System.currentTimeMillis() + ops.size() * TIMEOUT_PER_OP; | 473 | + return System.currentTimeMillis() + data.size() * TIMEOUT_PER_OP; |
474 | } | 474 | } |
475 | 475 | ||
476 | @Override | 476 | @Override |
... | @@ -484,7 +484,7 @@ public class IntentManager | ... | @@ -484,7 +484,7 @@ public class IntentManager |
484 | // (we can also try to update these individually) | 484 | // (we can also try to update these individually) |
485 | 485 | ||
486 | 486 | ||
487 | - //new IntentBatchApplyFirst(ops, processIntentUpdates(updates), endTime, 0, null).run(); | 487 | + //new IntentBatchApplyFirst(data, processIntentUpdates(updates), endTime, 0, null).run(); |
488 | } catch (Exception e) { | 488 | } catch (Exception e) { |
489 | log.error("Error submitting batches:", e); | 489 | log.error("Error submitting batches:", e); |
490 | // FIXME incomplete Intents should be cleaned up | 490 | // FIXME incomplete Intents should be cleaned up |
... | @@ -494,12 +494,12 @@ public class IntentManager | ... | @@ -494,12 +494,12 @@ public class IntentManager |
494 | // TODO: maybe we should do more? | 494 | // TODO: maybe we should do more? |
495 | log.error("Walk the plank, matey..."); | 495 | log.error("Walk the plank, matey..."); |
496 | //FIXME | 496 | //FIXME |
497 | -// batchService.removeIntentOperations(ops); | 497 | +// batchService.removeIntentOperations(data); |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | private List<Future<IntentUpdate>> createIntentUpdates() { | 501 | private List<Future<IntentUpdate>> createIntentUpdates() { |
502 | - return ops.stream() | 502 | + return data.stream() |
503 | .map(IntentManager.this::submitIntentData) | 503 | .map(IntentManager.this::submitIntentData) |
504 | .collect(Collectors.toList()); | 504 | .collect(Collectors.toList()); |
505 | } | 505 | } |
... | @@ -550,7 +550,7 @@ public class IntentManager | ... | @@ -550,7 +550,7 @@ public class IntentManager |
550 | @Override | 550 | @Override |
551 | public void run() { | 551 | public void run() { |
552 | Future<CompletedBatchOperation> future = applyNextBatch(intentUpdates); | 552 | Future<CompletedBatchOperation> future = applyNextBatch(intentUpdates); |
553 | - new IntentBatchProcessFutures(ops, intentUpdates, endTime, installAttempt, future).run(); | 553 | + new IntentBatchProcessFutures(data, intentUpdates, endTime, installAttempt, future).run(); |
554 | } | 554 | } |
555 | 555 | ||
556 | /** | 556 | /** |
... | @@ -587,7 +587,7 @@ public class IntentManager | ... | @@ -587,7 +587,7 @@ public class IntentManager |
587 | log.error("Walk the plank, matey..."); | 587 | log.error("Walk the plank, matey..."); |
588 | future = null; | 588 | future = null; |
589 | //FIXME | 589 | //FIXME |
590 | -// batchService.removeIntentOperations(ops); | 590 | +// batchService.removeIntentOperations(data); |
591 | } | 591 | } |
592 | } | 592 | } |
593 | 593 | ||
... | @@ -607,13 +607,14 @@ public class IntentManager | ... | @@ -607,13 +607,14 @@ public class IntentManager |
607 | // there are no outstanding batches; we are done | 607 | // there are no outstanding batches; we are done |
608 | //FIXME | 608 | //FIXME |
609 | return; //? | 609 | return; //? |
610 | -// batchService.removeIntentOperations(ops); | 610 | +// batchService.removeIntentOperations(data); |
611 | } else if (System.currentTimeMillis() > endTime) { | 611 | } else if (System.currentTimeMillis() > endTime) { |
612 | // - cancel current FlowRuleBatch and resubmit again | 612 | // - cancel current FlowRuleBatch and resubmit again |
613 | retry(); | 613 | retry(); |
614 | } else { | 614 | } else { |
615 | // we are not done yet, yield the thread by resubmitting ourselves | 615 | // we are not done yet, yield the thread by resubmitting ourselves |
616 | - batchExecutor.submit(new IntentBatchProcessFutures(ops, intentUpdates, endTime, installAttempt, future)); | 616 | + batchExecutor.submit(new IntentBatchProcessFutures(data, intentUpdates, endTime, |
617 | + installAttempt, future)); | ||
617 | } | 618 | } |
618 | } catch (Exception e) { | 619 | } catch (Exception e) { |
619 | log.error("Error submitting batches:", e); | 620 | log.error("Error submitting batches:", e); |
... | @@ -632,10 +633,10 @@ public class IntentManager | ... | @@ -632,10 +633,10 @@ public class IntentManager |
632 | updateBatches(completed); | 633 | updateBatches(completed); |
633 | return applyNextBatch(intentUpdates); | 634 | return applyNextBatch(intentUpdates); |
634 | } catch (TimeoutException | InterruptedException te) { | 635 | } catch (TimeoutException | InterruptedException te) { |
635 | - log.trace("Installation of intents are still pending: {}", ops); | 636 | + log.trace("Installation of intents are still pending: {}", data); |
636 | return future; | 637 | return future; |
637 | } catch (ExecutionException e) { | 638 | } catch (ExecutionException e) { |
638 | - log.warn("Execution of batch failed: {}", ops, e); | 639 | + log.warn("Execution of batch failed: {}", data, e); |
639 | abandonShip(); | 640 | abandonShip(); |
640 | return future; | 641 | return future; |
641 | } | 642 | } |
... | @@ -673,7 +674,7 @@ public class IntentManager | ... | @@ -673,7 +674,7 @@ public class IntentManager |
673 | long timeLimit = calculateTimeoutLimit(); | 674 | long timeLimit = calculateTimeoutLimit(); |
674 | int attempts = installAttempt + 1; | 675 | int attempts = installAttempt + 1; |
675 | if (attempts == MAX_ATTEMPTS) { | 676 | if (attempts == MAX_ATTEMPTS) { |
676 | - log.warn("Install request timed out: {}", ops); | 677 | + log.warn("Install request timed out: {}", data); |
677 | for (CompletedIntentUpdate update : intentUpdates) { | 678 | for (CompletedIntentUpdate update : intentUpdates) { |
678 | update.batchFailed(); | 679 | update.batchFailed(); |
679 | } | 680 | } |
... | @@ -682,7 +683,7 @@ public class IntentManager | ... | @@ -682,7 +683,7 @@ public class IntentManager |
682 | return; | 683 | return; |
683 | } | 684 | } |
684 | Future<CompletedBatchOperation> future = applyNextBatch(intentUpdates); | 685 | Future<CompletedBatchOperation> future = applyNextBatch(intentUpdates); |
685 | - batchExecutor.submit(new IntentBatchProcessFutures(ops, intentUpdates, timeLimit, attempts, future)); | 686 | + batchExecutor.submit(new IntentBatchProcessFutures(data, intentUpdates, timeLimit, attempts, future)); |
686 | } else { | 687 | } else { |
687 | log.error("Cancelling FlowRuleBatch failed."); | 688 | log.error("Cancelling FlowRuleBatch failed."); |
688 | abandonShip(); | 689 | abandonShip(); | ... | ... |
-
Please register or login to post a comment