本文整理汇总了Java中org.voltdb.client.ClientResponse类的典型用法代码示例。如果您正苦于以下问题:Java ClientResponse类的具体用法?Java ClientResponse怎么用?Java ClientResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientResponse类属于org.voltdb.client包,在下文中一共展示了ClientResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResult
import org.voltdb.client.ClientResponse; //导入依赖的package包/类
private VoltTable getResult(Client client, String procName) throws Exception
{
VoltTable result = null;
Procedure catalog_proc = runner.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;
}
示例2: testGetNewDestination
import org.voltdb.client.ClientResponse; //导入依赖的package包/类
/**
* testGetNewDestination
*/
public void testGetNewDestination() throws Exception {
Client client = this.getClient();
RegressionSuiteUtil.initializeTM1Database(this.getCatalogContext(), client);
TM1Client.Transaction txn = Transaction.DELETE_CALL_FORWARDING;
Object params[] = txn.generateParams(NUM_SUBSCRIBERS);
ClientResponse cresponse = null;
try {
cresponse = client.callProcedure(txn.callName, params);
assertEquals(Status.OK, cresponse.getStatus());
} catch (ProcCallException ex) {
cresponse = ex.getClientResponse();
assertEquals(cresponse.toString(), Status.ABORT_USER, cresponse.getStatus());
}
assertNotNull(cresponse);
assertTrue(cresponse.toString(), cresponse.isSinglePartition());
}
示例3: testDeleteCallForwarding
import org.voltdb.client.ClientResponse; //导入依赖的package包/类
/**
* testDeleteCallForwarding
*/
public void testDeleteCallForwarding() throws Exception {
Client client = this.getClient();
RegressionSuiteUtil.initializeTM1Database(this.getCatalogContext(), client);
TM1Client.Transaction txn = Transaction.DELETE_CALL_FORWARDING;
Object params[] = txn.generateParams(NUM_SUBSCRIBERS);
for (int i = 0; i < 1000; i++) {
ClientResponse cresponse = null;
try {
cresponse = client.callProcedure(txn.callName, params);
assertEquals(Status.OK, cresponse.getStatus());
} catch (ProcCallException ex) {
cresponse = ex.getClientResponse();
// System.err.println();
assertEquals(cresponse.toString(), Status.ABORT_USER, cresponse.getStatus());
}
assertNotNull(cresponse);
} // FOR
}
示例4: execute
import org.voltdb.client.ClientResponse; //导入依赖的package包/类
/**
* Executes a procedure synchronously and returns the result to the caller. The method
* internally tracks execution performance.
*
* @param procedure
* the name of the procedure to call.
* @param parameters
* the list of parameters to pass to the procedure.
* @return the response sent back by the VoltDB cluster for the procedure execution.
* @throws IOException
* @throws NoConnectionsException
* @throws ProcCallException
*/
public ClientResponse execute(String procedure, long timeout, Object... parameters)
throws NoConnectionsException, IOException, ProcCallException {
ClientImpl currentClient = this.getClient();
try {
// If connections are lost try reconnecting.
ClientResponse response = currentClient.callProcedure(procedure, parameters);
if (trace.val) {
LOG.trace(String.format("JDBC client executed qury %s", procedure));
}
return response;
}
catch (ProcCallException pce) {
throw pce;
}
catch (NoConnectionsException e) {
this.dropClient(currentClient);
throw e;
}
}
示例5: clientCallbackImpl
import org.voltdb.client.ClientResponse; //导入依赖的package包/类
@Override
public void clientCallbackImpl(ClientResponse clientResponse) {
if (clientResponse.getStatus() == Status.OK) {
// We can remove this from our set of full flights because know that there is now a free seat
BitSet seats = getSeatsBitSet(element.flight_id);
seats.set(element.seatnum, false);
// And then put it up for a pending insert
if (rng.nextInt(100) < SEATSConstants.PROB_REQUEUE_DELETED_RESERVATION) {
Buffer<Reservation> cache = CACHE_RESERVATIONS.get(CacheType.PENDING_INSERTS);
assert(cache != null) : "Unexpected " + CacheType.PENDING_INSERTS;
synchronized (cache) {
cache.add(element);
} // SYNCH
}
} else if (debug.val) {
LOG.info("DeleteReservation " + clientResponse.getStatus() + ": " + clientResponse.getStatusString(), clientResponse.getException());
LOG.info("BUSTED ID: " + element.flight_id + " / " + element.flight_id);
}
}
示例6: 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
}
示例7: testTupleAccessCountNoIndex
import org.voltdb.client.ClientResponse; //导入依赖的package包/类
/**
* testTupleAccessCountNoIndex
*/
public void testTupleAccessCountNoIndex() throws Exception {
CatalogContext catalogContext = this.getCatalogContext();
Client client = this.getClient();
RegressionSuiteUtil.initializeTPCCDatabase(catalogContext, client);
ClientResponse cresponse = RegressionSuiteUtil.getStats(client, SysProcSelector.TABLE);
assertNotNull(cresponse);
assertEquals(Status.OK, cresponse.getStatus());
this.checkTupleAccessCount(TPCCConstants.TABLENAME_ITEM, cresponse.getResults()[0], 0);
int expected = 20;
for (int i = 0; i < expected; i++) {
cresponse = client.callProcedure("GetItemNoIndex");
assertNotNull(cresponse);
assertEquals(Status.OK, cresponse.getStatus());
} // FOR
cresponse = RegressionSuiteUtil.getStats(client, SysProcSelector.TABLE);
assertNotNull(cresponse);
assertEquals(Status.OK, cresponse.getStatus());
this.checkTupleAccessCount(TPCCConstants.TABLENAME_ITEM, cresponse.getResults()[0], expected);
}
示例8: checkBalance
import org.voltdb.client.ClientResponse; //导入依赖的package包/类
public static void checkBalance(Client client, long acctId, double expected) throws Exception {
// Make sure that we set it correctly
String query = String.format("SELECT * FROM %s WHERE custid = %d",
SmallBankConstants.TABLENAME_CHECKING, acctId);
ClientResponse cresponse = client.callProcedure("@AdHoc", query);
assertEquals(Status.OK, cresponse.getStatus());
VoltTable results[] = cresponse.getResults();
assertEquals(1, results.length);
if (results[0].getRowCount() == 0) {
System.err.println(VoltTableUtil.format(results[0]));
}
assertEquals("No rows for acctId "+acctId, 1, results[0].getRowCount());
assertTrue(results[0].advanceRow());
assertEquals("Mismatched balance for acctId "+acctId, expected, results[0].getDouble("bal"));
}
示例9: 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
}
示例10: clientCallback
import org.voltdb.client.ClientResponse; //导入依赖的package包/类
@Override
public void clientCallback(ClientResponse clientResponse) {
if (clientResponse.getStatus() != Status.OK){
System.out.println(clientResponse.getStatusString());
System.out.println(clientResponse.getException());
System.exit(-1);
}
incrementTransactionCounter(clientResponse, 0);
final VoltTable vt = clientResponse.getResults()[0];
if (!vt.advanceRow()) {
System.err.println("No rows returned by SelectBlob");
System.exit(-1);
}
final byte bytes[] = vt.getStringAsBytes(1);
if (bytes.length != m_blobSize) {
System.err.println("Returned blob size was not correct. Expected "
+ m_blobSize + " but got " + bytes.length);
System.exit(-1);
}
}
示例11: 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;
}
示例12: 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
}
示例13: testMultiPartitionTxn
import org.voltdb.client.ClientResponse; //导入依赖的package包/类
/**
* testMultiPartitionTxn
*/
@Test
public void testMultiPartitionTxn() throws Exception {
this.loadData(this.getTable(TM1Constants.TABLENAME_SUBSCRIBER));
this.loadData(this.getTable(TM1Constants.TABLENAME_CALL_FORWARDING));
// Simple test to check whether we can execute multi-partition txns serially
Procedure catalog_proc = this.getProcedure(DeleteCallForwarding.class);
for (int i = 0; i < NUM_TXNS; i++) {
Object params[] = { Integer.toString(i), 1l, 1l };
ClientResponse cr = this.client.callProcedure(catalog_proc.getName(), params);
assertEquals(Status.OK, cr.getStatus());
}
// System.err.println(cr);
this.statusSnapshot();
}
示例14: 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
}
示例15: hasTuple
import org.voltdb.client.ClientResponse; //导入依赖的package包/类
private boolean hasTuple(String streamName)
{
boolean result = false;
try{
Client client = ClientFactory.createClient(128, null, false, null);
String hostname;
int port;
hostname = catalog_site.getHost().getIpaddr();
port = catalog_site.getProc_port();
client.createConnection(null, hostname, port, "user", "password");
String query = "select * from " + streamName;
ClientResponse cresponse = client.callProcedure("@AdHoc", query);
if (cresponse != null) {
if (cresponse.getStatus() == Status.OK) {
LOG.info(streamName + " - " + this.formatResult(cresponse));
VoltTable results[] = cresponse.getResults();
if(results[0].getRowCount() != 0)
result = true;
} else {
System.out.printf("Server Response: %s / %s\n",
cresponse.getStatus(),
cresponse.getStatusString());
}
}
client.close();
}
catch (Exception ex) {
ex.printStackTrace();
}
return result;
}