/// <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) { } }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
> 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)); }
> GetJournalState() { IDictionary <AsyncLogger, ListenableFuture <QJournalProtocolProtos.GetJournalStateResponseProto > > calls = Maps.NewHashMap(); foreach (AsyncLogger logger in loggers) { calls[logger] = logger.GetJournalState(); } return(QuorumCall.Create(calls)); }
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)); }
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)); }
> 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)); }
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)); }
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)); }