use of org.apache.distributedlog.exceptions.LogRecordTooLongException in project bookkeeper by apache.
the class TestBKDistributedLogManager method testMaxTransmissionSize.
@Test(timeout = 60000)
public void testMaxTransmissionSize() throws Exception {
DistributedLogConfiguration confLocal = new DistributedLogConfiguration();
confLocal.loadConf(conf);
confLocal.setOutputBufferSize(1024 * 1024);
BKDistributedLogManager dlm = createNewDLM(confLocal, "distrlog-transmissionSize");
AsyncLogWriter out = Utils.ioResult(dlm.openAsyncLogWriter());
boolean exceptionEncountered = false;
byte[] largePayload = new byte[(LogRecord.MAX_LOGRECORDSET_SIZE / 2) + 2];
RAND.nextBytes(largePayload);
try {
LogRecord op = new LogRecord(1L, largePayload);
CompletableFuture<DLSN> firstWriteFuture = out.write(op);
op = new LogRecord(2L, largePayload);
// the second write will flush the first one, since we reached the maximum transmission size.
out.write(op);
Utils.ioResult(firstWriteFuture);
} catch (LogRecordTooLongException exc) {
exceptionEncountered = true;
} finally {
Utils.ioResult(out.asyncClose());
}
assertFalse(exceptionEncountered);
Abortables.abortQuietly(out);
dlm.close();
}
Aggregations