Search in sources :

Example 26 with ClientResponse

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

the class MatchChecks method checkRowMismatch.

protected static long checkRowMismatch(Client client) {
    // check if any rows failed column by colunn comparison so we can fail fast
    ClientResponse response = doAdHoc(client, "select key from importcounts where value_mismatch = 1 limit 1;");
    VoltTable[] result = response.getResults();
    if (// || result[0].asScalarLong() == 0)
    result[0].getRowCount() == 0)
        return 0;
    return result[0].asScalarLong();
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) VoltTable(org.voltdb.VoltTable)

Example 27 with ClientResponse

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

the class AsyncBenchmark method runNoArgs.

public static void runNoArgs(boolean readOnly) throws Exception {
    Random r = new java.util.Random();
    // Run the benchmark loop for the requested duration
    long endTime = System.currentTimeMillis() + (1000l * duration);
    while (endTime > System.currentTimeMillis() && !stopTheMadness) {
        Con.executeAsync(new org.voltdb.client.ProcedureCallback() {

            public void clientCallback(ClientResponse clientResponse) throws Exception {
                if (clientResponse.getStatus() != ClientResponse.SUCCESS) {
                    System.out.println(clientResponse.getStatusString());
                    System.exit(-1);
                }
            }
        }, readOnly ? "NoArgs" : "NoArgsRW", r.nextLong(), resultSize);
        // Use the limiter to throttle client activity
        limiter.throttle();
    }
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) Random(java.util.Random) ProcedureCallback(org.voltdb.client.ProcedureCallback)

Example 28 with ClientResponse

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

the class ScanBenchmark method runBenchmark.

/**
     * Core benchmark code.
     * Connect. Initialize. Run the loop. Cleanup. Print Results.
     *
     * @throws Exception if anything unexpected happens.
     */
public void runBenchmark() throws Exception {
    System.out.print(HORIZONTAL_RULE);
    System.out.println(" Setup & Initialization");
    System.out.println(HORIZONTAL_RULE);
    // connect to one or more servers, loop until success
    connect(config.servers);
    System.out.print(HORIZONTAL_RULE);
    System.out.println("Loading Tuples");
    System.out.println(HORIZONTAL_RULE);
    String loadproc = null;
    String tablename = null;
    String scanproc = null;
    if (config.test.equals("sequential")) {
        loadproc = "NARROW_P.insert";
        tablename = "narrow_p";
        scanproc = "MinSeqScan";
    } else if (config.test.equals("index")) {
        loadproc = "NARROW_INDEX_P.insert";
        tablename = "narrow_index_p";
        scanproc = "MinIndexScan";
    }
    for (long i = 0; i < config.rows; i++) {
        client.callProcedure(new NullCallback(), loadproc, i % 509, /* radom prime */
        i);
        if ((i % 100000) == 0) {
            System.out.printf("Loading row at index %d.\n", i);
        }
    }
    client.drain();
    ClientResponse cr = client.callProcedure("@AdHoc", "select count(*) from " + tablename + ";");
    long rows = cr.getResults()[0].asScalarLong();
    System.out.printf("Loaded %d rows.\n", rows);
    assert (rows == config.rows);
    System.out.print(HORIZONTAL_RULE);
    System.out.println("Starting Benchmark");
    System.out.println(HORIZONTAL_RULE);
    // reset the stats after warmup
    fullStatsContext.fetchAndResetBaseline();
    periodicStatsContext.fetchAndResetBaseline();
    benchmarkStartTS = System.currentTimeMillis();
    System.out.printf("\nRunning %s scan benchmark...\n", config.test);
    for (int i = 0; i < config.runs; i++) {
        client.callProcedure(scanproc);
    }
    benchmarkEndTS = System.currentTimeMillis();
    // print the summary results
    printResults();
    // close down the client connections
    client.close();
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) NullCallback(org.voltdb.client.NullCallback)

Example 29 with ClientResponse

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

the class SchemaChangeUtility method maxId.

/**
     * Find the largest pkey value in the table.
     */
