use of org.voltdb.jni.ExecutionEngine in project voltdb by VoltDB.
the class Site method initializeEE.
/** Create a native VoltDB execution engine */
ExecutionEngine initializeEE() {
String hostname = CoreUtils.getHostnameOrAddress();
HashinatorConfig hashinatorConfig = TheHashinator.getCurrentConfig();
ExecutionEngine eeTemp = null;
Deployment deploy = m_context.cluster.getDeployment().get("deployment");
// 512KB
final int defaultDrBufferSize = Integer.getInteger("DR_DEFAULT_BUFFER_SIZE", 512 * 1024);
try {
if (m_backend == BackendTarget.NATIVE_EE_JNI) {
eeTemp = new ExecutionEngineJNI(m_context.cluster.getRelativeIndex(), m_siteId, m_partitionId, CoreUtils.getHostIdFromHSId(m_siteId), hostname, m_context.cluster.getDrclusterid(), defaultDrBufferSize, deploy.getSystemsettings().get("systemsettings").getTemptablemaxsize(), hashinatorConfig, m_hasMPDRGateway);
} else if (m_backend == BackendTarget.NATIVE_EE_SPY_JNI) {
Class<?> spyClass = Class.forName("org.mockito.Mockito");
Method spyMethod = spyClass.getDeclaredMethod("spy", Object.class);
ExecutionEngine internalEE = new ExecutionEngineJNI(m_context.cluster.getRelativeIndex(), m_siteId, m_partitionId, CoreUtils.getHostIdFromHSId(m_siteId), hostname, m_context.cluster.getDrclusterid(), defaultDrBufferSize, m_context.cluster.getDeployment().get("deployment").getSystemsettings().get("systemsettings").getTemptablemaxsize(), hashinatorConfig, m_hasMPDRGateway);
eeTemp = (ExecutionEngine) spyMethod.invoke(null, internalEE);
} else {
// set up the EE over IPC
eeTemp = new ExecutionEngineIPC(m_context.cluster.getRelativeIndex(), m_siteId, m_partitionId, CoreUtils.getHostIdFromHSId(m_siteId), hostname, m_context.cluster.getDrclusterid(), defaultDrBufferSize, deploy.getSystemsettings().get("systemsettings").getTemptablemaxsize(), m_backend, VoltDB.instance().getConfig().m_ipcPort, hashinatorConfig, m_hasMPDRGateway);
}
eeTemp.loadCatalog(m_startupConfig.m_timestamp, m_startupConfig.m_serializedCatalog);
eeTemp.setBatchTimeout(m_context.cluster.getDeployment().get("deployment").getSystemsettings().get("systemsettings").getQuerytimeout());
}// just print error info an bail if we run into an error here
catch (final Exception ex) {
hostLog.l7dlog(Level.FATAL, LogKeys.host_ExecutionSite_FailedConstruction.name(), new Object[] { m_siteId, m_siteIndex }, ex);
VoltDB.crashLocalVoltDB(ex.getMessage(), true, ex);
}
return eeTemp;
}
use of org.voltdb.jni.ExecutionEngine in project voltdb by VoltDB.
the class TestTheHashinator method testSameLongHash1.
@Test
public void testSameLongHash1() throws Exception {
int partitionCount = 2;
TheHashinator.initialize(TheHashinator.getConfiguredHashinatorClass(), TheHashinator.getConfigureBytes(partitionCount));
HashinatorConfig hashinatorConfig = TheHashinator.getCurrentConfig();
ExecutionEngine ee = new ExecutionEngineJNI(1, 1, 0, 0, "", 0, 64 * 1024, 100, hashinatorConfig, false);
long valueToHash = 0;
int eehash = ee.hashinate(valueToHash, hashinatorConfig);
int javahash = TheHashinator.getPartitionForParameter(VoltType.typeFromObject(valueToHash).getValue(), valueToHash);
if (eehash != javahash) {
System.out.printf("Mismatched hash of (%s) %d with %d partitions => EE: %d, Java: %d\n", VoltType.typeFromObject(valueToHash).toSQLString(), valueToHash, partitionCount, eehash, javahash);
}
assertEquals(eehash, javahash);
assertTrue(eehash < partitionCount);
assertTrue(eehash >= 0);
valueToHash = 1;
eehash = ee.hashinate(valueToHash, hashinatorConfig);
javahash = TheHashinator.getPartitionForParameter(VoltType.typeFromObject(valueToHash).getValue(), valueToHash);
if (eehash != javahash) {
System.out.printf("Mismatched hash of (%s) %d with %d partitions => EE: %d, Java: %d\n", VoltType.typeFromObject(valueToHash).toSQLString(), valueToHash, partitionCount, eehash, javahash);
}
assertEquals(eehash, javahash);
assertTrue(eehash < partitionCount);
assertTrue(eehash >= 0);
valueToHash = 2;
eehash = ee.hashinate(valueToHash, hashinatorConfig);
javahash = TheHashinator.getPartitionForParameter(VoltType.typeFromObject(valueToHash).getValue(), valueToHash);
if (eehash != javahash) {
System.out.printf("Mismatched hash of (%s) %d with %d partitions => EE: %d, Java: %d\n", VoltType.typeFromObject(valueToHash).toSQLString(), valueToHash, partitionCount, eehash, javahash);
}
assertEquals(eehash, javahash);
assertTrue(eehash < partitionCount);
assertTrue(eehash >= 0);
valueToHash = 3;
eehash = ee.hashinate(valueToHash, hashinatorConfig);
javahash = TheHashinator.getPartitionForParameter(VoltType.typeFromObject(valueToHash).getValue(), valueToHash);
if (eehash != javahash) {
System.out.printf("Mismatched hash of (%s) %d with %d partitions => EE: %d, Java: %d\n", VoltType.typeFromObject(valueToHash).toSQLString(), valueToHash, partitionCount, eehash, javahash);
}
assertEquals(eehash, javahash);
assertTrue(eehash < partitionCount);
assertTrue(eehash >= 0);
try {
ee.release();
} catch (Exception e) {
}
}
use of org.voltdb.jni.ExecutionEngine in project voltdb by VoltDB.
the class TestTheHashinator method testEdgeCases.
@Test
public void testEdgeCases() throws Exception {
byte[] configBytes = TheHashinator.getConfigureBytes(1);
ExecutionEngine ee = new ExecutionEngineJNI(1, 1, 0, 0, "", 0, 64 * 1024, 100, new HashinatorConfig(hashinatorType, configBytes, 0, 0), false);
/**
* Run with 100k of random values and make sure C++ and Java hash to
* the same value.
*/
for (int i = 0; i < 500; i++) {
int partitionCount = r.nextInt(1000) + 1;
long[] values = new long[] { Long.MIN_VALUE, Long.MAX_VALUE, Long.MAX_VALUE - 1, Long.MIN_VALUE + 1 };
configBytes = TheHashinator.getConfigureBytes(partitionCount);
TheHashinator.initialize(TheHashinator.getConfiguredHashinatorClass(), configBytes);
for (long valueToHash : values) {
int eehash = ee.hashinate(valueToHash, TheHashinator.getCurrentConfig());
int javahash = TheHashinator.getPartitionForParameter(VoltType.typeFromObject(valueToHash).getValue(), valueToHash);
if (eehash != javahash) {
System.out.printf("Mismatched hash of (%s) %d with %d partitions => EE: %d, Java: %d\n", VoltType.typeFromObject(valueToHash).toSQLString(), valueToHash, partitionCount, eehash, javahash);
}
assertEquals(eehash, javahash);
assertTrue(eehash < partitionCount);
assertTrue(eehash >= 0);
}
}
try {
ee.release();
} catch (Exception e) {
}
}
use of org.voltdb.jni.ExecutionEngine in project voltdb by VoltDB.
the class TestTheHashinator method testSizeChanges.
@Test
public void testSizeChanges() {
// try with lots of partition counts
for (int partitionCount = 1; partitionCount <= 11; partitionCount++) {
TheHashinator.initialize(TheHashinator.getConfiguredHashinatorClass(), TheHashinator.getConfigureBytes(partitionCount));
HashinatorConfig hashinatorConfig = TheHashinator.getCurrentConfig();
ExecutionEngine ee = new ExecutionEngineJNI(1, 1, 0, 0, "", 0, 64 * 1024, 100, hashinatorConfig, false);
// use a short value hashed as a long type
for (short valueToHash = -7; valueToHash <= 7; valueToHash++) {
int eehash = ee.hashinate(valueToHash, hashinatorConfig);
int javahash = TheHashinator.getPartitionForParameter(VoltType.BIGINT.getValue(), valueToHash);
if (eehash != javahash) {
System.out.printf("Mismatched hash of (%s) %d with %d partitions => EE: %d, Java: %d\n", VoltType.typeFromObject(valueToHash).toSQLString(), valueToHash, partitionCount, eehash, javahash);
}
assertEquals(eehash, javahash);
assertTrue(eehash < partitionCount);
assertTrue(eehash >= 0);
}
// use a long value hashed as a short type
for (long valueToHash = -7; valueToHash <= 7; valueToHash++) {
int eehash = ee.hashinate(valueToHash, hashinatorConfig);
int javahash = TheHashinator.getPartitionForParameter(VoltType.SMALLINT.getValue(), valueToHash);
if (eehash != javahash) {
System.out.printf("Mismatched hash of (%s) %d with %d partitions => EE: %d, Java: %d\n", VoltType.typeFromObject(valueToHash).toSQLString(), valueToHash, partitionCount, eehash, javahash);
}
assertEquals(eehash, javahash);
assertTrue(eehash < partitionCount);
assertTrue(eehash >= 0);
}
try {
ee.release();
} catch (Exception e) {
}
}
}
use of org.voltdb.jni.ExecutionEngine in project voltdb by VoltDB.
the class TestTheHashinator method testSameLongHash.
@Test
public void testSameLongHash() throws Exception {
byte[] configBytes = TheHashinator.getConfigureBytes(1);
ExecutionEngine ee = new ExecutionEngineJNI(1, 1, 0, 0, "", 0, 64 * 1024, 100, new HashinatorConfig(hashinatorType, configBytes, 0, 0), false);
/**
* Run with 10k of random values and make sure C++ and Java hash to
* the same value.
*/
for (int i = 0; i < 1500; i++) {
final int partitionCount = r.nextInt(1000) + 1;
configBytes = TheHashinator.getConfigureBytes(partitionCount);
TheHashinator.initialize(TheHashinator.getConfiguredHashinatorClass(), configBytes);
// this will produce negative values, which is desired here.
final long valueToHash = r.nextLong();
final int javahash = TheHashinator.getPartitionForParameter(VoltType.typeFromObject(valueToHash).getValue(), valueToHash);
final int eehash = ee.hashinate(valueToHash, TheHashinator.getCurrentConfig());
if (eehash != javahash) {
System.out.printf("Mismatched hash of (%s) %d with %d partitions => EE: %d, Java: %d\n", VoltType.typeFromObject(valueToHash).toSQLString(), valueToHash, partitionCount, eehash, javahash);
}
assertEquals(eehash, javahash);
assertTrue(eehash < partitionCount);
assertTrue(eehash > -1);
}
try {
ee.release();
} catch (Exception e) {
}
}
Aggregations