Package org.voltdb.client

Examples of org.voltdb.client.ClientResponse


        // We have to tell all our clients to pause first
        clientPSM.writeToAll(ControlCommand.PAUSE.name());
       
        // Then tell the cluster to drain all txns
        if (debug.val) LOG.debug("Draining execution queues on cluster");
        ClientResponse cresponse = null;
        String procName = VoltSystemProcedure.procCallName(Quiesce.class);
        try {
            cresponse = client.callProcedure(procName);
        } catch (Exception ex) {
            throw new Exception("Failed to execute " + procName, ex);
        }
        assert(cresponse.getStatus() == Status.OK) :
            String.format("Failed to quiesce cluster!\n%s", cresponse);
       
        // DUMP RESPONSE ENTRIES
        if (hstore_conf.client.output_responses != null) {
            File outputPath = new File(hstore_conf.client.output_responses);
View Full Code Here


            sysproc = VoltSystemProcedure.procCallName(Statistics.class);
            params = new Object[]{ sps.name(), 0 };
        }
       
        // Grab the data that we need from the cluster
        ClientResponse cresponse;
        try {
            cresponse = client.callProcedure(sysproc, params);
        } catch (Exception ex) {
            throw new Exception("Failed to execute " + sysproc, ex);
        }
        assert(cresponse.getStatus() == Status.OK) :
            String.format("Failed to get %s stats\n%s", sps, cresponse);
        assert(cresponse.getResults().length == 1) :
            String.format("Failed to get %s stats\n%s", sps, cresponse);
        VoltTable vt = cresponse.getResults()[0];
       
        // Combine results (optional)
        boolean needCombine = false;
        if (sps == SysProcSelector.TXNPROFILER) needCombine = hstore_conf.client.output_txn_profiling_combine;
        if (sps == SysProcSelector.PLANNERPROFILER) needCombine = hstore_conf.client.output_planner_profiling_combine;
