本文整理汇总了Java中org.apache.kafka.common.errors.RetriableException类的典型用法代码示例。如果您正苦于以下问题:Java RetriableException类的具体用法?Java RetriableException怎么用?Java RetriableException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RetriableException类属于org.apache.kafka.common.errors包,在下文中一共展示了RetriableException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: doAutoCommitOffsetsAsync
import org.apache.kafka.common.errors.RetriableException; //导入依赖的package包/类
private void doAutoCommitOffsetsAsync() {
Map<TopicPartition, OffsetAndMetadata> allConsumedOffsets = subscriptions.allConsumed();
log.debug("Sending asynchronous auto-commit of offsets {} for group {}", allConsumedOffsets, groupId);
//rebalance
commitOffsetsAsync(allConsumedOffsets, new OffsetCommitCallback() {
@Override
public void onComplete(Map<TopicPartition, OffsetAndMetadata> offsets, Exception exception) {
if (exception != null) {
log.warn("Auto-commit of offsets {} failed for group {}: {}", offsets, groupId,
exception.getMessage());
if (exception instanceof RetriableException)
nextAutoCommitDeadline = Math.min(time.milliseconds() + retryBackoffMs, nextAutoCommitDeadline);
} else {
log.debug("Completed auto-commit of offsets {} for group {}", offsets, groupId);
}
}
});
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:19,代码来源:ConsumerCoordinator.java
示例2: doCommitOffsetsAsync
import org.apache.kafka.common.errors.RetriableException; //导入依赖的package包/类
private void doCommitOffsetsAsync(final Map<TopicPartition, OffsetAndMetadata> offsets, final OffsetCommitCallback callback) {
this.subscriptions.needRefreshCommits();
//rebalance
RequestFuture<Void> future = sendOffsetCommitRequest(offsets);
final OffsetCommitCallback cb = callback == null ? defaultOffsetCommitCallback : callback;
future.addListener(new RequestFutureListener<Void>() {
@Override
public void onSuccess(Void value) {
if (interceptors != null)
interceptors.onCommit(offsets);
completedOffsetCommits.add(new OffsetCommitCompletion(cb, offsets, null));
}
@Override
public void onFailure(RuntimeException e) {
Exception commitException = e;
if (e instanceof RetriableException)
commitException = RetriableCommitFailedException.withUnderlyingMessage(e.getMessage());
completedOffsetCommits.add(new OffsetCommitCompletion(cb, offsets, commitException));
}
});
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:26,代码来源:ConsumerCoordinator.java
示例3: send
import org.apache.kafka.common.errors.RetriableException; //导入依赖的package包/类
private <V extends AbstractStatus> void send(final String key,
final V status,
final CacheEntry<V> entry,
final boolean safeWrite) {
final int sequence;
synchronized (this) {
this.generation = status.generation();
if (safeWrite && !entry.canWriteSafely(status))
return;
sequence = entry.increment();
}
final byte[] value = status.state() == ConnectorStatus.State.DESTROYED ? null : serialize(status);
kafkaLog.send(key, value, new org.apache.kafka.clients.producer.Callback() {
@Override
public void onCompletion(RecordMetadata metadata, Exception exception) {
if (exception != null) {
if (exception instanceof RetriableException) {
synchronized (KafkaStatusBackingStore.this) {
if (entry.isDeleted()
|| status.generation() != generation
|| (safeWrite && !entry.canWriteSafely(status, sequence)))
return;
}
kafkaLog.send(key, value, this);
} else {
log.error("Failed to write status update", exception);
}
}
}
});
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:34,代码来源:KafkaStatusBackingStore.java
示例4: commitOffsetsAsync
import org.apache.kafka.common.errors.RetriableException; //导入依赖的package包/类
public void commitOffsetsAsync(final Map<TopicPartition, OffsetAndMetadata> offsets, OffsetCommitCallback callback) {
this.subscriptions.needRefreshCommits();
RequestFuture<Void> future = sendOffsetCommitRequest(offsets);
final OffsetCommitCallback cb = callback == null ? defaultOffsetCommitCallback : callback;
future.addListener(new RequestFutureListener<Void>() {
@Override
public void onSuccess(Void value) {
if (interceptors != null)
interceptors.onCommit(offsets);
cb.onComplete(offsets, null);
}
@Override
public void onFailure(RuntimeException e) {
if (e instanceof RetriableException) {
cb.onComplete(offsets, new RetriableCommitFailedException("Commit offsets failed with retriable exception. You should retry committing offsets.", e));
} else {
cb.onComplete(offsets, e);
}
}
});
// ensure the commit has a chance to be transmitted (without blocking on its completion).
// Note that commits are treated as heartbeats by the coordinator, so there is no need to
// explicitly allow heartbeats through delayed task execution.
client.pollNoWakeup();
}
开发者ID:txazo,项目名称:kafka,代码行数:28,代码来源:ConsumerCoordinator.java
示例5: strategy
import org.apache.kafka.common.errors.RetriableException; //导入依赖的package包/类
private RetryStrategy strategy() {
return Retries
.defaultStrategy(onStop)
.retryException(RetriableException.class);
}
开发者ID:epam,项目名称:Lagerta,代码行数:6,代码来源:ProducerProxyRetry.java
示例6: canRetry
import org.apache.kafka.common.errors.RetriableException; //导入依赖的package包/类
/**
* We can retry a send if the error is transient and the number of attempts taken is fewer than the maximum allowed
*/
private boolean canRetry(ProducerBatch batch, Errors error) {
return batch.attempts() < this.retries && error.exception() instanceof RetriableException;
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:7,代码来源:Sender.java
示例7: fail
import org.apache.kafka.common.errors.RetriableException; //导入依赖的package包/类
/**
* Handle a failure.
*
* Depending on what the exception is and how many times we have already tried, we may choose to
* fail the Call, or retry it. It is important to print the stack traces here in some cases,
* since they are not necessarily preserved in ApiVersionException objects.
*
* @param now The current time in milliseconds.
* @param throwable The failure exception.
*/
final void fail(long now, Throwable throwable) {
// If this is an UnsupportedVersionException that we can retry, do so.
if ((throwable instanceof UnsupportedVersionException) &&
handleUnsupportedVersionException((UnsupportedVersionException) throwable)) {
log.trace("{} attempting protocol downgrade.", this);
runnable.enqueue(this, now);
return;
}
tries++;
// If the call has timed out, fail.
if (calcTimeoutMsRemainingAsInt(now, deadlineMs) < 0) {
if (log.isDebugEnabled()) {
log.debug("{} timed out at {} after {} attempt(s)", this, now, tries,
new Exception(prettyPrintException(throwable)));
}
handleFailure(throwable);
return;
}
// If the exception is not retryable, fail.
if (!(throwable instanceof RetriableException)) {
if (log.isDebugEnabled()) {
log.debug("{} failed with non-retriable exception after {} attempt(s)", this, tries,
new Exception(prettyPrintException(throwable)));
}
handleFailure(throwable);
return;
}
// If we are out of retries, fail.
if (tries > maxRetries) {
if (log.isDebugEnabled()) {
log.debug("{} failed after {} attempt(s)", this, tries,
new Exception(prettyPrintException(throwable)));
}
handleFailure(throwable);
return;
}
if (log.isDebugEnabled()) {
log.debug("{} failed: {}. Beginning retry #{}",
this, prettyPrintException(throwable), tries);
}
runnable.enqueue(this, now);
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:53,代码来源:KafkaAdminClient.java
示例8: canRetry
import org.apache.kafka.common.errors.RetriableException; //导入依赖的package包/类
/**
* We can retry a send if the error is transient and the number of attempts taken is fewer than the maximum allowed
*/
private boolean canRetry(RecordBatch batch, Errors error) {
return batch.attempts < this.retries && error.exception() instanceof RetriableException;
}
开发者ID:txazo,项目名称:kafka,代码行数:7,代码来源:Sender.java
示例9: isRetriable
import org.apache.kafka.common.errors.RetriableException; //导入依赖的package包/类
/**
* Check if the request is retriable (convenience method for checking if
* the exception is an instance of {@link RetriableException}.
* @return true if it is retriable, false otherwise
* @throws IllegalStateException if the future is not complete or completed successfully
*/
public boolean isRetriable() {
return exception() instanceof RetriableException;
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:10,代码来源:RequestFuture.java
示例10: isRetriable
import org.apache.kafka.common.errors.RetriableException; //导入依赖的package包/类
/**
* Check if the request is retriable (convenience method for checking if
* the exception is an instance of {@link RetriableException}.
* @return true if it is retriable, false otherwise
*/
public boolean isRetriable() {
return exception instanceof RetriableException;
}
开发者ID:txazo,项目名称:kafka,代码行数:9,代码来源:RequestFuture.java
注:本文中的org.apache.kafka.common.errors.RetriableException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论