本文整理汇总了Java中org.apache.kafka.common.errors.ProducerFencedException类的典型用法代码示例。如果您正苦于以下问题:Java ProducerFencedException类的具体用法?Java ProducerFencedException怎么用?Java ProducerFencedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProducerFencedException类属于org.apache.kafka.common.errors包,在下文中一共展示了ProducerFencedException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: pollRequests
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
/**
* Get the next batch of records by polling.
* @return Next batch of records or null if no records available.
*/
private ConsumerRecords<byte[], byte[]> pollRequests() {
ConsumerRecords<byte[], byte[]> records = null;
try {
records = consumer.poll(pollTimeMs);
} catch (final InvalidOffsetException e) {
resetInvalidOffsets(e);
}
if (rebalanceException != null) {
if (!(rebalanceException instanceof ProducerFencedException)) {
throw new StreamsException(logPrefix + " Failed to rebalance.", rebalanceException);
}
}
return records;
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:22,代码来源:StreamThread.java
示例2: performOnStreamTasks
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
private RuntimeException performOnStreamTasks(final StreamTaskAction action) {
RuntimeException firstException = null;
final Iterator<Map.Entry<TaskId, StreamTask>> it = activeTasks.entrySet().iterator();
while (it.hasNext()) {
final StreamTask task = it.next().getValue();
try {
action.apply(task);
} catch (final ProducerFencedException e) {
closeZombieTask(task);
it.remove();
} catch (final RuntimeException t) {
log.error("{} Failed to {} stream task {}: ",
logPrefix,
action.name(),
task.id(),
t);
if (firstException == null) {
firstException = t;
}
}
}
return firstException;
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:25,代码来源:StreamThread.java
示例3: failBatch
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
private void failBatch(ProducerBatch batch, long baseOffset, long logAppendTime, RuntimeException exception) {
if (transactionManager != null) {
if (exception instanceof OutOfOrderSequenceException
&& !transactionManager.isTransactional()
&& transactionManager.hasProducerId(batch.producerId())) {
log.error("The broker received an out of order sequence number for topic-partition " +
"{} at offset {}. This indicates data loss on the broker, and should be investigated.",
batch.topicPartition, baseOffset);
// Reset the transaction state since we have hit an irrecoverable exception and cannot make any guarantees
// about the previously committed message. Note that this will discard the producer id and sequence
// numbers for all existing partitions.
transactionManager.resetProducerId();
} else if (exception instanceof ClusterAuthorizationException
|| exception instanceof TransactionalIdAuthorizationException
|| exception instanceof ProducerFencedException) {
transactionManager.transitionToFatalError(exception);
} else if (transactionManager.isTransactional()) {
transactionManager.transitionToAbortableError(exception);
}
}
batch.done(baseOffset, logAppendTime, exception);
this.accumulator.deallocate(batch);
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:25,代码来源:Sender.java
示例4: sendOffsetsToTransaction
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
@Override
public void sendOffsetsToTransaction(Map<TopicPartition, OffsetAndMetadata> offsets,
String consumerGroupId) throws ProducerFencedException {
verifyProducerState();
verifyTransactionsInitialized();
verifyNoTransactionInFlight();
Objects.requireNonNull(consumerGroupId);
if (offsets.size() == 0) {
return;
}
Map<TopicPartition, OffsetAndMetadata> uncommittedOffsets = this.uncommittedConsumerGroupOffsets.get(consumerGroupId);
if (uncommittedOffsets == null) {
uncommittedOffsets = new HashMap<>();
this.uncommittedConsumerGroupOffsets.put(consumerGroupId, uncommittedOffsets);
}
uncommittedOffsets.putAll(offsets);
this.sentOffsets = true;
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:19,代码来源:MockProducer.java
示例5: commitTransaction
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
@Override
public void commitTransaction() throws ProducerFencedException {
verifyProducerState();
verifyTransactionsInitialized();
verifyNoTransactionInFlight();
flush();
this.sent.addAll(this.uncommittedSends);
if (!this.uncommittedConsumerGroupOffsets.isEmpty())
this.consumerGroupOffsets.add(this.uncommittedConsumerGroupOffsets);
this.uncommittedSends.clear();
this.uncommittedConsumerGroupOffsets = new HashMap<>();
this.transactionCommitted = true;
this.transactionAborted = false;
this.transactionInFlight = false;
++this.commitCount;
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:21,代码来源:MockProducer.java
示例6: recoverAndCommit
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
@Override
protected void recoverAndCommit(KafkaTransactionState transaction) {
switch (semantic) {
case EXACTLY_ONCE:
try (FlinkKafkaProducer<byte[], byte[]> producer =
initTransactionalProducer(transaction.transactionalId, false)) {
producer.resumeTransaction(transaction.producerId, transaction.epoch);
producer.commitTransaction();
}
catch (InvalidTxnStateException | ProducerFencedException ex) {
// That means we have committed this transaction before.
LOG.warn("Encountered error {} while recovering transaction {}. " +
"Presumably this transaction has been already committed before",
ex,
transaction);
}
break;
case AT_LEAST_ONCE:
case NONE:
break;
default:
throw new UnsupportedOperationException("Not implemented semantic");
}
}
开发者ID:axbaretto,项目名称:flink,代码行数:25,代码来源:FlinkKafkaProducer011.java
示例7: checkForException
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
private void checkForException() {
if (sendException != null) {
if (sendException instanceof ProducerFencedException) {
throw (ProducerFencedException) sendException;
}
throw new StreamsException(String.format("%s exception caught when producing", logPrefix), sendException);
}
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:9,代码来源:RecordCollectorImpl.java
示例8: shouldCloseTaskAsZombieAndRemoveFromActiveTasksIfProducerGotFencedAtBeginTransactionWhenTaskIsResumed
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
@Test
public void shouldCloseTaskAsZombieAndRemoveFromActiveTasksIfProducerGotFencedAtBeginTransactionWhenTaskIsResumed() throws Exception {
builder.addSource("name", "topic").addSink("out", "output");
final MockClientSupplier clientSupplier = new MockClientSupplier(applicationId);
final StreamThread thread = new StreamThread(
builder,
new StreamsConfig(configProps(true)),
clientSupplier,
applicationId,
clientId,
processId,
new Metrics(),
new MockTime(),
new StreamsMetadataState(builder, StreamsMetadataState.UNKNOWN_HOST),
0);
final Map<TaskId, Set<TopicPartition>> activeTasks = new HashMap<>();
activeTasks.put(task1, task0Assignment);
thread.setPartitionAssignor(new MockStreamsPartitionAssignor(activeTasks));
thread.rebalanceListener.onPartitionsRevoked(null);
thread.rebalanceListener.onPartitionsAssigned(task0Assignment);
assertThat(thread.tasks().size(), equalTo(1));
thread.rebalanceListener.onPartitionsRevoked(null);
clientSupplier.producers.get(0).fenceProducer();
try {
thread.rebalanceListener.onPartitionsAssigned(task0Assignment);
fail("should have thrown " + ProducerFencedException.class.getSimpleName());
} catch (final ProducerFencedException e) { }
assertTrue(thread.tasks().isEmpty());
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:36,代码来源:StreamThreadTest.java
示例9: beginTransaction
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
@Override
public void beginTransaction() throws ProducerFencedException {
verifyProducerState();
verifyTransactionsInitialized();
this.transactionInFlight = true;
this.transactionCommitted = false;
this.transactionAborted = false;
this.sentOffsets = false;
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:10,代码来源:MockProducer.java
示例10: abortTransaction
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
@Override
public void abortTransaction() throws ProducerFencedException {
verifyProducerState();
verifyTransactionsInitialized();
verifyNoTransactionInFlight();
flush();
this.uncommittedSends.clear();
this.uncommittedConsumerGroupOffsets.clear();
this.transactionCommitted = false;
this.transactionAborted = true;
this.transactionInFlight = false;
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:13,代码来源:MockProducer.java
示例11: verifyProducerState
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
private void verifyProducerState() {
if (this.closed) {
throw new IllegalStateException("MockProducer is already closed.");
}
if (this.producerFenced) {
throw new ProducerFencedException("MockProducer is fenced.");
}
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:9,代码来源:MockProducer.java
示例12: beginTransaction
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
/**
* Should be called before the start of each new transaction.
*
* @throws ProducerFencedException if another producer is with the same
* transactional.id is active.
*/
public void beginTransaction() throws ProducerFencedException {
// Set the transactional bit in the producer.
if (transactionManager == null)
throw new IllegalStateException("Cannot use transactional methods without enabling transactions");
transactionManager.beginTransaction();
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:13,代码来源:KafkaProducer.java
示例13: shouldThrowOnBeginTransactionsIfProducerGotFenced
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
@Test
public void shouldThrowOnBeginTransactionsIfProducerGotFenced() {
producer.initTransactions();
producer.fenceProducer();
try {
producer.beginTransaction();
fail("Should have thrown as producer is fenced off");
} catch (ProducerFencedException e) { }
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:10,代码来源:MockProducerTest.java
示例14: shouldThrowOnSendIfProducerGotFenced
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
@Test
public void shouldThrowOnSendIfProducerGotFenced() {
producer.initTransactions();
producer.fenceProducer();
try {
producer.send(null);
fail("Should have thrown as producer is fenced off");
} catch (ProducerFencedException e) { }
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:10,代码来源:MockProducerTest.java
示例15: shouldThrowOnFlushIfProducerGotFenced
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
@Test
public void shouldThrowOnFlushIfProducerGotFenced() {
producer.initTransactions();
producer.fenceProducer();
try {
producer.flush();
fail("Should have thrown as producer is fenced off");
} catch (ProducerFencedException e) { }
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:10,代码来源:MockProducerTest.java
示例16: shouldThrowOnSendOffsetsToTransactionIfProducerGotFenced
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
@Test
public void shouldThrowOnSendOffsetsToTransactionIfProducerGotFenced() {
producer.initTransactions();
producer.fenceProducer();
try {
producer.sendOffsetsToTransaction(null, null);
fail("Should have thrown as producer is fenced off");
} catch (ProducerFencedException e) { }
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:10,代码来源:MockProducerTest.java
示例17: shouldThrowOnCommitTransactionIfProducerGotFenced
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
@Test
public void shouldThrowOnCommitTransactionIfProducerGotFenced() {
producer.initTransactions();
producer.fenceProducer();
try {
producer.commitTransaction();
fail("Should have thrown as producer is fenced off");
} catch (ProducerFencedException e) { }
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:10,代码来源:MockProducerTest.java
示例18: shouldThrowOnAbortTransactionIfProducerGotFenced
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
@Test
public void shouldThrowOnAbortTransactionIfProducerGotFenced() {
producer.initTransactions();
producer.fenceProducer();
try {
producer.abortTransaction();
fail("Should have thrown as producer is fenced off");
} catch (ProducerFencedException e) { }
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:10,代码来源:MockProducerTest.java
示例19: closeIgnoringProducerFenced
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
private void closeIgnoringProducerFenced(AutoCloseable autoCloseable) throws Exception {
try {
autoCloseable.close();
}
catch (Exception ex) {
if (!(ex.getCause() instanceof ProducerFencedException)) {
throw ex;
}
}
}
开发者ID:axbaretto,项目名称:flink,代码行数:11,代码来源:FlinkKafkaProducer011Tests.java
示例20: beginTransaction
import org.apache.kafka.common.errors.ProducerFencedException; //导入依赖的package包/类
@Override
public void beginTransaction() throws ProducerFencedException {
producer.beginTransaction();
}
开发者ID:opentracing-contrib,项目名称:java-kafka-client,代码行数:5,代码来源:TracingKafkaProducer.java
注:本文中的org.apache.kafka.common.errors.ProducerFencedException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论