use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.
the class DefaultFileSystemMaster method removeBlocks.
private void removeBlocks(Collection<Long> blocks) throws IOException {
if (blocks.isEmpty()) {
return;
}
RetryPolicy retry = new CountingRetry(3);
IOException lastThrown = null;
while (retry.attempt()) {
try {
mBlockMaster.removeBlocks(blocks, true);
return;
} catch (UnavailableException e) {
lastThrown = e;
}
}
throw new IOException("Failed to remove deleted blocks from block master", lastThrown);
}
use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.
the class DefaultBlockMaster method getLostWorkersInfoList.
@Override
public List<WorkerInfo> getLostWorkersInfoList() throws UnavailableException {
if (mSafeModeManager.isInSafeMode()) {
throw new UnavailableException(ExceptionMessage.MASTER_IN_SAFEMODE.getMessage());
}
List<WorkerInfo> workerInfoList = new ArrayList<>(mLostWorkers.size());
for (MasterWorkerInfo worker : mLostWorkers) {
// extractWorkerInfo handles the locking internally
workerInfoList.add(extractWorkerInfo(worker, null, false));
}
Collections.sort(workerInfoList, new WorkerInfo.LastContactSecComparator());
return workerInfoList;
}
use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.
the class DefaultBlockMaster method getWorkerReport.
@Override
public List<WorkerInfo> getWorkerReport(GetWorkerReportOptions options) throws UnavailableException, InvalidArgumentException {
if (mSafeModeManager.isInSafeMode()) {
throw new UnavailableException(ExceptionMessage.MASTER_IN_SAFEMODE.getMessage());
}
Set<MasterWorkerInfo> selectedLiveWorkers = new HashSet<>();
Set<MasterWorkerInfo> selectedLostWorkers = new HashSet<>();
WorkerRange workerRange = options.getWorkerRange();
switch(workerRange) {
case ALL:
selectedLiveWorkers.addAll(mWorkers);
selectedLostWorkers.addAll(mLostWorkers);
break;
case LIVE:
selectedLiveWorkers.addAll(mWorkers);
break;
case LOST:
selectedLostWorkers.addAll(mLostWorkers);
break;
case SPECIFIED:
Set<String> addresses = options.getAddresses();
Set<String> workerNames = new HashSet<>();
selectedLiveWorkers = selectInfoByAddress(addresses, mWorkers, workerNames);
selectedLostWorkers = selectInfoByAddress(addresses, mLostWorkers, workerNames);
if (!addresses.isEmpty()) {
String info = String.format("Unrecognized worker names: %s%n" + "Supported worker names: %s%n", addresses.toString(), workerNames.toString());
throw new InvalidArgumentException(info);
}
break;
default:
throw new InvalidArgumentException("Unrecognized worker range: " + workerRange);
}
List<WorkerInfo> workerInfoList = new ArrayList<>(selectedLiveWorkers.size() + selectedLostWorkers.size());
for (MasterWorkerInfo worker : selectedLiveWorkers) {
// extractWorkerInfo handles the locking internally
workerInfoList.add(extractWorkerInfo(worker, options.getFieldRange(), true));
}
for (MasterWorkerInfo worker : selectedLostWorkers) {
// extractWorkerInfo handles the locking internally
workerInfoList.add(extractWorkerInfo(worker, options.getFieldRange(), false));
}
return workerInfoList;
}
use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.
the class AccessTimeUpdater method flushUpdates.
private void flushUpdates() {
try (JournalContext context = mFileSystemMaster.createJournalContext()) {
for (Iterator<Map.Entry<Long, Long>> iterator = mAccessTimeUpdates.entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry<Long, Long> inodeEntry = iterator.next();
iterator.remove();
UpdateInodeEntry entry = UpdateInodeEntry.newBuilder().setId(inodeEntry.getKey()).setLastAccessTimeMs(inodeEntry.getValue()).build();
context.append(Journal.JournalEntry.newBuilder().setUpdateInode(entry).build());
}
} catch (UnavailableException e) {
LOG.debug("Failed to flush access time updates.", e);
}
}
use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.
the class FaultTolerantAlluxioMasterProcess method gainPrimacy.
/**
* Upgrades the master to primary mode.
*
* If the master loses primacy during the journal upgrade, this method will clean up the partial
* upgrade, leaving the master in standby mode.
*
* @return whether the master successfully upgraded to primary
*/
private boolean gainPrimacy() throws Exception {
LOG.info("Becoming a leader.");
// Don't upgrade if this master's primacy is unstable.
AtomicBoolean unstable = new AtomicBoolean(false);
try (Scoped scoped = mLeaderSelector.onStateChange(state -> unstable.set(true))) {
if (mLeaderSelector.getState() != State.PRIMARY) {
LOG.info("Lost leadership while becoming a leader.");
unstable.set(true);
}
stopMasters();
LOG.info("Standby stopped");
try (Timer.Context ctx = MetricsSystem.timer(MetricKey.MASTER_JOURNAL_GAIN_PRIMACY_TIMER.getName()).time()) {
mJournalSystem.gainPrimacy();
}
// We only check unstable here because mJournalSystem.gainPrimacy() is the only slow method
if (unstable.get()) {
LOG.info("Terminating an unstable attempt to become a leader.");
if (ServerConfiguration.getBoolean(PropertyKey.MASTER_JOURNAL_EXIT_ON_DEMOTION)) {
stop();
} else {
losePrimacy();
}
return false;
}
}
try {
startMasters(true);
} catch (UnavailableException e) {
LOG.warn("Error starting masters: {}", e.toString());
stopMasters();
return false;
}
mServingThread = new Thread(() -> {
try {
startCommonServices();
startLeaderServing(" (gained leadership)", " (lost leadership)");
} catch (Throwable t) {
Throwable root = Throwables.getRootCause(t);
if ((root != null && (root instanceof InterruptedException)) || Thread.interrupted()) {
return;
}
ProcessUtils.fatalError(LOG, t, "Exception thrown in main serving thread");
}
}, "MasterServingThread");
LOG.info("Starting a server thread.");
mServingThread.start();
if (!waitForReady(10 * Constants.MINUTE_MS)) {
ThreadUtils.logAllThreads();
throw new RuntimeException("Alluxio master failed to come up");
}
LOG.info("Primary started");
return true;
}
Aggregations