本文整理汇总了Java中org.voltdb.client.ClientResponse.getResults方法的典型用法代码示例。如果您正苦于以下问题:Java ClientResponse.getResults方法的具体用法?Java ClientResponse.getResults怎么用?Java ClientResponse.getResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.voltdb.client.ClientResponse
的用法示例。
在下文中一共展示了ClientResponse.getResults方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testInitialize
import org.voltdb.client.ClientResponse; //导入方法依赖的package包/类
/**
* testInitialize
*/
public void testInitialize() throws Exception {
Client client = this.getClient();
this.initWikipediaDatabase(this.getCatalogContext(), client);
Set<String> allTables = new HashSet<String>();
String procName = VoltSystemProcedure.procCallName(AdHoc.class);
for (String tableName : allTables) {
String query = "SELECT COUNT(*) FROM " + tableName;
ClientResponse cresponse = client.callProcedure(procName, query);
assertEquals(Status.OK, cresponse.getStatus());
VoltTable results[] = cresponse.getResults();
assertEquals(1, results.length);
long count = results[0].asScalarLong();
assertTrue(tableName + " -> " + count, count > 0);
// System.err.println(tableName + "\n" + results[0]);
} // FOR
}
示例2: getResult
import org.voltdb.client.ClientResponse; //导入方法依赖的package包/类
private VoltTable getResult(Client client, String procName) throws Exception
{
VoltTable result = null;
Procedure catalog_proc = this.catalog_db.getProcedures().getIgnoreCase(procName);
if (catalog_proc == null) {
throw new Exception("Invalid stored procedure name '" + procName + "'");
}
//result = client.asynCallProcedure(null, catalog_proc.getName(), null, params);
ClientResponse response = client.callProcedure(catalog_proc.getName());
if(response.getStatus()==Status.OK)
{
result = response.getResults()[0];
}
else
System.out.println("Failed : " + catalog_proc.getName());
return result;
}
示例3: testVoteLimit
import org.voltdb.client.ClientResponse; //导入方法依赖的package包/类
/**
* testVoteLimit
*/
public void testVoteLimit() throws Exception {
Client client = this.getClient();
this.initializeDatabase(client);
// Make sure that the phone number is only allowed to vote up to
// the limit and not anymore after that
ClientResponse cresponse = null;
for (int i = 0, cnt = (int)(maxVotesPerPhoneNumber*2); i < cnt; i++) {
long expected = (i < maxVotesPerPhoneNumber ? VoterConstants.VOTE_SUCCESSFUL :
VoterConstants.ERR_VOTER_OVER_VOTE_LIMIT);
cresponse = client.callProcedure(Vote.class.getSimpleName(),
voteId++,
phoneNumber,
contestantNumber,
maxVotesPerPhoneNumber);
assertEquals(Status.OK, cresponse.getStatus());
VoltTable results[] = cresponse.getResults();
assertEquals(1, results.length);
//assertEquals(expected, results[0].asScalarLong());
} // FOR
}
示例4: getRowCount
import org.voltdb.client.ClientResponse; //导入方法依赖的package包/类
public static long getRowCount(Client client, Table tbl) throws Exception {
ClientResponse cresponse = getStats(client, SysProcSelector.TABLE);
VoltTable result = cresponse.getResults()[0];
long count = 0;
boolean found = false;
while (result.advanceRow()) {
if (tbl.getName().equalsIgnoreCase(result.getString("TABLE_NAME"))) {
found = true;
count += result.getLong("TUPLE_COUNT");
if (tbl.getIsreplicated()) break;
}
} // WHILE
if (found == false) {
throw new IllegalArgumentException("Invalid table '" + tbl + "'");
}
return (count);
}
示例5: testInitialize
import org.voltdb.client.ClientResponse; //导入方法依赖的package包/类
/**
* testInitialize
*/
public void testInitialize() throws Exception {
Client client = this.getClient();
RegressionSuiteUtil.initializeTPCCDatabase(this.getCatalogContext(), client);
String procName = VoltSystemProcedure.procCallName(AdHoc.class);
for (String tableName : TPCCConstants.TABLENAMES) {
String query = "SELECT COUNT(*) FROM " + tableName;
ClientResponse cresponse = client.callProcedure(procName, query);
assertEquals(Status.OK, cresponse.getStatus());
VoltTable results[] = cresponse.getResults();
assertEquals(1, results.length);
long count = results[0].asScalarLong();
assertTrue(tableName + " -> " + count, count > 0);
// System.err.println(tableName + "\n" + VoltTableUtil.format(results[0]));
} // FOR
}
示例6: testTABLECOUNTS
import org.voltdb.client.ClientResponse; //导入方法依赖的package包/类
public void testTABLECOUNTS() throws IOException, ProcCallException {
Client client = getClient();
ClientResponse cr = null;
CatalogContext catalogContext = this.getCatalogContext();
Random rand = this.getRandom();
int num_tuples = 11;
for (Table catalog_tbl : catalogContext.database.getTables()) {
RegressionSuiteUtil.loadRandomData(client, catalog_tbl, rand, num_tuples);
} // FOR (table)
// Now get the counts for the tables that we just loaded
cr = client.callProcedure(GetTableCounts.class.getSimpleName());
// System.err.println(cr);
assertEquals(Status.OK, cr.getStatus());
assertEquals(1, cr.getResults().length);
VoltTable vt = cr.getResults()[0];
while (vt.advanceRow()) {
String tableName = vt.getString(0);
int count = (int)vt.getLong(1);
assertEquals(tableName, num_tuples, count);
} // WHILE
}
示例7: testReadRecord
import org.voltdb.client.ClientResponse; //导入方法依赖的package包/类
/**
* testReadRecord
*/
public void testReadRecord() throws Exception {
Client client = this.getClient();
this.initializeDatabase(client, NUM_TUPLES);
long key = NUM_TUPLES / 2;
String procName = ReadRecord.class.getSimpleName();
Object params[] = { key };
ClientResponse cresponse = client.callProcedure(procName, params);
assertNotNull(cresponse);
assertEquals(Status.OK, cresponse.getStatus());
assertEquals(1, cresponse.getResults().length);
VoltTable vt = cresponse.getResults()[0];
boolean adv = vt.advanceRow();
assert(adv);
assertEquals(key, vt.getLong(0));
}
示例8: formatResult
import org.voltdb.client.ClientResponse; //导入方法依赖的package包/类
private String formatResult(ClientResponse cr) {
final VoltTable results[] = cr.getResults();
final int num_results = results.length;
//System.out.println("num of results: " + String.valueOf(num_results));
StringBuilder sb = new StringBuilder();
sb.append(VoltTableUtil.format(results));
VoltTable vt = results[0];
int num_rows = vt.getRowCount();
//System.out.println("num of rows: " + String.valueOf(num_rows));
return (sb.toString());
}
示例9: formatResult
import org.voltdb.client.ClientResponse; //导入方法依赖的package包/类
private String formatResult(ClientResponse cr) {
final VoltTable results[] = cr.getResults();
final int num_results = results.length;
StringBuilder sb = new StringBuilder();
if (this.enable_debug) {
sb.append(cr.toString());
}
else {
// MAIN BODY
if (this.enable_csv) {
StringWriter out = new StringWriter();
for (int i = 0; i < num_results; i++) {
if (i > 0) out.write("\n\n");
VoltTableUtil.csv(out, results[i], true);
} // FOR
sb.append(out.toString());
} else {
sb.append(VoltTableUtil.format(results));
}
// FOOTER
String footer = "";
if (this.enable_csv == false) {
if (num_results == 1) {
int row_count = results[0].getRowCount();
footer = String.format("%d row%s in set", row_count, (row_count > 1 ? "s" : ""));
}
else if (num_results == 0) {
footer = "No results returned";
}
else {
footer = num_results + " tables returned";
}
sb.append(String.format("\n%s (%.2f sec)\n", footer, (cr.getClientRoundtrip() / 1000d)));
}
}
return (sb.toString());
}
示例10: loadVotes
import org.voltdb.client.ClientResponse; //导入方法依赖的package包/类
private void loadVotes(Client client, int num_txns) throws Exception {
// System.err.println("Loading data...");
LatchableProcedureCallback callback = new LatchableProcedureCallback(num_txns);
for (int i = 0; i < num_txns; i++) {
Object params[] = { new Long(i),
TestVoterSuite.phoneNumber+i,
TestVoterSuite.contestantNumber,
num_txns+1 };
client.callProcedure(callback, Vote.class.getSimpleName(), params);
} // FOR
// Wait until they all finish
boolean result = callback.latch.await(NOTIFY_TIMEOUT, TimeUnit.MILLISECONDS);
assertTrue(callback.toString(), result);
for (ClientResponse cr : callback.responses) {
assertEquals(cr.toString(), Status.OK, cr.getStatus());
}
// Make sure that our vote is actually in the real table and materialized views
String query = "SELECT COUNT(*) FROM votes";
String procName = VoltSystemProcedure.procCallName(AdHoc.class);
ClientResponse cresponse = client.callProcedure(procName, query);
assertEquals(Status.OK, cresponse.getStatus());
VoltTable results[] = cresponse.getResults();
assertEquals(1, results.length);
assertEquals(num_txns, results[0].asScalarLong());
// System.err.println("Finished Loading Data.");
}
示例11: checkConstraints
import org.voltdb.client.ClientResponse; //导入方法依赖的package包/类
private boolean checkConstraints(String procName, ClientResponse response) {
boolean isSatisfied = true;
int orig_position = -1;
// Check if all the tables in the result set satisfy the constraints.
for (int i = 0; isSatisfied && i < response.getResults().length; i++) {
Pair<String, Integer> key = Pair.of(procName, i);
if (!m_constraints.containsKey(key))
continue;
VoltTable table = response.getResults()[i];
orig_position = table.getActiveRowIndex();
table.resetRowPosition();
// Iterate through all rows and check if they satisfy the
// constraints.
while (isSatisfied && table.advanceRow()) {
isSatisfied = Verification.checkRow(m_constraints.get(key), table);
}
// Have to reset the position to its original position.
if (orig_position < 0)
table.resetRowPosition();
else
table.advanceToRow(orig_position);
}
if (!isSatisfied)
LOG.error("Transaction " + procName + " failed check");
return isSatisfied;
}
示例12: clientCallback
import org.voltdb.client.ClientResponse; //导入方法依赖的package包/类
@Override
public void clientCallback(ClientResponse clientResponse) {
// Increment the BenchmarkComponent's internal counter on the
// number of transactions that have been completed
incrementTransactionCounter(clientResponse, 0);
// Keep track of state (optional)
if (clientResponse.getStatus() == Status.OK) {
VoltTable results[] = clientResponse.getResults();
assert(results.length == 1);
long status = results[0].asScalarLong();
if (status == VoterConstants.VOTE_SUCCESSFUL) {
acceptedVotes.incrementAndGet();
}
else if (status == VoterConstants.ERR_INVALID_CONTESTANT) {
badContestantVotes.incrementAndGet();
}
else if (status == VoterConstants.ERR_VOTER_OVER_VOTE_LIMIT) {
badVoteCountVotes.incrementAndGet();
}
}
else if (clientResponse.getStatus() == Status.ABORT_UNEXPECTED) {
if (clientResponse.getException() != null) {
clientResponse.getException().printStackTrace();
}
if (debug.val && clientResponse.getStatusString() != null) {
LOG.warn(clientResponse.getStatusString());
}
}
}
示例13: main
import org.voltdb.client.ClientResponse; //导入方法依赖的package包/类
public static void main(String[] vargs) throws Exception {
ArgumentsParser args = ArgumentsParser.load(vargs);
args.require(ArgumentsParser.PARAM_CATALOG);
String procName = args.getOptParam(0);
String parameters[] = new String[args.getOptParamCount()-1];
for (int i = 0; i < parameters.length; i++) {
parameters[i] = args.getOptParam(i+1);
} // FOR
Client client = ClientFactory.createClient(128, null, false, null);
Cluster catalog_clus = args.catalog_db.getParent();
Site catalog_site = CollectionUtil.first(catalog_clus.getSites());
assert(catalog_site != null);
Host catalog_host = catalog_site.getHost();
assert(catalog_host != null);
Integer port = CollectionUtil.random(CatalogUtil.getExecutionSitePorts(catalog_site));
assert(port != null);
client.createConnection(null, catalog_host.getIpaddr(), port, "user", "password");
LOG.info(String.format("Connected to H-Store cluster at %s:%d", catalog_host.getIpaddr(), port));
ClientResponse cresponse = VoltProcedureInvoker.invoke(args.catalog,
client,
procName,
parameters);
if (cresponse == null) System.exit(-1);
// m.put("Status", cresponse.getStatus());
// m.put("Length", String.format("%d [bytes=%d]", cresponse.getResults().length, cresponse.getResultsSize()));
// m.put("Results", StringUtil.join("\n", ));
Map<String, Object> m = new LinkedHashMap<String, Object>();
for (int i = 0; i < cresponse.getResults().length; i++) {
VoltTable vt = cresponse.getResults()[i];
m.put(String.format(" [%02d]", i), vt);
} // FOR
LOG.info(StringUtil.repeat("-", 50));
LOG.info(String.format("%s Txn #%d - Status %s\n%s",
procName,
cresponse.getTransactionId(),
cresponse.getStatus(),
cresponse.toString()));
}
示例14: clientCallbackImpl
import org.voltdb.client.ClientResponse; //导入方法依赖的package包/类
@Override
public void clientCallbackImpl(ClientResponse clientResponse) {
final VoltTable[] results = clientResponse.getResults();
final BitSet seats = getSeatsBitSet(element.flight_id);
// Valid NewReservation
if (clientResponse.getStatus() == Status.OK) {
assert(results.length > 1);
assert(results[0].getRowCount() == 1);
assert(results[0].asScalarLong() == 1);
// Mark this seat as successfully reserved
seats.set(element.seatnum);
// Set it up so we can play with it later
SEATSClient.this.requeueReservation(element);
}
// Aborted - Figure out why!
else if (clientResponse.getStatus() == Status.ABORT_USER) {
String msg = clientResponse.getStatusString();
ErrorType errorType = ErrorType.getErrorType(msg);
if (debug.val)
LOG.debug(String.format("Client %02d :: NewReservation %s [ErrorType=%s] - %s",
getClientId(), clientResponse.getStatus(), errorType, clientResponse.getStatusString()),
clientResponse.getException());
switch (errorType) {
case NO_MORE_SEATS: {
seats.set(0, SEATSConstants.FLIGHTS_NUM_SEATS);
if (debug.val)
LOG.debug(String.format("FULL FLIGHT: %s", element.flight_id));
break;
}
case CUSTOMER_ALREADY_HAS_SEAT: {
Set<Long> f_ids = getCustomerBookedFlights(element.customer_id);
f_ids.add(element.flight_id);
if (debug.val)
LOG.debug(String.format("ALREADY BOOKED: %s -> %s", element.customer_id, f_ids));
break;
}
case SEAT_ALREADY_RESERVED: {
seats.set(element.seatnum);
if (debug.val)
LOG.debug(String.format("ALREADY BOOKED SEAT: %s/%d -> %s",
element.customer_id, element.seatnum, seats));
break;
}
case INVALID_CUSTOMER_ID: {
LOG.warn("Unexpected invalid CustomerId: " + element.customer_id);
break;
}
case INVALID_FLIGHT_ID: {
LOG.warn("Unexpected invalid FlightId: " + element.flight_id);
break;
}
case UNKNOWN: {
// if (debug.val)
LOG.warn(msg);
break;
}
default: {
if (debug.val) LOG.debug("BUSTED ID: " + element.flight_id + " / " + element.flight_id);
}
} // SWITCH
}
}
示例15: testConcurrentTxns
import org.voltdb.client.ClientResponse; //导入方法依赖的package包/类
/**
* testConcurrentTxns
*/
public void testConcurrentTxns() throws Exception {
Client client = this.getClient();
this.initializeDatabase(client);
final int num_txns = 500;
final CountDownLatch latch = new CountDownLatch(num_txns);
final AtomicInteger numTotal = new AtomicInteger(0);
final AtomicInteger numCompleted = new AtomicInteger(0);
final AtomicInteger numFailed = new AtomicInteger(0);
ProcedureCallback callback = new ProcedureCallback() {
@Override
public void clientCallback(ClientResponse cr) {
switch (cr.getStatus()) {
case OK:
if (cr.getResults()[0].asScalarLong() == VoterConstants.VOTE_SUCCESSFUL) {
numCompleted.incrementAndGet();
}
break;
default:
numFailed.incrementAndGet();
System.err.printf("UNEXPECTED: %s [%d]\n", cr.getStatus(), numFailed.get());
} // SWITCH
numTotal.incrementAndGet();
latch.countDown();
}
};
for (int i = 0; i < num_txns; i++) {
Object params[] = {
new Long(i),
PHONE_NUMBER + (i % 10),
i % VoterConstants.NUM_CONTESTANTS,
MAX_VOTES_PER_PHONE_NUMBER
};
client.callProcedure(callback, Vote.class.getSimpleName(), params);
} // FOR
System.err.printf("Invoked %d txns. Waiting for responses...\n", num_txns);
boolean result = latch.await(15, TimeUnit.SECONDS);
System.err.println("LATCH RESULT: " + result);
System.err.println("TOTAL: " + numTotal.get() + " / " + num_txns);
System.err.println("COMPLETED: " + numCompleted.get());
System.err.println("FAILED: " + numFailed.get());
if (result == false) {
System.err.println("BAD MOJO");
}
assertTrue("Timed out [latch="+latch.getCount() + "]", result);
assertEquals(0, numFailed.get());
// At this point we know that all of our txns have been committed to disk
// Make sure that our vote is actually in the real table and materialized views
String query = "SELECT COUNT(*) FROM votes";
ClientResponse cresponse = client.callProcedure("@AdHoc", query);
System.err.println(cresponse);
assertEquals(Status.OK, cresponse.getStatus());
VoltTable results[] = cresponse.getResults();
assertEquals(1, results.length);
assertEquals(numCompleted.get(), results[0].asScalarLong());
// TODO: We should go through the log and make sure that all of our
// transactions are still in there...
}