/** * @return index of leader master in {@link #mMasters}, or -1 if there is no leader temporarily */ public int getLeaderIndex() { for (int i = 0; i < mNumOfMasters; i++) { if (mMasters.get(i).isServing()) { return i; } } return -1; }
@Override public LocalAlluxioMaster getLocalAlluxioMaster() { for (LocalAlluxioMaster master : mMasters) { // Return the leader master, if possible. if (master.isServing()) { return master; } } return mMasters.get(0); }
/** * Iterates over the masters in the order of master creation, stops the leader master. * * @return true if the leader master is successfully stopped, false otherwise */ public boolean stopLeader() { for (int k = 0; k < mNumOfMasters; k++) { if (mMasters.get(k).isServing()) { try { LOG.info("master {} is the leader. stopping it...", k); mMasters.get(k).stop(); LOG.info("master {} stopped.", k); } catch (Exception e) { LOG.error(e.getMessage(), e); return false; } return true; } } return false; }
/** * Iterates over the masters in the order of master creation, stops the first standby master. * * @return true if a standby master is successfully stopped, otherwise, false */ public boolean stopStandby() { for (int k = 0; k < mNumOfMasters; k++) { if (!mMasters.get(k).isServing()) { try { LOG.info("master {} is a standby. stopping it...", k); mMasters.get(k).stop(); LOG.info("master {} stopped.", k); } catch (Exception e) { LOG.error(e.getMessage(), e); return false; } return true; } } return false; }
final LocalAlluxioMaster master = LocalAlluxioMaster.create(mWorkDirectory); master.start(); LOG.info("master NO.{} started, isServing: {}, address: {}", k, master.isServing(), master.getAddress()); mMasters.add(master); while (!hasLeader) { for (int i = 0; i < mMasters.size(); i++) { if (mMasters.get(i).isServing()) { LOG.info("master NO.{} is selected as leader. address: {}", i, mMasters.get(i).getAddress());
@Override public LocalAlluxioMaster getLocalAlluxioMaster() { for (LocalAlluxioMaster master : mMasters) { // Return the leader master, if possible. if (master.isServing()) { return master; } } return mMasters.get(0); }
/** * @return index of leader master in {@link #mMasters}, or -1 if there is no leader temporarily */ public int getLeaderIndex() { for (int i = 0; i < mNumOfMasters; i++) { if (mMasters.get(i).isServing()) { return i; } } return -1; }
/** * Iterates over the masters in the order of master creation, stops the first standby master. * * @return true if a standby master is successfully stopped, otherwise, false */ public boolean stopStandby() { for (int k = 0; k < mNumOfMasters; k++) { if (!mMasters.get(k).isServing()) { try { LOG.info("master {} is a standby. stopping it...", k); mMasters.get(k).stop(); LOG.info("master {} stopped.", k); } catch (Exception e) { LOG.error(e.getMessage(), e); return false; } return true; } } return false; }
/** * Iterates over the masters in the order of master creation, stops the leader master. * * @return true if the leader master is successfully stopped, false otherwise */ public boolean stopLeader() { for (int k = 0; k < mNumOfMasters; k++) { if (mMasters.get(k).isServing()) { try { LOG.info("master {} is the leader. stopping it...", k); mMasters.get(k).stop(); LOG.info("master {} stopped.", k); } catch (Exception e) { LOG.error(e.getMessage(), e); return false; } return true; } } return false; }
final LocalAlluxioMaster master = LocalAlluxioMaster.create(mWorkDirectory); master.start(); LOG.info("master NO.{} started, isServing: {}, address: {}", k, master.isServing(), master.getAddress()); mMasters.add(master); while (!hasLeader) { for (int i = 0; i < mMasters.size(); i++) { if (mMasters.get(i).isServing()) { LOG.info("master NO.{} is selected as leader. address: {}", i, mMasters.get(i).getAddress());