Search in sources :

Example 31 with AsyncLogWriter

use of org.apache.distributedlog.api.AsyncLogWriter in project bookkeeper by apache.

the class MVCCStoreFactoryImplTest method setup.

@Before
public void setup() throws IOException {
    this.namespace = mock(Namespace.class);
    DistributedLogManager dlm = mock(DistributedLogManager.class);
    when(dlm.asyncClose()).thenReturn(FutureUtils.Void());
    when(namespace.openLog(anyString())).thenReturn(dlm);
    AsyncLogWriter logWriter = mock(AsyncLogWriter.class);
    when(dlm.openAsyncLogWriter()).thenReturn(FutureUtils.value(logWriter));
    when(logWriter.getLastTxId()).thenReturn(-1L);
    DLSN dlsn = new DLSN(0L, 0L, 0L);
    when(logWriter.write(any(LogRecord.class))).thenReturn(FutureUtils.value(dlsn));
    when(logWriter.asyncClose()).thenReturn(FutureUtils.Void());
    AsyncLogReader logReader = mock(AsyncLogReader.class);
    when(dlm.openAsyncLogReader(anyLong())).thenReturn(FutureUtils.value(logReader));
    when(logReader.asyncClose()).thenReturn(FutureUtils.Void());
    LogRecordWithDLSN record = new LogRecordWithDLSN(dlsn, 0L, NOP_CMD.toByteArray(), 0L);
    when(logReader.readNext()).thenReturn(FutureUtils.value(record));
    int numDirs = 3;
    this.storeDirs = new File[numDirs];
    for (int i = 0; i < numDirs; i++) {
        storeDirs[i] = testDir.newFolder("test-" + i);
    }
    this.resources = StorageResources.create(StorageResourcesSpec.builder().numCheckpointThreads(3).numIOReadThreads(3).numIOWriteThreads(3).build());
    this.factory = new MVCCStoreFactoryImpl(() -> namespace, storeDirs, resources, false);
}
Also used : LogRecordWithDLSN(org.apache.distributedlog.LogRecordWithDLSN) DLSN(org.apache.distributedlog.DLSN) LogRecordWithDLSN(org.apache.distributedlog.LogRecordWithDLSN) LogRecord(org.apache.distributedlog.LogRecord) AsyncLogReader(org.apache.distributedlog.api.AsyncLogReader) DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) AsyncLogWriter(org.apache.distributedlog.api.AsyncLogWriter) Namespace(org.apache.distributedlog.api.namespace.Namespace) Before(org.junit.Before)

Example 32 with AsyncLogWriter

use of org.apache.distributedlog.api.AsyncLogWriter in project bookkeeper by apache.

the class MVCCAsyncStoreTestBase method mockNamespace.

private static Namespace mockNamespace() throws Exception {
    Namespace namespace = mock(Namespace.class);
    DistributedLogManager dlm = mock(DistributedLogManager.class);
    when(dlm.asyncClose()).thenReturn(FutureUtils.Void());
    when(namespace.openLog(anyString())).thenReturn(dlm);
    AsyncLogWriter logWriter = mock(AsyncLogWriter.class);
    when(dlm.openAsyncLogWriter()).thenReturn(FutureUtils.value(logWriter));
    when(logWriter.getLastTxId()).thenReturn(-1L);
    DLSN dlsn = new DLSN(0L, 0L, 0L);
    when(logWriter.write(any(LogRecord.class))).thenReturn(FutureUtils.value(dlsn));
    when(logWriter.asyncClose()).thenReturn(FutureUtils.Void());
    AsyncLogReader logReader = mock(AsyncLogReader.class);
    when(dlm.openAsyncLogReader(anyLong())).thenReturn(FutureUtils.value(logReader));
    when(logReader.asyncClose()).thenReturn(FutureUtils.Void());
    LogRecordWithDLSN record = new LogRecordWithDLSN(dlsn, 0L, NOP_CMD.toByteArray(), 0L);
    when(logReader.readNext()).thenReturn(FutureUtils.value(record));
    return namespace;
}
Also used : LogRecordWithDLSN(org.apache.distributedlog.LogRecordWithDLSN) DLSN(org.apache.distributedlog.DLSN) LogRecordWithDLSN(org.apache.distributedlog.LogRecordWithDLSN) LogRecord(org.apache.distributedlog.LogRecord) AsyncLogReader(org.apache.distributedlog.api.AsyncLogReader) DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) AsyncLogWriter(org.apache.distributedlog.api.AsyncLogWriter) Namespace(org.apache.distributedlog.api.namespace.Namespace)

Aggregations

AsyncLogWriter (org.apache.distributedlog.api.AsyncLogWriter)32 Test (org.junit.Test)23 DistributedLogManager (org.apache.distributedlog.api.DistributedLogManager)20 URI (java.net.URI)6 DLSN (org.apache.distributedlog.DLSN)4 LogRecord (org.apache.distributedlog.LogRecord)4 LogRecordWithDLSN (org.apache.distributedlog.LogRecordWithDLSN)4 Namespace (org.apache.distributedlog.api.namespace.Namespace)4 List (java.util.List)3 DynamicDistributedLogConfiguration (org.apache.distributedlog.config.DynamicDistributedLogConfiguration)3 IOException (java.io.IOException)2 DistributedLogConfiguration (org.apache.distributedlog.DistributedLogConfiguration)2 Entry (org.apache.distributedlog.Entry)2 LogSegmentMetadata (org.apache.distributedlog.LogSegmentMetadata)2 AsyncLogReader (org.apache.distributedlog.api.AsyncLogReader)2 BKNamespaceDriver (org.apache.distributedlog.impl.BKNamespaceDriver)2 RateLimiter (com.google.common.util.concurrent.RateLimiter)1 BufferedOutputStream (java.io.BufferedOutputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1