本文整理匯總了Java中org.apache.kafka.clients.producer.internals.ProduceRequestResult.done方法的典型用法代碼示例。如果您正苦於以下問題:Java ProduceRequestResult.done方法的具體用法?Java ProduceRequestResult.done怎麽用?Java ProduceRequestResult.done使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.kafka.clients.producer.internals.ProduceRequestResult
的用法示例。
在下文中一共展示了ProduceRequestResult.done方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testTimeout
import org.apache.kafka.clients.producer.internals.ProduceRequestResult; //導入方法依賴的package包/類
/**
* Test that waiting on a request that never completes times out
*/
@Test
public void testTimeout() throws Exception {
ProduceRequestResult request = new ProduceRequestResult(topicPartition);
FutureRecordMetadata future = new FutureRecordMetadata(request, relOffset,
RecordBatch.NO_TIMESTAMP, 0L, 0, 0);
assertFalse("Request is not completed", future.isDone());
try {
future.get(5, TimeUnit.MILLISECONDS);
fail("Should have thrown exception.");
} catch (TimeoutException e) { /* this is good */
}
request.set(baseOffset, RecordBatch.NO_TIMESTAMP, null);
request.done();
assertTrue(future.isDone());
assertEquals(baseOffset + relOffset, future.get().offset());
}
示例2: testTimeout
import org.apache.kafka.clients.producer.internals.ProduceRequestResult; //導入方法依賴的package包/類
/**
* Test that waiting on a request that never completes times out
*/
@Test
public void testTimeout() throws Exception {
ProduceRequestResult request = new ProduceRequestResult();
FutureRecordMetadata future = new FutureRecordMetadata(request, relOffset,
Record.NO_TIMESTAMP, 0, 0, 0);
assertFalse("Request is not completed", future.isDone());
try {
future.get(5, TimeUnit.MILLISECONDS);
fail("Should have thrown exception.");
} catch (TimeoutException e) { /* this is good */
}
request.done(topicPartition, baseOffset, null);
assertTrue(future.isDone());
assertEquals(baseOffset + relOffset, future.get().offset());
}
示例3: asyncRequest
import org.apache.kafka.clients.producer.internals.ProduceRequestResult; //導入方法依賴的package包/類
public ProduceRequestResult asyncRequest(final long baseOffset, final RuntimeException error, final long timeout) {
final ProduceRequestResult request = new ProduceRequestResult(topicPartition);
Thread thread = new Thread() {
public void run() {
try {
sleep(timeout);
request.set(baseOffset, RecordBatch.NO_TIMESTAMP, error);
request.done();
} catch (InterruptedException e) { }
}
};
thread.start();
return request;
}
示例4: asyncRequest
import org.apache.kafka.clients.producer.internals.ProduceRequestResult; //導入方法依賴的package包/類
public ProduceRequestResult asyncRequest(final long baseOffset, final RuntimeException error, final long timeout) {
final ProduceRequestResult request = new ProduceRequestResult();
Thread thread = new Thread() {
public void run() {
try {
sleep(timeout);
request.done(topicPartition, baseOffset, error);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
thread.start();
return request;
}