/** * Returns the goal state of the master * * @return master goal state */ public static String getGoalState() { MasterMonitorInfo mmi = getMmi(); if (mmi == null) { return NO_MASTERS; } return mmi.goalState.name(); }
if (serversToShutdown.contains(dead)) cause = "clean shutdown"; // maybe an incorrect assumption if (!getMasterGoalState().equals(MasterGoalState.CLEAN_STOP)) obit.post(dead.hostPort(), cause); unexpected.removeAll(this.serversToShutdown); if (unexpected.size() > 0) { if (stillMaster() && !getMasterGoalState().equals(MasterGoalState.CLEAN_STOP)) { log.warn("Lost servers {}", unexpected);
MasterGoalState getMasterGoalState() { while (true) try { byte[] data = context.getZooReaderWriter() .getData(getZooKeeperRoot() + Constants.ZMASTER_GOAL_STATE, null); return MasterGoalState.valueOf(new String(data)); } catch (Exception e) { log.error("Problem getting real goal state from zookeeper: ", e); sleepUninterruptibly(1, TimeUnit.SECONDS); } }
NodeExistsPolicy.FAIL); zoo.putPersistentData(zkInstanceRoot + Constants.ZMASTER_GOAL_STATE, MasterGoalState.NORMAL.toString().getBytes(UTF_8), NodeExistsPolicy.FAIL); zoo.putPersistentData(zkInstanceRoot + Constants.ZGC, EMPTY_BYTE_ARRAY, NodeExistsPolicy.FAIL); zoo.putPersistentData(zkInstanceRoot + Constants.ZGC_LOCK, EMPTY_BYTE_ARRAY,
public void write(org.apache.thrift.protocol.TProtocol oprot, setMasterGoalState_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.credentials != null) { oprot.writeFieldBegin(CREDENTIALS_FIELD_DESC); struct.credentials.write(oprot); oprot.writeFieldEnd(); } if (struct.state != null) { oprot.writeFieldBegin(STATE_FIELD_DESC); oprot.writeI32(struct.state.getValue()); oprot.writeFieldEnd(); } if (struct.tinfo != null) { oprot.writeFieldBegin(TINFO_FIELD_DESC); struct.tinfo.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); }
case 2: // STATE if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.state = org.apache.accumulo.core.master.thrift.MasterGoalState.findByValue(iprot.readI32()); struct.setStateIsSet(true); } else {
@Override public void start() throws IOException { StandaloneClusterControl control = getClusterControl(); // TODO We can check the hosts files, but that requires us to be on a host with the // installation. Limitation at the moment. control.setGoalState(MasterGoalState.NORMAL.toString()); for (ServerType type : ALL_SERVER_TYPES) { control.startAllServers(type); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, setMasterGoalState_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetTinfo()) { optionals.set(0); } if (struct.isSetCredentials()) { optionals.set(1); } if (struct.isSetState()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetTinfo()) { struct.tinfo.write(oprot); } if (struct.isSetCredentials()) { struct.credentials.write(oprot); } if (struct.isSetState()) { oprot.writeI32(struct.state.getValue()); } }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, setMasterGoalState_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { struct.tinfo = new org.apache.accumulo.core.trace.thrift.TInfo(); struct.tinfo.read(iprot); struct.setTinfoIsSet(true); } if (incoming.get(1)) { struct.credentials = new org.apache.accumulo.core.securityImpl.thrift.TCredentials(); struct.credentials.read(iprot); struct.setCredentialsIsSet(true); } if (incoming.get(2)) { struct.state = org.apache.accumulo.core.master.thrift.MasterGoalState.findByValue(iprot.readI32()); struct.setStateIsSet(true); } } }
void setMasterGoalState(MasterGoalState state) { try { context.getZooReaderWriter().putPersistentData( getZooKeeperRoot() + Constants.ZMASTER_GOAL_STATE, state.name().getBytes(), NodeExistsPolicy.OVERWRITE); } catch (Exception ex) { log.error("Unable to set master goal state in zookeeper"); } }
/** * Utility program that will change the goal state for the master from the command line. */ public static void main(String[] args) throws Exception { if (args.length != 1 || MasterGoalState.valueOf(args[0]) == null) { System.err.println( "Usage: accumulo " + SetGoalState.class.getName() + " [NORMAL|SAFE_MODE|CLEAN_STOP]"); System.exit(-1); } ServerContext context = new ServerContext(new SiteConfiguration()); SecurityUtil.serverLogin(context.getConfiguration()); ServerUtil.waitForZookeeperAndHdfs(context); context.getZooReaderWriter().putPersistentData( context.getZooKeeperRoot() + Constants.ZMASTER_GOAL_STATE, args[0].getBytes(UTF_8), NodeExistsPolicy.OVERWRITE); }
if (!(this_present_goalState && that_present_goalState)) return false; if (!this.goalState.equals(that.goalState)) return false;
ret = exec(Main.class, SetGoalState.class.getName(), MasterGoalState.NORMAL.toString()) .waitFor(); if (ret == 0)
if (struct.goalState != null) { oprot.writeFieldBegin(GOAL_STATE_FIELD_DESC); oprot.writeI32(struct.goalState.getValue()); oprot.writeFieldEnd();
case 8: // GOAL_STATE if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.goalState = org.apache.accumulo.core.master.thrift.MasterGoalState.findByValue(iprot.readI32()); struct.setGoalStateIsSet(true); } else {
private void setMasterGoalState(MasterGoalState state) { try { ZooReaderWriter.getInstance().putPersistentData(ZooUtil.getRoot(instance) + Constants.ZMASTER_GOAL_STATE, state.name().getBytes(UTF_8), NodeExistsPolicy.OVERWRITE); } catch (Exception ex) { log.error("Unable to set master goal state in zookeeper"); } }
/** * Wrapper around SetGoalState using the "server" <code>ACCUMULO_CONF_DIR</code> * * @param goalState * The goal state to set * @throws IOException * If SetGoalState returns a non-zero result */ public void setGoalState(String goalState) throws IOException { requireNonNull(goalState, "Goal state must not be null"); checkArgument(MasterGoalState.valueOf(goalState) != null, "Unknown goal state: " + goalState); File confDir = getConfDir(); String master = getHosts(new File(confDir, "masters")).get(0); String[] cmd = new String[] {SUDO_CMD, "-u", user, ACCUMULO_CONF_DIR + serverAccumuloConfDir, accumuloPath, SetGoalState.class.getName(), goalState}; Entry<Integer,String> pair = exec(master, cmd); if (0 != pair.getKey().intValue()) { throw new IOException("SetGoalState did not finish successfully, retcode=" + pair.getKey() + ", stdout=" + pair.getValue()); } }
if (!(this_present_state && that_present_state)) return false; if (!this.state.equals(that.state)) return false;
NodeExistsPolicy.FAIL); zoo.putPersistentData(zkInstanceRoot + Constants.ZMASTER_GOAL_STATE, MasterGoalState.NORMAL.toString().getBytes(UTF_8), NodeExistsPolicy.FAIL); zoo.putPersistentData(zkInstanceRoot + Constants.ZGC, EMPTY_BYTE_ARRAY, NodeExistsPolicy.FAIL); zoo.putPersistentData(zkInstanceRoot + Constants.ZGC_LOCK, EMPTY_BYTE_ARRAY,
@Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetTableMap()) ? 131071 : 524287); if (isSetTableMap()) hashCode = hashCode * 8191 + tableMap.hashCode(); hashCode = hashCode * 8191 + ((isSetTServerInfo()) ? 131071 : 524287); if (isSetTServerInfo()) hashCode = hashCode * 8191 + tServerInfo.hashCode(); hashCode = hashCode * 8191 + ((isSetBadTServers()) ? 131071 : 524287); if (isSetBadTServers()) hashCode = hashCode * 8191 + badTServers.hashCode(); hashCode = hashCode * 8191 + ((isSetState()) ? 131071 : 524287); if (isSetState()) hashCode = hashCode * 8191 + state.getValue(); hashCode = hashCode * 8191 + ((isSetGoalState()) ? 131071 : 524287); if (isSetGoalState()) hashCode = hashCode * 8191 + goalState.getValue(); hashCode = hashCode * 8191 + unassignedTablets; hashCode = hashCode * 8191 + ((isSetServersShuttingDown()) ? 131071 : 524287); if (isSetServersShuttingDown()) hashCode = hashCode * 8191 + serversShuttingDown.hashCode(); hashCode = hashCode * 8191 + ((isSetDeadTabletServers()) ? 131071 : 524287); if (isSetDeadTabletServers()) hashCode = hashCode * 8191 + deadTabletServers.hashCode(); hashCode = hashCode * 8191 + ((isSetBulkImports()) ? 131071 : 524287); if (isSetBulkImports()) hashCode = hashCode * 8191 + bulkImports.hashCode(); return hashCode; }