Package org.voltdb.client

Examples of org.voltdb.client.Client


    // - single column
    // - multi-column
    // - multi-map

    public void testParameterizedLimitOnIndexScan() throws IOException, ProcCallException {
        Client client = getClient();
        ClientResponse cr = null;
        for (String table : ALL_TABLES) {
            client.callProcedure("Insert", table, 1, "a", 100, 1, 14.5);
            client.callProcedure("Insert", table, 2, "b", 100, 2, 15.5);
            client.callProcedure("Insert", table, 3, "c", 200, 3, 16.5);
            client.callProcedure("Insert", table, 6, "f", 200, 6, 17.5);
            client.callProcedure("Insert", table, 7, "g", 300, 7, 18.5);
            client.callProcedure("Insert", table, 8, "h", 300, 8, 19.5);
           
            cr = RegressionSuiteUtil.sql(client, "SELECT * FROM " + table);
            assertEquals(cr.toString(), Status.OK, cr.getStatus());

            cr = client.callProcedure("Eng397LimitIndex"+table, 2);
            assertEquals(cr.toString(), Status.OK, cr.getStatus());
            VoltTable[] results = cr.getResults();
            assertEquals(cr.toString(), 2, results[0].getRowCount());
        }
    }
View Full Code Here


    }

    public void testOrderedUniqueOneColumnIntIndex()
    throws IOException, ProcCallException
    {
        Client client = getClient();
        for (String table : ALL_TABLES) {
            client.callProcedure("Insert", table, 1, "a", 100, 1, 14.5);
            client.callProcedure("Insert", table, 2, "b", 100, 2, 15.5);
            client.callProcedure("Insert", table, 3, "c", 200, 3, 16.5);
            client.callProcedure("Insert", table, 6, "f", 200, 6, 17.5);
            client.callProcedure("Insert", table, 7, "g", 300, 7, 18.5);
            client.callProcedure("Insert", table, 8, "h", 300, 8, 19.5);
            String query = String.format("select * from %s where %s.ID > 1",
                                         table, table);
            VoltTable[] results = client.callProcedure("@AdHoc", query).getResults();
            System.out.println(results[0].toString());
            assertEquals(5, results[0].getRowCount());
            // make sure that we work if the value we want isn't present
            query = String.format("select * from %s where %s.ID > 4",
                                  table, table);           
            results = client.callProcedure("@AdHoc", query).getResults();
            System.out.println(results[0].toString());
            assertEquals(3, results[0].getRowCount());
            query = String.format("select * from %s where %s.ID > 8",
                                  table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(0, results[0].getRowCount());
            query = String.format("select * from %s where %s.ID >= 1",
                                  table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(6, results[0].getRowCount());
            query = String.format("select * from %s where %s.ID >= 4",
                                  table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(3, results[0].getRowCount());
            query = String.format("select * from %s where %s.ID >= 9",
                                  table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(0, results[0].getRowCount());
            query = String.format("select * from %s where %s.ID > 1 and %s.ID < 6",
                                  table, table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(2, results[0].getRowCount());
            query = String.format("select * from %s where %s.ID > 1 and %s.ID <= 6",
                                  table, table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(3, results[0].getRowCount());
            query = String.format("select * from %s where %s.ID > 1 and %s.ID <= 5",
                                  table, table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(2, results[0].getRowCount());
            query = String.format("select * from %s where %s.ID >= 1 and %s.ID < 7",
                                  table, table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(4, results[0].getRowCount());
            // Check that >= work in conjunction with <
            // run over the end of the index to catch the keyIterate bug
            // in the first >= index fix
            query = String.format("select * from %s where %s.ID >= 1 and %s.ID < 10",
                                  table, table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(6, results[0].getRowCount());
            // XXX THIS CASE CURRENTLY FAILS
            // SEE TICKET 194
//            query = String.format("select * from %s where %s.ID >= 2.9",
//                                  table, table);
View Full Code Here

    // @throws ProcCallException
    //
    public void testOrderedMultiOneColumnIntIndex()
    throws IOException, ProcCallException
    {
        Client client = getClient();
        for (String table : ALL_TABLES) {
            client.callProcedure("Insert", table, 1, "a", 100, 1, 14.5);
            client.callProcedure("Insert", table, 2, "b", 100, 2, 15.5);
            client.callProcedure("Insert", table, 3, "c", 200, 3, 16.5);
            client.callProcedure("Insert", table, 6, "f", 200, 6, 17.5);
            client.callProcedure("Insert", table, 7, "g", 300, 7, 18.5);
            client.callProcedure("Insert", table, 8, "h", 300, 8, 19.5);
            String query = String.format("select * from %s where %s.NUM > 100",
                                         table, table);
            VoltTable[] results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(4, results[0].getRowCount());
            query = String.format("select * from %s where %s.NUM > 150",
                                  table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(4, results[0].getRowCount());
            query = String.format("select * from %s where %s.NUM > 300",
                                  table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(0, results[0].getRowCount());
            query = String.format("select * from %s where %s.NUM >= 100",
                                  table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(6, results[0].getRowCount());
            query = String.format("select * from %s where %s.NUM >= 150",
                                  table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(4, results[0].getRowCount());
            query = String.format("select * from %s where %s.NUM >= 301",
                                  table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(0, results[0].getRowCount());
            query = String.format("select * from %s where %s.NUM > 100 and %s.NUM < 300",
                                  table, table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(2, results[0].getRowCount());
            // Check that >= work in conjunction with <
            // run over the end of the index to catch the keyIterate bug
            // in the first >= index fix
            query = String.format("select * from %s where %s.NUM >= 100 and %s.NUM < 400",
                                  table, table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(6, results[0].getRowCount());
            query = String.format("select * from %s where %s.NUM = 100",
                                  table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(2, results[0].getRowCount());
            query = String.format("select * from %s where %s.NUM > 100 and %s.NUM <= 300",
                                  table, table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(4, results[0].getRowCount());
            query = String.format("select * from %s where %s.NUM > 100 and %s.NUM <= 250",
                                  table, table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(2, results[0].getRowCount());
        }
    }
View Full Code Here

    }

    public void testTicket195()
    throws IOException, ProcCallException
    {
        Client client = getClient();
        for (String table : ALL_TABLES)
        {
            client.callProcedure("Insert", table, 1, "a", 100, 1, 14.5);
            client.callProcedure("Insert", table, 2, "b", 100, 2, 15.5);
            client.callProcedure("Insert", table, 3, "c", 200, 3, 16.5);
            client.callProcedure("Insert", table, 6, "f", 200, 6, 17.5);
            client.callProcedure("Insert", table, 7, "g", 300, 7, 18.5);
            client.callProcedure("Insert", table, 8, "h", 300, 8, 19.5);
            String query = String.format("select * from %s where %s.NUM >= 100 and %s.NUM <= 400",
                                  table, table, table);
            VoltTable[] results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(6, results[0].getRowCount());
        }
    }
View Full Code Here

    //
    public void testOrderedMultiMultiColumnIntIndex()
    throws IOException, ProcCallException
    {
        String[] tables = {"P3", "R3"};
        Client client = getClient();
        for (String table : tables)
        {
            client.callProcedure("Insert", table, 1, "a", 100, 1, 14.5);
            client.callProcedure("Insert", table, 2, "b", 100, 2, 15.5);
            client.callProcedure("Insert", table, 3, "c", 200, 3, 16.5);
            client.callProcedure("Insert", table, 6, "f", 200, 6, 17.5);
            client.callProcedure("Insert", table, 7, "g", 300, 7, 18.5);
            client.callProcedure("Insert", table, 8, "h", 300, 8, 19.5);
            String query = String.format("select * from %s where %s.NUM > 100 AND %s.NUM2 > 1",
                                         table, table, table);
            VoltTable[] results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(4, results[0].getRowCount());
        }
    }
View Full Code Here

    /**
     * testInitialize
     */
    public void testInitialize() throws Exception {
        Client client = this.getClient();
        this.initializeDatabase(client);
       
        String query = "SELECT COUNT(*) FROM contestants";
        ClientResponse cresponse = client.callProcedure("@AdHoc", query);
        assertEquals(Status.OK, cresponse.getStatus());
        VoltTable results[] = cresponse.getResults();
        assertEquals(1, results.length);
        assertEquals(VoterConstants.NUM_CONTESTANTS, results[0].asScalarLong());
        System.err.println(results[0]);
View Full Code Here

    /**
     * testVote
     */
    public void testVote() throws Exception {
        Client client = this.getClient();
        this.initializeDatabase(client);
       
        ClientResponse cresponse = client.callProcedure(Vote.class.getSimpleName(),
                                                        voteId++,
                                                        phoneNumber,
                                                        contestantNumber,
                                                        maxVotesPerPhoneNumber);
        assertEquals(Status.OK, cresponse.getStatus());
        VoltTable results[] = cresponse.getResults();
        assertEquals(1, results.length);
        assertEquals(VoterConstants.VOTE_SUCCESSFUL, results[0].asScalarLong());
       
        // Make sure that our vote is actually in the real table and materialized views
        String query = "SELECT COUNT(*) FROM votes";
        cresponse = client.callProcedure("@AdHoc", query);
        assertEquals(Status.OK, cresponse.getStatus());
        results = cresponse.getResults();
        assertEquals(1, results.length);
        assertEquals(1, results[0].asScalarLong());

       
        query = "SELECT * FROM v_votes_by_phone_number";
        cresponse = client.callProcedure("@AdHoc", query);
        assertEquals(Status.OK, cresponse.getStatus());
        results = cresponse.getResults();
        assertEquals(1, results.length);
        System.err.println(results[0]);
        assertTrue(results[0].advanceRow());
View Full Code Here

   
    /**
     * testVoteLimit
     */
    public void testVoteLimit() throws Exception {
        Client client = this.getClient();
        this.initializeDatabase(client);
       
        // Make sure that the phone number is only allowed to vote up to
        // the limit and not anymore after that
        ClientResponse cresponse = null;
        for (int i = 0, cnt = (int)(maxVotesPerPhoneNumber*2); i < cnt; i++) {
            long expected = (i < maxVotesPerPhoneNumber ? VoterConstants.VOTE_SUCCESSFUL :
                                                          VoterConstants.ERR_VOTER_OVER_VOTE_LIMIT);
            cresponse = client.callProcedure(Vote.class.getSimpleName(),
                                             voteId++,
                                             phoneNumber,
                                             contestantNumber,
                                             maxVotesPerPhoneNumber);
            assertEquals(Status.OK, cresponse.getStatus());
View Full Code Here

    public void blockUntilNoOutstandingTransactions() {

    }

    public void testUpdate() throws Exception {
        Client client = getClient();

        String newCatalogURL;
        VoltTable[] results;
        CatTestCallback callback;

        loadSomeData(client, 0, 25);
        client.drain();

        testStuffThatShouldObviouslyFail(client);

        // asynchronously call some random inserts
        loadSomeData(client, 25, 25);

        // add a procedure "InsertOrderLineBatched"
        newCatalogURL = VoltServerConfig.getPathToCatalogForTest("catalogupdate-cluster-expanded.jar");
        callback = new CatTestCallback(Status.OK);
        client.callProcedure(callback, "@UpdateApplicationCatalog", newCatalogURL);

        client.drain();

        // don't care if this succeeds or fails.
        // calling the new proc before the cat change returns is not guaranteed to work
        // we just hope it doesn't crash anything
        int x = 3;
        SyncCallback cb = new SyncCallback();
        client.callProcedure(cb,
                org.voltdb.benchmark.tpcc.procedures.InsertOrderLineBatched.class.getSimpleName(),
                new long[] {x}, new long[] {x}, x, new long[] {x},
                new long[] {x}, new long[] {x}, new TimestampType[] { new TimestampType() }, new long[] {x},
                new double[] {x}, new String[] {"a"});
        cb.waitForResponse();

        // make sure the previous catalog change has completed
        client.drain();

        // now calling the new proc better work
        x = 2;
        client.callProcedure(org.voltdb.benchmark.tpcc.procedures.InsertOrderLineBatched.class.getSimpleName(),
                new long[] {x}, new long[] {x}, x, new long[] {x},
                new long[] {x}, new long[] {x}, new TimestampType[] { new TimestampType() }, new long[] {x},
                new double[] {x}, new String[] {"a"});

        loadSomeData(client, 50, 5);

        // this is a do nothing change... shouldn't affect anything
        newCatalogURL = VoltServerConfig.getPathToCatalogForTest("catalogupdate-cluster-expanded.jar");
        results = client.callProcedure("@UpdateApplicationCatalog", newCatalogURL).getResults();
        assertTrue(results.length == 1);

        client.drain();

        // now calling the new proc better work
        x = 4;
        client.callProcedure(org.voltdb.benchmark.tpcc.procedures.InsertOrderLineBatched.class.getSimpleName(),
                new long[] {x}, new long[] {x}, x, new long[] {x},
                new long[] {x}, new long[] {x}, new TimestampType[] { new TimestampType() }, new long[] {x},
                new double[] {x}, new String[] {"a"});

        loadSomeData(client, 55, 5);

        // remove the procedure we just added async
        newCatalogURL = VoltServerConfig.getPathToCatalogForTest("catalogupdate-cluster-base.jar");
        callback = new CatTestCallback(Status.OK);
        client.callProcedure(callback, "@UpdateApplicationCatalog", newCatalogURL);

        // don't care if this works now
        x = 4;
        cb = new SyncCallback();
        client.callProcedure(cb,
                org.voltdb.benchmark.tpcc.procedures.InsertOrderLineBatched.class.getSimpleName(),
                new long[] {x}, new long[] {x}, x, new long[] {x},
                new long[] {x}, new long[] {x}, new TimestampType[] { new TimestampType() }, new long[] {x},
                new double[] {x}, new String[] {"a"});
        cb.waitForResponse();

        // make sure the previous catalog change has completed
        client.drain();

        // now calling the new proc better fail
        x = 5;
        cb = new SyncCallback();
        client.callProcedure(cb,
                org.voltdb.benchmark.tpcc.procedures.InsertOrderLineBatched.class.getSimpleName(),
                new long[] {x}, new long[] {x}, x, new long[] {x},
                new long[] {x}, new long[] {x}, new TimestampType[] { new TimestampType() }, new long[] {x},
                new double[] {x}, new String[] {"a"});
        cb.waitForResponse();
        assertNotSame(cb.getResponse().getStatus(), Status.OK);

        loadSomeData(client, 60, 5);

        // change the insert new order procedure
        newCatalogURL = VoltServerConfig.getPathToCatalogForTest("catalogupdate-cluster-conflict.jar");
        results = client.callProcedure("@UpdateApplicationCatalog", newCatalogURL).getResults();
        assertTrue(results.length == 1);

        // call the new proc and make sure the one we want gets run
        results = client.callProcedure(InsertNewOrder.class.getSimpleName(), 100, 100, 100, 100, 100, 100, 1.0, "a").getResults();
        assertEquals(1, results.length);
        assertEquals(1776, results[0].asScalarLong());

        // load a big catalog change just to make sure nothing fails horribly
        newCatalogURL = VoltServerConfig.getPathToCatalogForTest("catalogupdate-cluster-many.jar");
        results = client.callProcedure("@UpdateApplicationCatalog", newCatalogURL).getResults();
        assertTrue(results.length == 1);

        loadSomeData(client, 65, 5);

        client.drain();

        assertTrue(true);
    }
View Full Code Here

     * @throws Exception
     */
    @Test
    public void testPrefetch() throws Exception {
        CatalogContext catalogContext = this.getCatalogContext();
        Client client = this.getClient();
        TestSmallBankSuite.initializeSmallBankDatabase(catalogContext, client);
       
        // Check to make sure that we have some prefetch queries
        Procedure catalog_proc = catalogContext.procedures.getIgnoreCase(SendPayment.class.getSimpleName());
        assertNotNull(catalog_proc);
        int prefetch_ctr = 0;
        for (Statement catalog_stmt : catalog_proc.getStatements()) {
            assertNotNull(catalog_stmt);
            if (catalog_stmt.getPrefetchable()) prefetch_ctr++;
        } // FOR
        assertTrue(prefetch_ctr > 0);
       
        long acctIds[] = { 1l, 2l };
        double balances[] = { 100d, 0d };
        for (int i = 0; i < acctIds.length; i++) {
            TestSmallBankSuite.updateBalance(client, acctIds[i], balances[i]);
//            TestSmallBankSuite.checkBalance(client, acctIds[i], balances[i]);
        } // FOR
       
        // Run the SendPayment txn to send all the money from the first
        // account to the second account.
        ClientResponse cresponse = client.callProcedure(catalog_proc.getName(),
                                                        acctIds[0], acctIds[1], balances[0]);
        assertEquals(Status.OK, cresponse.getStatus());
        assertFalse(cresponse.toString(), cresponse.isSinglePartition());
        assertTrue(cresponse.toString(), cresponse.getDebug().hadPrefetchedQueries());
       
View Full Code Here

TOP

Related Classes of org.voltdb.client.Client

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.