Search in sources :

Example 16 with ClientResponse

use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.

the class TestBlobType method testBigFatBlobs.

public void testBigFatBlobs() throws Exception {
    String simpleSchema = "create table blah (" + "ival bigint default 0 not null, " + "b varbinary(256) default null, " + "s varchar(256) default null, " + "PRIMARY KEY(ival));";
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema(simpleSchema);
    builder.addProcedures(BigFatBlobAndStringMD5.class);
    boolean success = builder.compile(Configuration.getPathToCatalogForTest("bigfatblobs.jar"), 1, 1, 0);
    assertTrue("Failed to compile catalog", success);
    MiscUtils.copyFile(builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("bigfatblobs.xml"));
    VoltDB.Configuration config = new VoltDB.Configuration();
    config.m_pathToCatalog = Configuration.getPathToCatalogForTest("bigfatblobs.jar");
    config.m_pathToDeployment = Configuration.getPathToCatalogForTest("bigfatblobs.xml");
    config.m_backend = BackendTarget.NATIVE_EE_JNI;
    ServerThread localServer = null;
    Client client = null;
    try {
        localServer = new ServerThread(config);
        localServer.start();
        localServer.waitForInitialization();
        client = ClientFactory.createClient();
        client.createConnection("localhost");
        byte[] b = new byte[5000000];
        char[] c = new char[5000000];
        for (int i = 0; i < b.length; i++) {
            b[i] = (byte) (i % 256);
            c[i] = (char) (i % 128);
        }
        String s = new String(c);
        ClientResponse cr = client.callProcedure("BigFatBlobAndStringMD5", b, s);
        assertEquals(ClientResponse.SUCCESS, cr.getStatus());
        VoltTable t = cr.getResults()[0];
        assertEquals(1, t.getRowCount());
        assertTrue(t.advanceRow());
        // Validate MD5 sums instead of the actual data. The returned VoltTable
        // can't hold it anyway due to a 1 MB limit.
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        assertTrue(Arrays.equals(md5.digest(b), t.getVarbinary("b_md5")));
        assertTrue(Arrays.equals(md5.digest(s.getBytes()), t.getVarbinary("s_md5")));
    } finally {
        // stop execution
        if (client != null) {
            client.close();
        }
        if (localServer != null) {
            localServer.shutdown();
            localServer.join();
        }
    }
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) Configuration(org.voltdb.VoltDB.Configuration) VoltTable(org.voltdb.VoltTable) VoltDB(org.voltdb.VoltDB) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration) ServerThread(org.voltdb.ServerThread) Client(org.voltdb.client.Client) MessageDigest(java.security.MessageDigest)

Example 17 with ClientResponse

use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.

the class TestCSVLoader method tearDown.

@After
public void tearDown() throws IOException, ProcCallException {
    final ClientResponse response = client.callProcedure("@AdHoc", "TRUNCATE TABLE BLAH;");
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) After(org.junit.After)

Example 18 with ClientResponse

use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.

the class TestJDBCLoader method setup.

@Before
public void setup() throws IOException, ProcCallException {
    ClientResponse response = client.callProcedure("@AdHoc", "SELECT COUNT(*) FROM BLAH;");
    assertEquals(0, response.getResults()[0].asScalarLong());
    response = client.callProcedure("@AdHoc", "SELECT COUNT(*) FROM JBLAH;");
    assertEquals(0, response.getResults()[0].asScalarLong());
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) Before(org.junit.Before)

Example 19 with ClientResponse

use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.

the class DeletesClient method performSnapshot.

public static void performSnapshot(Client client) {
    checkSnapshotComplete(client);
    if (m_snapshotInProgress) {
        System.out.println("Snapshot still in progress, bailing");
        return;
    }
    try {
        VoltTable[] results = client.callProcedure("@SnapshotDelete", new String[] { m_snapshotDir }, new String[] { m_snapshotId }).getResults();
    } catch (NoConnectionsException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (ProcCallException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    // m_totalRows should be accurate at this point
    m_snapshotSizes.add(m_totalRows);
    System.out.println("Performing Snapshot with total rows: " + m_totalRows);
    try {
        if (m_blockingSnapshots) {
            ClientResponse response = client.callProcedure("@SnapshotSave", m_snapshotDir, m_snapshotId, 1);
            if (response.getStatus() != ClientResponse.SUCCESS) {
                System.out.println("failed snapshot");
                System.out.println(response.getStatusString());
            }
        } else {
            client.callProcedure(new ProcedureCallback() {

                @Override
                public void clientCallback(ClientResponse response) {
                    if (response.getStatus() != ClientResponse.SUCCESS) {
                        System.out.println("failed snapshot");
                        System.out.println(response.getStatusString());
                    }
                }
            }, "@SnapshotSave", m_snapshotDir, m_snapshotId, 0);
        }
    } catch (NoConnectionsException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ProcCallException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) ProcedureCallback(org.voltdb.client.ProcedureCallback) NoConnectionsException(org.voltdb.client.NoConnectionsException) IOException(java.io.IOException) VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

Example 20 with ClientResponse

use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.

the class DeletesClient method collectStats.

static void collectStats(Client client) {
    try {
        ClientResponse resp = client.callProcedure("@Statistics", "management", 0);
        parseStats(resp);
    } catch (NoConnectionsException e) {
        System.err.println("Lost connection to database, terminating");
        System.exit(-1);
    } catch (IOException e) {
        e.printStackTrace();
    } catch (ProcCallException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) NoConnectionsException(org.voltdb.client.NoConnectionsException) IOException(java.io.IOException) ProcCallException(org.voltdb.client.ProcCallException)

Aggregations

ClientResponse (org.voltdb.client.ClientResponse)385 VoltTable (org.voltdb.VoltTable)195 Client (org.voltdb.client.Client)184 ProcCallException (org.voltdb.client.ProcCallException)107 IOException (java.io.IOException)54 NoConnectionsException (org.voltdb.client.NoConnectionsException)35 Test (org.junit.Test)32 ProcedureCallback (org.voltdb.client.ProcedureCallback)32 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)29 Configuration (org.voltdb.VoltDB.Configuration)28 File (java.io.File)19 Timestamp (java.sql.Timestamp)16 VoltDB (org.voltdb.VoltDB)16 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)16 VoltCompiler (org.voltdb.compiler.VoltCompiler)15 JSONException (org.json_voltpatches.JSONException)11 BigDecimal (java.math.BigDecimal)10 ExecutionException (java.util.concurrent.ExecutionException)10 ClientResponseImpl (org.voltdb.ClientResponseImpl)10 KeeperException (org.apache.zookeeper_voltpatches.KeeperException)9