Search in sources :

Example 1 with ExecutionEngine

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;
}
Also used : HashinatorConfig(org.voltdb.TheHashinator.HashinatorConfig) MockExecutionEngine(org.voltdb.jni.MockExecutionEngine) ExecutionEngine(org.voltdb.jni.ExecutionEngine) ExecutionEngineJNI(org.voltdb.jni.ExecutionEngineJNI) Deployment(org.voltdb.catalog.Deployment) ExecutionEngineIPC(org.voltdb.jni.ExecutionEngineIPC) Method(java.lang.reflect.Method) EEException(org.voltdb.exceptions.EEException) VoltAbortException(org.voltdb.VoltProcedure.VoltAbortException) IOException(java.io.IOException)

Example 2 with ExecutionEngine

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) {
    }
}
Also used : HashinatorConfig(org.voltdb.TheHashinator.HashinatorConfig) ExecutionEngine(org.voltdb.jni.ExecutionEngine) ExecutionEngineJNI(org.voltdb.jni.ExecutionEngineJNI) IOException(java.io.IOException) JSONException(org.json_voltpatches.JSONException) Test(org.junit.Test)

Example 3 with ExecutionEngine

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) {
    }
}
Also used : HashinatorConfig(org.voltdb.TheHashinator.HashinatorConfig) ExecutionEngine(org.voltdb.jni.ExecutionEngine) ExecutionEngineJNI(org.voltdb.jni.ExecutionEngineJNI) IOException(java.io.IOException) JSONException(org.json_voltpatches.JSONException) Test(org.junit.Test)

Example 4 with ExecutionEngine

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) {
        }
    }
}
Also used : HashinatorConfig(org.voltdb.TheHashinator.HashinatorConfig) ExecutionEngine(org.voltdb.jni.ExecutionEngine) ExecutionEngineJNI(org.voltdb.jni.ExecutionEngineJNI) IOException(java.io.IOException) JSONException(org.json_voltpatches.JSONException) Test(org.junit.Test)

Example 5 with ExecutionEngine

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) {
    }
}
Also used : HashinatorConfig(org.voltdb.TheHashinator.HashinatorConfig) ExecutionEngine(org.voltdb.jni.ExecutionEngine) ExecutionEngineJNI(org.voltdb.jni.ExecutionEngineJNI) IOException(java.io.IOException) JSONException(org.json_voltpatches.JSONException) Test(org.junit.Test)

Aggregations

HashinatorConfig (org.voltdb.TheHashinator.HashinatorConfig)10 ExecutionEngine (org.voltdb.jni.ExecutionEngine)10 ExecutionEngineJNI (org.voltdb.jni.ExecutionEngineJNI)10 IOException (java.io.IOException)9 JSONException (org.json_voltpatches.JSONException)8 Test (org.junit.Test)8 File (java.io.File)1 Method (java.lang.reflect.Method)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 VoltAbortException (org.voltdb.VoltProcedure.VoltAbortException)1 TPCCProjectBuilder (org.voltdb.benchmark.tpcc.TPCCProjectBuilder)1 Catalog (org.voltdb.catalog.Catalog)1 Deployment (org.voltdb.catalog.Deployment)1 PlanFragment (org.voltdb.catalog.PlanFragment)1 Procedure (org.voltdb.catalog.Procedure)1 Statement (org.voltdb.catalog.Statement)1 EEException (org.voltdb.exceptions.EEException)1 ExecutionEngineIPC (org.voltdb.jni.ExecutionEngineIPC)1 MockExecutionEngine (org.voltdb.jni.MockExecutionEngine)1 FastDeserializer (org.voltdb.messaging.FastDeserializer)1