use of com.twitter.heron.spi.statefulstorage.StatefulStorageException in project incubator-heron by apache.
the class DlogStorage method init.
@Override
public void init(Map<String, Object> conf) throws StatefulStorageException {
LOG.info("Initializing ... Config: " + conf.toString());
LOG.info("Class path: " + System.getProperty("java.class.path"));
checkpointNamespaceUriStr = (String) conf.get(NS_URI_KEY);
checkpointNamespaceUri = URI.create(checkpointNamespaceUriStr);
Integer numReplicasValue = (Integer) conf.get(NUM_REPLICAS_KEY);
this.numReplicas = null == numReplicasValue ? 3 : numReplicasValue;
try {
this.namespace = initializeNamespace(checkpointNamespaceUri);
} catch (IOException ioe) {
throw new StatefulStorageException("Failed to open distributedlog namespace @ " + checkpointNamespaceUri, ioe);
}
}
use of com.twitter.heron.spi.statefulstorage.StatefulStorageException in project incubator-heron by apache.
the class HDFSStorage method dispose.
@Override
public void dispose(String topologyName, String oldestCheckpointPreserved, boolean deleteAll) throws StatefulStorageException {
String topologyCheckpointRoot = getTopologyCheckpointRoot(topologyName);
Path topologyRootPath = new Path(topologyCheckpointRoot);
if (deleteAll) {
// Clean all checkpoint states
try {
fileSystem.delete(topologyRootPath, true);
if (fileSystem.exists(topologyRootPath)) {
throw new StatefulStorageException("Failed to delete " + topologyRootPath);
}
} catch (IOException e) {
throw new StatefulStorageException("Error while deleting " + topologyRootPath, e);
}
} else {
try {
FileStatus[] statuses = fileSystem.listStatus(topologyRootPath);
for (FileStatus status : statuses) {
String name = status.getPath().getName();
if (name.compareTo(oldestCheckpointPreserved) < 0) {
fileSystem.delete(status.getPath(), true);
}
}
// Do a double check. Now all checkpoints with smaller checkpoint id should be cleaned
statuses = fileSystem.listStatus(topologyRootPath);
for (FileStatus status : statuses) {
String name = status.getPath().getName();
if (name.compareTo(oldestCheckpointPreserved) < 0) {
throw new StatefulStorageException("Error while deleting " + name);
}
}
} catch (IOException e) {
throw new StatefulStorageException("Failed to clean to: " + oldestCheckpointPreserved, e);
}
}
}
use of com.twitter.heron.spi.statefulstorage.StatefulStorageException 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);
}
Aggregations