Search in sources :

Example 1 with HashinatorConfig

use of org.voltdb.TheHashinator.HashinatorConfig in project voltdb by VoltDB.

the class StatsAgent method collectTopoStats.

private void collectTopoStats(PendingOpsRequest psr, boolean jsonConfig) {
    VoltTable[] tables = null;
    VoltTable topoStats = getStatsAggregate(StatsSelector.TOPO, false, psr.startTime);
    if (topoStats != null) {
        tables = new VoltTable[2];
        tables[0] = topoStats;
        VoltTable vt = new VoltTable(new VoltTable.ColumnInfo("HASHTYPE", VoltType.STRING), new VoltTable.ColumnInfo("HASHCONFIG", VoltType.VARBINARY));
        tables[1] = vt;
        HashinatorConfig hashConfig = TheHashinator.getCurrentConfig();
        if (!jsonConfig) {
            vt.addRow(hashConfig.type.toString(), hashConfig.configBytes);
        } else {
            vt.addRow(hashConfig.type.toString(), TheHashinator.getCurrentHashinator().getConfigJSONCompressed());
        }
    }
    psr.aggregateTables = tables;
    try {
        sendClientResponse(psr);
    } catch (Exception e) {
        VoltDB.crashLocalVoltDB("Unable to return TOPO results to client.", true, e);
    }
}
Also used : HashinatorConfig(org.voltdb.TheHashinator.HashinatorConfig) ColumnInfo(org.voltdb.VoltTable.ColumnInfo)

Example 2 with HashinatorConfig

use of org.voltdb.TheHashinator.HashinatorConfig 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 3 with HashinatorConfig

use of org.voltdb.TheHashinator.HashinatorConfig 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 4 with HashinatorConfig

use of org.voltdb.TheHashinator.HashinatorConfig 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 5 with HashinatorConfig

use of org.voltdb.TheHashinator.HashinatorConfig 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)

Aggregations

HashinatorConfig (org.voltdb.TheHashinator.HashinatorConfig)15 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 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 TPCCProjectBuilder (org.voltdb.benchmark.tpcc.TPCCProjectBuilder)3 ArrayList (java.util.ArrayList)2 BBContainer (org.voltcore.utils.DBBPool.BBContainer)2 Procedure (org.voltdb.catalog.Procedure)2 SnapshotPredicates (org.voltdb.sysprocs.saverestore.SnapshotPredicates)2 File (java.io.File)1 Method (java.lang.reflect.Method)1 VoltAbortException (org.voltdb.VoltProcedure.VoltAbortException)1 VoltTable (org.voltdb.VoltTable)1 ColumnInfo (org.voltdb.VoltTable.ColumnInfo)1 Catalog (org.voltdb.catalog.Catalog)1 Cluster (org.voltdb.catalog.Cluster)1 Deployment (org.voltdb.catalog.Deployment)1