Skip to content

Commit

Permalink
Reset error timout when starting a new task update
Browse files Browse the repository at this point in the history
  • Loading branch information
dain committed Sep 25, 2015
1 parent 3ce9e7f commit 2ac2286
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@
import static io.airlift.http.client.Request.Builder.preparePost;
import static io.airlift.http.client.StatusResponseHandler.createStatusResponseHandler;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.Objects.requireNonNull;

public class HttpRemoteTask
implements RemoteTask
Expand Down Expand Up @@ -419,6 +419,8 @@ private synchronized void scheduleUpdate()
.setBodyGenerator(jsonBodyGenerator(taskUpdateRequestCodec, updateRequest))
.build();

updateErrorTracker.startRequest();

ListenableFuture<JsonResponse<TaskInfo>> future = httpClient.executeAsync(request, createFullJsonResponseHandler(taskInfoCodec));
currentRequest = future;
currentRequestStartNanos = System.nanoTime();
Expand Down Expand Up @@ -855,6 +857,15 @@ public ListenableFuture<?> acquireRequestPermit()
return futureTask;
}

public void startRequest()
{
// before scheduling a new request clear the error timer
// we consider a request to be "new" if there are no current failures
if (backoff.getFailureCount() == 0) {
requestSucceeded();
}
}

public void requestSucceeded()
{
backoff.success();
Expand Down

0 comments on commit 2ac2286

Please sign in to comment.