Search in sources :

Example 6 with ProcCallException

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

the class TestRoutingEdgeCases method testPartitionKeyAsBytes.

/**
     * Insert into a <8byte integer column using byte[] to send
     * the int. The column is also the partition column. Make sure
     * TheHashinator doesn't screw up.
     */
@Test
public void testPartitionKeyAsBytes() throws Exception {
    ServerThread localServer = null;
    Client client = null;
    try {
        String simpleSchema = "create table blah (" + "ival integer default 0 not null, " + "PRIMARY KEY(ival)); " + "PARTITION TABLE blah ON COLUMN ival;";
        VoltProjectBuilder builder = new VoltProjectBuilder();
        builder.addLiteralSchema(simpleSchema);
        builder.addStmtProcedure("Insert", "insert into blah values (?);", null);
        boolean success = builder.compile(Configuration.getPathToCatalogForTest("edgecases.jar"), 7, 1, 0);
        assert (success);
        MiscUtils.copyFile(builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("edgecases.xml"));
        VoltDB.Configuration config = new VoltDB.Configuration();
        config.m_pathToCatalog = Configuration.getPathToCatalogForTest("edgecases.jar");
        config.m_pathToDeployment = Configuration.getPathToCatalogForTest("edgecases.xml");
        localServer = new ServerThread(config);
        localServer.start();
        localServer.waitForInitialization();
        client = ClientFactory.createClient();
        client.createConnection("localhost");
        try {
            ByteBuffer buf = ByteBuffer.allocate(4);
            buf.order(ByteOrder.LITTLE_ENDIAN);
            buf.putInt(7);
            byte[] value = buf.array();
            client.callProcedure("Insert", value);
            fail();
        } catch (ProcCallException pce) {
            assertTrue(pce.getMessage().contains("Array / Scalar parameter mismatch"));
        }
    // For now, @LoadSinglepartitionTable assumes 8 byte integers, even if type is < 8 bytes
    // This is ok because we don't expose this functionality.
    // The code below will throw a constraint violation, but it really shouldn't. There's
    // Another comment about this in ProcedureRunner about a reasonable fix for this.
    //VoltTable t = new VoltTable(new VoltTable.ColumnInfo("foo", VoltType.INTEGER));
    //t.addRow(13);
    //
    //ByteBuffer buf = ByteBuffer.allocate(4);
    //buf.order(ByteOrder.LITTLE_ENDIAN);
    //buf.putInt(13);
    //byte[] value = buf.array();
    //client.callProcedure("@LoadSinglepartitionTable", value, "blah", t);
    } finally {
        if (client != null)
            client.close();
        if (localServer != null)
            localServer.shutdown();
    }
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration) Client(org.voltdb.client.Client) ByteBuffer(java.nio.ByteBuffer) ProcCallException(org.voltdb.client.ProcCallException) Test(org.junit.Test)

Example 7 with ProcCallException

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

the class TestCatchExceptionsInProcedure method mpChecker.

private void mpChecker(Client client, int hasPreviousBatch, int tryCatchContains1Batch, int hasFollowingBatch) throws NoConnectionsException, IOException, ProcCallException {
    VoltTable vt;
    String sql;
    final String MPErrorMessage = "attempted to execute new batch " + "after hitting EE exception in a previous batch";
    String[] procs = { "MPInsertOnReplicatedTable", "MPInsertOnPartitionTable" };
    String[] tables = { "R1", "P1" };
    int[] followingBatchHasExceptions = { 0, 1 };
    for (int i = 0; i < procs.length; i++) {
        String proc = procs[i];
        String tb = tables[i];
        for (int followingBatchHasException : followingBatchHasExceptions) {
            try {
                vt = client.callProcedure(proc, hasPreviousBatch, tryCatchContains1Batch, hasFollowingBatch, followingBatchHasException).getResults()[0];
                // validate returned value from the procedure calls
                validateRowOfLongs(vt, new long[] { -1 });
            } catch (Exception e) {
                assertTrue(e.getMessage().contains(MPErrorMessage));
            }
            sql = "select ratio from " + tb + " order by 1;";
            // empty table
            validateTableColumnOfScalarFloat(client, sql, new double[] {});
            // empty table
            sql = "select count(*) from " + tb;
            validateTableOfScalarLongs(client, sql, new long[] { 0 });
            client.callProcedure("@AdHoc", "truncate table " + tb);
        }
    }
}
Also used : VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException) NoConnectionsException(org.voltdb.client.NoConnectionsException) IOException(java.io.IOException)

