Search in sources :

Example 1 with DrRoleType

use of org.voltdb.compiler.deploymentfile.DrRoleType in project voltdb by VoltDB.

the class HealthMonitor method checkDRRole.

private void checkDRRole() {
    SyncCallback cb = new SyncCallback();
    if (getConnectionHadler().callProcedure(getInternalUser(), false, BatchTimeoutOverrideType.NO_TIMEOUT, cb, "@Statistics", "DRROLE", 0)) {
        try {
            cb.waitForResponse();
        } catch (InterruptedException e) {
            m_logger.error("Interrupted while retrieving cluster for DRROLE STATS", e);
            return;
        }
        ClientResponse r = cb.getResponse();
        if (r.getStatus() != ClientResponse.SUCCESS) {
            // timeout could happen if hostdown
            if (m_logger.isDebugEnabled()) {
                m_logger.debug("Unable to retrieve DRROLE STATS: " + r.getStatusString());
            }
            return;
        }
        VoltTable result = r.getResults()[0];
        while (result.advanceRow()) {
            DrRoleType drRole = DrRoleType.fromValue(result.getString(DRRoleStats.CN_ROLE).toLowerCase());
            DRRoleStats.State state = DRRoleStats.State.valueOf(result.getString(DRRoleStats.CN_STATE));
            byte remoteCluster = (byte) result.getLong(DRRoleStats.CN_REMOTE_CLUSTER_ID);
            if (m_logger.isDebugEnabled()) {
                m_logger.debug("DRROLE stats: Role:" + drRole + " State:" + state + " Remote Cluster ID:" + remoteCluster);
            }
            if (drRole == DrRoleType.NONE) {
                continue;
            }
            if (DRRoleStats.State.STOPPED == state) {
                if (!m_snmpDRTrapSent.getOrDefault(remoteCluster, false)) {
                    m_snmpTrapSender.statistics(FaultFacility.DR, String.format("Database Replication ROLE: %s break with Remote Cluster %d.", drRole, remoteCluster));
                    m_snmpDRTrapSent.put(remoteCluster, true);
                }
            } else {
                // reset
                if (m_snmpDRTrapSent.getOrDefault(remoteCluster, false)) {
                    m_snmpDRTrapSent.put(remoteCluster, false);
                }
            }
        }
    } else {
        m_logger.error("Unable to retrieve DRROLE STATS:: failed to invoke @Statistics DRROLE, 0.");
    }
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) DrRoleType(org.voltdb.compiler.deploymentfile.DrRoleType) SyncCallback(org.voltdb.client.SyncCallback)

Example 2 with DrRoleType

use of org.voltdb.compiler.deploymentfile.DrRoleType in project voltdb by VoltDB.

the class Promote method run.

