Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.

Commit dd42158

Browse files
committed
reseting load balancer
1 parent a7786d8 commit dd42158

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

proteus-client/src/main/java/io/netifi/proteus/rsocket/WeightedReconnectingRSocket.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,7 @@ public Mono<Void> metadataPush(Payload payload) {
442442

443443
@Override
444444
public synchronized double predictedLatency() {
445-
return interArrivalTime.value();
446-
/*long now = Clock.now();
445+
long now = Clock.now();
447446
long elapsed = Math.max(now - stamp, 1L);
448447

449448
double weight;
@@ -473,7 +472,7 @@ public synchronized double predictedLatency() {
473472
}
474473
}
475474

476-
return weight;*/
475+
return weight;
477476
}
478477

479478
private synchronized long instantaneous(long now) {
@@ -482,19 +481,24 @@ private synchronized long instantaneous(long now) {
482481

483482
private synchronized long start() {
484483
long now = Clock.now();
484+
interArrivalTime.insert(now - stamp);
485+
duration += Math.max(0, now - stamp0) * pending;
485486
pending += 1;
486487
stamp = now;
488+
stamp0 = now;
487489
return now;
488490
}
489491

490492
private synchronized long stop(long timestamp) {
491493
long now = Clock.now();
494+
duration += Math.max(0, now - stamp0) * pending - (now - timestamp);
492495
pending -= 1;
496+
stamp0 = now;
493497
return now;
494498
}
495499

496500
private synchronized void record(double roundTripTime) {
497-
interArrivalTime.insert(roundTripTime);
501+
median.insert(roundTripTime);
498502
lowerQuantile.insert(roundTripTime);
499503
higherQuantile.insert(roundTripTime);
500504
}
@@ -543,11 +547,6 @@ public long lastTimeUsedMillis() {
543547
public double availability() {
544548
if (Clock.now() - stamp > tau) {
545549
recordError(1.0);
546-
double m = interArrivalTime.value();
547-
if (m > 0) {
548-
m *= 0.5;
549-
record(m);
550-
}
551550
}
552551
return availability * errorPercentage.value();
553552
}
@@ -578,7 +577,7 @@ void resetMono() {
578577
}
579578

580579
if (old != null && !old.isTerminated()) {
581-
old.onError(new InterruptedException("reset while waiting for new connection"));
580+
old.onError(new InterruptedException("reset will waiting for new connection"));
582581
}
583582
}
584583
}

0 commit comments

Comments
 (0)