Search in sources :

Example 6 with NoConnectionsException

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

the class ExportBenchmark method doInserts.

/**
     * Inserts values into the export table for the test. First it does warmup
     * inserts, then tracked inserts.
     * @throws InterruptedException
     * @throws NoConnectionsException
     */
public void doInserts(Client client) {
    // Don't track warmup inserts
    System.out.println("Warming up...");
    long now = System.currentTimeMillis();
    AtomicLong rowId = new AtomicLong(0);
    while (benchmarkWarmupEndTS > now) {
        try {
            client.callProcedure(new NullCallback(), "InsertExport", rowId.getAndIncrement(), 0);
            // Check the time every 50 transactions to avoid invoking System.currentTimeMillis() too much
            if (++totalInserts % 50 == 0) {
                now = System.currentTimeMillis();
            }
        } catch (Exception ignore) {
        }
    }
    System.out.println("Warmup complete");
    rowId.set(0);
    // reset the stats after warmup is done
    fullStatsContext.fetchAndResetBaseline();
    periodicStatsContext.fetchAndResetBaseline();
    schedulePeriodicStats();
    // Insert objects until we've run for long enough
    System.out.println("Running benchmark...");
    now = System.currentTimeMillis();
    while (benchmarkEndTS > now) {
        try {
            client.callProcedure(new ExportCallback(), "InsertExport", rowId.getAndIncrement(), 0);
            // Check the time every 50 transactions to avoid invoking System.currentTimeMillis() too much
            if (++totalInserts % 50 == 0) {
                now = System.currentTimeMillis();
            }
        } catch (Exception e) {
            System.err.println("Couldn't insert into VoltDB\n");
            e.printStackTrace();
            System.exit(1);
        }
    }
    try {
        client.drain();
    } catch (Exception e) {
        e.printStackTrace();
    }
    System.out.println("Benchmark complete: wrote " + successfulInserts.get() + " objects");
    System.out.println("Failed to insert " + failedInserts.get() + " objects");
    testFinished.set(true);
    if (config.target.equals("socket")) {
        statsSocketSelector.wakeup();
    }
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) NullCallback(org.voltdb.client.NullCallback) IOException(java.io.IOException) JSONException(org.json_voltpatches.JSONException) ProcCallException(org.voltdb.client.ProcCallException) NoConnectionsException(org.voltdb.client.NoConnectionsException)

Example 7 with NoConnectionsException

use of org.voltdb.client.NoConnectionsException 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)

Example 8 with NoConnectionsException

use of org.voltdb.client.NoConnectionsException 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 9 with NoConnectionsException

use of org.voltdb.client.NoConnectionsException 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)

Example 10 with NoConnectionsException

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

the class VoltDBOsmSink method process.

/**
     * {@inheritDoc}
     */
public void process(RelationContainer relationContainer) {
    Relation relation;
    int memberSequenceId;
    relation = relationContainer.getEntity();
    try {
        client.callProcedure(new InsertCallback(), INS_RELATIONS_PROC, relation.getId(), relation.getVersion(), relation.getUser().getId(), relation.getTimestamp(), relation.getChangesetId());
    } catch (NoConnectionsException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    memberSequenceId = 0;
    for (RelationMember member : relation.getMembers()) {
        try {
            client.callProcedure(new InsertCallback(), INS_RELATIONS_MEMBER_PROC, relation.getId(), member.getMemberId(), member.getMemberType().ordinal(), member.getMemberRole(), memberSequenceId);
        } catch (NoConnectionsException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        memberSequenceId++;
    }
    for (Tag tag : relation.getTags()) {
        try {
            client.callProcedure(new InsertCallback(), INS_RELATION_TAGS_PROC, relation.getId(), tag.getKey(), tag.getValue());
        } catch (NoConnectionsException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : Relation(org.openstreetmap.osmosis.core.domain.v0_6.Relation) NoConnectionsException(org.voltdb.client.NoConnectionsException) RelationMember(org.openstreetmap.osmosis.core.domain.v0_6.RelationMember) IOException(java.io.IOException) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag)

Aggregations

NoConnectionsException (org.voltdb.client.NoConnectionsException)50 IOException (java.io.IOException)41 ProcCallException (org.voltdb.client.ProcCallException)38 VoltTable (org.voltdb.VoltTable)27 ClientResponse (org.voltdb.client.ClientResponse)21 Client (org.voltdb.client.Client)19 Date (java.util.Date)7 VoltTableRow (org.voltdb.VoltTableRow)6 ProcedureCallback (org.voltdb.client.ProcedureCallback)5 Timestamp (java.sql.Timestamp)4 File (java.io.File)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)3 ClientResponseImpl (org.voltdb.ClientResponseImpl)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)2 LineString (org.postgis.LineString)2 VoltCompiler (org.voltdb.compiler.VoltCompiler)2