@Test public void noUnexpiredRequestsTest() throws InterruptedException { primeTracker(localColoTracker, MIN_DATA_POINTS_REQUIRED, LOCAL_COLO_LATENCY_RANGE); primeTracker(crossColoTracker, MIN_DATA_POINTS_REQUIRED, CROSS_COLO_LATENCY_RANGE); double localColoCutoff = localColoTracker.getSnapshot().getValue(QUANTILE); OperationTracker ot = getOperationTracker(createRouterConfig(false, 1, 1, 6, null, true), mockPartition); sendRequests(ot, 1); time.sleep((long) localColoCutoff + 2); sendRequests(ot, 1); ot.onResponse(partitionAndInflightReplicas.get(mockPartition).pollLast(), TrackedRequestFinalState.FAILURE); assertFalse("Operation should not be done", ot.isDone()); sendRequests(ot, 1); ot.onResponse(partitionAndInflightReplicas.get(mockPartition).pollLast(), TrackedRequestFinalState.SUCCESS); assertTrue("Operation should have succeeded", ot.hasSucceeded()); assertEquals("Past due counter is inconsistent", 1, pastDueCounter.getCount()); }
@Override public void onResponse(ReplicaId replicaId, TrackedRequestFinalState trackedRequestFinalState) { super.onResponse(replicaId, trackedRequestFinalState); long elapsedTime; if (unexpiredRequestSendTimes.containsKey(replicaId)) { elapsedTime = time.milliseconds() - unexpiredRequestSendTimes.remove(replicaId).getSecond(); } else { elapsedTime = time.milliseconds() - expiredRequestSendTimes.remove(replicaId); } if (trackedRequestFinalState != TrackedRequestFinalState.TIMED_OUT || !routerConfig.routerOperationTrackerExcludeTimeoutEnabled) { getLatencyHistogram(replicaId).update(elapsedTime); if (routerConfig.routerOperationTrackerMetricScope != OperationTrackerScope.Datacenter) { Histogram histogram = replicaId.getDataNodeId().getDatacenterName().equals(datacenterName) ? localDcHistogram : crossDcHistogram; histogram.update(elapsedTime); } } }
AdaptiveOperationTracker extends SimpleOperationTracker { @Override public void onResponse(ReplicaId replicaId, TrackedRequestFinalState trackedRequestFinalState) { super.onResponse(replicaId, trackedRequestFinalState); long elapsedTime; if (unexpiredRequestSendTimes.containsKey(replicaId)) { elapsedTime = time.milliseconds() - unexpiredRequestSendTimes.remove(replicaId).getSecond(); } else { elapsedTime = time.milliseconds() - expiredRequestSendTimes.remove(replicaId); } if (trackedRequestFinalState != TrackedRequestFinalState.TIMED_OUT || !routerConfig.routerOperationTrackerExcludeTimeoutEnabled) { getLatencyHistogram(replicaId).update(elapsedTime); if (routerConfig.routerOperationTrackerMetricScope != OperationTrackerScope.Datacenter) { Histogram histogram = replicaId.getDataNodeId().getDatacenterName().equals(datacenterName) ? localDcHistogram : crossDcHistogram; histogram.update(elapsedTime); } } } }
AdaptiveOperationTracker extends SimpleOperationTracker { @Override public void onResponse(ReplicaId replicaId, TrackedRequestFinalState trackedRequestFinalState) { super.onResponse(replicaId, trackedRequestFinalState); long elapsedTime; if (unexpiredRequestSendTimes.containsKey(replicaId)) { elapsedTime = time.milliseconds() - unexpiredRequestSendTimes.remove(replicaId).getSecond(); } else { elapsedTime = time.milliseconds() - expiredRequestSendTimes.remove(replicaId); } if (trackedRequestFinalState != TrackedRequestFinalState.TIMED_OUT || !routerConfig.routerOperationTrackerExcludeTimeoutEnabled) { getLatencyHistogram(replicaId).update(elapsedTime); if (routerConfig.routerOperationTrackerMetricScope != OperationTrackerScope.Datacenter) { Histogram histogram = replicaId.getDataNodeId().getDatacenterName().equals(datacenterName) ? localDcHistogram : crossDcHistogram; histogram.update(elapsedTime); } } } AdaptiveOperationTracker(RouterConfig routerConfig, NonBlockingRouterMetrics routerMetrics,
      RouterOperation routerOperation, PartitionId partitionId, String originatingDcName, Time time); }
AdaptiveOperationTracker extends SimpleOperationTracker { @Override public void onResponse(ReplicaId replicaId, TrackedRequestFinalState trackedRequestFinalState) { super.onResponse(replicaId, trackedRequestFinalState); long elapsedTime; if (unexpiredRequestSendTimes.containsKey(replicaId)) { elapsedTime = time.milliseconds() - unexpiredRequestSendTimes.remove(replicaId).getSecond(); } else { elapsedTime = time.milliseconds() - expiredRequestSendTimes.remove(replicaId); } if (trackedRequestFinalState != TrackedRequestFinalState.TIMED_OUT || !routerConfig.routerOperationTrackerExcludeTimeoutEnabled) { getLatencyHistogram(replicaId).update(elapsedTime); if (routerConfig.routerOperationTrackerMetricScope != OperationTrackerScope.Datacenter) { Histogram histogram = replicaId.getDataNodeId().getDatacenterName().equals(datacenterName) ? localDcHistogram : crossDcHistogram; histogram.update(elapsedTime); } } } AdaptiveOperationTracker(RouterConfig routerConfig, NonBlockingRouterMetrics routerMetrics,
      RouterOperation routerOperation, PartitionId partitionId, String originatingDcName, Time time); @Override void onResponse(ReplicaId replicaId, TrackedRequestFinalState trackedRequestFinalState); @Override Iterator<ReplicaId> getReplicaIterator(); }
AdaptiveOperationTracker extends SimpleOperationTracker { @Override public void onResponse(ReplicaId replicaId, TrackedRequestFinalState trackedRequestFinalState) { super.onResponse(replicaId, trackedRequestFinalState); long elapsedTime; if (unexpiredRequestSendTimes.containsKey(replicaId)) { elapsedTime = time.milliseconds() - unexpiredRequestSendTimes.remove(replicaId).getSecond(); } else { elapsedTime = time.milliseconds() - expiredRequestSendTimes.remove(replicaId); } if (trackedRequestFinalState != TrackedRequestFinalState.TIMED_OUT || !routerConfig.routerOperationTrackerExcludeTimeoutEnabled) { getLatencyHistogram(replicaId).update(elapsedTime); if (routerConfig.routerOperationTrackerMetricScope != OperationTrackerScope.Datacenter) { Histogram histogram = replicaId.getDataNodeId().getDatacenterName().equals(datacenterName) ? localDcHistogram : crossDcHistogram; histogram.update(elapsedTime); } } } AdaptiveOperationTracker(RouterConfig routerConfig, NonBlockingRouterMetrics routerMetrics,
      RouterOperation routerOperation, PartitionId partitionId, String originatingDcName, Time time); @Override void onResponse(ReplicaId replicaId, TrackedRequestFinalState trackedRequestFinalState); @Override Iterator<ReplicaId> getReplicaIterator();  }