Package org.voltdb.client

Examples of org.voltdb.client.ClientResponse


    // - 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


        Object params[] = {
            VoterConstants.NUM_CONTESTANTS,
            VoterConstants.CONTESTANT_NAMES_CSV
        };
       
        ClientResponse cresponse = client.callProcedure(Initialize.class.getSimpleName(), params);
        assertNotNull(cresponse);
        assertEquals(Status.OK, cresponse.getStatus());
    }
View Full Code Here

    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

     */
    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());
        assertEquals(phoneNumber, results[0].getLong(0));
        //assertEquals(1, results[0].getLong(1));
View Full Code Here

        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());
            VoltTable results[] = cresponse.getResults();
            assertEquals(1, results.length);
            //assertEquals(expected, results[0].asScalarLong());
        } // FOR
    }
View Full Code Here

        Client client = this.getClient();
        RegressionSuiteUtil.initializeTPCCDatabase(catalogContext, client, true);
       
        String procName = VoltSystemProcedure.procCallName(AdHoc.class);
        String sql = "SELECT MIN(I_ID), MAX(I_ID) FROM " + TPCCConstants.TABLENAME_ITEM;
        ClientResponse cr = client.callProcedure(procName, sql);
        assertEquals(Status.OK, cr.getStatus());
        VoltTable results[] = cr.getResults();
        assertEquals(1, results.length);
        assertEquals(1, results[0].getRowCount());
        assertTrue(results[0].advanceRow());
        int minId = (int)results[0].getLong(0);
        int maxId = (int)results[0].getLong(1);
        assert(minId < maxId);
       
//        System.err.printf("MinItemId=%d / MaxItemId=%d\n", minId, maxId);
        procName = "GetStockWarehouseIds";
        for (int itemId = minId; itemId <= maxId; itemId++) {
            cr = client.callProcedure(procName, itemId);
            assertEquals(cr.toString(), Status.OK, cr.getStatus());
            results = cr.getResults();
            assertEquals(sql+"\n"+cr, 1, results.length);
            assertEquals(sql+"\n"+cr, 1, results[0].getRowCount());
            assertEquals(sql+"\n"+cr, catalogContext.numberOfPartitions, results[0].asScalarLong());
//            if (itemId > 0 && itemId % 100 == 0)
//                System.err.printf("ITEM %d\n", itemId);
View Full Code Here

        Client client = this.getClient();
        RegressionSuiteUtil.initializeTPCCDatabase(catalogContext, client, true);
       
        String procName = neworder.class.getSimpleName();
        Object params[] = RegressionSuiteUtil.generateNewOrder(catalogContext.numberOfPartitions, true, WAREHOUSE_ID, DISTRICT_ID);
        ClientResponse cr = client.callProcedure(procName, params);
        assertTrue(cr.hasDebug());
       
        PartitionSet touched = new PartitionSet(cr.getDebug().getExecTouchedPartitions());
        assertEquals(cr.toString(), 2, touched.size());
        int basePartition = cr.getBasePartition();
        assertTrue(cr.toString(), touched.contains(basePartition));
        PartitionSet early = cr.getDebug().getEarlyPreparePartitions();
        assertFalse(cr.toString(), early.isEmpty());
        touched.remove(basePartition);
        int remotePartition = touched.get();
        assertNotSame(HStoreConstants.NULL_PARTITION_ID, remotePartition);
       
        // System.err.println(cr);
        assertFalse(cr.toString(), early.contains(basePartition));
        assertTrue(cr.toString(), early.contains(remotePartition));
    }
