use of org.voltdb.DevNullSnapshotTarget in project voltdb by VoltDB.
the class SnapshotWritePlan method createAllDevNullTargets.
/**
* In case the deferred setup phase fails, some data targets may have not been created yet.
* This method will close all existing data targets and replace all with DevNullDataTargets
* so that snapshot can be drained.
*/
public void createAllDevNullTargets() {
Map<Integer, SnapshotDataTarget> targets = Maps.newHashMap();
final AtomicInteger numTargets = new AtomicInteger();
for (Deque<SnapshotTableTask> tasksForSite : m_taskListsForHSIds.values()) {
for (SnapshotTableTask task : tasksForSite) {
// Close any created targets and replace them with DevNull, go web-scale
if (task.getTarget(true) != null) {
try {
task.getTarget().close();
} catch (Exception e) {
SNAP_LOG.error("Failed closing data target after error", e);
}
}
SnapshotDataTarget target = targets.get(task.m_table.getRelativeIndex());
if (target == null) {
target = new DevNullSnapshotTarget();
final Runnable onClose = new TargetStatsClosure(target, task.m_table.getTypeName(), numTargets, m_snapshotRecord);
target.setOnCloseHandler(onClose);
targets.put(task.m_table.getRelativeIndex(), target);
m_targets.add(target);
numTargets.incrementAndGet();
}
task.setTarget(target);
}
}
}
use of org.voltdb.DevNullSnapshotTarget in project voltdb by VoltDB.
the class IndexSnapshotWritePlan method createTasksForTable.
/**
* For each site, generate a task for each target it has for this table.
*/
private void createTasksForTable(Table table, Collection<IndexSnapshotRequestConfig.PartitionRanges> partitionRanges, Map<Integer, Long> pidToLocalHSIDs, AtomicInteger numTables, SnapshotRegistry.Snapshot snapshotRecord) {
// no work on this node
if (pidToLocalHSIDs.isEmpty()) {
return;
}
// create a null data target
final DevNullSnapshotTarget dataTarget = new DevNullSnapshotTarget();
final Runnable onClose = new TargetStatsClosure(dataTarget, table.getTypeName(), numTables, snapshotRecord);
dataTarget.setOnCloseHandler(onClose);
m_targets.add(dataTarget);
// go over all local sites, create a task for each source site
for (IndexSnapshotRequestConfig.PartitionRanges partitionRange : partitionRanges) {
Long localHSId = pidToLocalHSIDs.get(partitionRange.partitionId);
// The partition may not exist on this node. If so, keep calm and carry on
if (localHSId != null) {
// based on the source partition, the predicate is different
final SnapshotTableTask task = new SnapshotTableTask(table, new SnapshotDataFilter[0], createIndexExpressionForTable(table, partitionRange.ranges), false);
task.setTarget(dataTarget);
placeTask(task, Arrays.asList(localHSId));
}
}
}
Aggregations