Package org.voltdb.client

Examples of org.voltdb.client.Client


        String parameters[] = new String[args.getOptParamCount()-1];
        for (int i = 0; i < parameters.length; i++) {
            parameters[i] = args.getOptParam(i+1);
        } // FOR
       
        Client client = ClientFactory.createClient(128, null, false, null);
        Cluster catalog_clus = args.catalog_db.getParent();
        Site catalog_site = CollectionUtil.first(catalog_clus.getSites());
        assert(catalog_site != null);
        Host catalog_host = catalog_site.getHost();
        assert(catalog_host != null);
        Integer port = CollectionUtil.random(CatalogUtil.getExecutionSitePorts(catalog_site));
        assert(port != null);
        client.createConnection(null, catalog_host.getIpaddr(), port, "user", "password");
        LOG.info(String.format("Connected to H-Store cluster at %s:%d", catalog_host.getIpaddr(), port));
       
        ClientResponse cresponse = VoltProcedureInvoker.invoke(args.catalog,
                                                               client,
                                                               procName,
View Full Code Here


    public static void main(String[] vargs) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs);
        args.require(ArgumentsParser.PARAM_CATALOG_HOSTS);
       
        // connect to VoltDB server
        Client client = ClientFactory.createClient();
        client.createConnection(null, args.getParam(ArgumentsParser.PARAM_CATALOG_HOSTS), HStoreConstants.DEFAULT_PORT, "user", "password");

        // long w_id, String w_name, String w_street_1, String w_street_2, String w_city, String w_state, String w_zip, double w_tax, double w_ytd
        VoltTable[] result = client.callProcedure("InsertSubscriber", 1l, "0000001").getResults();
       
//        VoltTable[] result = client.callProcedure("InsertWarehouse",
//                0l,
//                "w_name",
//                "w_street_1",
View Full Code Here

        pb.compile(catalog);

        ServerThread server = new ServerThread(catalog,  BackendTarget.NATIVE_EE_JNI);
        server.start();
        server.waitForInitialization();
        Client client = ClientFactory.createClient();
        client.createConnection(null, "localhost", HStoreConstants.DEFAULT_PORT, "program", "none");

        Date generationDateTime = new Date();
        long tm = System.currentTimeMillis();

        System.out.println("making order line table...");
        tm = System.currentTimeMillis();
        // int BATCH_SIZE = parameters.districtsPerWarehouse * (parameters.customersPerDistrict / 30);
        int BATCH_SIZE = 1000;
        long[] b_ol_o_id = new long[BATCH_SIZE];
        long[] b_ol_d_id = new long[BATCH_SIZE];
        long[] b_ol_number = new long[BATCH_SIZE];
        long[] b_ol_i_id = new long[BATCH_SIZE];
        long[] b_ol_supply_w_id = new long[BATCH_SIZE];
        Date[] b_ol_delivery_d = new Date[BATCH_SIZE];
        long[] b_ol_quantity = new long[BATCH_SIZE];
        double[] b_ol_amount = new double[BATCH_SIZE];
        String[] b_ol_dist_info = new String[BATCH_SIZE];
        int total = 0;
        int batch_cnt = 0;
        int w_id = 1;
        int customersPerDistrictAfterInsertion = (int) (parameters.customersPerDistrict * 3.0);
        for (int d_id = 1; d_id <= parameters.districtsPerWarehouse; ++d_id) {
            for (int o_id = 1; o_id <= customersPerDistrictAfterInsertion; ++o_id) { //10% more
                // Generate each OrderLine for the order
                long o_ol_cnt = generator.number(TPCCConstants.MIN_OL_CNT, TPCCConstants.MAX_OL_CNT);
                boolean newOrder =
                    parameters.customersPerDistrict - parameters.newOrdersPerDistrict < o_id;
                for (int ol_number = 1; ol_number <= o_ol_cnt; ++ol_number) {
                    //generateOrderLine(w_id, d_id, o_id, ol_number, newOrder);
                    //(long ol_w_id, long ol_d_id, long ol_o_id, long ol_number, boolean newOrder)
                    b_ol_o_id[batch_cnt] = o_id;
                    b_ol_d_id[batch_cnt] = d_id;
                    b_ol_number[batch_cnt] = ol_number;
                    b_ol_i_id[batch_cnt] = generator.number(1, parameters.num_items);
                    b_ol_supply_w_id[batch_cnt] = w_id;
                    b_ol_delivery_d[batch_cnt] = generationDateTime;
                    b_ol_quantity[batch_cnt] = TPCCConstants.INITIAL_QUANTITY;

                    if (!newOrder) {
                        b_ol_amount[batch_cnt] = 0.00;
                    } else {
                        b_ol_amount[batch_cnt] = generator.fixedPoint(TPCCConstants.MONEY_DECIMALS, TPCCConstants.MIN_AMOUNT,
                                TPCCConstants.MAX_PRICE * TPCCConstants.MAX_OL_QUANTITY);
                        b_ol_delivery_d[batch_cnt] = null;
                    }
                    b_ol_dist_info[batch_cnt] = generator.astring(TPCCConstants.DIST, TPCCConstants.DIST);
                    ++batch_cnt;
                    if (batch_cnt == BATCH_SIZE) {
                        total += BATCH_SIZE;
                        System.out.println ("loading: " + total + "/" + (parameters.districtsPerWarehouse * customersPerDistrictAfterInsertion * (TPCCConstants.MAX_OL_CNT - TPCCConstants.MIN_OL_CNT)));
                        client.callProcedure(InsertOrderLineBatched.class.getSimpleName(),
                            b_ol_o_id, b_ol_d_id, w_id, b_ol_number, b_ol_i_id,
                            b_ol_supply_w_id, b_ol_delivery_d, b_ol_quantity, b_ol_amount, b_ol_dist_info);
                        batch_cnt = 0;
                    }
                }
            }
        }

        System.out.println("created " + (System.currentTimeMillis() - tm) + "ms");
        tm = System.currentTimeMillis();

        //delete the 10% orderline
        client.callProcedure(ResetWarehouse.class.getSimpleName(),
                1L,
                (long) parameters.districtsPerWarehouse,
                (long) parameters.customersPerDistrict,
                (long) parameters.newOrdersPerDistrict);
        System.out.println("deleted " + (System.currentTimeMillis() - tm) + "ms");
