Exemple #1
0
 private static void CheckAllResults(long[] toCheck, bool shouldSucceed)
 {
     if (shouldSucceed)
     {
         DFSUtil.AssertAllResultsEqual(Arrays.AsList(toCheck));
     }
     else
     {
         try
         {
             DFSUtil.AssertAllResultsEqual(Arrays.AsList(toCheck));
             NUnit.Framework.Assert.Fail("Should not have succeeded with input: " + Arrays.ToString
                                             (toCheck));
         }
         catch (Exception ae)
         {
             GenericTestUtils.AssertExceptionContains("Not all elements match", ae);
         }
     }
 }
        /// <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 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.");
        }