Search in sources :

Example 1 with SnmpTrapSender

use of org.voltdb.snmp.SnmpTrapSender in project voltdb by VoltDB.

the class RealVoltDB method halt.

@Override
public void halt() {
    SnmpTrapSender snmp = getSnmpTrapSender();
    if (snmp != null) {
        try {
            snmp.hostDown(FaultLevel.INFO, m_messenger.getHostId(), "Host is shutting down because of @StopNode");
            snmp.shutdown();
        } catch (Throwable t) {
            VoltLogger log = new VoltLogger("HOST");
            log.warn("failed to issue a crash SNMP trap", t);
        }
    }
    Thread shutdownThread = new Thread() {

        @Override
        public void run() {
            hostLog.warn("VoltDB node shutting down as requested by @StopNode command.");
            System.exit(0);
        }
    };
    shutdownThread.start();
}
Also used : VoltLogger(org.voltcore.logging.VoltLogger) SnmpTrapSender(org.voltdb.snmp.SnmpTrapSender) DummySnmpTrapSender(org.voltdb.snmp.DummySnmpTrapSender)

Example 2 with SnmpTrapSender

use of org.voltdb.snmp.SnmpTrapSender in project voltdb by VoltDB.

the class VoltDB method sendCrashSNMPTrap.

/**
     * send a SNMP trap crash notification
     * @param msg
     */
private static void sendCrashSNMPTrap(String msg) {
    if (msg == null || msg.trim().isEmpty()) {
        return;
    }
    VoltDBInterface vdbInstance = instance();
    if (vdbInstance == null) {
        return;
    }
    SnmpTrapSender snmp = vdbInstance.getSnmpTrapSender();
    if (snmp == null) {
        return;
    }
    try {
        snmp.crash(msg);
    } catch (Throwable t) {
        VoltLogger log = new VoltLogger("HOST");
        log.warn("failed to issue a crash SNMP trap", t);
    }
}
Also used : VoltLogger(org.voltcore.logging.VoltLogger) SnmpTrapSender(org.voltdb.snmp.SnmpTrapSender)

Example 3 with SnmpTrapSender

use of org.voltdb.snmp.SnmpTrapSender in project voltdb by VoltDB.

the class Pause method run.

/**
     * Enter admin mode
     * @param ctx       Internal parameter. Not user-accessible.
     * @return          Standard STATUS table.
     */
public VoltTable[] run(SystemProcedureExecutionContext ctx) {
    if (ctx.isLowestSiteId()) {
        VoltDBInterface voltdb = VoltDB.instance();
        OperationMode opMode = voltdb.getMode();
        if (LOG.isDebugEnabled()) {
            LOG.debug("voltdb opmode is " + opMode);
        }
        ZooKeeper zk = voltdb.getHostMessenger().getZK();
        try {
            Stat stat;
            OperationMode zkMode = null;
            Code code;
            do {
                stat = new Stat();
                code = Code.BADVERSION;
                try {
                    byte[] data = zk.getData(VoltZK.operationMode, false, stat);
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("zkMode is " + (zkMode == null ? "(null)" : OperationMode.valueOf(data)));
                    }
                    zkMode = data == null ? opMode : OperationMode.valueOf(data);
                    if (zkMode == PAUSED) {
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("read node at version " + stat.getVersion() + ", txn " + ll(stat.getMzxid()));
                        }
                        break;
                    }
                    stat = zk.setData(VoltZK.operationMode, PAUSED.getBytes(), stat.getVersion());
                    code = Code.OK;
                    zkMode = PAUSED;
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("!WROTE! node at version " + stat.getVersion() + ", txn " + ll(stat.getMzxid()));
                    }
                    break;
                } catch (BadVersionException ex) {
                    code = ex.code();
                }
            } while (zkMode != PAUSED && code == Code.BADVERSION);
            m_stat = stat;
            voltdb.getHostMessenger().pause();
            voltdb.setMode(PAUSED);
            // for snmp
            SnmpTrapSender snmp = voltdb.getSnmpTrapSender();
            if (snmp != null) {
                snmp.pause("Cluster paused.");
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    // Force a tick so that stats will be updated.
    // Primarily added to get latest table stats for DR pause and empty db check.
    ctx.getSiteProcedureConnection().tick();
    VoltTable t = new VoltTable(VoltSystemProcedure.STATUS_SCHEMA);
    t.addRow(VoltSystemProcedure.STATUS_OK);
    return (new VoltTable[] { t });
}
Also used : VoltDBInterface(org.voltdb.VoltDBInterface) ZooKeeper(org.apache.zookeeper_voltpatches.ZooKeeper) Stat(org.apache.zookeeper_voltpatches.data.Stat) BadVersionException(org.apache.zookeeper_voltpatches.KeeperException.BadVersionException) SnmpTrapSender(org.voltdb.snmp.SnmpTrapSender) OperationMode(org.voltdb.OperationMode) Code(org.apache.zookeeper_voltpatches.KeeperException.Code) VoltTable(org.voltdb.VoltTable) BadVersionException(org.apache.zookeeper_voltpatches.KeeperException.BadVersionException)

