Package org.voltdb.client

Examples of org.voltdb.client.Client


            fail();
        }
    }

    public void testBatchedMultipartitionTxns() throws IOException, ProcCallException {
        Client client = getClient();

        ClientResponse cresponse = client.callProcedure("BatchedMultiPartitionTest");
        System.err.println(cresponse);
        VoltTable[] results = cresponse.getResults();
        assertEquals(5, results.length);
        assertEquals(1, results[0].asScalarLong());
        assertEquals(1, results[1].asScalarLong());
View Full Code Here


    public void testLongStringUsage() throws IOException {
        System.err.println("CURRENT: " + ClassUtil.getCurrentMethodName());
        final int STRLEN = 5000;

        Client client = getClient();

        String longStringPart = "volt!";
        StringBuilder sb = new StringBuilder();
        while(sb.length() < STRLEN)
            sb.append(longStringPart);
        String longString = sb.toString();
        assertEquals(STRLEN, longString.length());

        VoltTable[] results = null;
        try {
            results = client.callProcedure("WorkWithBigString", 1, longString).getResults();
        } catch (ProcCallException e) {
            e.printStackTrace();
            fail();
        }
        assertEquals(1, results.length);
View Full Code Here

    public void testStringAsByteArrayParam() throws IOException {
        System.err.println("CURRENT: " + ClassUtil.getCurrentMethodName());
        final int STRLEN = 5000;

        Client client = getClient();

        String longStringPart = "volt!";
        StringBuilder sb = new StringBuilder();
        while(sb.length() < STRLEN)
            sb.append(longStringPart);
        String longString = sb.toString();
        assertEquals(STRLEN, longString.length());


        VoltTable[] results = null;
        try {
            results = client.callProcedure("PassByteArrayArg", 1, 2, longString.getBytes("UTF-8")).getResults();
        } catch (ProcCallException e) {
            e.printStackTrace();
            fail();
        }
        assertEquals(1, results.length);
View Full Code Here

        long l = Long.MAX_VALUE - 10;
        long lArray[] = new long[] { Long.MAX_VALUE - 10, Long.MAX_VALUE - 9, Long.MAX_VALUE - 8 };
        String str = "foo";
        byte bString[] = "bar".getBytes("UTF-8");

        Client client = getClient();
        try {
            client.callProcedure("PassAllArgTypes", b, bArray, s, sArray, i, iArray, l, lArray, str, bString);
        } catch (Exception e) {
            fail();
        }
    }
View Full Code Here

    private void executeAndTestUpdate(String table, String update,
                                      int expectedRowsChanged)
    throws IOException, ProcCallException
    {
        Client client = getClient();
        for (int i = 0; i < ROWS; ++i)
        {
            client.callProcedure("Insert", table, i, "desc", i, 14.5);
        }
        VoltTable[] results = client.callProcedure("@AdHoc", update).getResults();
        // ADHOC update still returns number of modified rows * number of partitions
        // Comment this out until it's fixed; the select count should be good enough, though
        //assertEquals(expectedRowsChanged, results[0].asScalarLong());
        String query = String.format("select count(%s.NUM) from %s where %s.NUM = -1",
                                     table, table, table);
        results = client.callProcedure("@AdHoc", query).getResults();
        assertEquals(expectedRowsChanged, results[0].asScalarLong());
    }
View Full Code Here

    //
    // Insert strings that violate the VARCHAR size limit.
    //
    public void testInsertViolatesStringLength() throws IOException, ProcCallException  {
        final Client client = this.getClient();
        boolean caught = false;


        // perform this test on the NULLS and NO_NULLS tables
        // by looping twice and setting params[0] differently each time.
        for (int i=0; i < 2; ++i) {
            final Object params[] = new Object[COLS + 2];
            params[0] = (i == 0) ? "NO_NULLS" : "ALLOW_NULLS";

            // insert a string that violates the varchar size.
            // there are three strings in the schema with sizes
            // that can be violated. test each.
            // loop three times and set a different
            // varchar to the too-big value each time.
            for (int stringcount = 0; stringcount < 3; ++stringcount) {
                int curr_string = 0;
                params[1] = pkey.incrementAndGet();
                for (int k=0; k < COLS; ++k) {
                    if ((m_types[k] == VoltType.STRING) && (stringcount == curr_string)) {
                        params[k+2] = ReallyLongString;
                    }
                    else {
                        params[k+2] = m_midValues[k];
                    }
                    if (m_types[k] == VoltType.STRING)
                        curr_string++;
                }
                try {
                    caught = false;
                    client.callProcedure("Insert", params);
                } catch (final ProcCallException e) {
                    caught = true;
                }

                assertTrue(caught);
View Full Code Here

    //
    // Test that the max serializable string length is correctly handled.
    // It must be rejected always since it is greater than the max varchar size.
    //
    public void testMaxSerializeStringSize() throws IOException, ProcCallException {
        final Client client = getClient();
        boolean caught = false;
        final Object params[] = new Object[COLS + 2];
        params[0] = "NO_NULLS";

        // array to build the Big String.
        final char blob[] = new char[VoltType.MAX_VALUE_LENGTH + 4];
        for (int i=0; i < blob.length; i++) {
            blob[i] = 'a';
        }

        // try to insert a max length string blob into each of the string fields
        // this string *is* fastserializable.
        for (int stringcount = 0; stringcount < 4; ++stringcount) {
            int curr_string = 0;
            params[1] = pkey.incrementAndGet();
            for (int k=0; k < COLS; ++k) {
                if ((m_types[k] == VoltType.STRING) && (stringcount == curr_string)) {
                    params[k+2] = new String(blob);
                }
                else {
                    params[k+2] = m_midValues[k];
                }
                if (m_types[k] == VoltType.STRING)
                    curr_string++;
            }
            try {
                caught = false;
                client.callProcedure("Insert", params);
            }
            catch (final RuntimeException e) {
                assertTrue(e.getCause() instanceof java.io.IOException);
                assertTrue(e.toString().contains("String exceeds maximum length of"));
                caught = true;
View Full Code Here

    //
    // Test that the max supported varchar can be inserted.
    //
    public void testMaxValidStringSize() throws IOException, ProcCallException {
        final Client client = getClient();
        boolean caught = false;
        final Object params[] = new Object[COLS + 2];
        params[0] = "NO_NULLS";

        // array to build the Big String.
        final char blob[] = new char[VoltType.MAX_VALUE_LENGTH];
        for (int i=0; i < blob.length; i++) {
            blob[i] = 'a';
        }

        // try to insert a max length string blob into each of the string fields
        // this string *is* fastserializable.
        for (int stringcount = 0; stringcount < 4; ++stringcount) {
            int curr_string = 0;
            params[1] = pkey.incrementAndGet();
            for (int k=0; k < COLS; ++k) {
                if ((m_types[k] == VoltType.STRING) && (stringcount == curr_string)) {
                    params[k+2] = new String(blob);
                }
                else {
                    params[k+2] = m_midValues[k];
                }
                if (m_types[k] == VoltType.STRING)
                    curr_string++;
            }
            try {
                caught = false;
                ClientResponse cr = client.callProcedure("Insert", params);
                assertNotNull(cr);
            }
            catch (final ProcCallException e) {
                caught = true;
            }
View Full Code Here

    //
    // Verify that NULLS are rejected in in NOT NULL columns
    //
    public void testInsertNulls_No_Nulls() throws 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) {
            boolean caught = false;

            // build the parameter list as described above
            params[0] = "NO_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);
            }

            // Each insert into the NO_NULLS table must fail with a
            // constraint failure.  Verify this.

            System.out.println("testNullsRejected: :" + k + " " + m_types[k]);
            try {
                ClientResponse cr = client.callProcedure("Insert", params);
                assertNotNull(cr);
            } catch (final ProcCallException e) {
                if (e.getMessage().contains("CONSTRAINT VIOLATION"))
                    caught = true;
                else {
View Full Code Here

    //
    // Verify that NULLS are allowed in non-NOT NULL columns
    //
    public void testInsertNulls_Nulls_Allowed() throws 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
            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);
            }

            // Each insert in to the ALLOW_NULLS table must succeed.
            // Perform the inserts and execute selects, verifying the
            // content of the select matches the parameters passed to
            // insert

            System.out.println("testNullsAllowed: " + k + " NULL type is " + m_types[k]);

            try {
                params[0] = "ALLOW_NULLS";
                // We'll use the multi-partition insert for this test.  Between
                // this and testInsertNull_No_Nulls we should cover both
                // cases in ticket 306
                client.callProcedure("InsertMulti", params);
            } catch (final ProcCallException e) {
                e.printStackTrace();
                fail();
            } catch (final NoConnectionsException e) {
                e.printStackTrace();
                fail();
            }

            // verify that the row was inserted
            try {
                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

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.