use of com.twitter.heron.spi.statefulstorage.Checkpoint in project incubator-heron by apache.
the class LocalFileSystemStorageTest method testStore.
@Test
public void testStore() throws Exception {
PowerMockito.spy(FileUtils.class);
PowerMockito.doReturn(true).when(FileUtils.class, "createDirectory", anyString());
PowerMockito.doReturn(true).when(FileUtils.class, "isFileExists", anyString());
PowerMockito.doReturn(true).when(FileUtils.class, "isDirectoryExists", anyString());
PowerMockito.doReturn(true).when(FileUtils.class, "writeToFile", anyString(), any(byte[].class), anyBoolean());
Checkpoint mockCheckpoint = mock(Checkpoint.class);
when(mockCheckpoint.getCheckpoint()).thenReturn(checkpoint);
localFileSystemStorage.store(mockCheckpoint);
PowerMockito.verifyStatic(times(1));
FileUtils.writeToFile(anyString(), eq(checkpoint.toByteArray()), eq(true));
}
use of com.twitter.heron.spi.statefulstorage.Checkpoint in project incubator-heron by apache.
the class HDFSStorage method restore.
@Override
public Checkpoint restore(String topologyName, String checkpointId, PhysicalPlans.Instance instanceInfo) throws StatefulStorageException {
Path path = new Path(getCheckpointPath(topologyName, checkpointId, instanceInfo.getInfo().getComponentName(), instanceInfo.getInfo().getTaskId()));
FSDataInputStream in = null;
CheckpointManager.InstanceStateCheckpoint state = null;
try {
in = fileSystem.open(path);
state = CheckpointManager.InstanceStateCheckpoint.parseFrom(in);
} catch (IOException e) {
throw new StatefulStorageException("Failed to read", e);
} finally {
SysUtils.closeIgnoringExceptions(in);
}
return new Checkpoint(topologyName, instanceInfo, state);
}
use of com.twitter.heron.spi.statefulstorage.Checkpoint in project incubator-heron by apache.
the class HDFSStorageTest 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);
FSDataOutputStream mockFSDateOutputStream = mock(FSDataOutputStream.class);
when(mockFileSystem.create(any(Path.class))).thenReturn(mockFSDateOutputStream);
doNothing().when(hdfsStorage).createDir(anyString());
hdfsStorage.store(checkpoint);
verify(mockCheckpointState).writeTo(mockFSDateOutputStream);
}
Aggregations