View Full Code Here

        LOG.info(String.format("Wrote %s information to '%s'", sps, outputPath));
        return;
    }
   
    private ClientResponse[] invokeSysProcs(Client client, Class<? extends VoltSystemProcedure> sysprocs[], Object params[][]) {
        ClientResponse cr[] = new ClientResponse[sysprocs.length];
        for (int i = 0; i < sysprocs.length; i++) {
            String procName = VoltSystemProcedure.procCallName(sysprocs[i]);
            try {
                cr[i] = client.callProcedure(procName, params[i]);
            } catch (Exception ex) {
View Full Code Here

     * @param client
     * @param retrieveFiles
     */
    private void recomputeMarkovs(Client client, boolean retrieveFiles) {
        LOG.info("Requesting HStoreSites to recalculate Markov models");
        ClientResponse cr = null;
        String procName = VoltSystemProcedure.procCallName(MarkovUpdate.class);
        try {
            cr = client.callProcedure(procName, true);
        } catch (Exception ex) {
            LOG.error("Failed to recompute MarkovGraphs", ex);
            return;
        }
        assert(cr != null);
        if (retrieveFiles == false) return;

        File outputDir = FileUtil.join(hstore_conf.global.temp_dir, "markovs",
                                       this.projectBuilder.getProjectName());
        FileUtil.makeDirIfNotExists(outputDir);
       
        // The return should be a list of SiteIds->RemotePath
        // We just need to then pull down the files and then combine them into
        // a single MarkovGraphContainer
        Map<Integer, File> markovs = new HashMap<Integer, File>();
        List<Pair<String, File>> files_to_remove = new ArrayList<Pair<String, File>>();
        VoltTable results[] = cr.getResults();
        assert(results.length == 1);
        while (results[0].advanceRow()) {
            int site_id = (int)results[0].getLong(0);
            int partition_id = (int)results[0].getLong(1);
            File remote_path = new File(results[0].getString(2));
View Full Code Here

       
        if (trace.val) LOG.trace(String.format("%s: Loading %d new rows - TOTAL %d [bytes=%d/%d]",
                                   tableName.toUpperCase(), rowCount, rowTotal, byteCount, byteTotal));
       
        // Load up this dirty mess...
        ClientResponse cr = null;
        if (m_noUploading == false) {
            boolean locked = m_hstoreConf.client.blocking_loader;
            if (locked) m_loaderBlock.lock();
            try {
                int tries = 3;
                String procName = VoltSystemProcedure.procCallName(LoadMultipartitionTable.class);
                while (tries-- > 0) {
                    try {
                        cr = m_voltClient.callProcedure(procName, tableName, vt);
                    } catch (ProcCallException ex) {
                        // If this thing was rejected, then we'll allow us to try again.
                        cr = ex.getClientResponse();
                        if (cr.getStatus() == Status.ABORT_REJECT && tries > 0) {
                            if (debug.val)
                                LOG.warn(String.format("Loading data for %s was rejected. Going to try again\n%s",
                                         tableName, cr.toString()));
                            continue;
                        }
                        // Anything else needs to be thrown out of here
                        throw ex;
                    }
                    break;
                } // WHILE
            } catch (Throwable ex) {
                throw new RuntimeException("Error when trying load data for '" + tableName + "'", ex);
            } finally {
                if (locked) m_loaderBlock.unlock();
            } // SYNCH
            assert(cr != null);
            assert(cr.getStatus() == Status.OK);
            if (trace.val) LOG.trace(String.format("Load %s: txn #%d / %s / %d",
                                       tableName, cr.getTransactionId(), cr.getStatus(), cr.getClientHandle()));
        } else {
            cr = m_dummyResponse;
        }
        if (cr.getStatus() != Status.OK) {
            LOG.warn(String.format("Failed to load %d rows for '%s': %s",
                     rowCount, tableName, cr.getStatusString()), cr.getException());
            return (cr);
        }
       
        m_tableTuples.put(tableName, rowCount);
        m_tableBytes.put(tableName, byteCount);
       
        // Keep track of table stats
        if (m_tableStats && cr.getStatus() == Status.OK) {
            final CatalogContext catalogContext = this.getCatalogContext();
            assert(catalogContext != null);
            final Table catalog_tbl = catalogContext.getTableByName(tableName);
            assert(catalog_tbl != null) : "Invalid table name '" + tableName + "'";
           
View Full Code Here

            System.out.printf("Connected to %s:%d / Server Version: %s\n",
                              tc.hostname, tc.port, tc.client.getBuildString());
        }
       
        String query = "";
        ClientResponse cresponse = null;
        boolean stop = false;
        try {
            do {
                try {
                    query = (this.enable_csv ? reader.readLine() : reader.readLine(PROMPT));
                    if (query == null || query.isEmpty()) continue;
                    query = query.trim();
                   
                    // Check if the first token is one of our special keywords
                    String tokens[] = SPLITTER.split(query);
                   
                    int retries = 3;
                    Command targetCmd = null;
                    boolean usage = false;
                    boolean reconnect = false;
                    while (retries-- > 0 && stop == false) {
                        // Check whether they want to execute a special command
                        for (Command c : Command.values()) {
                            if (tokens[0].equalsIgnoreCase(c.name())) {
                                targetCmd = c;
                            }
                        } // FOR
                       
                        try {
                            if (targetCmd != null) {
                                switch (targetCmd) {
                                    case EXEC:
                                        // The second position should be the name of the procedure
                                        // that they want to execute
                                        if (tokens.length < 2) {
                                            usage = true;
                                        } else {
                                            cresponse = this.execProcedure(tc.client, tokens[1], query, reconnect);
                                        }
                                        break;
                                    case ENABLE:
                                        this.processEnable(tc.client, tokens[1], query, reconnect);
                                        break;
                                    case QUIT:
                                        stop = true;
                                        break;
                                    case DESCRIBE:
                                    case SHOW:
                                        throw new NotImplementedException("The command '" + targetCmd + "' is is not implemented");
                                    default:
                                        throw new RuntimeException("Unexpected command '" + targetCmd);
                                } // SWITCH
                            }
                            // Otherwise we'll send it to the server to deal with as an ad-hoc query
                            else {
                                cresponse = this.execQuery(tc.client, query);
                            }
                        } catch (NoConnectionsException ex) {
                            LOG.warn("Connection lost. Going to try to connect again...");
                            tc = this.getClientConnection();
                            reconnect = true;
                            continue;
                        }
                        break;
                    } // WHILE
                   
                    // Just print out the result
                    if (cresponse != null) {
                        if (cresponse.getStatus() == Status.OK) {
                            System.out.println(this.formatResult(cresponse));   
                        } else {
                            System.out.printf("Server Response: %s / %s\n",
                                              cresponse.getStatus(),
                                              cresponse.getStatusString());
                        }
                    }
                    // Print target command usage
                    else if (usage) {
                        assert(targetCmd != null);
View Full Code Here

     * @return
     * @throws Exception
     */
    private ClientResponse execQuery(Client client, String query) throws Exception {
        if (debug.val) LOG.debug("QUERY: " + query);
        ClientResponse cresponse = client.callProcedure("@AdHoc", query);
        return (cresponse);
    }
View Full Code Here

        Object params[] = procParams.toArray();
        if (this.enable_csv == false && reconnect == false) {
            LOG.info(String.format("Executing transaction " + setBoldText + "%s(%s)" + setPlainText,
                     catalog_proc.getName(), StringUtil.toString(params, false, false)));
        }
        ClientResponse cresponse = client.callProcedure(catalog_proc.getName(), params);
        return (cresponse);
    }
View Full Code Here

        // find that there is a conflict with the single-partition txn.
        // Everyone should get restarted.
        dtxnVoltProc.LOCK_AFTER.release();
        result = dtxnCallback.latch.await(HStoreSiteTestUtil.NOTIFY_TIMEOUT*3, TimeUnit.MILLISECONDS);
        assertTrue("DTXN LATCH: "+dtxnCallback.latch, result);
        ClientResponse dtxnResponse = CollectionUtil.first(dtxnCallback.responses);
        assertEquals(dtxnResponse.toString(), Status.OK, dtxnResponse.getStatus());
        assertTrue(dtxnResponse.toString(), dtxnResponse.getRestartCounter() >= 1);
       
        // The other transaction should be executed now on the remote partition
        result = spCallback0.latch.await(HStoreSiteTestUtil.NOTIFY_TIMEOUT, TimeUnit.MILLISECONDS);
        assertTrue("SP LATCH: "+spCallback0.latch, result);
        ClientResponse spResponse = CollectionUtil.first(spCallback0.responses);
        assertEquals(Status.OK, spResponse.getStatus());
        assertTrue(spResponse.isSpeculative());
        assertTrue(spResponse.toString(), spResponse.getRestartCounter() >= 1);
       
        assertTrue(remotePartitionCheck.get());
    }
View Full Code Here

        assertEquals(Status.OK, CollectionUtil.first(dtxnCallback.responses).getStatus());

        // The other transaction should be executed now on the remote partition
        result = spCallback0.latch.await(HStoreSiteTestUtil.NOTIFY_TIMEOUT, TimeUnit.MILLISECONDS);
        assertTrue("SP LATCH"+spCallback0.latch, result);
        ClientResponse spResponse = CollectionUtil.first(spCallback0.responses);
        assertEquals(Status.OK, spResponse.getStatus());
        assertTrue(spResponse.isSpeculative());
       
    }
View Full Code Here

TOP

Related Classes of org.voltdb.client.ClientResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.