Search in sources :

Example 1 with TruncateStreamCommand

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();
}
Also used : DistributedLogConfiguration(org.apache.distributedlog.DistributedLogConfiguration) LogRecordWithDLSN(org.apache.distributedlog.LogRecordWithDLSN) DLSN(org.apache.distributedlog.DLSN) LogRecordWithDLSN(org.apache.distributedlog.LogRecordWithDLSN) DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) LogReader(org.apache.distributedlog.api.LogReader) TruncateStreamCommand(org.apache.distributedlog.tools.DistributedLogTool.TruncateStreamCommand) Test(org.junit.Test)

Aggregations

DLSN (org.apache.distributedlog.DLSN)1 DistributedLogConfiguration (org.apache.distributedlog.DistributedLogConfiguration)1 LogRecordWithDLSN (org.apache.distributedlog.LogRecordWithDLSN)1 DistributedLogManager (org.apache.distributedlog.api.DistributedLogManager)1 LogReader (org.apache.distributedlog.api.LogReader)1 TruncateStreamCommand (org.apache.distributedlog.tools.DistributedLogTool.TruncateStreamCommand)1 Test (org.junit.Test)1