use of herddb.client.impl.RetryRequestException in project herddb by diennea.
the class RoutedClientSideConnection method rollbackTransaction.
void rollbackTransaction(String tableSpace, long tx) throws HDBException, ClientSideMetadataProviderException {
Channel _channel = ensureOpen();
try {
Message message = Message.EXECUTE_STATEMENT(clientId, tableSpace, "ROLLBACK TRANSACTION '" + tableSpace + "'," + tx, 0, false, null);
Message reply = _channel.sendMessageWithReply(message, timeout);
if (reply.type == Message.TYPE_ERROR) {
boolean notLeader = reply.parameters.get("notLeader") != null;
if (notLeader) {
this.connection.requestMetadataRefresh();
throw new RetryRequestException(reply + "");
}
throw new HDBException(reply);
}
} catch (InterruptedException | TimeoutException err) {
throw new HDBException(err);
}
}
use of herddb.client.impl.RetryRequestException in project herddb by diennea.
the class RoutedClientSideConnection method executeUpdate.
DMLResult executeUpdate(String tableSpace, String query, long tx, boolean returnValues, List<Object> params) throws HDBException, ClientSideMetadataProviderException {
Channel _channel = ensureOpen();
try {
Message message = Message.EXECUTE_STATEMENT(clientId, tableSpace, query, tx, returnValues, params);
Message reply = _channel.sendMessageWithReply(message, timeout);
if (reply.type == Message.TYPE_ERROR) {
boolean notLeader = reply.parameters.get("notLeader") != null;
if (notLeader) {
this.connection.requestMetadataRefresh();
throw new RetryRequestException(reply + "");
}
throw new HDBException(reply);
}
long updateCount = (Long) reply.parameters.get("updateCount");
long transactionId = (Long) reply.parameters.get("tx");
Object key = null;
Map<String, Object> newvalue = null;
Map<String, Object> data = (Map<String, Object>) reply.parameters.get("data");
if (data != null) {
key = data.get("key");
newvalue = (Map<String, Object>) data.get("newvalue");
}
return new DMLResult(updateCount, key, newvalue, transactionId);
} catch (InterruptedException | TimeoutException err) {
throw new HDBException(err);
}
}
use of herddb.client.impl.RetryRequestException in project herddb by diennea.
the class RoutedClientSideConnection method dumpTableSpace.
void dumpTableSpace(String tableSpace, int fetchSize, boolean includeTransactionLog, TableSpaceDumpReceiver receiver) throws HDBException, ClientSideMetadataProviderException {
Channel _channel = ensureOpen();
try {
String dumpId = this.clientId + ":" + SCANNERID_GENERATOR.incrementAndGet();
Message message = Message.REQUEST_TABLESPACE_DUMP(clientId, tableSpace, dumpId, fetchSize, includeTransactionLog);
LOGGER.log(Level.SEVERE, "dumpTableSpace id " + dumpId + " for tablespace " + tableSpace);
dumpReceivers.put(dumpId, receiver);
Message reply = _channel.sendMessageWithReply(message, timeout);
LOGGER.log(Level.SEVERE, "dumpTableSpace id " + dumpId + " for tablespace " + tableSpace + ": first reply " + reply.parameters);
if (reply.type == Message.TYPE_ERROR) {
boolean notLeader = reply.parameters.get("notLeader") != null;
if (notLeader) {
this.connection.requestMetadataRefresh();
throw new RetryRequestException(reply + "");
}
throw new HDBException(reply);
}
} catch (InterruptedException | TimeoutException err) {
throw new HDBException(err);
}
}
Aggregations