Search in sources :

Example 21 with ClientResponse

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

the class MatchChecks method getExportRowCount.

protected static long getExportRowCount(Client client) {
    // get the count of rows exported
    ClientResponse response = doAdHoc(client, "select sum(TOTAL_ROWS_EXPORTED) from exportcounts order by 1;");
    VoltTable[] countQueryResult = response.getResults();
    VoltTable data = countQueryResult[0];
    if (data.asScalarLong() == VoltType.NULL_BIGINT)
        return 0;
    return data.asScalarLong();
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) VoltTable(org.voltdb.VoltTable)

Example 22 with ClientResponse

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

the class MatchChecks method doAdHoc.

static ClientResponse doAdHoc(Client client, String query) {
    /* a very similar method is used in txnid2::txnidutils, try to keep them in sync */
    Boolean sleep = false;
    Boolean noConnections = false;
    Boolean timedOutOnce = false;
    while (true) {
        try {
            ClientResponse cr = client.callProcedure("@AdHoc", query);
            if (cr.getStatus() == ClientResponse.SUCCESS) {
                return cr;
            } else {
                log.debug(cr.getStatusString());
                log.error("unexpected response");
                System.exit(-1);
            }
        } catch (NoConnectionsException e) {
            noConnections = true;
        } catch (IOException e) {
            log.error("IOException", e);
            System.exit(-1);
        } catch (ProcCallException e) {
            ClientResponse cr = e.getClientResponse();
            String ss = cr.getStatusString();
            log.debug(ss);
            if (!timedOutOnce && ss.matches("(?s).*No response received in the allotted time.*")) /* allow a generic timeout but only once so that we don't risk masking error conditions */
            {
                //false;
                timedOutOnce = false;
                sleep = true;
            } else if (/*cr.getStatus() == ClientResponse.USER_ABORT &&*/
            (ss.matches("(?s).*AdHoc transaction -?[0-9]+ wasn.t planned against the current catalog version.*") || ss.matches(".*Connection to database host \\(.*\\) was lost before a response was received.*") || ss.matches(".*Transaction dropped due to change in mastership. It is possible the transaction was committed.*") || ss.matches("(?s).*Transaction being restarted due to fault recovery or shutdown.*") || ss.matches("(?s).*Invalid catalog update.  Catalog or deployment change was planned against one version of the cluster configuration but that version was no longer live.*"))) {
            } else if (ss.matches(".*Server is currently unavailable; try again later.*") || ss.matches(".*Server is paused.*") || ss.matches("(?s).*Server is shutting down.*")) {
                sleep = true;
            } else {
                log.error("Unexpected ProcCallException", e);
                System.exit(-1);
            }
        }
        if (sleep | noConnections) {
            try {
                Thread.sleep(3000);
            } catch (Exception f) {
            }
            sleep = false;
            if (noConnections)
                while (client.getConnectedHostList().size() == 0) ;
            noConnections = false;
        }
    }
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) NoConnectionsException(org.voltdb.client.NoConnectionsException) IOException(java.io.IOException) ProcCallException(org.voltdb.client.ProcCallException) ProcCallException(org.voltdb.client.ProcCallException) NoConnectionsException(org.voltdb.client.NoConnectionsException) IOException(java.io.IOException)

Example 23 with ClientResponse

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

the class MatchChecks method getStats.

protected static long[] getStats(Client client) {
    // check the start time, end time, and row count to calculate TPS
    long[] stats = new long[3];
    ClientResponse response = doAdHoc(client, "select count(*), since_epoch(Second, max(insert_time)), since_epoch(Second, min(insert_time)) from KAFKAIMPORTTABLE1;");
    VoltTable countQueryResult = response.getResults()[0];
    countQueryResult.advanceRow();
    stats[0] = (long) countQueryResult.get(0, VoltType.BIGINT);
    stats[1] = (long) countQueryResult.get(1, VoltType.BIGINT);
    stats[2] = (long) countQueryResult.get(2, VoltType.BIGINT);
    // double tps = (double) importRowCount / (double) elapsedMicroSecs;
    return stats;
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) VoltTable(org.voltdb.VoltTable)

Example 24 with ClientResponse

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

the class MatchChecks method checkPounderResults.

public static boolean checkPounderResults(long expected_rows, Client client) {
    // make sure import table has expected number of rows, and without gaps
    // we check the row count, then use min & max to infer the range is complete
    long importRowCount = 0;
    long importMax = 0;
    long importMin = 0;
    // check row count in import table
    // String table = alltypes ? "KafkaImportTable2" : "KafkaImportTable1";
    ClientResponse response = doAdHoc(client, "select count(key), min(key), max(key) from kafkaimporttable1");
    VoltTable countQueryResult = response.getResults()[0];
    countQueryResult.advanceRow();
    importRowCount = (long) countQueryResult.get(0, VoltType.BIGINT);
    importMin = (long) countQueryResult.get(1, VoltType.BIGINT);
    importMax = (long) countQueryResult.get(2, VoltType.BIGINT);
    if (importRowCount != expected_rows) {
        log.error(expected_rows + " expected. " + importRowCount + " received.");
        return false;
    }
    if (importMax == VoltType.NULL_BIGINT) {
        importMax = 0;
    }
    if (importMin == VoltType.NULL_BIGINT) {
        importMin = 0;
    }
    if ((importMax - importMin + 1) != expected_rows) {
        log.error(expected_rows + " expected. " + (importMax - importMin + 1) + " rows received.");
        return false;
    }
    return true;
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) VoltTable(org.voltdb.VoltTable)

Example 25 with ClientResponse

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

the class MatchChecks method getImportRowCount.

protected static long getImportRowCount(Client client) {
    // get the count of rows imported
    ClientResponse response = doAdHoc(client, "select sum(TOTAL_ROWS_DELETED) from importcounts order by 1;");
    VoltTable[] countQueryResult = response.getResults();
    VoltTable data = countQueryResult[0];
    if (data.asScalarLong() == VoltType.NULL_BIGINT)
        return 0;
    return data.asScalarLong();
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) VoltTable(org.voltdb.VoltTable)

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