Package org.voltdb.client

Examples of org.voltdb.client.Client


        }
    }

    public void testUpdateToNull() throws IOException, ProcCallException
    {
        final Client client = this.getClient();

        final Object params[] = new Object[COLS + 2];

        for (int k=0; k < COLS; ++k) {

            // build the parameter list as described above
            // Fill the row with non-null data and insert
            params[0] = "";
            params[1] = pkey.incrementAndGet();
            for (int i = 0; i < COLS; i++) {
                params[i+2] = m_midValues[i];
                assert(params[i+2] != null);
            }
            params[0] = "ALLOW_NULLS";
            client.callProcedure("Insert", params);


            for (int i = 0; i < COLS; i++) {
                params[i+2] = (i == k) ? m_nullValues[i] : m_midValues[i];
                assert(params[i+2] != null);
            }

            try {
                client.callProcedure("Update", params);
            } catch (final ProcCallException e) {
                e.printStackTrace();
                fail();
            } catch (final NoConnectionsException e) {
                e.printStackTrace();
                fail();
            }

            // verify that the row was updated
            final VoltTable[] result = client.callProcedure("Select", "ALLOW_NULLS", pkey.get()).getResults();
            final VoltTableRow row = result[0].fetchRow(0);
            for (int i=0; i < COLS; ++i) {
                final Object obj = row.get(i+1, m_types[i]);
                if (i == k) {
                    assertTrue(row.wasNull());
View Full Code Here


    }

    public void testUpdateFromNull()
    throws NoConnectionsException, ProcCallException, IOException
    {
        final Client client = this.getClient();

        final Object params[] = new Object[COLS + 2];

        for (int k=0; k < COLS; ++k) {

            // build the parameter list as described above
            // Fill the row with diagonal null data and insert
            params[0] = "";
            params[1] = pkey.incrementAndGet();
            for (int i = 0; i < COLS; i++) {
                params[i+2] = (i == k) ? m_nullValues[i] : m_midValues[i];
                assert(params[i+2] != null);
            }
            params[0] = "ALLOW_NULLS";
            client.callProcedure("Insert", params);

            for (int i = 0; i < COLS; i++) {
                params[i+2] = m_midValues[i];
                assert(params[i+2] != null);
            }

            try {
                client.callProcedure("Update", params);
            } catch (final ProcCallException e) {
                e.printStackTrace();
                fail();
            } catch (final NoConnectionsException e) {
                e.printStackTrace();
                fail();
            }

            // verify that the row was updated
            final VoltTable[] result = client.callProcedure("Select", "ALLOW_NULLS", pkey.get()).getResults();
            final VoltTableRow row = result[0].fetchRow(0);
            for (int i=0; i < COLS; ++i) {
                final Object obj = row.get(i+1, m_types[i]);
                assertTrue( comparisonHelper(obj, params[i+2], m_types[i]) );
            }
View Full Code Here

    }

    public void testDeleteNulls()
    throws NoConnectionsException, ProcCallException, IOException
    {
        final Client client = this.getClient();

        // Insert a NULL value for each column. For the first
        // row, insert null in the first column, for the 5th row
        // in the 5 column, etc.

        final Object params[] = new Object[COLS + 2];

        for (int k=0; k < COLS; ++k) {

            // build the parameter list as described above
            // Fill the row with diagonal null data and insert
            params[0] = "ALLOW_NULLS";
            params[1] = pkey.incrementAndGet();
            for (int i = 0; i < COLS; i++) {
                params[i+2] = (i == k) ? m_nullValues[i] : m_midValues[i];
                assert(params[i+2] != null);
            }
            client.callProcedure("Insert", params);
            VoltTable[] result = client.callProcedure("Select", "ALLOW_NULLS", pkey.get()).getResults();
            System.out.println(result[0]);

            try {
                client.callProcedure("Delete", "ALLOW_NULLS", pkey.get());
            } catch (final ProcCallException e) {
                e.printStackTrace();
                fail();
            } catch (final NoConnectionsException e) {
                e.printStackTrace();
                fail();
            }

            // verify that the row was deleted
            result = client.callProcedure("Select", "ALLOW_NULLS", pkey.get()).getResults();
            assertEquals(0, result[0].getRowCount());
        }
     }
View Full Code Here

     }

    public void testMissingAttributeInsert_With_Defaults()
    throws NoConnectionsException, ProcCallException, IOException
    {
        Client client = this.getClient();

        Object params[] = new Object[COLS + 2];

        params[0] = "WITH_DEFAULTS";
        params[1] = pkey.incrementAndGet();
        for (int i = 0; i < COLS; i++) {
            params[i+2] = m_defaultValues[i];
            assert(params[i+2] != null);
        }

        try {
            client.callProcedure("Insert", params);
        } catch (ProcCallException e) {
            e.printStackTrace();
            fail();
        } catch (NoConnectionsException e) {
            e.printStackTrace();
            fail();
        }

        VoltTable[] result = client.callProcedure("Select", "WITH_DEFAULTS", pkey.get()).getResults();
        VoltTableRow row = result[0].fetchRow(0);
        for (int i=0; i < COLS; ++i) {
            Object obj = row.get(i+1, m_types[i]);
            assertTrue( comparisonHelper(obj, params[i+2], m_types[i]) );
        }
View Full Code Here

    }

    public void testMissingAttributeInsert_With_Null_Defaults()
    throws NoConnectionsException, ProcCallException, IOException
    {
        Client client = this.getClient();

        Object params[] = new Object[COLS + 2];

        params[0] = "WITH_NULL_DEFAULTS";
        params[1] = pkey.incrementAndGet();
        for (int i = 0; i < COLS; i++) {
            params[i+2] = m_nullValues[i];
            assert(params[i+2] != null);
        }

        try {
            client.callProcedure("Insert", params);
        } catch (ProcCallException e) {
            e.printStackTrace();
            fail();
        } catch (NoConnectionsException e) {
            e.printStackTrace();
            fail();
        }

        VoltTable[] result = client.callProcedure("Select", "WITH_NULL_DEFAULTS", pkey.get()).getResults();
        VoltTableRow row = result[0].fetchRow(0);
        for (int i=0; i < COLS; ++i) {
            Object obj = row.get(i+1, m_types[i]);
            assertTrue( comparisonHelper(obj, params[i+2], m_types[i]) );
        }
View Full Code Here

    // Round trip the maximum value
    //
    public void testInsertMaxValues_No_Nulls()
    throws NoConnectionsException, ProcCallException, IOException
    {
        final Client client = this.getClient();

        // Insert a MAX value for each column. For the first
        // row, insert MAX in the first column, for the 5th row
        // in the 5 column, etc.

        final Object params[] = new Object[COLS + 2];

        for (int k=0; k < COLS; ++k) {

            // build the parameter list as described above
            params[0] = "";
            params[1] = pkey.incrementAndGet();
            for (int i = 0; i < COLS; i++) {
                params[i+2] = (i == k) ? m_maxValues[i] : m_midValues[i];
                assert(params[i+2] != null);
            }

            // Perform the inserts and execute selects, verifying the
            // content of the select matches the parameters passed to
            // insert

            System.out.println("testInsertMaxValues: " + k + " MAX type is " + m_types[k]);
            params[0] = "NO_NULLS";
            client.callProcedure("Insert", params);
            // verify that the row was updated
            final VoltTable[] result = client.callProcedure("Select", "NO_NULLS", pkey.get()).getResults();
            final VoltTableRow row = result[0].fetchRow(0);
            for (int i=0; i < COLS; ++i) {
                final Object obj = row.get(i+1, m_types[i]);
                assertTrue (!row.wasNull());
                assertTrue( comparisonHelper(obj, params[i+2], m_types[i]) );
View Full Code Here

    // Round trip the minimum value.
    //
    public void testInsertMinValues_No_Nulls()
        throws NoConnectionsException, ProcCallException, IOException
    {
        final Client client = this.getClient();

        // Insert a MIN value for each column. For the first
        // row, insert null in the first column, for the 5th row
        // in the 5 column, etc.

        final Object params[] = new Object[COLS + 2];

        for (int k=0; k < COLS; ++k) {

            // build the parameter list as described above
            params[0] = "";
            params[1] = pkey.incrementAndGet();
            for (int i = 0; i < COLS; i++) {
                params[i+2] = (i == k) ? m_minValues[i] : m_midValues[i];
                assert(params[i+2] != null);
            }

            // Perform the inserts and execute selects, verifying the
            // content of the select matches the parameters passed to
            // insert

            System.out.println("testInsertMinValues: " + k + " MIN type is " + m_types[k]);
            params[0] = "NO_NULLS";
            client.callProcedure("Insert", params);
            final VoltTable[] result = client.callProcedure("Select", "NO_NULLS", pkey.get()).getResults();
            final VoltTableRow row = result[0].fetchRow(0);
            for (int i=0; i < COLS; ++i) {
                final Object obj = row.get(i+1, m_types[i]);
                assertTrue (!row.wasNull());
                assertTrue( comparisonHelper(obj, params[i+2], m_types[i]) );
View Full Code Here

//            assertEquals(expect, got);
//        }
//    }

    public void testJumboRow() throws Exception {
        final Client client = getClient();
        byte firstStringBytes[] = new byte[1048576];
        java.util.Arrays.fill(firstStringBytes, (byte)'c');
        String firstString = new String(firstStringBytes, "UTF-8");
        byte secondStringBytes[] = new byte[1048564];
        java.util.Arrays.fill(secondStringBytes, (byte)'a');
        String secondString = new String(secondStringBytes, "UTF-8");

        Object params[] = new Object[] {
                "JUMBO_ROW",
                0,
                0,
                0,
                0,
                0,
                0.0,
                new TimestampType(0),
                firstString,
                secondString,
                "",
                "",
                VoltType.NULL_DECIMAL
        };
        VoltTable results[] = client.callProcedure("Insert", params).getResults();
        params = null;
        firstString = null;
        secondString = null;

        assertEquals(results.length, 1);
        assertEquals( 1, results[0].asScalarLong());

        results = client.callProcedure("Select", "JUMBO_ROW", 0).getResults();
        assertEquals(results.length, 1);
        assertTrue(results[0].advanceRow());
        assertTrue(java.util.Arrays.equals( results[0].getStringAsBytes(1), firstStringBytes));
        assertTrue(java.util.Arrays.equals( results[0].getStringAsBytes(2), secondStringBytes));

        java.util.Arrays.fill(firstStringBytes, (byte)'q');
        firstString = new String(firstStringBytes, "UTF-8");
        java.util.Arrays.fill(secondStringBytes, (byte)'r');
        secondString = new String(secondStringBytes, "UTF-8");

        params = new Object[] {
                "JUMBO_ROW",
                0,
                0,
                0,
                0,
                0,
                0.0,
                new TimestampType(0),
                firstString,
                secondString,
                "",
                "",
                VoltType.NULL_DECIMAL
        };

        results = client.callProcedure("Update", params).getResults();
        params = null;
        firstString = null;
        secondString = null;

        assertEquals(results.length, 1);
        assertEquals( 1, results[0].asScalarLong());

        results = client.callProcedure("Select", "JUMBO_ROW", 0).getResults();
        assertEquals(results.length, 1);
        assertTrue(results[0].advanceRow());
        assertTrue(java.util.Arrays.equals( results[0].getStringAsBytes(1), firstStringBytes));
        assertTrue(java.util.Arrays.equals( results[0].getStringAsBytes(2), secondStringBytes));
    }
View Full Code Here

        deleteTestFiles();
        setUpSnapshotDir();

        VoltTable results[] = null;
        Client client = this.getClient();
        CatalogContext cc = this.getCatalogContext();      
       
        // Load database
        try {
            initializeTPCCDatabase(cc, client, false);
        } catch (Exception e) {
            e.printStackTrace();
        }
        // Take Snapshot
        results = null;
        results = saveTables(client);

        validateSnapshot(true);
        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(results[0]);

        VoltTable[] results_tmp = null;
        results_tmp = client.callProcedure("@Statistics", "table", 0).getResults();

        System.out.println("@Statistics before restart :");
        System.out.println(results_tmp[0]);
               
        // Kill and restart all the execution sites.
        m_config.shutDown();
        m_config.startUp();
        client = getClient();

        Calendar calendar;
        long t1,t2;

        calendar = Calendar.getInstance();                   
        t1 = calendar.getTimeInMillis();
       
        // LOGICAL : SNAPSHOT + CMD LOG
        try {
            results = client.callProcedure("@SnapshotRestore", TMPDIR, TESTNONCE, ALLOWEXPORT).getResults();

            System.out.println(results[0]);
            while (results[0].advanceRow()) {
                if (results[0].getString("RESULT").equals("FAILURE")) {
                    fail(results[0].getString("ERR_MSG"));
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            fail("SnapshotRestore exception: " + ex.getMessage());
        }       
       
        validateSnapshot(true);
       
        System.out.println("@Statistics after LOGICAL snapshot restore:");
        results = client.callProcedure("@Statistics", "table", 0).getResults();
        System.out.println(results[0]);
               
        //File logDir = new File("/mnt/pmfs" + File.separator + "cmdlog");                              
        File logDir = new File("./obj" + File.separator + "cmdlog");                              
       
View Full Code Here

        }

        int ctr = 0;
        Iterator<LogEntry> log_itr = reader.iterator();
        ClientResponse cresponse = null;
        Client client = this.getClient();
        CatalogContext cc = this.getCatalogContext();
        VoltTable results[] = null;

        while (log_itr.hasNext()) {
            LogEntry entry = log_itr.next();

            assert(entry != null);
            //System.err.println("REDO :: TXN ID :" + entry.getTransactionId().longValue());
            //System.err.println("REDO :: PROC ID :" + entry.getProcedureId());

            Object[] entryParams = entry.getProcedureParams().toArray();
       
            String procName = cc.getProcedureById(entry.getProcedureId()).fullName();
            Procedure catalog_proc = cc.procedures.getIgnoreCase(procName);

            if(catalog_proc.getReadonly() == false){
                // System.out.println("Invoking procedure ::" + procName);

                cresponse = client.callProcedure(procName, entryParams);
                assertEquals(cresponse.getStatus(), Status.OK);
               
                // results = cresponse.getResults();
                // assertEquals(results.length, 1);
            }
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.