コード例 #1
0
ファイル: TestQuorumCall.cs プロジェクト: orf53975/hadoop.net
        /// <exception cref="System.Exception"/>
        public virtual void TestQuorums()
        {
            IDictionary <string, SettableFuture <string> > futures = ImmutableMap.Of("f1", SettableFuture
                                                                                     .Create <string>(), "f2", SettableFuture.Create <string>(), "f3", SettableFuture.Create
                                                                                     <string>());
            QuorumCall <string, string> q = QuorumCall.Create(futures);

            NUnit.Framework.Assert.AreEqual(0, q.CountResponses());
            futures["f1"].Set("first future");
            q.WaitFor(1, 0, 0, 100000, "test");
            // wait for 1 response
            q.WaitFor(0, 1, 0, 100000, "test");
            // wait for 1 success
            NUnit.Framework.Assert.AreEqual(1, q.CountResponses());
            futures["f2"].SetException(new Exception("error"));
            NUnit.Framework.Assert.AreEqual(2, q.CountResponses());
            futures["f3"].Set("second future");
            q.WaitFor(3, 0, 100, 100000, "test");
            // wait for 3 responses
            q.WaitFor(0, 2, 100, 100000, "test");
            // 2 successes
            NUnit.Framework.Assert.AreEqual(3, q.CountResponses());
            NUnit.Framework.Assert.AreEqual("f1=first future,f3=second future", Joiner.On(","
                                                                                          ).WithKeyValueSeparator("=").Join(new SortedDictionary <string, string>(q.GetResults
                                                                                                                                                                      ())));
            try
            {
                q.WaitFor(0, 4, 100, 10, "test");
                NUnit.Framework.Assert.Fail("Didn't time out waiting for more responses than came back"
                                            );
            }
            catch (TimeoutException)
            {
            }
        }
コード例 #2
0
        public virtual QuorumCall <AsyncLogger, bool> IsFormatted()
        {
            IDictionary <AsyncLogger, ListenableFuture <bool> > calls = Maps.NewHashMap();

            foreach (AsyncLogger logger in loggers)
            {
                calls[logger] = logger.IsFormatted();
            }
            return(QuorumCall.Create(calls));
        }
コード例 #3
0
        public virtual QuorumCall <AsyncLogger, long> GetJournalCTime()
        {
            IDictionary <AsyncLogger, ListenableFuture <long> > calls = Maps.NewHashMap();

            foreach (AsyncLogger logger in loggers)
            {
                ListenableFuture <long> future = logger.GetJournalCTime();
                calls[logger] = future;
            }
            return(QuorumCall.Create(calls));
        }
コード例 #4
0
        public virtual QuorumCall <AsyncLogger, Void> DoRollback()
        {
            IDictionary <AsyncLogger, ListenableFuture <Void> > calls = Maps.NewHashMap();

            foreach (AsyncLogger logger in loggers)
            {
                ListenableFuture <Void> future = logger.DoRollback();
                calls[logger] = future;
            }
            return(QuorumCall.Create(calls));
        }
コード例 #5
0
        public virtual QuorumCall <AsyncLogger, Void> DiscardSegments(long startTxId)
        {
            IDictionary <AsyncLogger, ListenableFuture <Void> > calls = Maps.NewHashMap();

            foreach (AsyncLogger logger in loggers)
            {
                ListenableFuture <Void> future = logger.DiscardSegments(startTxId);
                calls[logger] = future;
            }
            return(QuorumCall.Create(calls));
        }
コード例 #6
0
        internal virtual QuorumCall <AsyncLogger, Void> Format(NamespaceInfo nsInfo)
        {
            IDictionary <AsyncLogger, ListenableFuture <Void> > calls = Maps.NewHashMap();

            foreach (AsyncLogger logger in loggers)
            {
                ListenableFuture <Void> future = logger.Format(nsInfo);
                calls[logger] = future;
            }
            return(QuorumCall.Create(calls));
        }
コード例 #7
0
        public virtual QuorumCall <AsyncLogger, Void> FinalizeLogSegment(long firstTxId, long
                                                                         lastTxId)
        {
            IDictionary <AsyncLogger, ListenableFuture <Void> > calls = Maps.NewHashMap();

            foreach (AsyncLogger logger in loggers)
            {
                calls[logger] = logger.FinalizeLogSegment(firstTxId, lastTxId);
            }
            return(QuorumCall.Create(calls));
        }
