Search in sources :

Example 81 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestStatisticsSuiteDatabaseElementStats method testInvalidCalls.

public void testInvalidCalls() throws Exception {
    System.out.println("\n\nTESTING INVALID CALLS\n\n\n");
    Client client = getFullyConnectedClient();
    //
    try {
        // No selector at all.
        client.callProcedure("@Statistics");
        fail();
    } catch (ProcCallException ex) {
        // All badness gets turned into ProcCallExceptions, so we need
        // to check specifically for this error, otherwise things that
        // crash the cluster also turn into ProcCallExceptions and don't
        // trigger failure (ENG-2347)
        assertEquals("Incorrect number of arguments to @Statistics (expects 2, received 0)", ex.getMessage());
    }
    try {
        // extra stuff
        client.callProcedure("@Statistics", "table", 0, "OHHAI");
        fail();
    } catch (ProcCallException ex) {
        assertEquals("Incorrect number of arguments to @Statistics (expects 2, received 3)", ex.getMessage());
    }
    try {
        // Invalid selector
        client.callProcedure("@Statistics", "garbage", 0);
        fail();
    } catch (ProcCallException ex) {
    }
}
Also used : Client(org.voltdb.client.Client) ProcCallException(org.voltdb.client.ProcCallException)

Example 82 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestStatisticsSuite method testInvalidCalls.

public void testInvalidCalls() throws Exception {
    System.out.println("\n\nTESTING INVALID CALLS\n\n\n");
    Client client = getFullyConnectedClient();
    //
    try {
        // No selector at all.
        client.callProcedure("@Statistics");
        fail();
    } catch (ProcCallException ex) {
        // All badness gets turned into ProcCallExceptions, so we need
        // to check specifically for this error, otherwise things that
        // crash the cluster also turn into ProcCallExceptions and don't
        // trigger failure (ENG-2347)
        assertEquals("Incorrect number of arguments to @Statistics (expects 2, received 0)", ex.getMessage());
    }
    try {
        // extra stuff
        client.callProcedure("@Statistics", "table", 0, "OHHAI");
        fail();
    } catch (ProcCallException ex) {
        assertEquals("Incorrect number of arguments to @Statistics (expects 2, received 3)", ex.getMessage());
    }
    try {
        // Invalid selector
        client.callProcedure("@Statistics", "garbage", 0);
        fail();
    } catch (ProcCallException ex) {
    }
}
Also used : Client(org.voltdb.client.Client) ProcCallException(org.voltdb.client.ProcCallException)

Example 83 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestProcedureDetails method testProcedureDetail.

public void testProcedureDetail() throws Exception {
    Client client = getClient();
    // Exhaust all the combinatorial possibilities of the *m_optionCount* options.
    // In total, 32 (2^5) different scenarios are being tested here.
    int maxConfigValue = 1 << ProcedureDetailTestConfig.m_optionCount;
    for (int configValue = 0; configValue < maxConfigValue; configValue++) {
        ProcedureDetailTestConfig testConfig = new ProcedureDetailTestConfig(configValue);
        System.out.println("\n========================================================================================");
        System.out.println(String.format("exec %s %d '%s'", testConfig.getNameOfProcedureToCall(), configValue, testConfig.getArgumentString()));
        boolean caughtException = false;
        try {
            client.callProcedure(testConfig.getNameOfProcedureToCall(), configValue, testConfig.getArgumentString());
        } catch (ProcCallException pce) {
            if (!testConfig.expectsException()) {
                throw pce;
            }
            System.out.println("\nCaught exception as expected:\n" + pce.getMessage());
            caughtException = true;
        } finally {
            // Note that pass 1 as the second parameter to get incremental statistics.
            VoltTable procedureDetail = client.callProcedure("@Statistics", "PROCEDUREDETAIL", 1).getResults()[0];
            System.out.println(procedureDetail.toFormattedString());
            verifyProcedureDetailResult(testConfig, procedureDetail);
        }
        // The test configuration says an exception is expected, but we did not get it.
        if (testConfig.expectsException() && !caughtException) {
            fail(String.format("Expects an exception from exec %s %d '%s', but did not get it.", testConfig.getNameOfProcedureToCall(), configValue, testConfig.getArgumentString()));
        }
    }
}
Also used : Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

Example 84 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class Benchmark method printPlannerStatistics.

/**
     * Print planner and cache statistics.
     * @throws IOException
     * @throws NoConnectionsException
     */
