Search in sources :

Example 21 with TPCCProjectBuilder

use of org.voltdb.benchmark.tpcc.TPCCProjectBuilder in project voltdb by VoltDB.

the class TestTwoSitePlans method setUp.

@SuppressWarnings("deprecation")
@Override
public void setUp() throws IOException, InterruptedException {
    VoltDB.instance().readBuildInfo("Test");
    // compile a catalog
    String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
    String catalogJar = testDir + File.separator + JAR;
    TPCCProjectBuilder pb = new TPCCProjectBuilder();
    pb.addDefaultSchema();
    pb.addDefaultPartitioning();
    pb.addProcedures(MultiSiteSelect.class, InsertNewOrder.class);
    pb.compile(catalogJar, 2, 0);
    // load a catalog
    byte[] bytes = MiscUtils.fileToBytes(new File(catalogJar));
    String serializedCatalog = CatalogUtil.getSerializedCatalogStringFromJar(CatalogUtil.loadAndUpgradeCatalogFromJar(bytes, false).getFirst());
    // create the catalog (that will be passed to the ClientInterface
    catalog = new Catalog();
    catalog.execute(serializedCatalog);
    // update the catalog with the data from the deployment file
    String pathToDeployment = pb.getPathToDeployment();
    assertTrue(CatalogUtil.compileDeployment(catalog, pathToDeployment, false) == null);
    cluster = catalog.getClusters().get("cluster");
    CatalogMap<Procedure> procedures = cluster.getDatabases().get("database").getProcedures();
    Procedure insertProc = procedures.get("InsertNewOrder");
    assert (insertProc != null);
    selectProc = procedures.get("MultiSiteSelect");
    assert (selectProc != null);
    // Each EE needs its own thread for correct initialization.
    final AtomicReference<ExecutionEngine> site1Reference = new AtomicReference<ExecutionEngine>();
    final byte[] configBytes = LegacyHashinator.getConfigureBytes(2);
    Thread site1Thread = new Thread() {

        @Override
        public void run() {
            site1Reference.set(new ExecutionEngineJNI(cluster.getRelativeIndex(), 1, 0, 0, "", 0, 64 * 1024, 100, new HashinatorConfig(HashinatorType.LEGACY, configBytes, 0, 0), false));
        }
    };
    site1Thread.start();
    site1Thread.join();
    final AtomicReference<ExecutionEngine> site2Reference = new AtomicReference<ExecutionEngine>();
    Thread site2Thread = new Thread() {

        @Override
        public void run() {
            site2Reference.set(new ExecutionEngineJNI(cluster.getRelativeIndex(), 2, 1, 0, "", 0, 64 * 1024, 100, new HashinatorConfig(HashinatorType.LEGACY, configBytes, 0, 0), false));
        }
    };
    site2Thread.start();
    site2Thread.join();
    // create two EEs
    ee1 = site1Reference.get();
    ee1.loadCatalog(0, catalog.serialize());
    ee2 = site2Reference.get();
    ee2.loadCatalog(0, catalog.serialize());
    // cache some plan fragments
    selectStmt = selectProc.getStatements().get("selectAll");
    assert (selectStmt != null);
    int i = 0;
    // this kinda assumes the right order
    for (PlanFragment f : selectStmt.getFragments()) {
        if (i == 0)
            selectTopFrag = f;
        else
            selectBottomFrag = f;
        i++;
    }
    assert (selectTopFrag != null);
    assert (selectBottomFrag != null);
    if (selectTopFrag.getHasdependencies() == false) {
        PlanFragment temp = selectTopFrag;
        selectTopFrag = selectBottomFrag;
        selectBottomFrag = temp;
    }
    // get the insert frag
    Statement insertStmt = insertProc.getStatements().get("insert");
    assert (insertStmt != null);
    for (PlanFragment f : insertStmt.getFragments()) insertFrag = f;
    // populate plan cache
    ActivePlanRepository.clear();
    ActivePlanRepository.addFragmentForTest(CatalogUtil.getUniqueIdForFragment(selectBottomFrag), Encoder.decodeBase64AndDecompressToBytes(selectBottomFrag.getPlannodetree()), selectStmt.getSqltext());
    ActivePlanRepository.addFragmentForTest(CatalogUtil.getUniqueIdForFragment(selectTopFrag), Encoder.decodeBase64AndDecompressToBytes(selectTopFrag.getPlannodetree()), selectStmt.getSqltext());
    ActivePlanRepository.addFragmentForTest(CatalogUtil.getUniqueIdForFragment(insertFrag), Encoder.decodeBase64AndDecompressToBytes(insertFrag.getPlannodetree()), insertStmt.getSqltext());
    // insert some data
    ParameterSet params = ParameterSet.fromArrayNoCopy(1L, 1L, 1L);
    FastDeserializer fragResult2 = ee2.executePlanFragments(1, new long[] { CatalogUtil.getUniqueIdForFragment(insertFrag) }, null, new ParameterSet[] { params }, null, new String[] { selectStmt.getSqltext() }, null, null, 1, 1, 0, 42, Long.MAX_VALUE, false);
    // ignore totalsize field in message
    fragResult2.readInt();
    VoltTable[] results = TableHelper.convertBackedBufferToTables(fragResult2.buffer(), 1);
    assert (results[0].asScalarLong() == 1L);
    params = ParameterSet.fromArrayNoCopy(2L, 2L, 2L);
    FastDeserializer fragResult1 = ee1.executePlanFragments(1, new long[] { CatalogUtil.getUniqueIdForFragment(insertFrag) }, null, new ParameterSet[] { params }, null, new String[] { selectStmt.getSqltext() }, null, null, 2, 2, 1, 42, Long.MAX_VALUE, false);
    // ignore totalsize field in message
    fragResult1.readInt();
    results = TableHelper.convertBackedBufferToTables(fragResult1.buffer(), 1);
    assert (fragResult1.buffer() != fragResult2.buffer());
    assert (results[0].asScalarLong() == 1L);
}
Also used : HashinatorConfig(org.voltdb.TheHashinator.HashinatorConfig) ExecutionEngineJNI(org.voltdb.jni.ExecutionEngineJNI) FastDeserializer(org.voltdb.messaging.FastDeserializer) Statement(org.voltdb.catalog.Statement) AtomicReference(java.util.concurrent.atomic.AtomicReference) Catalog(org.voltdb.catalog.Catalog) PlanFragment(org.voltdb.catalog.PlanFragment) ExecutionEngine(org.voltdb.jni.ExecutionEngine) Procedure(org.voltdb.catalog.Procedure) TPCCProjectBuilder(org.voltdb.benchmark.tpcc.TPCCProjectBuilder) File(java.io.File)

Example 22 with TPCCProjectBuilder

use of org.voltdb.benchmark.tpcc.TPCCProjectBuilder in project voltdb by VoltDB.

the class TPCCDebugTest method setUp.

@Override
public void setUp() throws IOException {
    Class<?>[] procedures = ALL_PROCEDURES;
    int siteCount = 1;
    BackendTarget target = BackendTarget.NATIVE_EE_JNI;
    String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
    String catalogJar = testDir + File.separator + JAR;
    TPCCProjectBuilder pb = new TPCCProjectBuilder();
    pb.addDefaultSchema();
    pb.addDefaultPartitioning();
    pb.addProcedures(procedures);
    pb.addSupplementalClasses(SUPPLEMENTALS);
    pb.compile(catalogJar, siteCount, 0);
    // start VoltDB server using hzsqlsb backend
    server = new ServerThread(catalogJar, pb.getPathToDeployment(), target);
    server.start();
    server.waitForInitialization();
    ClientConfig clientConfig = new ClientConfig("program", "none");
    client = ClientFactory.createClient(clientConfig);
    // connect
    client.createConnection("localhost");
}
Also used : ServerThread(org.voltdb.ServerThread) BackendTarget(org.voltdb.BackendTarget) ClientConfig(org.voltdb.client.ClientConfig) TPCCProjectBuilder(org.voltdb.benchmark.tpcc.TPCCProjectBuilder)

Example 23 with TPCCProjectBuilder

use of org.voltdb.benchmark.tpcc.TPCCProjectBuilder in project voltdb by VoltDB.

the class TestMultiPartitionSuite method suite.

/**
     * Build a list of the tests that will be run when TestTPCCSuite gets run by JUnit.
     * Use helper classes that are part of the RegressionSuite framework.
     * This particular class runs all tests on the the local JNI backend with both
     * one and two partition configurations, as well as on the hsql backend.
     *
     * @return The TestSuite containing all the tests to be run.
     */
public static Test suite() {
    // the suite made here will all be using the tests from this class
    MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestMultiPartitionSuite.class);
    /////////////////////////////////////////////////////////////
    // CONFIG #1: 1 Local Site/Partitions running on JNI backend
    /////////////////////////////////////////////////////////////
    // get a server config for the native backend with one sites/partitions
    VoltServerConfig config = new LocalCluster("distregression-onesite.jar", 1, 1, 0, BackendTarget.NATIVE_EE_JNI);
    // build up a project builder for the workload
    TPCCProjectBuilder project = new TPCCProjectBuilder();
    project.addDefaultSchema();
    project.addDefaultPartitioning();
    project.addProcedures(PROCEDURES);
    project.addStmtProcedure("InsertNewOrder", "INSERT INTO NEW_ORDER VALUES (?, ?, ?);", "NEW_ORDER.NO_W_ID: 2");
    // build the jarfile
    boolean success = config.compile(project);
    assertTrue(success);
    // add this config to the set of tests to run
    builder.addServerConfig(config);
    /////////////////////////////////////////////////////////////
    // CONFIG #2: 1 Local Site/Partition running on HSQL backend
    /////////////////////////////////////////////////////////////
    // get a server config that similar, but doesn't use the same backend
    config = new LocalCluster("distregression-hsql.jar", 1, 1, 0, BackendTarget.HSQLDB_BACKEND);
    // build the jarfile (note the reuse of the TPCC project)
    success = config.compile(project);
    assertTrue(success);
    // add this config to the set of tests to run
    builder.addServerConfig(config);
    /////////////////////////////////////////////////////////////
    // CONFIG #3: N=3 K=1 Cluster
    /////////////////////////////////////////////////////////////
    config = new LocalCluster("distregression-cluster.jar", 2, 3, 1, BackendTarget.NATIVE_EE_JNI);
    success = config.compile(project);
    assertTrue(success);
    builder.addServerConfig(config);
    return builder;
}
Also used : TPCCProjectBuilder(org.voltdb.benchmark.tpcc.TPCCProjectBuilder)

Aggregations

TPCCProjectBuilder (org.voltdb.benchmark.tpcc.TPCCProjectBuilder)23 File (java.io.File)6 Catalog (org.voltdb.catalog.Catalog)4 UserInfo (org.voltdb.compiler.VoltProjectBuilder.UserInfo)4 IOException (java.io.IOException)3 HashinatorConfig (org.voltdb.TheHashinator.HashinatorConfig)3 RoleInfo (org.voltdb.compiler.VoltProjectBuilder.RoleInfo)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ServerThread (org.voltdb.ServerThread)2 Procedure (org.voltdb.catalog.Procedure)2 Client (org.voltdb.client.Client)2 ClientConfig (org.voltdb.client.ClientConfig)2 ProcedureInfo (org.voltdb.compiler.VoltProjectBuilder.ProcedureInfo)2 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)2 Date (java.util.Date)1 Properties (java.util.Properties)1 Callable (java.util.concurrent.Callable)1 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 ExecutorService (java.util.concurrent.ExecutorService)1