Example 4 with SnmpTrapSender

use of org.voltdb.snmp.SnmpTrapSender in project voltdb by VoltDB.

the class Resume method run.

/**
     * Exit admin mode
     * @param ctx       Internal parameter. Not user-accessible.
     * @return          Standard STATUS table.
     */
public VoltTable[] run(SystemProcedureExecutionContext ctx) {
    // Choose the lowest site ID on this host to actually flip the bit
    VoltDBInterface voltdb = VoltDB.instance();
    OperationMode opMode = voltdb.getMode();
    if (ctx.isLowestSiteId()) {
        ZooKeeper zk = voltdb.getHostMessenger().getZK();
        try {
            Stat stat;
            OperationMode zkMode = null;
            Code code;
            do {
                stat = new Stat();
                code = Code.BADVERSION;
                try {
                    byte[] data = zk.getData(VoltZK.operationMode, false, stat);
                    zkMode = data == null ? opMode : OperationMode.valueOf(data);
                    if (zkMode == RUNNING) {
                        break;
                    }
                    stat = zk.setData(VoltZK.operationMode, RUNNING.getBytes(), stat.getVersion());
                    code = Code.OK;
                    zkMode = RUNNING;
                    break;
                } catch (BadVersionException ex) {
                    code = ex.code();
                }
            } while (zkMode != RUNNING && code == Code.BADVERSION);
            voltdb.getHostMessenger().unpause();
            voltdb.setMode(RUNNING);
            // for snmp
            SnmpTrapSender snmp = voltdb.getSnmpTrapSender();
            if (snmp != null) {
                snmp.resume("Cluster resumed.");
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    VoltTable t = new VoltTable(VoltSystemProcedure.STATUS_SCHEMA);
    t.addRow(VoltSystemProcedure.STATUS_OK);
    return new VoltTable[] { t };
}
Also used : VoltDBInterface(org.voltdb.VoltDBInterface) ZooKeeper(org.apache.zookeeper_voltpatches.ZooKeeper) Stat(org.apache.zookeeper_voltpatches.data.Stat) BadVersionException(org.apache.zookeeper_voltpatches.KeeperException.BadVersionException) SnmpTrapSender(org.voltdb.snmp.SnmpTrapSender) OperationMode(org.voltdb.OperationMode) Code(org.apache.zookeeper_voltpatches.KeeperException.Code) VoltTable(org.voltdb.VoltTable) BadVersionException(org.apache.zookeeper_voltpatches.KeeperException.BadVersionException)

Aggregations

SnmpTrapSender (org.voltdb.snmp.SnmpTrapSender)4 BadVersionException (org.apache.zookeeper_voltpatches.KeeperException.BadVersionException)2 Code (org.apache.zookeeper_voltpatches.KeeperException.Code)2 ZooKeeper (org.apache.zookeeper_voltpatches.ZooKeeper)2 Stat (org.apache.zookeeper_voltpatches.data.Stat)2 VoltLogger (org.voltcore.logging.VoltLogger)2 OperationMode (org.voltdb.OperationMode)2 VoltDBInterface (org.voltdb.VoltDBInterface)2 VoltTable (org.voltdb.VoltTable)2 DummySnmpTrapSender (org.voltdb.snmp.DummySnmpTrapSender)1