Package org.voltdb.client

Examples of org.voltdb.client.Client


     * @SnapshotDelete
     */
    public void testSnapshotSave() throws Exception {
        System.out.println("Starting testSnapshotSave");

        Client client = getClient();
        int num_replicated_items_per_chunk = 100;
        int num_replicated_chunks = 10;
        int num_partitioned_items_per_chunk = 120;
        int num_partitioned_chunks = 10;

        loadLargeReplicatedTable(client, "REPLICATED_TESTER", num_replicated_items_per_chunk, num_replicated_chunks);

        loadLargePartitionedTable(client, "PARTITION_TESTER", num_partitioned_items_per_chunk, num_partitioned_chunks);

        VoltTable[] results = null;
        results = client.callProcedure("@SnapshotSave", TMPDIR, TESTNONCE, (byte) 1).getResults();

        validateSnapshot(true);

        // MORE SNAPSHOT SAVE TESTS
        FilenameFilter cleaner = new FilenameFilter() {
            public boolean accept(File dir, String file) {
                return file.startsWith(TESTNONCE) && file.endsWith("vpt");
            }
        };

        File tmp_dir = new File(TMPDIR);
        File[] tmp_files = tmp_dir.listFiles(cleaner);
        tmp_files[0].delete();

        // Instead of something exhaustive, let's just make sure that we get
        // the number of result rows corresponding to the number of
        // ExecutionSites
        // that did save work
        Cluster cluster = CatalogUtil.getCluster(this.getCatalog());
        Database database = cluster.getDatabases().get("database");
        CatalogMap<Table> tables = database.getTables();

        CatalogMap<Site> sites = cluster.getSites();
        int num_hosts = cluster.getHosts().size();
        int replicated = 0;
        int total_tables = 0;
        int expected_entries = 0;

        for (Table table : tables) {
            total_tables++;
            if (table.getIsreplicated()) {
                replicated++;
            }
        }

        for (Site s : sites) {
            for(Partition p : s.getPartitions())
                expected_entries++;
        }

        assertEquals(expected_entries, results[0].getRowCount());

        // Now, try the save again and verify that we fail (since all the save
        // files will still exist. This will return one entry per table
        // per host
        expected_entries = ((total_tables - replicated) * num_hosts) + replicated;
        try {
            results = client.callProcedure("@SnapshotSave", TMPDIR, TESTNONCE, (byte) 1).getResults();
        } catch (Exception ex) {
            ex.printStackTrace();
            fail("SnapshotSave exception: " + ex.getMessage());
        }

        System.out.println(results[0]);
        while (results[0].advanceRow()) {
            if (!tmp_files[0].getName().contains(results[0].getString("TABLE"))) {
                assertEquals(results[0].getString("RESULT"), "FAILURE");
                // can also fail due to "SNAPSHOT IN PROGRESS"
                // assertTrue(results[0].getString("ERR_MSG").contains("SAVE FILE ALREADY EXISTS"));
            }
        }

        VoltTable deleteResults[] = client.callProcedure("@SnapshotDelete", new String[] { TMPDIR }, new String[] { TESTNONCE }).getResults();

        assertNotNull(deleteResults);
        assertEquals(1, deleteResults.length);
        System.out.println(deleteResults[0]);
        assertEquals(9, deleteResults[0].getColumnCount());
View Full Code Here


    /**
     * testSendPayment
     */
    public void testSendPayment() throws Exception {
        CatalogContext catalogContext = this.getCatalogContext();
        Client client = this.getClient();
        TestSmallBankSuite.initializeSmallBankDatabase(catalogContext, client);
        long acctIds[] = { 1l, 2l };
        double balances[] = { 100d, 0d };
        ClientResponse cresponse;
        VoltTable results[];

        Table catalog_tbl = catalogContext.getTableByName(SmallBankConstants.TABLENAME_ACCOUNTS);
        long num_rows = RegressionSuiteUtil.getRowCount(client, catalog_tbl);
        assert(num_rows > acctIds[acctIds.length-1]);
        // System.err.println("# of Rows: " + num_rows);
       
        for (int i = 0; i < acctIds.length; i++) {
            updateBalance(client, acctIds[i], balances[i]);
            checkBalance(client, acctIds[i], balances[i]);
        } // FOR
       
        // Run the SendPayment txn to send all the money from the first
        // account to the second account.
        cresponse = client.callProcedure(SendPayment.class.getSimpleName(),
                                         acctIds[0], acctIds[1], balances[0]);
        assertEquals(Status.OK, cresponse.getStatus());
        results = cresponse.getResults();
        assertEquals(2, results.length);
        for (int i = 0; i < results.length; i++) {
View Full Code Here

    /**
     * testSendPaymentInsufficientFunds
     */
    public void testSendPaymentInsufficientFunds() throws Exception {
        CatalogContext catalogContext = this.getCatalogContext();
        Client client = this.getClient();
        TestSmallBankSuite.initializeSmallBankDatabase(catalogContext, client);
       
        long acctIds[] = { 1l, 2l };
        double balances[] = { 0d, 100d };
        ClientResponse cresponse;
       
        for (int i = 0; i < acctIds.length; i++) {
            updateBalance(client, acctIds[i], balances[i]);
            checkBalance(client, acctIds[i], balances[i]);
        } // FOR
       
        // Run the SendPayment txn that tries to send to money from the first account,
        // but it should fail because the balance is zero
        try {
            cresponse = client.callProcedure(SendPayment.class.getSimpleName(),
                                             acctIds[0], acctIds[1], balances[1]);
        } catch (ProcCallException ex) {
            cresponse = ex.getClientResponse();
        }
        assertEquals(Status.ABORT_USER, cresponse.getStatus());
View Full Code Here

    };

    public void testSinglePartitionInsert()
    throws IOException, ProcCallException
    {
        Client client = getClient();
        VoltTable[] results = client.callProcedure("InsertSinglePart", 1,
                                                   "desc", 100, 14.5).getResults();
        assertEquals(1, results[0].asScalarLong());
        results = client.callProcedure("SelectSinglePart", 1).getResults();
        System.out.println(results[0].toString());
        assertEquals(1, results[0].getRowCount());
        results = client.callProcedure("UpdateSinglePart", 200, 1).getResults();
    }
View Full Code Here

    }

    public void testMultiPartitionInsert()
    throws IOException, ProcCallException
    {
        Client client = getClient();
        VoltTable[] results = client.callProcedure("InsertMultiPart", 1,
                                                   "desc", 100, 14.5).getResults();
        assertEquals(1, results[0].asScalarLong());
        results = client.callProcedure("SelectMultiPart").getResults();
        System.out.println(results[0].toString());
        assertEquals(1, results[0].getRowCount());
    }
View Full Code Here

    }

    public void testMultiPartitionReplInsert()
    throws IOException, ProcCallException
    {
        Client client = getClient();
        VoltTable[] results = client.callProcedure("InsertMultiPartRepl", 1,
                                                   "desc", 100, 14.5).getResults();
        System.out.println("results: " + results[0].toString());
        assertEquals(1, results[0].asScalarLong());
        results = client.callProcedure("SelectMultiPartRepl").getResults();
        System.out.println(results[0].toString());
        assertEquals(1, results[0].getRowCount());
        results = client.callProcedure("UpdateMultiPartRepl", 200).getResults();
    }
View Full Code Here

    // read/write so that it would block and eventually time out
    // when it fails.
    public void testSelectEmptyTable()
    throws IOException, ProcCallException, InterruptedException
    {
        Client client = getClient();
        VoltTable[] results = client.callProcedure("SelectEmptyTable", 1).getResults();
        System.out.println("results: " + results[0].toString());
    }
View Full Code Here

    // Make sure date and random number APIs return deterministic results
    public void testDeterminismInAPI()
    throws IOException, ProcCallException
    {
        Client client = getClient();
        // should fail if both copies don't return the same result or if an
        // exception is thrown
        VoltTable[] results = client.callProcedure("EvilDeterminism", 1).getResults();
        assertEquals(1, results[0].getRowCount());
    }
View Full Code Here

    public TestFailuresSuite(String name) {
        super(name);
    }
   
    public void testAssertError() throws IOException {
        Client client = getClient();
        boolean had_error = false;
        try {
            client.callProcedure(AssertFail.class.getSimpleName(), 0L, 0L, 1L);
            System.out.println("FAIL(1) testAssertError");
        } catch (ProcCallException e) {
            e.printStackTrace();
            assertTrue(e.getMessage(), e.getMessage().contains(AssertFail.ERROR_MSG));
            System.out.println("PASSED testAssertError");
View Full Code Here

        return;
    }

    public void testVoilateUniqueness() throws IOException {
        System.out.println("STARTING testVU");
        Client client = getClient();

        VoltTable[] results = null;
        try {
            results = client.callProcedure("ViolateUniqueness", 1L, 1L, 1L).getResults();
            System.out.println("testVU client response received");
            assertEquals(results.length, 0);
        } catch (ProcCallException e) {
            try {
                results = client.callProcedure("InsertNewOrder", 2L, 2L, 2L).getResults();
            } catch (ProcCallException e1) {
                fail(e1.toString());
            } catch (IOException e1) {
                fail(e1.toString());
            }
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.