Example 8 with ProcCallException

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

the class TestFailuresSuite method testDivideByZero.

public void testDivideByZero() throws IOException {
    System.out.println("STARTING DivideByZero");
    Client client = getClient();
    VoltTable[] results = null;
    try {
        results = client.callProcedure("DivideByZero", 0L, 0L, (byte) 1).getResults();
        System.out.println("DivideByZero client response received");
        assertEquals(results.length, 0);
    } catch (ProcCallException e) {
        System.out.println(e.getMessage());
        if (e.getMessage().contains("SQL ERROR"))
            return;
        if (isHSQL())
            if (e.getMessage().contains("HSQL-BACKEND ERROR"))
                return;
    } catch (IOException e) {
        fail(e.toString());
        return;
    }
    fail("testDivideByZero should return while catching ProcCallException");
}
Also used : IOException(java.io.IOException) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

Example 9 with ProcCallException

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

the class TestFailuresSuite method testBadFloatToVarcharCompare.

// Subcase of ENG-800
public void testBadFloatToVarcharCompare() throws IOException {
    System.out.println("STARTING testBadFloatToVarcharCompare");
    Client client = getClient();
    boolean threw = false;
    try {
        client.callProcedure("BadFloatToVarcharCompare", 1).getResults();
    } catch (ProcCallException e) {
        if (!isHSQL()) {
            if ((e.getMessage().contains("SQL ERROR")) && (e.getMessage().contains("VARCHAR cannot be cast for comparison to type FLOAT"))) {
                threw = true;
            } else {
                e.printStackTrace();
            }
        } else {
            threw = true;
        }
    }
    assertTrue(threw);
}
Also used : Client(org.voltdb.client.Client) ProcCallException(org.voltdb.client.ProcCallException)

Example 10 with ProcCallException

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

the class TestCatchExceptionsInProcedure method bigBatchChecker.

private void bigBatchChecker(Client client, int hasPreviousBatch, int duplicatedID, int hasFollowingBatch, int followingBatchHasException, double[] expected, int tableCount) throws NoConnectionsException, IOException, ProcCallException {
    VoltTable vt;
    String sql;
    try {
        // use the default value for partition column to route this procedure
        vt = client.callProcedure("SPBigBatchOnPartitionTable", 0, hasPreviousBatch, duplicatedID, hasFollowingBatch, followingBatchHasException).getResults()[0];
        if (isTrue(followingBatchHasException)) {
            assertTrue(isTrue(hasFollowingBatch));
            fail("Expected failure but succeeded.");
        }
        // validate returned value from the procedure calls
        validateRowOfLongs(vt, new long[] { duplicatedID > BIGBATCHTESTSIZE ? 0 : -1 });
    } catch (Exception e) {
        assertTrue(e.getMessage().contains("CONSTRAINT VIOLATION"));
        // violated at row (3, 3.2)
        assertTrue(e.getMessage().contains("500.2"));
        assertTrue(isTrue(hasFollowingBatch) && isTrue(followingBatchHasException));
    }
    sql = "select distinct ratio from P1 order by 1; ";
    validateTableColumnOfScalarFloat(client, sql, expected);
    sql = "select count(*) from P1; ";
    validateTableOfScalarLongs(client, sql, new long[] { tableCount });
    client.callProcedure("@AdHoc", "truncate table P1");
}
Also used : VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException) NoConnectionsException(org.voltdb.client.NoConnectionsException) IOException(java.io.IOException)

Aggregations

ProcCallException (org.voltdb.client.ProcCallException)239 Client (org.voltdb.client.Client)151 VoltTable (org.voltdb.VoltTable)120 ClientResponse (org.voltdb.client.ClientResponse)91 IOException (java.io.IOException)81 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