Search in sources :

Example 6 with AppendOnlyStreamWriter

use of org.apache.distributedlog.AppendOnlyStreamWriter in project incubator-heron by apache.

the class DlogUploaderTest method testUploadPackage.

@Test
public void testUploadPackage() throws Exception {
    uploader = Mockito.spy(uploader);
    Namespace ns = mock(Namespace.class);
    when(nsBuilder.build()).thenReturn(ns);
    when(ns.logExists(anyString())).thenReturn(false);
    DistributedLogManager dlm = mock(DistributedLogManager.class);
    when(ns.openLog(anyString())).thenReturn(dlm);
    AppendOnlyStreamWriter asw = mock(AppendOnlyStreamWriter.class);
    when(dlm.getAppendOnlyStreamWriter()).thenReturn(asw);
    Mockito.doReturn(true).when(uploader).isLocalFileExists(Mockito.anyString());
    uploader.initialize(config);
    uploader.uploadPackage();
    verify(ns, never()).deleteLog(eq(uploader.getPackageName()));
    verify(copier, times(1)).copyFileToStream(eq(uploader.getTopologyPackageLocation()), any(OutputStream.class));
    verify(asw, times(1)).close();
    verify(dlm, times(1)).close();
}
Also used : DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) AppendOnlyStreamWriter(org.apache.distributedlog.AppendOnlyStreamWriter) OutputStream(java.io.OutputStream) Namespace(org.apache.distributedlog.api.namespace.Namespace) Test(org.junit.Test)

Example 7 with AppendOnlyStreamWriter

use of org.apache.distributedlog.AppendOnlyStreamWriter in project incubator-heron by apache.

the class DlogStorage method openOutputStream.

protected OutputStream openOutputStream(String path) throws IOException {
    DistributedLogManager dlm = namespace.openLog(path);
    AppendOnlyStreamWriter writer = dlm.getAppendOnlyStreamWriter();
    return new DLOutputStream(dlm, writer);
}
Also used : DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) AppendOnlyStreamWriter(org.apache.distributedlog.AppendOnlyStreamWriter) DLOutputStream(com.twitter.heron.dlog.DLOutputStream)

Example 8 with AppendOnlyStreamWriter

use of org.apache.distributedlog.AppendOnlyStreamWriter in project incubator-heron by apache.

the class DlogStorageTest method testStore.

@Test
public void testStore() throws Exception {
    PowerMockito.mockStatic(CheckpointManager.InstanceStateCheckpoint.class);
    CheckpointManager.InstanceStateCheckpoint mockCheckpointState = mock(CheckpointManager.InstanceStateCheckpoint.class);
    Checkpoint checkpoint = new Checkpoint(StatefulStorageTestContext.TOPOLOGY_NAME, instance, mockCheckpointState);
    DistributedLogManager mockDLM = mock(DistributedLogManager.class);
    when(mockNamespace.openLog(anyString())).thenReturn(mockDLM);
    AppendOnlyStreamWriter mockWriter = mock(AppendOnlyStreamWriter.class);
    when(mockDLM.getAppendOnlyStreamWriter()).thenReturn(mockWriter);
    dlogStorage.store(checkpoint);
    verify(mockWriter).markEndOfStream();
    verify(mockWriter).close();
}
Also used : Checkpoint(com.twitter.heron.spi.statefulstorage.Checkpoint) CheckpointManager(com.twitter.heron.proto.ckptmgr.CheckpointManager) DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) AppendOnlyStreamWriter(org.apache.distributedlog.AppendOnlyStreamWriter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 9 with AppendOnlyStreamWriter

use of org.apache.distributedlog.AppendOnlyStreamWriter in project incubator-heron by apache.

the class DLUploader method openOutputStream.

protected OutputStream openOutputStream(String pkgName) throws IOException {
    DistributedLogManager dlm = namespace.openLog(pkgName);
    AppendOnlyStreamWriter writer = dlm.getAppendOnlyStreamWriter();
    return new DLOutputStream(dlm, writer);
}
Also used : DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) AppendOnlyStreamWriter(org.apache.distributedlog.AppendOnlyStreamWriter) DLOutputStream(com.twitter.heron.dlog.DLOutputStream)

Example 10 with AppendOnlyStreamWriter

use of org.apache.distributedlog.AppendOnlyStreamWriter in project incubator-heron by apache.

the class Util method openOutputStream.

private static OutputStream openOutputStream(Namespace namespace, String pkgName) throws IOException {
    DistributedLogManager dlm = namespace.openLog(pkgName);
    AppendOnlyStreamWriter writer = dlm.getAppendOnlyStreamWriter();
    return new DLOutputStream(dlm, writer);
}
Also used : DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) AppendOnlyStreamWriter(org.apache.distributedlog.AppendOnlyStreamWriter)

Aggregations

AppendOnlyStreamWriter (org.apache.distributedlog.AppendOnlyStreamWriter)13 DistributedLogManager (org.apache.distributedlog.api.DistributedLogManager)13 Test (org.junit.Test)6 OutputStream (java.io.OutputStream)3 Test (org.testng.annotations.Test)3 DLOutputStream (com.twitter.heron.dlog.DLOutputStream)2 Namespace (org.apache.distributedlog.api.namespace.Namespace)2 CheckpointManager (com.twitter.heron.proto.ckptmgr.CheckpointManager)1 Checkpoint (com.twitter.heron.spi.statefulstorage.Checkpoint)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 DLOutputStream (org.apache.pulsar.functions.worker.dlog.DLOutputStream)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1