public CompletableFuture<ClientResponse> run() {
    if (VoltDB.instance().getReplicationRole() == ReplicationRole.NONE) {
        return makeQuickResponse(ClientResponse.GRACEFUL_FAILURE, "@Promote issued on non-replica cluster. No action taken.");
    }
    DrRoleType drRole = DrRoleType.fromValue(VoltDB.instance().getCatalogContext().getCluster().getDrrole());
    boolean useDDLSchema = VoltDB.instance().getCatalogContext().cluster.getUseddlschema();
    if (!allowPausedModeWork(false, isAdminConnection())) {
        return makeQuickResponse(ClientResponse.SERVER_UNAVAILABLE, "Server is paused and is available in read-only mode - please try again later.");
    }
    CatalogChangeResult ccr = null;
    try {
        ccr = prepareApplicationCatalogDiff("@UpdateApplicationCatalog", null, null, new String[0], null, true, /* isPromotion */
        drRole, useDDLSchema, false, getHostname(), getUsername());
    } catch (PrepareDiffFailureException pe) {
        hostLog.info("A request to update the database catalog and/or deployment settings has been rejected. More info returned to client.");
        return makeQuickResponse(pe.statusCode, pe.getMessage());
    }
    // Log something useful about catalog upgrades when they occur.
    if (ccr.upgradedFromVersion != null) {
        hostLog.info(String.format("In order to update the application catalog it was " + "automatically upgraded from version %s.", ccr.upgradedFromVersion));
    }
    // case for @CatalogChangeResult
    if (ccr.encodedDiffCommands.trim().length() == 0) {
        return makeQuickResponse(ClientResponseImpl.SUCCESS, "Catalog update with no changes was skipped.");
    }
    // initiate the transaction.
    return callProcedure("@UpdateCore", ccr.encodedDiffCommands, ccr.catalogHash, ccr.catalogBytes, ccr.expectedCatalogVersion, ccr.deploymentString, ccr.tablesThatMustBeEmpty, ccr.reasonsForEmptyTables, ccr.requiresSnapshotIsolation ? 1 : 0, ccr.worksWithElastic ? 1 : 0, ccr.deploymentHash, ccr.requireCatalogDiffCmdsApplyToEE ? 1 : 0, ccr.hasSchemaChange ? 1 : 0, ccr.requiresNewExportGeneration ? 1 : 0);
}
Also used : CatalogChangeResult(org.voltdb.compiler.CatalogChangeResult) DrRoleType(org.voltdb.compiler.deploymentfile.DrRoleType) PrepareDiffFailureException(org.voltdb.compiler.CatalogChangeResult.PrepareDiffFailureException)

Example 3 with DrRoleType

use of org.voltdb.compiler.deploymentfile.DrRoleType in project voltdb by VoltDB.

the class UpdateApplicationCatalog method run.

public CompletableFuture<ClientResponse> run(byte[] catalogJarBytes, String deploymentString) {
    // catalogJarBytes if null, when passed along, will tell the
    // catalog change planner that we want to use the current catalog.
    DrRoleType drRole = DrRoleType.fromValue(VoltDB.instance().getCatalogContext().getCluster().getDrrole());
    boolean useDDLSchema = VoltDB.instance().getCatalogContext().cluster.getUseddlschema() && !isRestoring();
    // normalize empty string and null
    if ((catalogJarBytes != null) && (catalogJarBytes.length == 0)) {
        catalogJarBytes = null;
    }
    if (!allowPausedModeWork(isRestoring(), isAdminConnection())) {
        return makeQuickResponse(ClientResponse.SERVER_UNAVAILABLE, "Server is paused and is available in read-only mode - please try again later.");
    }
    if (catalogJarBytes != null && useDDLSchema) {
        return makeQuickResponse(ClientResponse.GRACEFUL_FAILURE, "Cluster is configured to use AdHoc DDL to change application schema. " + "Use of @UpdateApplicationCatalog is forbidden.");
    }
    CatalogChangeResult ccr = null;
    try {
        ccr = prepareApplicationCatalogDiff("@UpdateApplicationCatalog", catalogJarBytes, deploymentString, new String[0], null, false, /* isPromotion */
        drRole, useDDLSchema, false, getHostname(), getUsername());
    } catch (PrepareDiffFailureException pe) {
        hostLog.info("A request to update the database catalog and/or deployment settings has been rejected. More info returned to client.");
        return makeQuickResponse(pe.statusCode, pe.getMessage());
    }
    // Log something useful about catalog upgrades when they occur.
    if (ccr.upgradedFromVersion != null) {
        hostLog.info(String.format("In order to update the application catalog it was " + "automatically upgraded from version %s.", ccr.upgradedFromVersion));
    }
    // case for @CatalogChangeResult
    if (ccr.encodedDiffCommands.trim().length() == 0) {
        return makeQuickResponse(ClientResponseImpl.SUCCESS, "Catalog update with no changes was skipped.");
    }
    // This means no more @UAC calls when using DDL mode.
    if (isRestoring()) {
        noteRestoreCompleted();
    }
    // initiate the transaction.
    return callProcedure("@UpdateCore", ccr.encodedDiffCommands, ccr.catalogHash, ccr.catalogBytes, ccr.expectedCatalogVersion, ccr.deploymentString, ccr.tablesThatMustBeEmpty, ccr.reasonsForEmptyTables, ccr.requiresSnapshotIsolation ? 1 : 0, ccr.worksWithElastic ? 1 : 0, ccr.deploymentHash, ccr.requireCatalogDiffCmdsApplyToEE ? 1 : 0, ccr.hasSchemaChange ? 1 : 0, ccr.requiresNewExportGeneration ? 1 : 0);
}
Also used : CatalogChangeResult(org.voltdb.compiler.CatalogChangeResult) DrRoleType(org.voltdb.compiler.deploymentfile.DrRoleType) PrepareDiffFailureException(org.voltdb.compiler.CatalogChangeResult.PrepareDiffFailureException)

