use of org.apache.distributedlog.tools.DistributedLogTool.TruncateStreamCommand in project bookkeeper by apache.
the class TestDistributedLogTool method testToolTruncateStream.
@Test(timeout = 60000)
public void testToolTruncateStream() throws Exception {
DistributedLogConfiguration confLocal = new DistributedLogConfiguration();
confLocal.addConfiguration(conf);
confLocal.setLogSegmentCacheEnabled(false);
DistributedLogManager dlm = DLMTestUtil.createNewDLM("testToolTruncateStream", confLocal, defaultUri);
DLMTestUtil.generateCompletedLogSegments(dlm, confLocal, 3, 1000);
DLSN dlsn = new DLSN(2, 1, 0);
TruncateStreamCommand cmd = new TruncateStreamCommand();
cmd.setDlsn(dlsn);
cmd.setUri(defaultUri);
cmd.setStreamName("testToolTruncateStream");
cmd.setForce(true);
assertEquals(0, cmd.runCmd());
LogReader reader = dlm.getInputStream(0);
LogRecordWithDLSN record = reader.readNext(false);
assertEquals(dlsn, record.getDlsn());
reader.close();
dlm.close();
}
Aggregations