static long maxId(Client client, VoltTable t, int timeout) {
    if (t == null) {
        return 0;
    }
    ClientResponse cr = callROProcedureWithRetry(client, "@AdHoc", timeout, String.format("select pkey from %s order by pkey desc limit 1;", TableHelper.getTableName(t)));
    assert (cr.getStatus() == ClientResponse.SUCCESS);
    VoltTable result = cr.getResults()[0];
    return result.getRowCount() > 0 ? result.asScalarLong() : 0;
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) VoltTable(org.voltdb.VoltTable)

Example 30 with ClientResponse

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

the class SchemaChangeUtility method callROProcedureWithRetry.

/**
     * Call a procedure and check the return code.
     * Success just returns the result to the caller.
     * Unpossible errors end the process.
     * Some errors will retry the call until the global progress timeout with various waits.
     * After the global progress timeout, the process is killed.
     */
static ClientResponse callROProcedureWithRetry(Client client, String procName, int timeout, Object... params) {
    long startTime = System.currentTimeMillis();
    long now = startTime;
    int retry = 0;
    while (now - startTime < (timeout * 1000)) {
        ClientResponse cr = null;
        try {
            cr = client.callProcedure(procName, params);
        } catch (ProcCallException e) {
            log.debug("callROProcedureWithRetry operation exception:", e);
            cr = e.getClientResponse();
        } catch (NoConnectionsException e) {
            log.debug("callROProcedureWithRetry operation exception:", e);
            // wait a bit to retry
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e1) {
            }
        } catch (IOException e) {
            log.debug("callROProcedureWithRetry operation exception:", e);
            // IOException is not cool man
            logStackTrace(e);
            System.exit(-1);
        }
        if (cr != null) {
            if (cr.getStatus() != ClientResponse.SUCCESS) {
                log.debug("callROProcedureWithRetry operation failed: " + ((ClientResponseImpl) cr).toJSONString());
            }
            switch(cr.getStatus()) {
                case ClientResponse.SUCCESS:
                    // hooray!
                    return cr;
                case ClientResponse.CONNECTION_LOST:
                case ClientResponse.CONNECTION_TIMEOUT:
                    // can retry after a delay
                    try {
                        Thread.sleep(5 * 1000);
                    } catch (Exception e) {
                    }
                    break;
                case ClientResponse.RESPONSE_UNKNOWN:
                    // can try again immediately - cluster is up but a node died
                    break;
                case ClientResponse.SERVER_UNAVAILABLE:
                    // shouldn't be in admin mode (paused) in this app, but can retry after a delay
                    try {
                        Thread.sleep(30 * 1000);
                    } catch (Exception e) {
                    }
                    break;
                case ClientResponse.GRACEFUL_FAILURE:
                    //logStackTrace(new Throwable());
                    return // caller should always check return status
                    cr;
                case ClientResponse.UNEXPECTED_FAILURE:
                case ClientResponse.USER_ABORT:
                    // for starters, I'm assuming these errors can't happen for reads in a sound system
                    String ss = cr.getStatusString();
                    if (ss.contains("Statement: select count(*) from")) {
                        // We might need to retry
                        log.warn(ss);
                        if ((ss.matches("(?s).*AdHoc transaction [0-9]+ wasn.t planned against the current catalog version.*") || 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.*"))) {
                            log.info("retrying...");
                        } else {
                            log.error(String.format("Error in procedure call for: %s", procName));
                            log.error(((ClientResponseImpl) cr).toJSONString());
                            assert (false);
                            System.exit(-1);
                        }
                    }
            }
        }
        now = System.currentTimeMillis();
    }
    log.error(String.format("Error no progress timeout (%d seconds) reached, terminating", timeout));
    System.exit(-1);
    return null;
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) NoConnectionsException(org.voltdb.client.NoConnectionsException) IOException(java.io.IOException) ClientResponseImpl(org.voltdb.ClientResponseImpl) ProcCallException(org.voltdb.client.ProcCallException) ProcCallException(org.voltdb.client.ProcCallException) NoConnectionsException(org.voltdb.client.NoConnectionsException) IOException(java.io.IOException)

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