com.signalfx.connection.RetryStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of signalfx-java Show documentation
Show all versions of signalfx-java Show documentation
Bare minimum core library needed to sending metrics to SignalFx from Java clients
The newest version!
package com.signalfx.connection;
import com.signalfx.shaded.apache.http.HttpResponse;
import com.signalfx.shaded.apache.http.HttpStatus;
import com.signalfx.shaded.apache.http.client.ServiceUnavailableRetryStrategy;
import com.signalfx.shaded.apache.http.protocol.HttpContext;
public class RetryStrategy implements ServiceUnavailableRetryStrategy {
private final int maxRetries;
public RetryStrategy(final int maxRetries) {
this.maxRetries = maxRetries;
}
@Override
public boolean retryRequest(final HttpResponse httpResponse, final int executionCount, final HttpContext httpContext) {
final int statusCode = httpResponse.getStatusLine().getStatusCode();
return executionCount <= maxRetries && (statusCode == HttpStatus.SC_REQUEST_TIMEOUT || statusCode == HttpStatus.SC_GATEWAY_TIMEOUT || statusCode == 598 || statusCode == -1);
}
@Override
public long getRetryInterval() {
return 0;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy