Search in sources :

Example 21 with ServerThread

use of org.voltdb.ServerThread in project voltdb by VoltDB.

the class TestJDBCSecurityEnabled method startServer.

private static void startServer() throws ClassNotFoundException, SQLException {
    server = new ServerThread(testjar, pb.getPathToDeployment(), BackendTarget.NATIVE_EE_JNI);
    server.start();
    server.waitForInitialization();
    Class.forName("org.voltdb.jdbc.Driver");
    if (ClientConfig.ENABLE_SSL_FOR_TEST) {
        conn = DriverManager.getConnection("jdbc:voltdb://localhost:21212?" + JDBCTestCommons.SSL_URL_SUFFIX, "defaultadmin", "admin");
    } else {
        conn = DriverManager.getConnection("jdbc:voltdb://localhost:21212", "defaultadmin", "admin");
    }
    myconn = null;
}
Also used : ServerThread(org.voltdb.ServerThread)

Example 22 with ServerThread

use of org.voltdb.ServerThread in project voltdb by VoltDB.

the class TestSqlCmdErrorHandling method setUp.

@Override
public void setUp() throws Exception {
    String[] mytype = new String[] { "integer", "varbinary", "decimal", "float" };
    String simpleSchema = "create table intkv (" + "  key integer, " + "  myinteger integer default 0, " + "  myvarbinary varbinary default 'ff', " + "  mydecimal decimal default 10.10, " + "  myfloat float default 9.9, " + "  PRIMARY KEY(key) );" + "\n" + "";
    // Define procs that to complain when sqlcmd passes them garbage parameters.
    for (String type : mytype) {
        simpleSchema += "create procedure myfussy_" + type + "_proc as" + " insert into intkv (key, my" + type + ") values (?, ?);" + "\n";
    }
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema(simpleSchema);
    builder.setUseDDLSchema(false);
    String catalogPath = Configuration.getPathToCatalogForTest("sqlcmderror.jar");
    assertTrue(builder.compile(catalogPath, 1, 1, 0));
    VoltDB.Configuration config = new VoltDB.Configuration();
    config.m_pathToCatalog = catalogPath;
    config.m_pathToDeployment = builder.getPathToDeployment();
    m_server = new ServerThread(config);
    m_server.start();
    m_server.waitForInitialization();
    m_client = ClientFactory.createClient();
    m_client.createConnection("localhost");
    assertEquals("sqlcmd dry run failed -- maybe some sqlcmd component (the voltdb jar file?) needs to be rebuilt.", 0, callSQLcmd(true, ";\n"));
    assertEquals("sqlcmd --stop-on-error=false dry run failed.", 0, callSQLcmd(false, ";\n"));
    // Execute the constrained write to end all constrained writes.
    // This poisons all future executions of the badWriteCommand() query.
    ClientResponse response = m_client.callProcedure("@AdHoc", badWriteCommand());
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    VoltTable[] results = response.getResults();
    assertEquals(1, results.length);
    VoltTable result = results[0];
    assertEquals(1, result.asScalarLong());
    // Assert that the procs don't complain when fed good parameters.
    // Keep these dry run key values out of range of the test cases.
    // Also make sure they have an even number of digits so they can be used as hex byte values.
    int goodValue = 1000;
    for (String type : mytype) {
        response = m_client.callProcedure("myfussy_" + type + "_proc", goodValue, "" + goodValue);
        // keeping keys unique
        ++goodValue;
        assertEquals(ClientResponse.SUCCESS, response.getStatus());
        results = response.getResults();
        assertEquals(1, results.length);
        result = results[0];
        assertEquals(1, result.asScalarLong());
    }
}
Also used : VoltDB(org.voltdb.VoltDB) ClientResponse(org.voltdb.client.ClientResponse) Configuration(org.voltdb.VoltDB.Configuration) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration) ServerThread(org.voltdb.ServerThread) VoltTable(org.voltdb.VoltTable)

Example 23 with ServerThread

use of org.voltdb.ServerThread in project voltdb by VoltDB.

the class TestVoltBulkLoader method test_multiplexing.

public void test_multiplexing(String my_schema, boolean multipleClients, boolean multipleLoaders, boolean multiPartTable, String my_tableName1, Object[][] my_data1, int my_batchSize1, ArrayList<Integer> expectedFailList1, boolean abort1, boolean upsert1, String my_tableName2, Object[][] my_data2, int my_batchSize2, ArrayList<Integer> expectedFailList2, boolean abort2, boolean upsert2) throws Exception {
    try {
        pathToCatalog = Configuration.getPathToCatalogForTest("vbl.jar");
        pathToDeployment = Configuration.getPathToCatalogForTest("vbl.xml");
        builder = new VoltProjectBuilder();
        builder.addLiteralSchema(my_schema);
        boolean sameTable = my_tableName1.equals(my_tableName2);
        assert (!(abort1 && abort2));
        if (abort1 || abort2)
            // No point in testing abort with a single loader
            assert (multipleLoaders);
        if (!multiPartTable) {
            builder.addPartitionInfo(my_tableName1, "clm_integer");
            if (!sameTable)
                builder.addPartitionInfo(my_tableName2, "clm_integer");
        }
        boolean success = builder.compile(pathToCatalog, 2, 1, 0);
        assertTrue(success);
        MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
        config = new VoltDB.Configuration();
        config.m_pathToCatalog = pathToCatalog;
        config.m_pathToDeployment = pathToDeployment;
        localServer = new ServerThread(config);
        client1 = null;
        client2 = null;
        localServer.start();
        localServer.waitForInitialization();
        client1 = ClientFactory.createClient();
        client1.createConnection("localhost");
        if (multipleClients) {
            client2 = ClientFactory.createClient();
            client2.createConnection("localhost");
            // This is implicit
            multipleLoaders = true;
        } else
            client2 = client1;
        prepare();
        TestFailureCallback testCallback1 = new TestFailureCallback();
        TestFailureCallback testCallback2 = new TestFailureCallback();
        VoltBulkLoader bulkLoader1 = client1.getNewBulkLoader(my_tableName1, my_batchSize1, upsert1, testCallback1);
        VoltBulkLoader bulkLoader2;
        if (multipleLoaders) {
            bulkLoader2 = client2.getNewBulkLoader(my_tableName2, my_batchSize2, upsert2, testCallback2);
            if (!multipleClients && sameTable) {
                assert (bulkLoader1.getMaxBatchSize() == Math.min(my_batchSize1, my_batchSize2));
                assert (bulkLoader1.getMaxBatchSize() == bulkLoader2.getMaxBatchSize());
            }
        } else
            bulkLoader2 = bulkLoader1;
        // do the test
        VoltTable modCount1;
        modCount1 = client1.callProcedure("@AdHoc", "SELECT * FROM " + my_tableName1 + ";").getResults()[0];
        System.out.println("data inserted to table " + my_tableName1 + ":\n" + modCount1);
        // Call validate partitioning to check if we are good.
        VoltTable valTable1;
        valTable1 = client1.callProcedure("@ValidatePartitioning", null, null).getResults()[0];
        System.out.println("Validate for " + my_tableName1 + ":\n" + valTable1);
        while (valTable1.advanceRow()) {
            long miscnt = valTable1.getLong("MISPARTITIONED_ROWS");
            assertEquals(miscnt, 0);
        }
        if (multipleClients) {
            VoltTable modCount2;
            modCount2 = client2.callProcedure("@AdHoc", "SELECT * FROM " + my_tableName2 + ";").getResults()[0];
            System.out.println("data inserted to table " + my_tableName2 + ":\n" + modCount2);
            // Call validate partitioning to check if we are good.
            VoltTable valTable2;
            valTable2 = client2.callProcedure("@ValidatePartitioning", null, null).getResults()[0];
            System.out.println("Validate for " + my_tableName1 + ":\n" + valTable2);
            while (valTable2.advanceRow()) {
                long miscnt = valTable2.getLong("MISPARTITIONED_ROWS");
                assertEquals(miscnt, 0);
            }
        }
        int rowCnt1 = 1;
        int rowCnt2 = 1;
        try {
            while (rowCnt1 <= my_data1.length || rowCnt2 <= my_data2.length) {
                if (rowCnt1 <= my_data1.length) {
                    Integer rowId = new Integer(rowCnt1);
                    bulkLoader1.insertRow(rowId, my_data1[rowCnt1 - 1]);
                    rowCnt1++;
                //                      if (rnd.nextInt() % 30 == 0)
                //                          //  Randomly inject a flush
                //                          bulkLoader1.flush();
                }
                if (rowCnt2 <= my_data2.length) {
                    Integer rowId = new Integer(rowCnt2);
                    bulkLoader2.insertRow(rowId, my_data2[rowCnt2 - 1]);
                    rowCnt2++;
                //                      if (rnd.nextInt() % 30 == 0)
                //                          //  Randomly inject a flush
                //                          bulkLoader2.flush();
                }
            }
        } catch (Exception e) {
            System.err.print(e.getMessage());
        }
        System.out.println(String.format("Attempted inserting %d rows in Table %s and %d rows in Table %s", --rowCnt1, my_tableName1, --rowCnt2, my_tableName2));
        if (!abort1 && rnd.nextInt() % 4 == 0) {
            // One in 4 tests generate a sync and VoltBulkLoader internal state verification
            bulkLoader1.drain();
            assert (bulkLoader1.getOutstandingRowCount() == 0);
            assert (bulkLoader1.getCompletedRowCount() == rowCnt1);
        }
        if (multipleLoaders && !abort2 && rnd.nextInt() % 4 == 0) {
            bulkLoader2.drain();
            assert (bulkLoader2.getOutstandingRowCount() == 0);
            assert (bulkLoader2.getCompletedRowCount() == rowCnt2);
        }
        bulkLoader1.close();
        if (multipleLoaders)
            bulkLoader2.close();
        assert (abort1 || testCallback1.failureRowListMatches(expectedFailList1));
        assert (abort2 || testCallback2.failureRowListMatches(expectedFailList2));
    } finally {
        if (client1 != null) {
            client1.close();
            if (multipleClients && client2 != null) {
                client2.close();
                client2 = null;
            }
            client1 = null;
        }
        if (localServer != null) {
            localServer.shutdown();
            localServer.join();
        }
        localServer = null;
        // no clue how helpful this is
        System.gc();
    }
}
Also used : VoltDB(org.voltdb.VoltDB) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration) ServerThread(org.voltdb.ServerThread) VoltBulkLoader(org.voltdb.client.VoltBulkLoader.VoltBulkLoader) VoltTable(org.voltdb.VoltTable)

Example 24 with ServerThread

use of org.voltdb.ServerThread in project voltdb by VoltDB.

the class TestJDBCLoader method startDatabase.

@BeforeClass
public static void startDatabase() throws Exception {
    prepare();
    String pathToCatalog = Configuration.getPathToCatalogForTest("csv.jar");
    String pathToDeployment = Configuration.getPathToCatalogForTest("csv.xml");
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema("create table BLAH (" + "clm_integer integer not null, " + "clm_tinyint tinyint default 0, " + "clm_smallint smallint default 0, " + "clm_bigint bigint default 0, " + "clm_string varchar(20) default null, " + "clm_decimal decimal default null, " + "clm_float float default null, " + "clm_timestamp timestamp default null, " + "PRIMARY KEY(clm_integer) " + ");\n" + "create table JBLAH (" + "clm_integer integer not null, " + "clm_tinyint tinyint default 0, " + "clm_smallint smallint default 0, " + "clm_bigint bigint default 0, " + "clm_string varchar(16) default null, " + "clm_decimal decimal default null, " + "clm_float float default null, " + "clm_timestamp timestamp default null, " + "PRIMARY KEY(clm_integer) " + ");");
    builder.addPartitionInfo("BLAH", "clm_integer");
    builder.addPartitionInfo("JBLAH", "clm_integer");
    boolean success = builder.compile(pathToCatalog, 2, 1, 0);
    assertTrue(success);
    MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
    Configuration config = new Configuration();
    config.m_pathToCatalog = pathToCatalog;
    config.m_pathToDeployment = pathToDeployment;
    localServer = new ServerThread(config);
    client = null;
    localServer.start();
    localServer.waitForInitialization();
    client = ClientFactory.createClient(new ClientConfig());
    client.createConnection("localhost");
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) ServerThread(org.voltdb.ServerThread) ClientConfig(org.voltdb.client.ClientConfig) BeforeClass(org.junit.BeforeClass)

Example 25 with ServerThread

use of org.voltdb.ServerThread in project voltdb by VoltDB.

the class LocalCluster method initLocalServer.

void initLocalServer(int hostId, boolean clearLocalDataDirectories) throws IOException {
    // Make the local Configuration object...
    CommandLine cmdln = (templateCmdLine.makeCopy());
    cmdln.startCommand(StartAction.INITIALIZE);
    cmdln.setJavaProperty(clusterHostIdProperty, String.valueOf(hostId));
    if (this.m_additionalProcessEnv != null) {
        for (String name : this.m_additionalProcessEnv.keySet()) {
            cmdln.setJavaProperty(name, this.m_additionalProcessEnv.get(name));
        }
    }
    if (new Integer(hostId).equals(m_mismatchNode)) {
        assert m_usesStagedSchema;
        cmdln.m_userSchema = m_mismatchSchema == null ? null : VoltProjectBuilder.createFileForSchema(m_mismatchSchema);
    }
    cmdln.setForceVoltdbCreate(clearLocalDataDirectories);
    //If we are initializing lets wait for it to finish.
    ServerThread th = new ServerThread(cmdln);
    File root = VoltFile.getServerSpecificRoot(String.valueOf(hostId), clearLocalDataDirectories);
    assert (root.getName().equals(Constants.DBROOT) == false) : root.getAbsolutePath();
    cmdln.voltdbRoot(new File(root, Constants.DBROOT));
    try {
        th.initialize();
    } catch (VoltDB.SimulatedExitException expected) {
    //All ok
    } catch (Exception ex) {
        log.error("Failed to initialize cluster process:" + ex.getMessage(), ex);
        assert (false);
    }
    //Keep track by hostid the voltdbroot
    String hostIdStr = cmdln.getJavaProperty(clusterHostIdProperty);
    m_hostRoots.put(hostIdStr, root.getAbsolutePath());
}
Also used : VoltDB(org.voltdb.VoltDB) CommandLine(org.voltdb.utils.CommandLine) ServerThread(org.voltdb.ServerThread) VoltFile(org.voltdb.utils.VoltFile) File(java.io.File) IOException(java.io.IOException)

Aggregations

ServerThread (org.voltdb.ServerThread)36 Configuration (org.voltdb.VoltDB.Configuration)24 VoltDB (org.voltdb.VoltDB)16 File (java.io.File)12 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)12 VoltTable (org.voltdb.VoltTable)9 Client (org.voltdb.client.Client)7 ClientResponse (org.voltdb.client.ClientResponse)6 IOException (java.io.IOException)5 ClientConfig (org.voltdb.client.ClientConfig)5 DeploymentBuilder (org.voltdb.compiler.DeploymentBuilder)5 BeforeClass (org.junit.BeforeClass)2 ClientResponseImpl (org.voltdb.ClientResponseImpl)2 TableHelper (org.voltdb.TableHelper)2 TPCCProjectBuilder (org.voltdb.benchmark.tpcc.TPCCProjectBuilder)2 ProcCallException (org.voltdb.client.ProcCallException)2 VoltBulkLoader (org.voltdb.client.VoltBulkLoader.VoltBulkLoader)2 CatalogBuilder (org.voltdb.compiler.CatalogBuilder)2 DeploymentType (org.voltdb.compiler.deploymentfile.DeploymentType)2 CommandLine (org.voltdb.utils.CommandLine)2