use of org.voltdb.sysprocs.saverestore.SnapshotPredicates in project voltdb by VoltDB.
the class TestExecutionEngine method testStreamTables.
public void testStreamTables() throws Exception {
sourceEngine.loadCatalog(0, m_catalog.serialize());
// Each EE needs its own thread for correct initialization.
final AtomicReference<ExecutionEngine> destinationEngine = new AtomicReference<ExecutionEngine>();
final byte[] configBytes = LegacyHashinator.getConfigureBytes(1);
Thread destEEThread = new Thread() {
@Override
public void run() {
destinationEngine.set(new ExecutionEngineJNI(CLUSTER_ID, NODE_ID, 0, 0, "", 0, 64 * 1024, 100, new HashinatorConfig(HashinatorType.LEGACY, configBytes, 0, 0), false));
}
};
destEEThread.start();
destEEThread.join();
destinationEngine.get().loadCatalog(0, m_catalog.serialize());
int WAREHOUSE_TABLEID = warehouseTableId(m_catalog);
int STOCK_TABLEID = stockTableId(m_catalog);
loadTestTables(sourceEngine, m_catalog);
sourceEngine.activateTableStream(WAREHOUSE_TABLEID, TableStreamType.RECOVERY, Long.MAX_VALUE, new SnapshotPredicates(-1).toBytes());
sourceEngine.activateTableStream(STOCK_TABLEID, TableStreamType.RECOVERY, Long.MAX_VALUE, new SnapshotPredicates(-1).toBytes());
final BBContainer origin = DBBPool.allocateDirect(1024 * 1024 * 2);
origin.b().clear();
final BBContainer container = new BBContainer(origin.b()) {
@Override
public void discard() {
checkDoubleFree();
origin.discard();
}
};
try {
List<BBContainer> output = new ArrayList<BBContainer>();
output.add(container);
int serialized = sourceEngine.tableStreamSerializeMore(WAREHOUSE_TABLEID, TableStreamType.RECOVERY, output).getSecond()[0];
assertTrue(serialized > 0);
container.b().limit(serialized);
destinationEngine.get().processRecoveryMessage(container.b(), container.address());
serialized = sourceEngine.tableStreamSerializeMore(WAREHOUSE_TABLEID, TableStreamType.RECOVERY, output).getSecond()[0];
assertEquals(5, serialized);
assertEquals(RecoveryMessageType.Complete.ordinal(), container.b().get());
assertEquals(sourceEngine.tableHashCode(WAREHOUSE_TABLEID), destinationEngine.get().tableHashCode(WAREHOUSE_TABLEID));
container.b().clear();
serialized = sourceEngine.tableStreamSerializeMore(STOCK_TABLEID, TableStreamType.RECOVERY, output).getSecond()[0];
assertTrue(serialized > 0);
container.b().limit(serialized);
destinationEngine.get().processRecoveryMessage(container.b(), container.address());
serialized = sourceEngine.tableStreamSerializeMore(STOCK_TABLEID, TableStreamType.RECOVERY, output).getSecond()[0];
assertEquals(5, serialized);
assertEquals(RecoveryMessageType.Complete.ordinal(), container.b().get());
assertEquals(STOCK_TABLEID, container.b().getInt());
assertEquals(sourceEngine.tableHashCode(STOCK_TABLEID), destinationEngine.get().tableHashCode(STOCK_TABLEID));
} finally {
container.discard();
}
}
use of org.voltdb.sysprocs.saverestore.SnapshotPredicates in project voltdb by VoltDB.
the class TestExecutionEngine method testStreamIndex.
public void testStreamIndex() throws Exception {
sourceEngine.loadCatalog(0, m_catalog.serialize());
// Each EE needs its own thread for correct initialization.
final AtomicReference<ExecutionEngine> destinationEngine = new AtomicReference<ExecutionEngine>();
final byte[] configBytes = LegacyHashinator.getConfigureBytes(1);
Thread destEEThread = new Thread() {
@Override
public void run() {
destinationEngine.set(new ExecutionEngineJNI(CLUSTER_ID, NODE_ID, 0, 0, "", 0, 64 * 1024, 100, new HashinatorConfig(HashinatorType.LEGACY, configBytes, 0, 0), false));
}
};
destEEThread.start();
destEEThread.join();
destinationEngine.get().loadCatalog(0, m_catalog.serialize());
int STOCK_TABLEID = stockTableId(m_catalog);
loadTestTables(sourceEngine, m_catalog);
SnapshotPredicates predicates = new SnapshotPredicates(-1);
predicates.addPredicate(new HashRangeExpressionBuilder().put(0x00000000, 0x7fffffff).build(0), true);
// Build the index
sourceEngine.activateTableStream(STOCK_TABLEID, TableStreamType.ELASTIC_INDEX, Long.MAX_VALUE, predicates.toBytes());
// Humor serializeMore() by providing a buffer, even though it's not used.
final BBContainer origin = DBBPool.allocateDirect(1024 * 1024 * 2);
origin.b().clear();
BBContainer container = new BBContainer(origin.b()) {
@Override
public void discard() {
checkDoubleFree();
origin.discard();
}
};
try {
List<BBContainer> output = new ArrayList<BBContainer>();
output.add(container);
assertEquals(0, sourceEngine.tableStreamSerializeMore(STOCK_TABLEID, TableStreamType.ELASTIC_INDEX, output).getSecond()[0]);
} finally {
container.discard();
}
}
use of org.voltdb.sysprocs.saverestore.SnapshotPredicates in project voltdb by VoltDB.
the class SnapshotSiteProcessor method makeTablesAndPredicatesToSnapshot.
private Map<Integer, byte[]> makeTablesAndPredicatesToSnapshot(Collection<SnapshotTableTask> tasks) {
Map<Integer, SnapshotPredicates> tablesAndPredicates = Maps.newHashMap();
Map<Integer, byte[]> predicateBytes = Maps.newHashMap();
for (SnapshotTableTask task : tasks) {
SNAP_LOG.debug("Examining SnapshotTableTask: " + task);
// Add the task to the task list for the given table
m_snapshotTableTasks.put(task.m_table.getRelativeIndex(), task);
// Make sure there is a predicate object for each table, the predicate could contain
// empty expressions. So activateTableStream() doesn't have to do a null check.
SnapshotPredicates predicates = tablesAndPredicates.get(task.m_table.getRelativeIndex());
if (predicates == null) {
predicates = new SnapshotPredicates(task.m_table.getRelativeIndex());
tablesAndPredicates.put(task.m_table.getRelativeIndex(), predicates);
}
predicates.addPredicate(task.m_predicate, task.m_deleteTuples);
}
for (Map.Entry<Integer, SnapshotPredicates> e : tablesAndPredicates.entrySet()) {
predicateBytes.put(e.getKey(), e.getValue().toBytes());
}
return predicateBytes;
}
Aggregations