public void printPlannerStatistics() throws IOException, NoConnectionsException {
    try {
        VoltTable result = client.callProcedure("@Statistics", "PLANNER", 0).getResults()[0];
        while (result.advanceRow()) {
            String hostname = result.getString("HOSTNAME");
            long siteId = result.getLong("SITE_ID");
            long partitionId = result.getLong("PARTITION_ID");
            long hits1 = result.getLong("CACHE1_HITS");
            long hits2 = result.getLong("CACHE2_HITS");
            long level1 = result.getLong("CACHE1_LEVEL");
            long level2 = result.getLong("CACHE2_LEVEL");
            long misses = result.getLong("CACHE_MISSES");
            long total = hits1 + hits2 + misses;
            double hitpc1 = (100.0 * hits1) / total;
            double hitpc2 = (100.0 * hits2) / total;
            double planTimeMin = result.getLong("PLAN_TIME_MIN") / 1000000.0;
            double planTimeMax = result.getLong("PLAN_TIME_MAX") / 1000000.0;
            double planTimeAvg = result.getLong("PLAN_TIME_AVG") / 1000000.0;
            long failures = result.getLong("FAILURES");
            // Global stats
            System.out.printf("          HOSTNAME: %s\n", hostname);
            if (siteId == -1) {
                System.out.printf("              SITE: (global)\n");
            } else {
                System.out.printf("              SITE: %d\n", siteId);
                System.out.printf("         PARTITION: %d\n", partitionId);
            }
            System.out.printf("       TOTAL PLANS: %d\n", total);
            System.out.printf("      CACHE MISSES: %d\n", misses);
            if (siteId == -1) {
                System.out.printf("LEVEL 1 CACHE HITS: %d (%.1f%%)\n", hits1, hitpc1);
                System.out.printf("LEVEL 2 CACHE HITS: %d (%.1f%%)\n", hits2, hitpc2);
                System.out.printf("LEVEL 1 CACHE SIZE: %d\n", level1);
                System.out.printf("LEVEL 2 CACHE SIZE: %d\n", level2);
            } else {
                System.out.printf("   PLAN CACHE HITS: %d (%.1f%%)\n", hits1, hitpc1);
                System.out.printf("   PLAN CACHE SIZE: %d\n", level1);
            }
            System.out.printf("     PLAN TIME MIN: %6.2f ms\n", planTimeMin);
            System.out.printf("     PLAN TIME MAX: %6.2f ms\n", planTimeMax);
            System.out.printf("     PLAN TIME AVG: %6.2f ms\n", planTimeAvg);
            System.out.printf("          FAILURES: %d\n\n", failures);
        }
    } catch (ProcCallException e) {
        e.printStackTrace();
    }
}
Also used : VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

Example 85 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestAdhocAlterTable method testAlterLimitPartitionRows.

@Test
public void testAlterLimitPartitionRows() throws Exception {
    String pathToCatalog = Configuration.getPathToCatalogForTest("adhocddl.jar");
    String pathToDeployment = Configuration.getPathToCatalogForTest("adhocddl.xml");
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema("create table FOO (" + "ID integer not null," + "VAL varchar(50), " + "constraint PK_TREE primary key (ID)" + ");\n");
    builder.addPartitionInfo("FOO", "ID");
    builder.setUseDDLSchema(true);
    boolean success = builder.compile(pathToCatalog, 1, 1, 0);
    assertTrue("Schema compilation failed", success);
    MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
    VoltDB.Configuration config = new VoltDB.Configuration();
    config.m_pathToCatalog = pathToCatalog;
    config.m_pathToDeployment = pathToDeployment;
    try {
        startSystem(config);
        VoltTable results = m_client.callProcedure("@Statistics", "TABLE", 0).getResults()[0];
        while (results.getRowCount() == 0) {
            results = m_client.callProcedure("@Statistics", "TABLE", 0).getResults()[0];
        }
        System.out.println(results);
        assertEquals(1, results.getRowCount());
        results.advanceRow();
        Long limit = results.getLong("TUPLE_LIMIT");
        assertTrue(results.wasNull());
        try {
            m_client.callProcedure("@AdHoc", "alter table foo add limit partition rows 10;");
        } catch (ProcCallException pce) {
            fail("Should be able to alter partition row limit: " + pce.toString());
        }
        do {
            results = m_client.callProcedure("@Statistics", "TABLE", 0).getResults()[0];
            results.advanceRow();
            limit = results.getLong("TUPLE_LIMIT");
        } while (results.wasNull());
        System.out.println(results);
        assertEquals(10L, (long) limit);
        try {
            m_client.callProcedure("@AdHoc", "alter table foo drop limit partition rows;");
        } catch (ProcCallException pce) {
            fail("Should be able to drop partition row limit: " + pce.toString());
        }
        do {
            results = m_client.callProcedure("@Statistics", "TABLE", 0).getResults()[0];
            results.advanceRow();
            limit = results.getLong("TUPLE_LIMIT");
        } while (!results.wasNull());
        System.out.println(results);
    } finally {
        teardownSystem();
    }
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration) ProcCallException(org.voltdb.client.ProcCallException) Test(org.junit.Test)

Aggregations

ProcCallException (org.voltdb.client.ProcCallException)240 Client (org.voltdb.client.Client)151 VoltTable (org.voltdb.VoltTable)120 ClientResponse (org.voltdb.client.ClientResponse)92 IOException (java.io.IOException)82 NoConnectionsException (org.voltdb.client.NoConnectionsException)55 Test (org.junit.Test)44 Configuration (org.voltdb.VoltDB.Configuration)41 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)36 File (java.io.File)21 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)19 VoltCompiler (org.voltdb.compiler.VoltCompiler)15 VoltDB (org.voltdb.VoltDB)10 VoltTableRow (org.voltdb.VoltTableRow)10 Timestamp (java.sql.Timestamp)5 TimestampType (org.voltdb.types.TimestampType)5 BigDecimal (java.math.BigDecimal)4 Date (java.util.Date)4 HashSet (java.util.HashSet)3 ClientResponseImpl (org.voltdb.ClientResponseImpl)3