Package org.voltdb.client

Examples of org.voltdb.client.Client


     * select sum(V.SUM_V1), sum(V.SUM_V2), sum(V.SUM_V3) from V
     * @throws InterruptedException
     */
    public void testDistributedSum_View() throws IOException, ProcCallException, InterruptedException {
        VoltTable vt;
        Client client = getClient();
        loadF(client, 0);

        // FIXME String qs = "select sum(V.SUM_v1), sum(V.SUM_V2), sum(V.SUM_V3) from V";
        String qs = "select sum(V.SUM_v1), sum(V.SUM_V2) from V";

        vt = client.callProcedure("@AdHoc", qs).getResults()[0];
        System.out.println("testDistributedSum_View result: " + vt);
        assertTrue(vt.getRowCount() == 1);
        while (vt.advanceRow()) {
            Integer sum1 = (Integer) vt.get(0, VoltType.INTEGER);
            assertEquals(2000, sum1.intValue());
View Full Code Here


     * @throws InterruptedException
     */
    public void testDistributedSumAndGroup() throws NoConnectionsException,
    ProcCallException, IOException, InterruptedException {
        VoltTable vt;
        Client client = getClient();
        loadF(client, 0);

        // FIXME String qs = "select V.V_D1_PKEY, sum(V.SUM_V1), sum(V.SUM_V2), sum(V.SUM_V3) "
//            + "from V group by V.V_D1_PKEY";
        String qs = "select V.V_D1_PKEY, sum(V.SUM_V1), sum(V.SUM_V2) "
                + "from V group by V.V_D1_PKEY";
       

        vt = client.callProcedure("@AdHoc", qs).getResults()[0];
        System.out.println("testDistributedSumAndJoin result: " + vt);
        assert (vt.getRowCount() == 10); // 10 unique values for dim1 which is
        // the grouping col

        int found[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
View Full Code Here

       
        System.out.println("Starting testTPCC - Physical Recovery");               
      
        VoltTable results[] = null;
        ClientResponse cresponse = null;
        Client client = this.getClient();
        CatalogContext cc = this.getCatalogContext();      

        // Load database       
        try{
            initializeTPCCDatabase(cc, client, false);
        }
        catch(Exception e){
            e.printStackTrace();
        }       
       
        final String MOCK_ARGS[] = { "HOST=localhost", "NUMCLIENTS=1",
                // XXX HACK to find catalog jar
                "CATALOG=" + "./obj/release/testobjects/" + projectJAR, "" };

        MOCK_ARGS[MOCK_ARGS.length - 1] = HStoreConstants.BENCHMARK_PARAM_PREFIX;

        TPCCClient tpccClient = new TPCCClient(MOCK_ARGS);

        // Run transactions
        long k_itr = 0;
        long numTransactions = NUM_TRANSACTIONS;
        long period = numTransactions / 10;

        for (k_itr = 0; k_itr < numTransactions; k_itr++) {
            boolean response = tpccClient.runOnce();
            assertEquals(response, true);

            if (k_itr % period == 0)
                System.out.println(String.format("Transactions Processed: %6d / %d", k_itr, numTransactions));
        }           
               
        // Statistics
        results = client.callProcedure("@Statistics", "table", 0).getResults();
        System.out.println("@Statistics before RESTART :");              
        System.out.println(results[0]);       
       
        // Kill and restart all the execution sites.
        m_config.shutDown();
        m_config.startUp();
        client = getClient();       

        results = client.callProcedure("@Statistics", "table", 0).getResults();
        System.out.println("@Statistics after PHYSICAL restore :");
        System.out.println(results[0]);     
       
    }
View Full Code Here

     * testAdHocSQL
     */
    public void testAdHocSQL() throws Exception {
        // This was originally from org.voltdb.TestAdHocQueries
       
        Client client = this.getClient();
        String procName = VoltSystemProcedure.procCallName(AdHoc.class);
        ClientResponse cr;
       
        cr = client.callProcedure(procName, "INSERT INTO NEW_ORDER VALUES (1, 1, 1);");
        VoltTable modCount = cr.getResults()[0];
        assertTrue(modCount.getRowCount() == 1);
        assertTrue(modCount.asScalarLong() == 1);

        cr = client.callProcedure(procName, "SELECT * FROM NEW_ORDER;");
        VoltTable result = cr.getResults()[0];
        assertTrue(result.getRowCount() == 1);
        // System.out.println(result.toString());

        boolean caught = false;
        try {
            client.callProcedure("@AdHoc", "SLEECT * FROOM NEEEW_OOORDERERER;");
        } catch (Exception e) {
            caught = true;
        }
        assertTrue("Bad SQL failed to throw expected exception", caught);
    }
View Full Code Here

     * testNetworkThreadInitialization
     */
    public void testNetworkThreadInitialization() throws Exception {
        // Test transaction execution where the network processing threads are
        // responsible for initializing the transactions.
        Client client = this.getClient();
        // RegressionSuiteUtil.setHStoreConf(client, "site.network_txn_initialization", true);
        this.executeTestWorkload(client);
    }
View Full Code Here

    /**
     * testStoredProcedureInvocationHints
     */
    public void testStoredProcedureInvocationHints() throws Exception {
        CatalogContext catalogContext = this.getCatalogContext();
        Client client = this.getClient();
        RegressionSuiteUtil.initializeTPCCDatabase(catalogContext, client, true);
       
        final int repeat = 100;
        final StoredProcedureInvocationHints hints = new StoredProcedureInvocationHints();
        final ProcedureCallback callbacks[] = new ProcedureCallback[catalogContext.numberOfPartitions];
        final CountDownLatch latch = new CountDownLatch(catalogContext.numberOfPartitions * repeat);
        for (int p = 0; p < catalogContext.numberOfPartitions; p++) {
            final int partition = p;
            callbacks[p] = new ProcedureCallback() {
                @Override
                public void clientCallback(ClientResponse cresponse) {
                    assertEquals(Status.OK, cresponse.getStatus());
                    assertEquals(partition, cresponse.getBasePartition());
                    latch.countDown();
                }
            };
        } // FOR
       
        for (int i = 0; i < 100; i++) {
            for (int p = 0; p < catalogContext.numberOfPartitions; p++) {
                hints.basePartition = p;
               
                // Once with a callback
                client.callProcedure(callbacks[p], "GetItem", hints, 1);
               
                // And once without a callback
                ClientResponse cresponse = client.callProcedure("GetItem", hints, 1);
                assertNotNull(cresponse);
                assertEquals(Status.OK, cresponse.getStatus());
                assertEquals(p, cresponse.getBasePartition());
            } // FOR
        } // FOR
View Full Code Here

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

    /**
     * testReadRecord
     */
    public void testReadRecord() throws Exception {
        Client client = this.getClient();
        this.initializeDatabase(client, NUM_TUPLES);
       
        long key = NUM_TUPLES / 2;
        String procName = ReadRecord.class.getSimpleName();
        Object params[] = { key };
        ClientResponse cresponse = client.callProcedure(procName, params);
        assertNotNull(cresponse);
        assertEquals(Status.OK, cresponse.getStatus());
        assertEquals(1, cresponse.getResults().length);
       
        VoltTable vt = cresponse.getResults()[0];
View Full Code Here

    public void testDistinct() throws IOException, ProcCallException {
        String[] tables = {"P1", "R1"};
        for (String table : tables)
        {
            Client client = getClient();
            for (int i = 0; i < ROWS; ++i)
            {
                client.callProcedure("Insert", table, i, "desc",
                                     new BigDecimal(10.0), i / 2, 14.5);
            }
            String query = String.format("select distinct %s.NUM from %s",
                                         table, table);
            VoltTable[] results = client.callProcedure("@AdHoc", query).getResults();
            // lazy check that we get 5 rows back, put off checking contents
            assertEquals(5, results[0].getRowCount());
        }
    }
View Full Code Here

    public void testMultipleAverages() throws IOException, ProcCallException {
        String[] tables = {"P1", "R1"};
       
        Random rand = this.getRandom();
        for (String table : tables) {
            Client client = getClient();
            List<Long> val_nums = new ArrayList<Long>();
            List<Double> val_ratios = new ArrayList<Double>();
           
            for (int i = 0; i < ROWS; ++i) {
                BigDecimal cash = new BigDecimal(10.0);
                long num = i / 2;
                double ratio = rand.nextDouble();
                client.callProcedure("Insert", table, i, "desc", cash, num, ratio);
                val_nums.add(num);
                val_ratios.add(ratio);
            } // FOR
           
            double expected_results[] = {
                MathUtil.arithmeticMean(val_nums),
                MathUtil.arithmeticMean(val_ratios),
            };
            String query = String.format("SELECT AVG(NUM), AVG(RATIO) FROM %s", table);
            VoltTable[] results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(1, results.length);
            assertEquals(1, results[0].getRowCount());
            assertTrue(results[0].advanceRow());
            for (int i = 0; i < expected_results.length; ++i) {
                double val = ((Number)results[0].get(i, results[0].getColumnType(i))).doubleValue();
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.