/** Mostly copy-paste of old ExecutionSite.processInitiateTask() */
protected InitiateResponseMessage processInitiateTask(Iv2InitiateTaskMessage task,
SiteProcedureConnection siteConnection)
{
final InitiateResponseMessage response = new InitiateResponseMessage(task);
try {
Object[] callerParams = null;
/*
* Parameters are lazily deserialized. We may not find out until now
* that the parameter set is corrupt
*/
try {
callerParams = task.getParameters();
} catch (RuntimeException e) {
Writer result = new StringWriter();
PrintWriter pw = new PrintWriter(result);
e.printStackTrace(pw);
response.setResults(
new ClientResponseImpl(ClientResponse.GRACEFUL_FAILURE,
new VoltTable[] {},
"Exception while deserializing procedure params, procedure="
+ m_procName + "\n"
+ result.toString()));
}
if (callerParams != null) {
ClientResponseImpl cr = null;
ProcedureRunner runner = siteConnection.getProcedureRunner(m_procName);
if (runner == null) {
String error =
"Procedure " + m_procName + " is not present in the catalog. " +
"This can happen if a catalog update removing the procedure occurred " +
"after the procedure was submitted " +
"but before the procedure was executed.";
RateLimitedLogger.tryLogForMessage(
System.currentTimeMillis(),
60, TimeUnit.SECONDS,
hostLog,
Level.WARN, error + " %s", "This log message is rate limited to once every 60 seconds.");
response.setResults(
new ClientResponseImpl(
ClientResponse.UNEXPECTED_FAILURE,
new VoltTable[]{},
error));
return response;
}
// Check partitioning of single-partition and n-partition transactions.
if (runner.checkPartition(m_txnState, siteConnection.getCurrentHashinator())) {
runner.setupTransaction(m_txnState);
cr = runner.call(callerParams);
m_txnState.setHash(cr.getHash());
//Don't pay the cost of returning the result tables for a replicated write
//With reads don't apply the optimization just in case
// if (!task.shouldReturnResultTables() && !task.isReadOnly()) {
// cr.dropResultTable();
// }
response.setResults(cr);
// record the results of write transactions to the transaction state
// this may be used to verify the DR replica cluster gets the same value
// skip for multi-partition txns because only 1 of k+1 partitions will
// have the real results
if ((!task.isReadOnly()) && task.isSinglePartition()) {
m_txnState.storeResults(cr);
}
} else {
// mis-partitioned invocation, reject it and let the ClientInterface restart it
response.setMispartitioned(true, task.getStoredProcedureInvocation(),
TheHashinator.getCurrentVersionedConfig());
}
}
}
catch (final ExpectedProcedureException e) {
execLog.l7dlog( Level.TRACE, LogKeys.org_voltdb_ExecutionSite_ExpectedProcedureException.name(), e);
response.setResults(
new ClientResponseImpl(
ClientResponse.GRACEFUL_FAILURE,
new VoltTable[]{},
e.toString()));
}