Search in sources :

Example 1 with SettingsException

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");
}
Also used : ClusterSettings(org.voltdb.settings.ClusterSettings) ColumnInfo(org.voltdb.VoltTable.ColumnInfo) VoltTable(org.voltdb.VoltTable) SettingsException(org.voltdb.settings.SettingsException) CatalogSpecificPlanner(org.voltdb.CatalogSpecificPlanner) ZooKeeper(org.apache.zookeeper_voltpatches.ZooKeeper) Stat(org.apache.zookeeper_voltpatches.data.Stat) CatalogContext(org.voltdb.CatalogContext) DependencyPair(org.voltdb.DependencyPair)

Example 2 with SettingsException

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);
}
Also used : ClusterSettings(org.voltdb.settings.ClusterSettings) SettingsException(org.voltdb.settings.SettingsException)

Aggregations

ClusterSettings (org.voltdb.settings.ClusterSettings)2 SettingsException (org.voltdb.settings.SettingsException)2 ZooKeeper (org.apache.zookeeper_voltpatches.ZooKeeper)1 Stat (org.apache.zookeeper_voltpatches.data.Stat)1 CatalogContext (org.voltdb.CatalogContext)1 CatalogSpecificPlanner (org.voltdb.CatalogSpecificPlanner)1 DependencyPair (org.voltdb.DependencyPair)1 VoltTable (org.voltdb.VoltTable)1 ColumnInfo (org.voltdb.VoltTable.ColumnInfo)1