本文整理汇总了Java中com.github.rholder.retry.Attempt类的典型用法代码示例。如果您正苦于以下问题:Java Attempt类的具体用法?Java Attempt怎么用?Java Attempt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Attempt类属于com.github.rholder.retry包,在下文中一共展示了Attempt类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildRetryer
import com.github.rholder.retry.Attempt; //导入依赖的package包/类
/**
* Build Retryer.
* - If Writer implements Retriable, it will use the RetryerBuilder from the writer.
* - Otherwise, it will use DEFAULT writer builder.
*
* - If Gobblin metrics is enabled, it will emit all failure count in to metrics.
*
* @param state
* @return
*/
private Retryer<Void> buildRetryer(State state) {
RetryerBuilder<Void> builder = null;
if (writer instanceof Retriable) {
builder = ((Retriable) writer).getRetryerBuilder();
} else {
builder = createRetryBuilder(state);
}
if (GobblinMetrics.isEnabled(state)) {
final Optional<Meter> retryMeter = Optional.of(Instrumented.getMetricContext(state, getClass()).meter(FAILED_RETRY_WRITES_METER));
builder.withRetryListener(new RetryListener() {
@Override
public <V> void onRetry(Attempt<V> attempt) {
if (attempt.hasException()) {
LOG.warn("Caught exception. This may be retried.", attempt.getExceptionCause());
Instrumented.markMeter(retryMeter);
failedWrites++;
}
}
});
}
return builder.build();
}
开发者ID:apache,项目名称:incubator-gobblin,代码行数:35,代码来源:RetryWriter.java
示例2: buildResponseRetryer
import com.github.rholder.retry.Attempt; //导入依赖的package包/类
private Retryer<Response> buildResponseRetryer() {
final RetryListener retryListener = new RetryListener() {
@Override
public <V> void onRetry(Attempt<V> attempt) {
final long attemptNumber = attempt.getAttemptNumber();
if (attemptNumber > ONE) {
final long delaySinceFirstAttemptInMilliseconds = attempt.getDelaySinceFirstAttempt();
final long delaySinceFirstAttemptInSeconds = TimeUnit.SECONDS
.convert(delaySinceFirstAttemptInMilliseconds, TimeUnit.MILLISECONDS);
final Response response = (Response) attempt.getResult();
response.bufferEntity();
LOGGER.warn(String.format(RETRY_ATTEMPT_MESSAGE, delaySinceFirstAttemptInSeconds, attemptNumber,
response.getStatus(), response.readEntity(String.class)));
}
}
};
final long maximumWaitDuration = requestRetryConfiguration.getMininumWaitDuration() * TWO;
return RetryerBuilder.<Response> newBuilder().retryIfResult(this::shouldRetryResponse)
.withWaitStrategy(WaitStrategies.randomWait(requestRetryConfiguration.getMininumWaitDuration(),
requestRetryConfiguration.getMininumWaitUnit(), maximumWaitDuration,
requestRetryConfiguration.getMininumWaitUnit()))
.withRetryListener(retryListener)
.withStopStrategy(StopStrategies.stopAfterDelay(requestRetryConfiguration.getTimeoutDuration(),
requestRetryConfiguration.getTimeoutUnit()))
.build();
}
开发者ID:rjdavis3,项目名称:ebay-sdk,代码行数:28,代码来源:EbayClientImpl.java
示例3: CommandQueries
import com.github.rholder.retry.Attempt; //导入依赖的package包/类
CommandQueries(List<QueryRequest> queries, Keyspace keyspace) {
super(Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("BatchExecutor"))
.andThreadPoolPropertiesDefaults(
HystrixThreadPoolProperties.Setter()
.withCoreSize(threadPoolCoreSize)
// Sizing these two based on the thread pool core size
.withQueueSizeRejectionThreshold(
threadPoolCoreSize * QUEUE_MULTIPLIER)
.withMaxQueueSize(threadPoolCoreSize * QUEUE_MULTIPLIER))
.andCommandPropertiesDefaults(
HystrixCommandProperties.Setter()
.withExecutionTimeoutEnabled(false)
.withExecutionTimeoutInMilliseconds(timeoutMs)
.withRequestLogEnabled(requestLogEnabled)));
this.queries = queries;
this.keyspace = keyspace;
this.graqlExecuteTimer = metricRegistry.timer(name(this.getClass(), "execute"));
this.attemptMeter = metricRegistry.meter(name(this.getClass(), "attempt"));
this.retryer = RetryerBuilder.<List<QueryResponse>>newBuilder()
.retryIfException((throwable) ->
throwable instanceof GraknClientException
&& ((GraknClientException) throwable).isRetriable())
.retryIfExceptionOfType(ConnectException.class)
.withWaitStrategy(WaitStrategies.exponentialWait(10, 1, TimeUnit.MINUTES))
.withStopStrategy(StopStrategies.stopAfterAttempt(maxRetries + 1))
.withRetryListener(new RetryListener() {
@Override
public <V> void onRetry(Attempt<V> attempt) {
attemptMeter.mark();
}
})
.build();
}
开发者ID:graknlabs,项目名称:grakn,代码行数:36,代码来源:BatchExecutorClient.java
示例4: onRetry
import com.github.rholder.retry.Attempt; //导入依赖的package包/类
@Override
public <V> void onRetry(Attempt<V> attempt) {
attemptCount = attempt.getAttemptNumber();
if (delegate != null) {
delegate.onRetry(attempt);
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:RetryHelper.java
示例5: GuaranteedDeliveryTransport
import com.github.rholder.retry.Attempt; //导入依赖的package包/类
public GuaranteedDeliveryTransport( long maxWaitTimeSeconds, int maxAttempts ) {
retryer = RetryerBuilder.<Boolean>newBuilder()
.withRetryListener( new RetryListener() {
@Override
public <V> void onRetry( Attempt<V> attempt ) {
String errorMessage = attempt.hasException() ? attempt.getExceptionCause().toString() : "no errors";
V result = attempt.hasResult() ? attempt.getResult() : null;
log.info( "Attempt: {}, result: {}, error: {}", attempt.getAttemptNumber(), result, errorMessage );
}
} )
.retryIfException( e -> !( e instanceof InterruptedException ) )
.withWaitStrategy( WaitStrategies.fibonacciWait( maxWaitTimeSeconds, TimeUnit.SECONDS ) )
.withStopStrategy( StopStrategies.stopAfterAttempt( maxAttempts ) )
.build();
}
开发者ID:oaplatform,项目名称:oap,代码行数:16,代码来源:GuaranteedDeliveryTransport.java
示例6: onRestorePollPodsAttempt
import com.github.rholder.retry.Attempt; //导入依赖的package包/类
private <V> void onRestorePollPodsAttempt(Attempt<V> attempt) {
if (attempt.hasException()) {
LOG.warn("restore: failed polling pods, attempt = {}", attempt.getAttemptNumber(), attempt.getExceptionCause());
}
}
开发者ID:spotify,项目名称:styx,代码行数:6,代码来源:KubernetesDockerRunner.java
示例7: onRetry
import com.github.rholder.retry.Attempt; //导入依赖的package包/类
@Override
public <V> void onRetry(Attempt<V> attempt) {
if (attempt.hasException()) {
LOG.warn("Retrying transaction after {" + attempt.getAttemptNumber() + "} attempts due to exception {" + attempt.getExceptionCause().getMessage() + "}");
}
}
开发者ID:graknlabs,项目名称:grakn,代码行数:7,代码来源:GraqlController.java
示例8: onRetry
import com.github.rholder.retry.Attempt; //导入依赖的package包/类
@Override
public <V> void onRetry(Attempt<V> attempt) {
lastAttemptNumber = attempt.getAttemptNumber();
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:5,代码来源:MergeOp.java
注:本文中的com.github.rholder.retry.Attempt类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论