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); } }
/** * 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); }
/** * 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()); } }
MasterGoalState getMasterGoalState() { while (true) try { byte[] data = ZooReaderWriter.getInstance().getData(ZooUtil.getRoot(instance) + Constants.ZMASTER_GOAL_STATE, null); return MasterGoalState.valueOf(new String(data, UTF_8)); } catch (Exception e) { log.error("Problem getting real goal state: " + e); UtilWaitThread.sleep(1000); } }
MasterGoalState getMasterGoalState() { while (true) try { byte[] data = ZooReaderWriter.getInstance() .getData(ZooUtil.getRoot(getInstance()) + 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); } }
/** * 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); } SecurityUtil.serverLogin(SiteConfiguration.getInstance()); VolumeManager fs = VolumeManagerImpl.get(); Accumulo.waitForZookeeperAndHdfs(fs); ZooReaderWriter.getInstance().putPersistentData( ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZMASTER_GOAL_STATE, args[0].getBytes(UTF_8), NodeExistsPolicy.OVERWRITE); }
/** * 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); } SecurityUtil.serverLogin(); FileSystem fs = FileUtil.getFileSystem(CachedConfiguration.getInstance(), ServerConfiguration.getSiteConfiguration()); Accumulo.waitForZookeeperAndHdfs(fs); ZooReaderWriter.getInstance().putPersistentData(ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZMASTER_GOAL_STATE, args[0].getBytes(UTF_8), NodeExistsPolicy.OVERWRITE); }