}
} catch (Exception e) {
Throwables.propagate(e);
}
return new DependencyPair(DEP_updateCatalogSync,
new VoltTable(new ColumnInfo[] { new ColumnInfo("UNUSED", VoltType.BIGINT) } ));
}
else if (fragmentId == SysProcFragmentId.PF_updateCatalogPrecheckAndSyncAggregate) {
// Don't actually care about the returned table, just need to send something
// back to the MPI scoreboard
return new DependencyPair(DEP_updateCatalogSyncAggregate,
new VoltTable(new ColumnInfo[] { new ColumnInfo("UNUSED", VoltType.BIGINT) } ));
}
else if (fragmentId == SysProcFragmentId.PF_updateCatalog) {
String catalogDiffCommands = (String)params.toArray()[0];
String commands = Encoder.decodeBase64AndDecompress(catalogDiffCommands);
int expectedCatalogVersion = (Integer)params.toArray()[1];
boolean requiresSnapshotIsolation = ((Byte) params.toArray()[2]) != 0;
CatalogAndIds catalogStuff = null;
try {
catalogStuff = CatalogUtil.getCatalogFromZK(VoltDB.instance().getHostMessenger().getZK());
} catch (Exception e) {
Throwables.propagate(e);
}
String replayInfo = m_runner.getTxnState().isForReplay() ? " (FOR REPLAY)" : "";
// if this is a new catalog, do the work to update
if (context.getCatalogVersion() == expectedCatalogVersion) {
// update the global catalog if we get there first
@SuppressWarnings("deprecation")
Pair<CatalogContext, CatalogSpecificPlanner> p =
VoltDB.instance().catalogUpdate(
commands,
catalogStuff.catalogBytes,
catalogStuff.getCatalogHash(),
expectedCatalogVersion,
getVoltPrivateRealTransactionIdDontUseMe(),
getUniqueId(),
catalogStuff.getDeploymentHash());
// update the local catalog. Safe to do this thanks to the check to get into here.
context.updateCatalog(commands, p.getFirst(), p.getSecond(), requiresSnapshotIsolation);
log.info(String.format("Site %s completed catalog update with catalog hash %s, deployment hash %s%s.",
CoreUtils.hsIdToString(m_site.getCorrespondingSiteId()),
Encoder.hexEncode(catalogStuff.getCatalogHash()).substring(0, 10),
Encoder.hexEncode(catalogStuff.getDeploymentHash()).substring(0, 10),
replayInfo));
}
// if seen before by this code, then check to see if this is a restart
else if ((context.getCatalogVersion() == (expectedCatalogVersion + 1) &&
(Arrays.equals(context.getCatalogHash(), catalogStuff.getCatalogHash()) &&
Arrays.equals(context.getDeploymentHash(), catalogStuff.getDeploymentHash()))))
{
log.info(String.format("Site %s will NOT apply an assumed restarted and identical catalog update with catalog hash %s and deployment hash %s.",
CoreUtils.hsIdToString(m_site.getCorrespondingSiteId()),
Encoder.hexEncode(catalogStuff.getCatalogHash()),
Encoder.hexEncode(catalogStuff.getDeploymentHash())));
}
else {
VoltDB.crashLocalVoltDB("Invalid catalog update. Expected version: " + expectedCatalogVersion +
", current version: " + context.getCatalogVersion(), false, null);
}
VoltTable result = new VoltTable(VoltSystemProcedure.STATUS_SCHEMA);
result.addRow(VoltSystemProcedure.STATUS_OK);
return new DependencyPair(DEP_updateCatalog, result);
} else if (fragmentId == SysProcFragmentId.PF_updateCatalogAggregate) {
VoltTable result = VoltTableUtil.unionTables(dependencies.get(DEP_updateCatalog));
return new DependencyPair(DEP_updateCatalogAggregate, result);
} else {
VoltDB.crashLocalVoltDB(
"Received unrecognized plan fragment id " + fragmentId + " in UpdateApplicationCatalog",
false,
null);