use of org.voltdb.client.ProcedureCallback in project voltdb by VoltDB.
the class DeletesClient method deleteBatch.
static void deleteBatch(Client client, long batchesToKeep) {
long prune_ts = m_batchNumber - batchesToKeep;
Date date = new Date();
System.out.println(date.toString() + "\n\tPruning batches older than batch: " + prune_ts);
m_expectedDeletes = NUM_NAMES;
long start_time = System.currentTimeMillis();
for (int i = 0; i < NUM_NAMES; i++) {
try {
while (!client.callProcedure(new ProcedureCallback() {
@Override
public void clientCallback(ClientResponse response) {
if (response.getStatus() != ClientResponse.SUCCESS) {
System.out.println("failed delete batch");
System.out.println(response.getStatusString());
} else {
m_totalRows -= response.getResults()[0].asScalarLong();
m_totalDeletedRows += response.getResults()[0].asScalarLong();
}
//we don't care if tx fail, but don't get stuck in yield
m_expectedDeletes--;
}
}, "DeleteOldBatches", m_names[i], prune_ts)) {
try {
client.backpressureBarrier();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} catch (NoConnectionsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
while (m_expectedDeletes != 0) {
Thread.yield();
}
long elapsed = System.currentTimeMillis() - start_time;
m_totalDeletes += NUM_NAMES;
m_totalDeleteTime += elapsed;
System.out.println("\tAfter delete, total rows: " + m_totalRows);
System.out.println("\tDeleting batch: " + NUM_NAMES + " took " + elapsed + " millis");
System.out.println("\t\t (" + ((NUM_NAMES * 1000) / elapsed) + " tps)");
System.out.println("\tTotal delete TPS: " + (m_totalDeletes * 1000) / m_totalDeleteTime);
System.out.println("\tTotal delete RPS: " + (m_totalDeletedRows * 1000) / m_totalDeleteTime);
}
use of org.voltdb.client.ProcedureCallback in project voltdb by VoltDB.
the class JDBC4ClientConnection method executeAsync.
/**
* Executes a procedure asynchronously, returning a Future that can be used by the caller to
* wait upon completion before processing the server response.
*
* @param procedure
* the name of the procedure to call.
* @param parameters
* the list of parameters to pass to the procedure.
* @return the Future created to wrap around the asynchronous process.
*/
public Future<ClientResponse> executeAsync(String procedure, Object... parameters) throws NoConnectionsException, IOException {
ClientImpl currentClient = this.getClient();
final JDBC4ExecutionFuture future = new JDBC4ExecutionFuture(this.defaultAsyncTimeout);
try {
currentClient.callProcedure(new TrackingCallback(this, procedure, new ProcedureCallback() {
@SuppressWarnings("unused")
final JDBC4ExecutionFuture result;
{
this.result = future;
}
@Override
public void clientCallback(ClientResponse response) throws Exception {
future.set(response);
}
}), procedure, parameters);
} catch (NoConnectionsException e) {
this.dropClient(currentClient);
throw e;
}
return future;
}
use of org.voltdb.client.ProcedureCallback in project voltdb by VoltDB.
the class ScanPerfTest method fillTable.
public static void fillTable(int mb, Client client, Random rand) throws Exception {
final AtomicInteger outstanding = new AtomicInteger(0);
ProcedureCallback callback = new ProcedureCallback() {
@Override
public void clientCallback(ClientResponse clientResponse) throws Exception {
outstanding.decrementAndGet();
if (clientResponse.getStatus() != ClientResponse.SUCCESS) {
System.err.printf(clientResponse.getStatusString());
System.err.flush();
System.exit(-1);
}
}
};
int i = 0;
while (MiscUtils.getMBRss(client) < mb) {
System.out.println("Loading 100000 rows");
for (int j = 0; j < 100000; j++) {
long rvalue = rand.nextInt();
long absvalue = Math.abs(rvalue);
long shift = absvalue << 30L;
long id = shift + i++;
outstanding.incrementAndGet();
client.callProcedure(callback, "P.insert", id, 0);
}
while (outstanding.get() > 0) {
Thread.yield();
}
}
}
use of org.voltdb.client.ProcedureCallback in project voltdb by VoltDB.
the class TestMPMultiRoundTripSuite method testSimultaneousMultiAndSinglePartTxnsWithRollback.
public void testSimultaneousMultiAndSinglePartTxnsWithRollback() throws Exception {
int test_size = 100;
final Client client = this.getClient();
ProcedureCallback callback = new ProcedureCallback() {
@Override
public void clientCallback(ClientResponse clientResponse) throws Exception {
if (clientResponse.getStatus() != ClientResponse.SUCCESS) {
throw new RuntimeException("Failed with response: " + clientResponse.getStatusString());
}
}
};
client.callProcedure(callback, "MultiRoundMixReadsAndWrites", test_size, test_size / 2);
for (int i = 0; i < test_size; i++) {
client.callProcedure(callback, "P1.insert", i, i, 2, Integer.toHexString(i));
}
client.drain();
ClientResponse resp2 = client.callProcedure("GetP1");
ClientResponse resp = client.callProcedure("SumP1");
assertEquals(resp2.getResults()[0].toString(), test_size * 2, resp.getResults()[0].asScalarLong());
}
Aggregations