Skip to content

Commit

Permalink
Add attempted addresses to RetriesFailedException
Browse files Browse the repository at this point in the history
  • Loading branch information
viczhang861 authored and arhimondr committed Nov 16, 2019
1 parent 4b5830e commit d6a6da5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ private synchronized void fail(String reason)
invocationAttempts,
succinctNanos(ticker.read() - startTime),
failedConnections,
overloadedRejects);
overloadedRejects,
attemptedAddresses);

// attach message exception to the exception thrown to caller
if (cause instanceof DriftApplicationException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
*/
package com.facebook.drift.client;

import com.facebook.drift.transport.client.Address;
import com.google.common.collect.ImmutableSet;
import io.airlift.units.Duration;

import java.util.Set;

import static java.lang.String.format;
import static java.util.Objects.requireNonNull;

Expand All @@ -27,20 +31,29 @@ public class RetriesFailedException
private final int failedConnections;
private final Duration retryTime;
private final int overloadedRejects;
private final Set<? extends Address> attemptedAddresses;

public RetriesFailedException(String reason, int invocationAttempts, Duration retryTime, int failedConnections, int overloadedRejects)
public RetriesFailedException(
String reason,
int invocationAttempts,
Duration retryTime,
int failedConnections,
int overloadedRejects,
Set<? extends Address> attemptedAddresses)
{
super(format(
"%s (invocationAttempts: %s, duration: %s, failedConnections: %s, overloadedRejects: %s)",
"%s (invocationAttempts: %s, duration: %s, failedConnections: %s, overloadedRejects: %s, attemptedAddresses: %s)",
reason,
invocationAttempts,
retryTime,
failedConnections,
overloadedRejects));
overloadedRejects,
attemptedAddresses));
this.invocationAttempts = invocationAttempts;
this.failedConnections = failedConnections;
this.retryTime = requireNonNull(retryTime, "retryTime is null");
this.overloadedRejects = overloadedRejects;
this.attemptedAddresses = ImmutableSet.copyOf(requireNonNull(attemptedAddresses, "attemptedAddresses is null"));
}

public int getInvocationAttempts()
Expand All @@ -62,4 +75,9 @@ public int getOverloadedRejects()
{
return overloadedRejects;
}

public Set<? extends Address> getAttemptedAddresses()
{
return attemptedAddresses;
}
}

0 comments on commit d6a6da5

Please sign in to comment.