use of org.voltdb.settings.SettingsException in project voltdb by VoltDB.
the class UpdateSettings method executePlanFragment.
@Override
public DependencyPair executePlanFragment(Map<Integer, List<VoltTable>> dependencies, long fragmentId, ParameterSet params, SystemProcedureExecutionContext context) {
if (fragmentId == SysProcFragmentId.PF_updateSettingsBarrier) {
DependencyPair success = new DependencyPair.TableDependencyPair(DEP_updateSettingsBarrier, new VoltTable(new ColumnInfo[] { new ColumnInfo("UNUSED", VoltType.BIGINT) }));
if (log.isInfoEnabled()) {
log.info("Site " + CoreUtils.hsIdToString(m_site.getCorrespondingSiteId()) + " reached settings update barrier.");
}
return success;
} else if (fragmentId == SysProcFragmentId.PF_updateSettingsBarrierAggregate) {
Object[] paramarr = params.toArray();
byte[] settingsBytes = (byte[]) paramarr[0];
int version = ((Integer) paramarr[1]).intValue();
ZooKeeper zk = getHostMessenger().getZK();
Stat stat = null;
try {
stat = zk.setData(VoltZK.cluster_settings, settingsBytes, version);
} catch (KeeperException | InterruptedException e) {
String msg = "Failed to update cluster settings";
log.error(msg, e);
throw new SettingsException(msg, e);
}
log.info("Saved new cluster settings state");
return new DependencyPair.TableDependencyPair(DEP_updateSettingsBarrierAggregate, getVersionResponse(stat.getVersion()));
} else if (fragmentId == SysProcFragmentId.PF_updateSettings) {
Object[] paramarr = params.toArray();
byte[] settingsBytes = (byte[]) paramarr[0];
int version = ((Integer) paramarr[1]).intValue();
ClusterSettings settings = ClusterSettings.create(settingsBytes);
Pair<CatalogContext, CatalogSpecificPlanner> ctgdef = getVoltDB().settingsUpdate(settings, version);
context.updateSettings(ctgdef.getFirst(), ctgdef.getSecond());
VoltTable result = new VoltTable(VoltSystemProcedure.STATUS_SCHEMA);
result.addRow(VoltSystemProcedure.STATUS_OK);
return new DependencyPair.TableDependencyPair(DEP_updateSettings, result);
} else if (fragmentId == SysProcFragmentId.PF_updateSettingsAggregate) {
VoltTable result = VoltTableUtil.unionTables(dependencies.get(DEP_updateSettings));
return new DependencyPair.TableDependencyPair(DEP_updateSettingsAggregate, result);
} else {
VoltDB.crashLocalVoltDB("Received unrecognized plan fragment id " + fragmentId + " in UpdateSettings", false, null);
}
throw new RuntimeException("Should not reach this code");
}
use of org.voltdb.settings.SettingsException in project voltdb by VoltDB.
the class RealVoltDB method settingsUpdate.
@Override
public Pair<CatalogContext, CatalogSpecificPlanner> settingsUpdate(ClusterSettings settings, final int expectedVersionId) {
CatalogSpecificPlanner csp = new CatalogSpecificPlanner(/*m_asyncCompilerAgent,*/
m_catalogContext);
synchronized (m_catalogUpdateLock) {
int[] stamp = new int[] { 0 };
ClusterSettings expect = m_clusterSettings.get(stamp);
if (stamp[0] == expectedVersionId && m_clusterSettings.compareAndSet(expect, settings, stamp[0], expectedVersionId + 1)) {
try {
settings.store();
} catch (SettingsException e) {
hostLog.error(e);
throw e;
}
} else if (stamp[0] != expectedVersionId + 1) {
String msg = "Failed to update cluster setting to version " + (expectedVersionId + 1) + ", from current version " + stamp[0] + ". Reloading from Zookeeper";
hostLog.warn(msg);
m_clusterSettings.load(m_messenger.getZK());
}
if (m_MPI != null) {
m_MPI.updateSettings(m_catalogContext, csp);
}
// good place to set deadhost timeout once we make it a config
}
return Pair.of(m_catalogContext, csp);
}
Aggregations