Package org.voltdb.client

Examples of org.voltdb.client.Client


        }
        fail("testViolateUniqueness should return while catching ProcCallException");
    }

    public void testVoilateUniquenessAndCatchException() throws IOException {
        Client client = getClient();
        System.out.println("STARTING testVoilateUniquenessAndCatchException");
        VoltTable[] results = null;
        try {
            results = client.callProcedure("ViolateUniquenessAndCatchException", 1L, 1L, 1L).getResults();
            assertTrue(results.length == 1);
            System.out.println("PASSED testVoilateUandCE");
        } catch (ProcCallException e) {
            System.out.println("FAIL(1) testVoilateUandCE");
            e.printStackTrace();
            fail("ViolateUniquenessAndCatchException should not have thrown a ProcCallException");
        } catch (IOException e) {
            System.out.println("FAIL(2) testVoilateUandCE");
            fail(e.toString());
            return;
        }

        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


    /*
     * Check that a very large ConstraintFailureException can serialize correctly.
     */
    public void testTicket511_ViolateUniquenessWithLargeString() throws Exception {
        Client client = getClient();
        System.out.println("STARTING testTicket511_ViolateUniquenessWithLargeString");
        byte stringData[] = new byte[60000];
        java.util.Arrays.fill(stringData, (byte)'a');

        client.callProcedure("InsertBigString", 0, new String(stringData, "UTF-8"));

        java.util.Arrays.fill(stringData, (byte)'b');
        boolean threwException = false;
        try {
            client.callProcedure("InsertBigString", 0, new String(stringData, "UTF-8"));
        } catch (ProcCallException e) {
            threwException = true;
            assertTrue(e.getMessage().contains("CONSTRAINT VIOLATION"));
            assertTrue(e.getCause().getMessage().toUpperCase().contains("UNIQUE"));
            if (!isHSQL()) {
View Full Code Here

//        fail("Should gracefully fail from using too much temp table memory, but didn't.");
//    }

    public void testQueueCleanupFailure() throws IOException, ProcCallException {
        System.out.println("STARTING testQueueCleanupFailure");
        Client client = getClient();

        VoltTable[] results = null;

        results = client.callProcedure("CleanupFail", 0, 0, 0).getResults();
        assertEquals(1, results.length);
        assertEquals(1, results[0].asScalarLong());

        results = client.callProcedure("CleanupFail", 2, 2, 2).getResults();
        assertEquals(1, results.length);
        assertEquals(1, results[0].asScalarLong());
    }
View Full Code Here

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

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

        try {
            client.callProcedure("TooFewParams", 1);
            fail();
        } catch (ProcCallException e) {
            assertTrue(e.getMessage(), e.getMessage().contains("EXPECTS"));
        }

        try {
            client.callProcedure("TooFewParams");
            fail();
        } catch (ProcCallException e) {
            assertTrue(e.getMessage(), e.getMessage().contains("EXPECTS"));
        }
    }
View Full Code Here

        }
    }

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

        try {
            client.callProcedure("TooFewParams", 1, 1);
            fail();
        } catch (ProcCallException e) {
        }
    }
View Full Code Here

