use of org.voltdb.SnapshotDataTarget in project voltdb by VoltDB.
the class CSVSnapshotWritePlan method createDataTargetForTable.
private SnapshotDataTarget createDataTargetForTable(String file_path, String file_nonce, int hostId, AtomicInteger numTables, SnapshotRegistry.Snapshot snapshotRecord, Table table) throws IOException {
SnapshotDataTarget sdt;
File saveFilePath = SnapshotUtil.constructFileForTable(table, file_path, file_nonce, SnapshotFormat.CSV, hostId);
sdt = new SimpleFileSnapshotDataTarget(saveFilePath, !table.getIsreplicated());
m_targets.add(sdt);
final Runnable onClose = new TargetStatsClosure(sdt, table.getTypeName(), numTables, snapshotRecord);
sdt.setOnCloseHandler(onClose);
return sdt;
}
use of org.voltdb.SnapshotDataTarget in project voltdb by VoltDB.
the class CSVSnapshotWritePlan method createDeferredSetup.
private Callable<Boolean> createDeferredSetup(final String file_path, final String pathType, final String file_nonce, final Table[] tables, final long txnId, final Map<Integer, Long> partitionTransactionIds, final SystemProcedureExecutionContext context, final ExtensibleSnapshotDigestData extraSnapshotData, final long timestamp, final AtomicInteger numTables, final SnapshotRegistry.Snapshot snapshotRecord, final ArrayList<SnapshotTableTask> partitionedSnapshotTasks, final ArrayList<SnapshotTableTask> replicatedSnapshotTasks) {
return new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
NativeSnapshotWritePlan.createFileBasedCompletionTasks(file_path, pathType, file_nonce, txnId, partitionTransactionIds, context, extraSnapshotData, null, timestamp, context.getNumberOfPartitions(), tables);
for (SnapshotTableTask task : replicatedSnapshotTasks) {
final SnapshotDataTarget target = createDataTargetForTable(file_path, file_nonce, context.getHostId(), numTables, snapshotRecord, task.m_table);
task.setTarget(target);
}
for (SnapshotTableTask task : partitionedSnapshotTasks) {
final SnapshotDataTarget target = createDataTargetForTable(file_path, file_nonce, context.getHostId(), numTables, snapshotRecord, task.m_table);
task.setTarget(target);
}
return true;
}
};
}
use of org.voltdb.SnapshotDataTarget 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.SnapshotDataTarget in project voltdb by VoltDB.
the class NativeSnapshotWritePlan method createDataTargetForTable.
private SnapshotDataTarget createDataTargetForTable(String file_path, String file_nonce, Table table, long txnId, int hostId, String clusterName, String databaseName, int partitionCount, boolean isActiveActiveDRed, SiteTracker tracker, long timestamp, AtomicInteger numTables, SnapshotRegistry.Snapshot snapshotRecord) throws IOException {
SnapshotDataTarget sdt;
File saveFilePath = SnapshotUtil.constructFileForTable(table, file_path, file_nonce, SnapshotFormat.NATIVE, hostId);
if (isActiveActiveDRed && table.getIsdred()) {
sdt = new DefaultSnapshotDataTarget(saveFilePath, hostId, clusterName, databaseName, table.getTypeName(), partitionCount, table.getIsreplicated(), tracker.getPartitionsForHost(hostId), CatalogUtil.getVoltTable(table, CatalogUtil.DR_HIDDEN_COLUMN_INFO), txnId, timestamp);
} else {
sdt = new DefaultSnapshotDataTarget(saveFilePath, hostId, clusterName, databaseName, table.getTypeName(), partitionCount, table.getIsreplicated(), tracker.getPartitionsForHost(hostId), CatalogUtil.getVoltTable(table), txnId, timestamp);
}
m_targets.add(sdt);
final Runnable onClose = new TargetStatsClosure(sdt, table.getTypeName(), numTables, snapshotRecord);
sdt.setOnCloseHandler(onClose);
return sdt;
}
use of org.voltdb.SnapshotDataTarget in project voltdb by VoltDB.
the class NativeSnapshotWritePlan method createDeferredSetup.
private Callable<Boolean> createDeferredSetup(final String file_path, final String pathType, final String file_nonce, final long txnId, final Map<Integer, Long> partitionTransactionIds, final SystemProcedureExecutionContext context, final ExtensibleSnapshotDigestData extraSnapshotData, final SiteTracker tracker, final HashinatorSnapshotData hashinatorData, final long timestamp, final int newPartitionCount, final Table[] tables, final SnapshotRegistry.Snapshot snapshotRecord, final ArrayList<SnapshotTableTask> partitionedSnapshotTasks, final ArrayList<SnapshotTableTask> replicatedSnapshotTasks, final boolean isTruncationSnapshot) {
return new Callable<Boolean>() {
private final HashMap<Integer, SnapshotDataTarget> m_createdTargets = Maps.newHashMap();
@Override
public Boolean call() throws Exception {
final AtomicInteger numTables = new AtomicInteger(tables.length);
NativeSnapshotWritePlan.createFileBasedCompletionTasks(file_path, pathType, file_nonce, txnId, partitionTransactionIds, context, extraSnapshotData, hashinatorData, timestamp, newPartitionCount, tables);
for (SnapshotTableTask task : replicatedSnapshotTasks) {
SnapshotDataTarget target = getSnapshotDataTarget(numTables, task);
task.setTarget(target);
}
for (SnapshotTableTask task : partitionedSnapshotTasks) {
SnapshotDataTarget target = getSnapshotDataTarget(numTables, task);
task.setTarget(target);
}
if (isTruncationSnapshot) {
// Only sync the DR Log on Native Snapshots
SnapshotSiteProcessor.m_tasksOnSnapshotCompletion.offer(new Runnable() {
@Override
public void run() {
context.forceAllDRNodeBuffersToDisk(false);
}
});
}
// Sync export buffer for all types of snapshot
SnapshotSiteProcessor.m_tasksOnSnapshotCompletion.offer(new Runnable() {
@Override
public void run() {
ExportManager.sync(false);
}
});
return true;
}
private SnapshotDataTarget getSnapshotDataTarget(AtomicInteger numTables, SnapshotTableTask task) throws IOException {
SnapshotDataTarget target = m_createdTargets.get(task.m_table.getRelativeIndex());
if (target == null) {
target = createDataTargetForTable(file_path, file_nonce, task.m_table, txnId, context.getHostId(), context.getCluster().getTypeName(), context.getDatabase().getTypeName(), context.getNumberOfPartitions(), DrRoleType.XDCR.value().equals(context.getCluster().getDrrole()), tracker, timestamp, numTables, snapshotRecord);
m_createdTargets.put(task.m_table.getRelativeIndex(), target);
}
return target;
}
};
}
Aggregations