Search in sources :

Example 1 with DRCatalogCommands

use of org.voltdb.catalog.DRCatalogCommands in project voltdb by VoltDB.

the class Site method updateCatalog.

/**
     * Update the catalog.  If we're the MPI, don't bother with the EE.
     */
public boolean updateCatalog(String diffCmds, CatalogContext context, CatalogSpecificPlanner csp, boolean requiresSnapshotIsolationboolean, boolean isMPI, long uniqueId, long spHandle, boolean requireCatalogDiffCmdsApplyToEE, boolean requiresNewExportGeneration) {
    CatalogContext oldContext = m_context;
    m_context = context;
    m_ee.setBatchTimeout(m_context.cluster.getDeployment().get("deployment").getSystemsettings().get("systemsettings").getQuerytimeout());
    m_loadedProcedures.loadProcedures(m_context, csp, false);
    if (isMPI) {
        // the rest of the work applies to sites with real EEs
        return true;
    }
    if (requireCatalogDiffCmdsApplyToEE == false) {
        // empty diff cmds for the EE to apply, so skip the JNI call
        hostLog.info("Skipped applying diff commands on EE.");
        return true;
    }
    CatalogMap<Table> tables = m_context.catalog.getClusters().get("cluster").getDatabases().get("database").getTables();
    boolean DRCatalogChange = false;
    for (Table t : tables) {
        if (t.getIsdred()) {
            DRCatalogChange |= diffCmds.contains("tables#" + t.getTypeName());
            if (DRCatalogChange) {
                break;
            }
        }
    }
    if (!DRCatalogChange) {
        // Check against old catalog for deletions
        CatalogMap<Table> oldTables = oldContext.catalog.getClusters().get("cluster").getDatabases().get("database").getTables();
        for (Table t : oldTables) {
            if (t.getIsdred()) {
                DRCatalogChange |= diffCmds.contains(CatalogDiffEngine.getDeleteDiffStatement(t, "tables"));
                if (DRCatalogChange) {
                    break;
                }
            }
        }
    }
    //
    if (requiresSnapshotIsolationboolean && m_snapshotter.isEESnapshotting()) {
        hostLog.info(String.format("Site %d performing schema change operation must block until snapshot is locally complete.", CoreUtils.getSiteIdFromHSId(m_siteId)));
        try {
            m_snapshotter.completeSnapshotWork(m_sysprocContext);
            hostLog.info(String.format("Site %d locally finished snapshot. Will update catalog now.", CoreUtils.getSiteIdFromHSId(m_siteId)));
        } catch (InterruptedException e) {
            VoltDB.crashLocalVoltDB("Unexpected Interrupted Exception while finishing a snapshot for a catalog update.", true, e);
        }
    }
    //Necessary to quiesce before updating the catalog
    //so export data for the old generation is pushed to Java.
    m_ee.quiesce(m_lastCommittedSpHandle);
    m_ee.updateCatalog(m_context.m_uniqueId, requiresNewExportGeneration, diffCmds);
    if (DRCatalogChange) {
        final DRCatalogCommands catalogCommands = DRCatalogDiffEngine.serializeCatalogCommandsForDr(m_context.catalog, -1);
        generateDREvent(EventType.CATALOG_UPDATE, uniqueId, m_lastCommittedSpHandle, spHandle, catalogCommands.commands.getBytes(Charsets.UTF_8));
    }
    return true;
}
Also used : VoltTable(org.voltdb.VoltTable) Table(org.voltdb.catalog.Table) DRCatalogCommands(org.voltdb.catalog.DRCatalogCommands) CatalogContext(org.voltdb.CatalogContext)

Aggregations

CatalogContext (org.voltdb.CatalogContext)1 VoltTable (org.voltdb.VoltTable)1 DRCatalogCommands (org.voltdb.catalog.DRCatalogCommands)1 Table (org.voltdb.catalog.Table)1