//        client.callProcedure("@AdHoc", "select * from warehouse;");
//    }

    public void testAppStatus() throws Exception {
        System.out.println("STARTING testAppStatus");
        Client client = getClient();

        ClientResponse response = client.callProcedure( "ReturnAppStatus", 0, "statusstring", (byte)0);
        assertNull(response.getAppStatusString());
        assertEquals(response.getAppStatus(), Byte.MIN_VALUE);
        assertEquals(response.getResults()[0].getStatusCode(), Byte.MIN_VALUE);

        response = client.callProcedure( "ReturnAppStatus", 1, "statusstring", (byte)1);
        assertTrue(response.getAppStatusString(), "statusstring".equals(response.getAppStatusString()));
        assertEquals(response.getAppStatus(), 1);
        assertEquals(response.getResults()[0].getStatusCode(), 1);

        response = client.callProcedure( "ReturnAppStatus", 2, "statusstring", (byte)2);
        assertNull(response.getAppStatusString(), response.getAppStatusString());
        assertEquals(response.getAppStatus(), 2);
        assertEquals(response.getResults()[0].getStatusCode(), 2);

        response = client.callProcedure( "ReturnAppStatus", 3, "statusstring", (byte)3);
        assertTrue(response.getAppStatusString(), "statusstring".equals(response.getAppStatusString()));
        assertEquals(response.getAppStatus(), Byte.MIN_VALUE);
        assertEquals(response.getResults()[0].getStatusCode(), 3);

        boolean threwException = false;
        try {
            response = client.callProcedure( "ReturnAppStatus", 4, "statusstring", (byte)4);
        } catch (ProcCallException e) {
            threwException = true;
            response = e.getClientResponse();
        }
        assertTrue(threwException);
View Full Code Here

   
    /**
     * testConflictingTxns
     */
    public void testConflictingTxns() throws Exception {
        Client client = this.getClient();
        RegressionSuiteUtil.initializeTM1Database(this.getCatalogContext(), client);
       
        // Submit a distributed txn and make sure that our conflicting
        // txn is not speculatively executed
        final int sleepTime = 5000; // ms
        final LatchableProcedureCallback dtxnCallback = new LatchableProcedureCallback(1);
       
        // We're going to first execute a dtxn that updates all SUBSCRIBER records
        String dtxnProcName = UpdateAll.class.getSimpleName();
        Object dtxnParams[] = { 0, sleepTime };
        client.callProcedure(dtxnCallback, dtxnProcName, dtxnParams);
       
        // Then fire off a proc that updates SUBSCRIBER as well. This should never
        // be allowed to execute speculatively
        String spProcName = UpdateOne.class.getSimpleName();
        Object spParams[] = new Object[]{ 1 };
        LatchableProcedureCallback spCallback = new LatchableProcedureCallback(1);
        ThreadUtil.sleep(100);
        client.callProcedure(spCallback, spProcName, spParams);
       
        // Wait until we have both latches
        dtxnCallback.latch.await(sleepTime*2, TimeUnit.MILLISECONDS);
        spCallback.latch.await(sleepTime*2, TimeUnit.MILLISECONDS);
       
        // Then verify the DTXN results
        ClientResponse dtxnResponse = CollectionUtil.first(dtxnCallback.responses);
        assertNotNull(dtxnResponse);
        assertEquals(Status.OK, dtxnResponse.getStatus());
        assertTrue(dtxnResponse.hasDebug());
        assertFalse(dtxnResponse.isSinglePartition());
        assertFalse(dtxnResponse.isSpeculative());
       
        // And the SP results. Where is your god now?
        ClientResponse spResponse = CollectionUtil.first(spCallback.responses);
        assertNotNull(spResponse);
        assertEquals(Status.OK, spResponse.getStatus());
        assertTrue(spResponse.hasDebug());
        assertTrue(spResponse.isSinglePartition());
       
        // There is currently a race condition for whether the txn will get
        // speculatively executed or not, so for now we'll just disable this
        // one check.
        // sassertTrue(spResponse.isSpeculative());
       
        // SANITY CHECK
        // We should have exaclty two different MSC_LOCATION values
        String procName = VoltSystemProcedure.procCallName(AdHoc.class);
        String query = "SELECT COUNT(DISTINCT MSC_LOCATION) FROM " + TM1Constants.TABLENAME_SUBSCRIBER;
        ClientResponse cresponse = client.callProcedure(procName, query);
        assertEquals(Status.OK, cresponse.getStatus());
        assertEquals(2, cresponse.getResults()[0].asScalarLong());
        System.err.println(cresponse);
    }
View Full Code Here

   
    /**
     * testRemoteIdle
     */
    public void testRemoteIdle() throws Exception {
        Client client = this.getClient();
        RegressionSuiteUtil.initializeTM1Database(this.getCatalogContext(), client);
       
        final int sleepTime = 10000; // ms
        final ClientResponse dtxnResponse[] = new ClientResponse[1];
        final AtomicBoolean latch = new AtomicBoolean(true);
        final ProcedureCallback callback = new ProcedureCallback() {
            @Override
            public void clientCallback(ClientResponse clientResponse) {
                // System.err.println("DISTRUBTED RESULT " + clientResponse);
                dtxnResponse[0] = clientResponse;
                latch.set(false);
            }
        };
       
        // We're going to first execute a long running and slow distributed transaction
        // on the first partition. It will sleep for 10 seconds
        String procName = RemoteIdle.class.getSimpleName();
        Object params[] = { 0, sleepTime };
        client.callProcedure(callback, procName, params);
        long start = System.currentTimeMillis();
       
        // While we're waiting for that to come back, we're going to fire off
        // a bunch of single-partition txns that should all be executed
        // speculatively at the other partition
        TM1Client.Transaction txn = Transaction.GET_SUBSCRIBER_DATA;
        params = new Object[]{ 1 };
        ClientResponse cresponse = null;
        int specexec_ctr = 0;
        while (latch.get()) {
            // Just sleep for a little bit so that we don't blast the cluster
            ThreadUtil.sleep(500);
           
            // System.err.println("Requesting " + txn + " for speculative execution");
            try {
                cresponse = client.callProcedure(txn.callName, params);
                assertEquals(Status.OK, cresponse.getStatus());
            } catch (ProcCallException ex) {
                cresponse = ex.getClientResponse();
                assertEquals(cresponse.toString(), Status.ABORT_USER, cresponse.getStatus());
            }
View Full Code Here

        setUpSnapshotDir();
       
        int num_replicated_items_per_chunk = 3;
        int num_replicated_chunks = 2;

        Client client = getClient();
        loadLargeReplicatedTable(client, "REPLICATED_TESTER", num_replicated_items_per_chunk, num_replicated_chunks);

        VoltTable[] results = null;
        results = saveTables(client);

        validateSnapshot(true);

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

        System.out.println("@Statistics after saveTables :");
        System.out.println(results_tmp[0]);

        // Kill and restart all the execution sites.
        m_config.shutDown();
        m_config.startUp();
        client = getClient();

        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());
        }

        System.out.println("@Statistics after restore:");
        results = client.callProcedure("@Statistics", "table", 0).getResults();
        System.out.println(results[0]);

        checkTable(client, "REPLICATED_TESTER", "RT_ID", num_replicated_items_per_chunk * num_replicated_chunks);

        int foundItem = 0;
View Full Code Here

     */
    public Client getClient() throws IOException {
        final List<String> listeners = m_config.getListenerAddresses();
        final Random r = new Random();
        final String listener = listeners.get(r.nextInt(listeners.size()));
        final Client client = ClientFactory.createClient();
        client.createConnection(null, listener, HStoreConstants.DEFAULT_PORT, m_username, m_password);
        m_clients.add(client);
        return client;
    }
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.