Example 4 with DrRoleType

use of org.voltdb.compiler.deploymentfile.DrRoleType in project voltdb by VoltDB.

the class UpdateClasses method run.

public CompletableFuture<ClientResponse> run(byte[] jarfileBytes, String classesToDeleteSelector) {
    DrRoleType drRole = DrRoleType.fromValue(VoltDB.instance().getCatalogContext().getCluster().getDrrole());
    boolean useDDLSchema = VoltDB.instance().getCatalogContext().cluster.getUseddlschema();
    if (!allowPausedModeWork(false, isAdminConnection())) {
        return makeQuickResponse(ClientResponse.SERVER_UNAVAILABLE, "Server is paused and is available in read-only mode - please try again later.");
    }
    // master and adhoc DDL method chosen
    if (!useDDLSchema) {
        return makeQuickResponse(ClientResponse.GRACEFUL_FAILURE, "Cluster is configured to use @UpdateApplicationCatalog " + "to change application schema.  Use of @UpdateClasses is forbidden.");
    }
    CatalogChangeResult ccr = null;
    try {
        ccr = prepareApplicationCatalogDiff("@UpdateClasses", jarfileBytes, classesToDeleteSelector, new String[0], null, false, /* isPromotion */
        drRole, useDDLSchema, false, getHostname(), getUsername());
    } catch (PrepareDiffFailureException pe) {
        hostLog.info("A request to update the loaded classes has been rejected. More info returned to client.");
        return makeQuickResponse(pe.statusCode, pe.getMessage());
    }
    // Log something useful about catalog upgrades when they occur.
    if (ccr.upgradedFromVersion != null) {
        hostLog.info(String.format("In order to update the application catalog it was " + "automatically upgraded from version %s.", ccr.upgradedFromVersion));
    }
    // case for @CatalogChangeResult
    if (ccr.encodedDiffCommands.trim().length() == 0) {
        return makeQuickResponse(ClientResponseImpl.SUCCESS, "Catalog update with no changes was skipped.");
    }
    // initiate the transaction.
    return callProcedure("@UpdateCore", ccr.encodedDiffCommands, ccr.catalogHash, ccr.catalogBytes, ccr.expectedCatalogVersion, ccr.deploymentString, ccr.tablesThatMustBeEmpty, ccr.reasonsForEmptyTables, ccr.requiresSnapshotIsolation ? 1 : 0, ccr.worksWithElastic ? 1 : 0, ccr.deploymentHash, ccr.requireCatalogDiffCmdsApplyToEE ? 1 : 0, ccr.hasSchemaChange ? 1 : 0, ccr.requiresNewExportGeneration ? 1 : 0);
}
Also used : CatalogChangeResult(org.voltdb.compiler.CatalogChangeResult) DrRoleType(org.voltdb.compiler.deploymentfile.DrRoleType) PrepareDiffFailureException(org.voltdb.compiler.CatalogChangeResult.PrepareDiffFailureException)

Aggregations

DrRoleType (org.voltdb.compiler.deploymentfile.DrRoleType)4 CatalogChangeResult (org.voltdb.compiler.CatalogChangeResult)3 PrepareDiffFailureException (org.voltdb.compiler.CatalogChangeResult.PrepareDiffFailureException)3 ClientResponse (org.voltdb.client.ClientResponse)1 SyncCallback (org.voltdb.client.SyncCallback)1