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 ) ; m_stat = stat ; 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 } ; }
Exit admin mode