View Full Code Here

        client.callProcedure("InsertDims");
    }

    /** select A1 from T1 group by A1 */
    public void testSelectAGroubyA() throws IOException, ProcCallException {
        Client client = this.getClient();
        VoltTable vt;

        loaderNxN(client, 0);

        vt = client.callProcedure("@AdHoc", "Select * from T1").getResults()[0];
        System.out.println("T1-*:" + vt);

        // execute the query
        vt = client.callProcedure("@AdHoc", "SELECT A1 from T1 group by A1").getResults()[0];

        // one row per unique value of A1
        System.out.println("testSelectAGroubyA: " + vt);
        assertTrue(vt.getRowCount() == 11);

View Full Code Here

    }

    /** select count(A1) from T1 group by A1 */
    public void testSelectCountAGroupbyA() throws IOException,
    ProcCallException {
        Client client = this.getClient();
        VoltTable vt;

        loaderNxN(client, 0);

        vt = client.callProcedure("@AdHoc",
        "select count(A1) from T1 group by A1").getResults()[0];
        System.out.println("testSelectCountAGroupbyA result: " + vt);
        assertTrue(vt.getRowCount() == 11);

        // Selecting count(A1) - should get two counts of 1 and one count each
View Full Code Here

    }

    /** select A1, sum(A1) from T1 group by A1 */
    public void testSelectSumAGroupbyA() throws IOException, ProcCallException {
        VoltTable vt;
        Client client = this.getClient();
        loaderNxN(client, 0);

        String qs = "select A1, sum(A1) from T1 group by A1";

        vt = client.callProcedure("@AdHoc", qs).getResults()[0];
        System.out.println("testSelectSumAGroupbyA result: " + vt);
        assertEquals(11, vt.getRowCount());

        int found[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        while (vt.advanceRow()) {
View Full Code Here

    }

    /** select count(distinct A1) from T1 */
    public void testSelectCountDistinct() throws IOException, ProcCallException {
        VoltTable vt;
        Client client = getClient();
        loaderNxN(client, 0);
        vt = client
        .callProcedure("@AdHoc", "select count(distinct A1) from T1").getResults()[0];
        assertTrue(vt.getRowCount() == 1);

        // there are 11 distinct values for A1
        while (vt.advanceRow()) {
View Full Code Here

    }

    /** select count(A1) from T1 */
    public void testSelectCount() throws IOException, ProcCallException {
        VoltTable vt;
        Client client = getClient();
        loaderNxN(client, 0);
        vt = client.callProcedure("@AdHoc", "select count(A1) from T1").getResults()[0];
        assertTrue(vt.getRowCount() == 1);

        // there are 56 rows in the table 1 + 2 + 3 + .. + 10 + 1
        while (vt.advanceRow()) {
            Integer A1 = (Integer) vt.get(0, VoltType.INTEGER);
View Full Code Here

        }
    }

    /** select distinct a1 from t1 */
    public void testSelectDistinctA() throws IOException, ProcCallException {
        Client client = this.getClient();
        VoltTable vt;

        loaderNxN(client, 0);

        vt = client.callProcedure("@AdHoc", "select distinct a1 from t1").getResults()[0];
        System.out.println("testSelectDistinctA result row("
                + vt.getColumnName(0) + ") " + vt);

        // valid result is the set {1,2,...,11}
        int found[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
View Full Code Here

     * select sum(F_VAL1), sum(F_VAL2), sum(F_VAL3) from F
     * @throws InterruptedException
     */
    public void testDistributedSum() throws IOException, ProcCallException, InterruptedException {
        VoltTable vt;
        Client client = getClient();
        loadF(client, 0);

        String qs = "select sum(F_VAL1), sum(F_VAL2), sum(F_VAL3) from F";

        vt = client.callProcedure("@AdHoc", qs).getResults()[0];
        System.out.println("testDistributedSum 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

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.