/// <exception cref="System.IO.IOException"/> public virtual bool HasSomeData() { QuorumCall <AsyncLogger, bool> call = loggers.IsFormatted(); try { call.WaitFor(loggers.Size(), 0, 0, HasdataTimeoutMs, "hasSomeData"); } catch (Exception) { throw new IOException("Interrupted while determining if JNs have data"); } catch (TimeoutException) { throw new IOException("Timed out waiting for response from loggers"); } if (call.CountExceptions() > 0) { call.RethrowException("Unable to check if JNs are ready for formatting"); } // If any of the loggers returned with a non-empty manifest, then // we should prompt for format. foreach (bool hasData in call.GetResults().Values) { if (hasData) { return(true); } } // Otherwise, none were formatted, we can safely format. return(false); }
/// <exception cref="System.IO.IOException"/> public override bool CanRollBack(StorageInfo storage, StorageInfo prevStorage, int targetLayoutVersion) { QuorumCall <AsyncLogger, bool> call = loggers.CanRollBack(storage, prevStorage, targetLayoutVersion ); try { call.WaitFor(loggers.Size(), loggers.Size(), 0, CanRollBackTimeoutMs, "lockSharedStorage" ); if (call.CountExceptions() > 0) { call.RethrowException("Could not check if roll back possible for" + " one or more JournalNodes" ); } // Either they all return the same thing or this call fails, so we can // just return the first result. try { DFSUtil.AssertAllResultsEqual(call.GetResults().Values); } catch (Exception ae) { throw new IOException("Results differed for canRollBack", ae); } foreach (bool result in call.GetResults().Values) { return(result); } } catch (Exception) { throw new IOException("Interrupted waiting for lockSharedStorage() " + "response" ); } catch (TimeoutException) { throw new IOException("Timed out waiting for lockSharedStorage() " + "response"); } throw new Exception("Unreachable code."); }
/// <exception cref="System.IO.IOException"/> public override void DoRollback() { QuorumCall <AsyncLogger, Void> call = loggers.DoRollback(); try { call.WaitFor(loggers.Size(), loggers.Size(), 0, RollBackTimeoutMs, "doRollback"); if (call.CountExceptions() > 0) { call.RethrowException("Could not perform rollback of one or more JournalNodes"); } } catch (Exception) { throw new IOException("Interrupted waiting for doFinalize() response"); } catch (TimeoutException) { throw new IOException("Timed out waiting for doFinalize() response"); } }
/// <exception cref="System.IO.IOException"/> public override void DoUpgrade(Storage storage) { QuorumCall <AsyncLogger, Void> call = loggers.DoUpgrade(storage); try { call.WaitFor(loggers.Size(), loggers.Size(), 0, UpgradeTimeoutMs, "doUpgrade"); if (call.CountExceptions() > 0) { call.RethrowException("Could not perform upgrade of one or more JournalNodes"); } } catch (Exception) { throw new IOException("Interrupted waiting for doUpgrade() response"); } catch (TimeoutException) { throw new IOException("Timed out waiting for doUpgrade() response"); } }
/// <exception cref="System.IO.IOException"/> public override void Format(NamespaceInfo nsInfo) { QuorumCall <AsyncLogger, Void> call = loggers.Format(nsInfo); try { call.WaitFor(loggers.Size(), loggers.Size(), 0, FormatTimeoutMs, "format"); } catch (Exception) { throw new IOException("Interrupted waiting for format() response"); } catch (TimeoutException) { throw new IOException("Timed out waiting for format() response"); } if (call.CountExceptions() > 0) { call.RethrowException("Could not format one or more JournalNodes"); } }
/// <exception cref="System.IO.IOException"/> public override void DiscardSegments(long startTxId) { QuorumCall <AsyncLogger, Void> call = loggers.DiscardSegments(startTxId); try { call.WaitFor(loggers.Size(), loggers.Size(), 0, DiscardSegmentsTimeoutMs, "discardSegments" ); if (call.CountExceptions() > 0) { call.RethrowException("Could not perform discardSegments of one or more JournalNodes" ); } } catch (Exception) { throw new IOException("Interrupted waiting for discardSegments() response"); } catch (TimeoutException) { throw new IOException("Timed out waiting for discardSegments() response"); } }
/// <exception cref="System.IO.IOException"/> public override long GetJournalCTime() { QuorumCall <AsyncLogger, long> call = loggers.GetJournalCTime(); try { call.WaitFor(loggers.Size(), loggers.Size(), 0, GetJournalCtimeTimeoutMs, "getJournalCTime" ); if (call.CountExceptions() > 0) { call.RethrowException("Could not journal CTime for one " + "more JournalNodes"); } // Either they all return the same thing or this call fails, so we can // just return the first result. try { DFSUtil.AssertAllResultsEqual(call.GetResults().Values); } catch (Exception ae) { throw new IOException("Results differed for getJournalCTime", ae); } foreach (long result in call.GetResults().Values) { return(result); } } catch (Exception) { throw new IOException("Interrupted waiting for getJournalCTime() " + "response"); } catch (TimeoutException) { throw new IOException("Timed out waiting for getJournalCTime() " + "response"); } throw new Exception("Unreachable code."); }