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();
}
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);
}
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();
}
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);
}
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);
}
Aggregations