use of org.voltdb.sysprocs.saverestore.HashinatorSnapshotData in project voltdb by VoltDB.
the class TestTheHashinator method testSaveRestoreRaw.
@Test
public void testSaveRestoreRaw() throws Exception {
if (hashinatorType == HashinatorType.LEGACY)
return;
ElasticHashinator h1 = new ElasticHashinator(ElasticHashinator.getConfigureBytes(3, ElasticHashinator.DEFAULT_TOTAL_TOKENS), false);
byte[] bytes = h1.getConfigBytes();
HashinatorSnapshotData d1 = new HashinatorSnapshotData(bytes, 1234);
InstanceId iid1 = new InstanceId(111, 222);
ByteBuffer b1 = d1.saveToBuffer(iid1);
ByteBuffer b2 = ByteBuffer.wrap(b1.array());
HashinatorSnapshotData d2 = new HashinatorSnapshotData();
InstanceId iid2 = d2.restoreFromBuffer(b2);
assertEquals(iid1, iid2);
assertTrue(Arrays.equals(d1.m_serData, d2.m_serData));
ElasticHashinator h2 = new ElasticHashinator(d2.m_serData, false);
assertEquals(h1.getTokens(), h2.getTokens());
}
use of org.voltdb.sysprocs.saverestore.HashinatorSnapshotData in project voltdb by VoltDB.
the class TheHashinator method serializeConfiguredHashinator.
/**
* Get optimized configuration data for wire serialization.
* @return optimized configuration data
* @throws IOException
*/
public static HashinatorSnapshotData serializeConfiguredHashinator() throws IOException {
HashinatorSnapshotData hashData = null;
Pair<Long, ? extends TheHashinator> currentInstance = instance.get();
switch(getConfiguredHashinatorType()) {
case LEGACY:
break;
case ELASTIC:
{
byte[] cookedData = currentInstance.getSecond().getCookedBytes();
hashData = new HashinatorSnapshotData(cookedData, currentInstance.getFirst());
break;
}
}
return hashData;
}
Aggregations