View Full Code Here

        // We need to execute the same request multiple times to ensure that the MarkovGraph
        // has all of the vertices that we need. We'll then invoke @MarkovUpdate and then
        // request the txn one more time
        String procName = neworder.class.getSimpleName();
        Object params[] = RegressionSuiteUtil.generateNewOrder(catalogContext.numberOfPartitions, true, WAREHOUSE_ID, DISTRICT_ID);
        ClientResponse cr = null;
        int repeat = 2;
        for (int i = 0; i < repeat; i++) {
            cr = client.callProcedure(procName, params);
            assertFalse(cr.toString(), cr.isSinglePartition());
            // System.err.println(cr);
           
            if (i == 0) {
                // Sleep for a little bit to make sure that the MarkovEstimatorState is cleaned up
                ThreadUtil.sleep(1000);
                cr = client.callProcedure(VoltSystemProcedure.procCallName(MarkovUpdate.class), false);
                // System.err.println(cr);
                assertEquals(cr.toString(), Status.OK, cr.getStatus());
            }
        } // FOR
        assertTrue(cr.hasDebug());
       
        ClientResponseDebug crDebug = cr.getDebug();
        assertFalse(crDebug.toString(), crDebug.isPredictSinglePartition());
        assertFalse(cr.toString(), cr.isSpeculative());
        assertEquals(crDebug.toString(), crDebug.getPredictTouchedPartitions(), crDebug.getExecTouchedPartitions());
        assertEquals(crDebug.toString(), crDebug.getPredictTouchedPartitions(), crDebug.getExecTouchedPartitions());
       
        Procedure catalog_proc = catalogContext.procedures.getIgnoreCase(procName);
        Set<Statement> expectedStmts = new HashSet<Statement>();
        expectedStmts.add(catalog_proc.getStatements().getIgnoreCase("getStockInfo"));
        expectedStmts.add(catalog_proc.getStatements().getIgnoreCase("updateStock"));
       
        for (int partition : crDebug.getExecTouchedPartitions()) {
            List<CountedStatement> query_estimates[] = crDebug.getRemoteQueryEstimates(catalogContext, partition);
            assertNotNull(query_estimates);

//            System.err.println("PARTITION: " + partition);
//            for (List<CountedStatement> queries : query_estimates) {
//                System.err.println(StringUtil.join("\n", queries));
//                System.err.println("------");
//            } // FOR
//            System.err.println();

            if (partition == cr.getBasePartition()) {
                // We can ignore anything on the base partition
                // XXX: Should we be getting remote query estimates at the base partition???
            } else {
                // We should only see updateStock and getStockInfo on the remote partition
                // We'll only examine the last query estimate
View Full Code Here

    public void testRemoteIdle() throws Exception {
        CatalogContext catalogContext = this.getCatalogContext();
        Client client = this.getClient();
        RegressionSuiteUtil.initializeTPCCDatabase(catalogContext, client, true);
       
        ClientResponse cresponse = null;
        String procName = null;
        Object params[] = null;
       
        // First execute a single-partition txn that will sleep for a while at the
        // partition that we're going to need to execute our dtxn on.
        // This will give us time to queue up a bunch of stuff to ensure that the
        // SpecExecScheduler has stuff to look at when the PartitionExecutor is idle.
        final int sleepBefore = 5000; // ms
        final int sleepAfter = 5000; // ms
        procName = Sleeper.class.getSimpleName();
        params = new Object[]{ WAREHOUSE_ID+1, sleepBefore, sleepAfter };
        client.callProcedure(new NullCallback(), procName, params);
       
        // Now fire off a distributed NewOrder transaction
        final LatchableProcedureCallback dtxnCallback = new LatchableProcedureCallback(1);
        procName = neworder.class.getSimpleName();
        params = RegressionSuiteUtil.generateNewOrder(catalogContext.numberOfPartitions, true, WAREHOUSE_ID, DISTRICT_ID);
        client.callProcedure(dtxnCallback, procName, params);
        long start = System.currentTimeMillis();
       
        // While we're waiting for that to come back, we're going to fire off
        // a bunch of single-partition neworder txns that should all be executed
        // speculatively at the other partition
        final List<ClientResponse> spResponse = new ArrayList<ClientResponse>();
        final AtomicInteger spLatch = new AtomicInteger(0);
        final ProcedureCallback spCallback = new ProcedureCallback() {
            @Override
            public void clientCallback(ClientResponse clientResponse) {
                spResponse.add(clientResponse);
                spLatch.decrementAndGet();
            }
        };
        while (dtxnCallback.responses.isEmpty()) {
            // Just sleep for a little bit so that we don't blast the cluster
            ThreadUtil.sleep(1000);
           
            spLatch.incrementAndGet();
            params = RegressionSuiteUtil.generateNewOrder(catalogContext.numberOfPartitions, true, WAREHOUSE_ID, DISTRICT_ID+1);
            client.callProcedure(spCallback, procName, params);
           
            // We'll only check the txns half way through the dtxns expected
            // sleep time
            long elapsed = System.currentTimeMillis() - start;
            assert(elapsed <= (sleepBefore+sleepAfter)*2);
        } // WHILE

        cresponse = CollectionUtil.first(dtxnCallback.responses);
        assertNotNull(cresponse);
        assertFalse(cresponse.isSinglePartition());
        assertTrue(cresponse.hasDebug());
        assertFalse(cresponse.isSpeculative());
       
        // Spin and wait for the single-p txns to finish
        while (spLatch.get() > 0) {
            long elapsed = System.currentTimeMillis() - start;
            assert(elapsed <= (sleepBefore+sleepAfter)*3);
 
View Full Code Here

//            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());
       
        VoltTable results[] = cresponse.getResults();
        assertEquals(2, results.length);
        for (int i = 0; i < results.length; i++) {
            assertEquals(1l, results[i].asScalarLong());
        } // FOR
       
View Full Code Here

TOP

Related Classes of org.voltdb.client.ClientResponse

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.