Search in sources :

Example 56 with ProcCallException

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

the class TestCatalogUpdateSuite method testAddDropTable.

public void testAddDropTable() throws IOException, ProcCallException, InterruptedException {
    Client client = getClient();
    loadSomeData(client, 0, 10);
    assertCallbackSuccess(client);
    // verify that an insert w/o a table fails.
    try {
        client.callProcedure("@AdHoc", "insert into O1 values (1, 1, 'foo', 'foobar');");
        fail();
    } catch (ProcCallException e) {
    }
    // Also can't call this not-yet-existing stored procedure
    try {
        client.callProcedure("InsertO1", new Integer(100), new Integer(200), "foo", "bar");
        fail();
    } catch (ProcCallException e) {
    }
    // add tables O1, O2, O3
    String newCatalogURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-addtables.jar");
    String deploymentURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-addtables.xml");
    VoltTable[] results = client.updateApplicationCatalog(new File(newCatalogURL), new File(deploymentURL)).getResults();
    assertTrue(results.length == 1);
    // verify that the new table(s) support an insert
    ClientResponse callProcedure = client.callProcedure("@AdHoc", "insert into O1 values (1, 1, 'foo', 'foobar');");
    assertTrue(callProcedure.getResults().length == 1);
    assertTrue(callProcedure.getStatus() == ClientResponse.SUCCESS);
    callProcedure = client.callProcedure("@AdHoc", "insert into O2 values (1, 1, 'foo', 'foobar');");
    assertTrue(callProcedure.getResults().length == 1);
    assertTrue(callProcedure.getStatus() == ClientResponse.SUCCESS);
    callProcedure = client.callProcedure("@AdHoc", "select * from O1");
    VoltTable result = callProcedure.getResults()[0];
    result.advanceRow();
    assertTrue(result.get(2, VoltType.STRING).equals("foo"));
    // old tables can still be accessed
    loadSomeData(client, 20, 10);
    assertCallbackSuccess(client);
    // and this new procedure is happy like clams
    callProcedure = client.callProcedure("InsertO1", new Integer(100), new Integer(200), "foo", "bar");
    assertTrue(callProcedure.getResults().length == 1);
    assertTrue(callProcedure.getStatus() == ClientResponse.SUCCESS);
    // revert to the original schema
    newCatalogURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-base.jar");
    deploymentURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-base.xml");
    results = client.updateApplicationCatalog(new File(newCatalogURL), new File(deploymentURL)).getResults();
    assertTrue(results.length == 1);
    // requests to the dropped table should fail
    try {
        client.callProcedure("@AdHoc", "insert into O1 values (1, 1, 'foo', 'foobar');");
        fail();
    } catch (ProcCallException e) {
    }
    try {
        client.callProcedure("InsertO1", new Integer(100), new Integer(200), "foo", "bar");
        fail();
    } catch (ProcCallException e) {
    }
    // and other requests still succeed
    loadSomeData(client, 30, 10);
    assertCallbackSuccess(client);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ClientResponse(org.voltdb.client.ClientResponse) Client(org.voltdb.client.Client) File(java.io.File) VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

Example 57 with ProcCallException

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

the class TestAdminMode method testBasicAdminFunction.

// Check that we can start in admin mode, access the DB only from the admin
// port, then switch out of admin mode and access the DB from both ports,
// then back in again
public void testBasicAdminFunction() throws Exception {
    final Client client = ClientFactory.createClient();
    final Client adminclient = ClientFactory.createClient();
    try {
        client.createConnection("localhost");
        adminclient.createConnection("localhost", 32323);
        // Try to use the normal port and verify that the server reports
        // that it is unavailable (and that nothing happened via the admin port)
        boolean admin_start = false;
        try {
            client.callProcedure("InsertA", 0, 1000);
        } catch (ProcCallException e) {
            assertEquals("Server did not report itself as unavailable on production port", ClientResponse.SERVER_UNAVAILABLE, e.getClientResponse().getStatus());
            admin_start = true;
        }
        assertTrue("Server did not report itself as unavailable on production port", admin_start);
        VoltTable[] results = adminclient.callProcedure("CountA").getResults();
        assertEquals(0, results[0].asScalarLong());
        // add several tuples
        for (int i = 0; i < 100; i++) {
            adminclient.callProcedure("InsertA", i, 1000 + i);
        }
        adminclient.drain();
        results = adminclient.callProcedure("CountA").getResults();
        assertEquals(100, results[0].asScalarLong());
        // Verify that @SystemInformation tells us the right thing
        results = adminclient.callProcedure("@SystemInformation").getResults();
        checkSystemInformationClusterState(results[0], "Paused");
        // exit admin mode and get busy from both ports
        adminclient.callProcedure("@Resume");
        results = client.callProcedure("CountA").getResults();
        assertEquals(100, results[0].asScalarLong());
        results = adminclient.callProcedure("CountA").getResults();
        assertEquals(100, results[0].asScalarLong());
        // Verify that @SystemInformation tells us the right thing
        results = adminclient.callProcedure("@SystemInformation").getResults();
        checkSystemInformationClusterState(results[0], "Running");
        // verify admin mode sysprocs not available on production port
        boolean admin_failed = false;
        try {
            client.callProcedure("@Pause");
        } catch (ProcCallException e) {
            admin_failed = true;
            assertTrue("Server returned an unexpected error", e.getClientResponse().getStatusString().contains("is not available to this client"));
        }
        assertTrue("Server allowed admin mode sysproc on production port", admin_failed);
        admin_failed = false;
        try {
            client.callProcedure("@Resume");
        } catch (ProcCallException e) {
            admin_failed = true;
            assertTrue("Server returned an unexpected error", e.getClientResponse().getStatusString().contains("is not available to this client"));
        }
        assertTrue("Server allowed admin mode sysproc on production port", admin_failed);
        // turn admin mode back on.
        adminclient.callProcedure("@Pause");
        // XXX-ADMIN add polling here although it shouldn't matter for
        // this synchronous, slow access.  We'll add another test for
        // clearing the backlog.
        // Try to use the normal port and verify that the server reports
        // that it is unavailable (and that nothing happened via the admin port)
        boolean admin_reentered = false;
        try {
            client.callProcedure("InsertA", 0, 1000);
        } catch (ProcCallException e) {
            assertEquals("Server did not report itself as unavailable on production port", ClientResponse.SERVER_UNAVAILABLE, e.getClientResponse().getStatus());
            admin_reentered = true;
        }
        assertTrue("Server did not report itself as unavailable on production port", admin_reentered);
        results = adminclient.callProcedure("CountA").getResults();
        assertEquals(100, results[0].asScalarLong());
        // Verify that @SystemInformation tells us the right thing
        results = adminclient.callProcedure("@SystemInformation").getResults();
        checkSystemInformationClusterState(results[0], "Paused");
    } finally {
        adminclient.close();
        client.close();
    }
}
Also used : Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

Example 58 with ProcCallException

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

the class TestAdminModeFromCommandLine method testPausedModeStartup.

public void testPausedModeStartup() throws Exception {
    final Client client = getClient();
    final Client adminclient = getAdminClient();
    try {
        // Try to use the normal port and verify that the server reports
        // that it is unavailable (and that nothing happened via the admin port)
        boolean admin_start = false;
        try {
            client.callProcedure("InsertA", 0, 1000);
        } catch (ProcCallException e) {
            assertEquals("Server did not report itself as unavailable on production port", ClientResponse.SERVER_UNAVAILABLE, e.getClientResponse().getStatus());
            admin_start = true;
        }
        assertTrue("Server did not report itself as unavailable on production port", admin_start);
        VoltTable[] results = adminclient.callProcedure("CountA").getResults();
        assertEquals(0, results[0].asScalarLong());
        // add several tuples
        for (int i = 0; i < 100; i++) {
            adminclient.callProcedure("InsertA", i, 1000 + i);
        }
        adminclient.drain();
        results = adminclient.callProcedure("CountA").getResults();
        assertEquals(100, results[0].asScalarLong());
        // Verify that @SystemInformation tells us the right thing
        results = adminclient.callProcedure("@SystemInformation").getResults();
        checkSystemInformationClusterState(results[0], "Paused");
        // exit admin mode and get busy from both ports
        adminclient.callProcedure("@Resume");
        results = client.callProcedure("CountA").getResults();
        assertEquals(100, results[0].asScalarLong());
        results = adminclient.callProcedure("CountA").getResults();
        assertEquals(100, results[0].asScalarLong());
        // Verify that @SystemInformation tells us the right thing
        results = adminclient.callProcedure("@SystemInformation").getResults();
        checkSystemInformationClusterState(results[0], "Running");
        // verify admin mode sysprocs not available on production port
        boolean admin_failed = false;
        try {
            client.callProcedure("@Pause");
        } catch (ProcCallException e) {
            admin_failed = true;
            assertTrue("Server returned an unexpected error", e.getClientResponse().getStatusString().contains("is not available to this client"));
        }
        assertTrue("Server allowed admin mode sysproc on production port", admin_failed);
        admin_failed = false;
        try {
            client.callProcedure("@Resume");
        } catch (ProcCallException e) {
            admin_failed = true;
            assertTrue("Server returned an unexpected error", e.getClientResponse().getStatusString().contains("is not available to this client"));
        }
        assertTrue("Server allowed admin mode sysproc on production port", admin_failed);
        // turn admin mode back on.
        adminclient.callProcedure("@Pause");
        // XXX-ADMIN add polling here although it shouldn't matter for
        // this synchronous, slow access.  We'll add another test for
        // clearing the backlog.
        // Try to use the normal port and verify that the server reports
        // that it is unavailable (and that nothing happened via the admin port)
        boolean admin_reentered = false;
        try {
            client.callProcedure("InsertA", 0, 1000);
        } catch (ProcCallException e) {
            assertEquals("Server did not report itself as unavailable on production port", ClientResponse.SERVER_UNAVAILABLE, e.getClientResponse().getStatus());
            admin_reentered = true;
        }
        assertTrue("Server did not report itself as unavailable on production port", admin_reentered);
        results = adminclient.callProcedure("CountA").getResults();
        assertEquals(100, results[0].asScalarLong());
        // Verify that @SystemInformation tells us the right thing
        results = adminclient.callProcedure("@SystemInformation").getResults();
        checkSystemInformationClusterState(results[0], "Paused");
    } finally {
        adminclient.close();
        client.close();
    }
}
Also used : Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

Example 59 with ProcCallException

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

the class TestCatalogUpdateAutoUpgradeSuite method testCatalogUpgradeWithBadDDL.

public void testCatalogUpgradeWithBadDDL() throws IOException, ProcCallException, InterruptedException {
    Client client = getClient();
    loadSomeData(client, 0, 10);
    client.drain();
    assertTrue(callbackSuccess);
    String tweakedJarPath = upgradeCatalogBasePath + "-tweaked.jar";
    OutputWatcher watcher = new OutputWatcher("Failed to generate upgraded catalog", 20, TimeUnit.MILLISECONDS);
    ((LocalCluster) m_config).setOutputWatcher(watcher);
    // Add a bad statement and tweak the version.
    CatalogUpgradeTools.dorkJar(upgradeCatalogJarPath, tweakedJarPath, "CREATE SQUIZZLE");
    File tweakedJarFile = new File(tweakedJarPath);
    try {
        try {
            client.updateApplicationCatalog(tweakedJarFile, new File(upgradeCatalogXMLPath)).getResults();
            fail("Expect ProcCallException");
        } catch (ProcCallException e) {
            assertTrue(e.getLocalizedMessage().contains("Catalog upgrade failed"));
            boolean found = watcher.waitForString();
            assertTrue(found);
        }
    } finally {
        tweakedJarFile.delete();
    }
}
Also used : Client(org.voltdb.client.Client) File(java.io.File) ProcCallException(org.voltdb.client.ProcCallException)

Example 60 with ProcCallException

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

the class TestCRUDSuite method testPartitionedPkWithoutPartitionCol.

public void testPartitionedPkWithoutPartitionCol() throws Exception {
    Client client = getClient();
    try {
        client.callProcedure("P2.delete", 0, "ABC");
    } catch (ProcCallException e) {
        assertTrue(e.getMessage().contains("was not found"));
        return;
    }
    fail();
}
Also used : Client(org.voltdb.client.Client) ProcCallException(org.voltdb.client.ProcCallException)

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