// Cut and pasted from ExecutionSite processFragmentTask(), then
// modifed to work in the new world
public FragmentResponseMessage processFragmentTask(SiteProcedureConnection siteConnection)
{
// IZZY: actually need the "executor" HSId these days?
final FragmentResponseMessage currentFragResponse =
new FragmentResponseMessage(m_fragmentMsg, m_initiator.getHSId());
currentFragResponse.setStatus(FragmentResponseMessage.SUCCESS, null);
if (m_inputDeps != null) {
siteConnection.stashWorkUnitDependencies(m_inputDeps);
}
if (m_fragmentMsg.isEmptyForRestart()) {
int outputDepId = m_fragmentMsg.getOutputDepId(0);
currentFragResponse.addDependency(outputDepId,
new VoltTable(new ColumnInfo[] {new ColumnInfo("UNUSED", VoltType.INTEGER)}, 1));
return currentFragResponse;
}
for (int frag = 0; frag < m_fragmentMsg.getFragmentCount(); frag++)
{
byte[] planHash = m_fragmentMsg.getPlanHash(frag);
final int outputDepId = m_fragmentMsg.getOutputDepId(frag);
ParameterSet params = m_fragmentMsg.getParameterSetForFragment(frag);
final int inputDepId = m_fragmentMsg.getOnlyInputDepId(frag);
long fragmentId = 0;
byte[] fragmentPlan = null;
/*
* Currently the error path when executing plan fragments
* does not adequately distinguish between fatal errors and
* abort type errors that should result in a roll back.
* Assume that it is ninja: succeeds or doesn't return.
* No roll back support.
*
* AW in 2012, the preceding comment might be wrong,
* I am pretty sure what we don't support is partial rollback.
* The entire procedure will roll back successfully on failure
*/
try {
VoltTable dependency;
fragmentPlan = m_fragmentMsg.getFragmentPlan(frag);
String stmtText = null;
// if custom fragment, load the plan and get local fragment id
if (fragmentPlan != null) {
// statement text for unplanned fragments are pulled from the message,
// to ensure that we get the correct constants from the most recent
// invocation.
stmtText = m_fragmentMsg.getStmtText(frag);
fragmentId = ActivePlanRepository.loadOrAddRefPlanFragment(planHash, fragmentPlan, null);
}
// otherwise ask the plan source for a local fragment id
else {
fragmentId = ActivePlanRepository.getFragmentIdForPlanHash(planHash);
stmtText = ActivePlanRepository.getStmtTextForPlanHash(planHash);
}
// set up the batch context for the fragment set
siteConnection.setBatch(m_fragmentMsg.getCurrentBatchIndex());
dependency = siteConnection.executePlanFragments(
1,
new long[] { fragmentId },
new long [] { inputDepId },
new ParameterSet[] { params },
stmtText == null ? null : new String[] { stmtText },
m_txnState.txnId,
m_txnState.m_spHandle,
m_txnState.uniqueId,
m_txnState.isReadOnly())[0];
if (hostLog.isTraceEnabled()) {
hostLog.l7dlog(Level.TRACE,
LogKeys.org_voltdb_ExecutionSite_SendingDependency.name(),
new Object[] { outputDepId }, null);
}
currentFragResponse.addDependency(outputDepId, dependency);
} catch (final EEException e) {
hostLog.l7dlog( Level.TRACE, LogKeys.host_ExecutionSite_ExceptionExecutingPF.name(), new Object[] { Encoder.hexEncode(planHash) }, e);
currentFragResponse.setStatus(FragmentResponseMessage.UNEXPECTED_ERROR, e);
break;
} catch (final SQLException e) {
hostLog.l7dlog( Level.TRACE, LogKeys.host_ExecutionSite_ExceptionExecutingPF.name(), new Object[] { Encoder.hexEncode(planHash) }, e);
currentFragResponse.setStatus(FragmentResponseMessage.UNEXPECTED_ERROR, e);
break;
}
catch (final InterruptException e) {
hostLog.l7dlog( Level.TRACE, LogKeys.host_ExecutionSite_ExceptionExecutingPF.name(), new Object[] { Encoder.hexEncode(planHash) }, e);
currentFragResponse.setStatus(FragmentResponseMessage.UNEXPECTED_ERROR, e);
break;
}
finally {
// ensure adhoc plans are unloaded
if (fragmentPlan != null) {