Search in sources :

Example 11 with ProcCallException

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

the class TestSystemCatalogSuite method testInvalidSelector.

public void testInvalidSelector() throws IOException {
    Client client = getClient();
    try {
        client.callProcedure("@SystemCatalog", "NONSENSE");
    } catch (ProcCallException pce) {
        assertTrue(pce.getMessage().contains("Invalid @SystemCatalog selector"));
        return;
    }
    fail("Invalid selector should have resulted in a ProcCallException but didn't");
}
Also used : Client(org.voltdb.client.Client) ProcCallException(org.voltdb.client.ProcCallException)

Example 12 with ProcCallException

use of org.voltdb.client.ProcCallException 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 13 with ProcCallException

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

the class ClientMoverEL method main.

public static void main(String[] args) {
    long numMoves = (long) Long.valueOf(args[0]);
    String serverList = args[1];
    long clientDurationSeconds = (long) Long.valueOf(args[2]);
    long loopPauseSeconds = (long) Long.valueOf(args[3]);
    m_logger.info(String.format("Executing %,d moves per transaction", numMoves));
    m_logger.info(String.format("Running for %,d second(s)", clientDurationSeconds));
    int num_partitions = 0;
    long playerId;
    long gameId;
    long socialId;
    long clientId;
    long visitTime;
    int intCounter;
    long longCounter;
    final org.voltdb.client.Client voltclient = ClientFactory.createClient();
    String[] voltServers = serverList.split(",");
    for (String thisServer : voltServers) {
        try {
            thisServer = thisServer.trim();
            m_logger.info(String.format("Connecting to server: %s", thisServer));
            voltclient.createConnection(thisServer, "program", "none");
        } catch (IOException e) {
            m_logger.error(e.toString());
            System.exit(-1);
        }
    }
    java.util.Random rand = new java.util.Random(0);
    long startTime = System.currentTimeMillis();
    long endTime = startTime + (1000l * clientDurationSeconds);
    long currentTime = startTime;
    // get the # of partitions in my cluster
    try {
        VoltTable[] vtPartitionInfo = voltclient.callProcedure("@Statistics", "partitioncount", 0l).getResults();
        num_partitions = (int) vtPartitionInfo[0].fetchRow(0).getLong(0);
        m_logger.info("System is running with " + num_partitions + " partition(s).");
    } catch (ProcCallException e) {
        m_logger.error("ProcCallException:");
        m_logger.error(e.toString());
    } catch (IOException e) {
        m_logger.error("IOException:");
        m_logger.error(e.toString());
        System.exit(-1);
    }
    boolean foundRows = true;
    boolean foundFullRowset = false;
    while (endTime > currentTime) {
        // do a single archive at each partition
        foundRows = false;
        foundFullRowset = false;
        long callTimeMillis = System.currentTimeMillis();
        try {
            for (longCounter = 0; longCounter < num_partitions; longCounter++) {
                try {
                    long callTimeBegin = System.currentTimeMillis();
                    VoltTable[] vtArchiveVisits = voltclient.callProcedure("ArchiveVisitsEL", longCounter, numMoves, callTimeMillis).getResults();
                    long callTimeEnd = System.currentTimeMillis();
                    int rowCount = (int) vtArchiveVisits[0].fetchRow(0).getLong(1);
                    if (rowCount > 0) {
                        // write out the rows
                        foundRows = true;
                        if (rowCount == numMoves) {
                            foundFullRowset = true;
                        }
                    }
                    String currentDate = new Date().toString();
                    m_logger.info(String.format("[%s] Ran archive on partition %d : archived %,d row(s) in %,d milliseconds", currentDate, longCounter, rowCount, (callTimeEnd - callTimeBegin)));
                } catch (ProcCallException e) {
                    m_logger.error("ProcCallException:");
                    m_logger.error(e.toString());
                } catch (NoConnectionsException e) {
                    m_logger.error("IOException:");
                    m_logger.error(e.toString());
                    System.exit(-1);
                }
            }
            if (!foundRows) {
                // no rows found
                m_logger.info("No rows found for this run.");
                // pause for 5 seconds
                m_logger.info(String.format("Pausing for %d seconds...", loopPauseSeconds));
                long pauseCurrentMillis = System.currentTimeMillis();
                long pauseEndMillis = pauseCurrentMillis + (loopPauseSeconds * 1000l);
                while (pauseCurrentMillis < pauseEndMillis) {
                    pauseCurrentMillis = System.currentTimeMillis();
                }
            } else if (!foundFullRowset) {
                // none of the rowsets were full (amount requested)
                // pause for given number seconds
                m_logger.info(String.format("No full rowsets found, pausing for %d seconds...", loopPauseSeconds));
                long pauseCurrentMillis = System.currentTimeMillis();
                long pauseEndMillis = pauseCurrentMillis + (loopPauseSeconds * 1000l);
                while (pauseCurrentMillis < pauseEndMillis) {
                    pauseCurrentMillis = System.currentTimeMillis();
                }
            }
        } catch (IOException e) {
            m_logger.error(e.toString());
            System.exit(-1);
        }
        currentTime = System.currentTimeMillis();
    }
    try {
        voltclient.drain();
    } catch (InterruptedException e) {
        m_logger.error(e.toString());
        System.exit(-1);
    } catch (NoConnectionsException e) {
        m_logger.error(e.toString());
        System.exit(-1);
    }
    try {
        voltclient.close();
    } catch (Exception e) {
        m_logger.error(e.toString());
        System.exit(-1);
    }
}
Also used : IOException(java.io.IOException) VoltTable(org.voltdb.VoltTable) Date(java.util.Date) ProcCallException(org.voltdb.client.ProcCallException) NoConnectionsException(org.voltdb.client.NoConnectionsException) IOException(java.io.IOException) NoConnectionsException(org.voltdb.client.NoConnectionsException) ProcCallException(org.voltdb.client.ProcCallException)

Example 14 with ProcCallException

use of org.voltdb.client.ProcCallException 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 15 with ProcCallException

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

Aggregations

ProcCallException (org.voltdb.client.ProcCallException)239 Client (org.voltdb.client.Client)151 VoltTable (org.voltdb.VoltTable)120 ClientResponse (org.voltdb.client.ClientResponse)91 IOException (java.io.IOException)81 NoConnectionsException (org.voltdb.client.NoConnectionsException)55 Test (org.junit.Test)44 Configuration (org.voltdb.VoltDB.Configuration)41 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)36 File (java.io.File)21 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)19 VoltCompiler (org.voltdb.compiler.VoltCompiler)15 VoltDB (org.voltdb.VoltDB)10 VoltTableRow (org.voltdb.VoltTableRow)10 Timestamp (java.sql.Timestamp)5 TimestampType (org.voltdb.types.TimestampType)5 BigDecimal (java.math.BigDecimal)4 Date (java.util.Date)4 HashSet (java.util.HashSet)3 ClientResponseImpl (org.voltdb.ClientResponseImpl)3