コード例 #8
0
        public virtual QuorumCall <AsyncLogger, Void> StartLogSegment(long txid, int layoutVersion
                                                                      )
        {
            IDictionary <AsyncLogger, ListenableFuture <Void> > calls = Maps.NewHashMap();

            foreach (AsyncLogger logger in loggers)
            {
                calls[logger] = logger.StartLogSegment(txid, layoutVersion);
            }
            return(QuorumCall.Create(calls));
        }
コード例 #9
0
                                   > NewEpoch(NamespaceInfo nsInfo, long epoch)
        {
            IDictionary <AsyncLogger, ListenableFuture <QJournalProtocolProtos.NewEpochResponseProto
                                                        > > calls = Maps.NewHashMap();

            foreach (AsyncLogger logger in loggers)
            {
                calls[logger] = logger.NewEpoch(epoch);
            }
            return(QuorumCall.Create(calls));
        }
コード例 #10
0
                                   > GetJournalState()
        {
            IDictionary <AsyncLogger, ListenableFuture <QJournalProtocolProtos.GetJournalStateResponseProto
                                                        > > calls = Maps.NewHashMap();

            foreach (AsyncLogger logger in loggers)
            {
                calls[logger] = logger.GetJournalState();
            }
            return(QuorumCall.Create(calls));
        }
コード例 #11
0
        internal virtual QuorumCall <AsyncLogger, Void> AcceptRecovery(QJournalProtocolProtos.SegmentStateProto
                                                                       log, Uri fromURL)
        {
            IDictionary <AsyncLogger, ListenableFuture <Void> > calls = Maps.NewHashMap();

            foreach (AsyncLogger logger in loggers)
            {
                ListenableFuture <Void> future = logger.AcceptRecovery(log, fromURL);
                calls[logger] = future;
            }
            return(QuorumCall.Create(calls));
        }
コード例 #12
0
        public virtual QuorumCall <AsyncLogger, bool> CanRollBack(StorageInfo storage, StorageInfo
                                                                  prevStorage, int targetLayoutVersion)
        {
            IDictionary <AsyncLogger, ListenableFuture <bool> > calls = Maps.NewHashMap();

            foreach (AsyncLogger logger in loggers)
            {
                ListenableFuture <bool> future = logger.CanRollBack(storage, prevStorage, targetLayoutVersion
                                                                    );
                calls[logger] = future;
            }
            return(QuorumCall.Create(calls));
        }
コード例 #13
0
                                     > PrepareRecovery(long segmentTxId)
        {
            IDictionary <AsyncLogger, ListenableFuture <QJournalProtocolProtos.PrepareRecoveryResponseProto
                                                        > > calls = Maps.NewHashMap();

            foreach (AsyncLogger logger in loggers)
            {
                ListenableFuture <QJournalProtocolProtos.PrepareRecoveryResponseProto> future = logger
                                                                                                .PrepareRecovery(segmentTxId);
                calls[logger] = future;
            }
            return(QuorumCall.Create(calls));
        }
コード例 #14
0
        public virtual QuorumCall <AsyncLogger, Void> SendEdits(long segmentTxId, long firstTxnId
                                                                , int numTxns, byte[] data)
        {
            IDictionary <AsyncLogger, ListenableFuture <Void> > calls = Maps.NewHashMap();

            foreach (AsyncLogger logger in loggers)
            {
                ListenableFuture <Void> future = logger.SendEdits(segmentTxId, firstTxnId, numTxns
                                                                  , data);
                calls[logger] = future;
            }
            return(QuorumCall.Create(calls));
        }
コード例 #15
0
        public virtual QuorumCall <AsyncLogger, RemoteEditLogManifest> GetEditLogManifest(
            long fromTxnId, bool inProgressOk)
        {
            IDictionary <AsyncLogger, ListenableFuture <RemoteEditLogManifest> > calls = Maps.NewHashMap
                                                                                             ();

            foreach (AsyncLogger logger in loggers)
            {
                ListenableFuture <RemoteEditLogManifest> future = logger.GetEditLogManifest(fromTxnId
                                                                                            , inProgressOk);
                calls[logger] = future;
            }
            return(QuorumCall.Create(calls));
        }