public ChangeFeedEstimatorRunner( ChangesEstimationHandler initialEstimateDelegate, TimeSpan?estimatorPeriod) : this(estimatorPeriod) { this.initialEstimateDelegate = initialEstimateDelegate ?? throw new ArgumentNullException(nameof(initialEstimateDelegate)); }
public ChangeFeedEstimatorDispatcher( ChangesEstimationHandler dispatchEstimation, TimeSpan?estimationPeriod = null) { this.dispatchEstimation = dispatchEstimation; this.DispatchPeriod = estimationPeriod; }
internal ChangeFeedEstimatorCore( ChangesEstimationHandler initialEstimateDelegate, TimeSpan?estimatorPeriod, RemainingWorkEstimator remainingWorkEstimator) : this(initialEstimateDelegate, estimatorPeriod) { this.remainingWorkEstimator = remainingWorkEstimator; }
public FeedEstimatorRunner( ChangesEstimationHandler dispatchEstimation, ChangeFeedEstimator remainingWorkEstimator, TimeSpan?estimationPeriod = null) { this.dispatchEstimation = dispatchEstimation; this.remainingWorkEstimator = remainingWorkEstimator; this.monitoringDelay = estimationPeriod ?? FeedEstimatorRunner.defaultMonitoringDelay; }
public override ChangeFeedProcessorBuilder GetChangeFeedEstimatorBuilder( string processorName, ChangesEstimationHandler estimationDelegate, TimeSpan?estimationPeriod = null) { return(this.container.GetChangeFeedEstimatorBuilder( processorName, estimationDelegate, estimationPeriod)); }
public ChangeFeedEstimatorCore( ChangesEstimationHandler initialEstimateDelegate, TimeSpan?estimatorPeriod) { if (initialEstimateDelegate == null) { throw new ArgumentNullException(nameof(initialEstimateDelegate)); } if (estimatorPeriod.HasValue && estimatorPeriod.Value <= TimeSpan.Zero) { throw new ArgumentOutOfRangeException(nameof(estimatorPeriod)); } this.initialEstimateDelegate = initialEstimateDelegate; this.estimatorPeriod = estimatorPeriod; }
public void ApplyBuildConfiguration_ValidatesNullMonitoredContainer() { ChangesEstimationHandler estimationDelegate = (long estimation, CancellationToken token) => { return(Task.CompletedTask); }; ChangeFeedEstimatorCore estimator = ChangeFeedEstimatorCoreTests.CreateEstimator(estimationDelegate, out Mock <RemainingWorkEstimator> remainingWorkEstimator); estimator.ApplyBuildConfiguration( null, ChangeFeedEstimatorCoreTests.GetMockedContainer("leases"), "something", "instanceName", new ChangeFeedLeaseOptions(), new ChangeFeedProcessorOptions(), null); }
public void ApplyBuildConfiguration_ValidCustomStore() { ChangesEstimationHandler estimationDelegate = (long estimation, CancellationToken token) => { return(Task.CompletedTask); }; ChangeFeedEstimatorCore estimator = ChangeFeedEstimatorCoreTests.CreateEstimator(estimationDelegate, out Mock <RemainingWorkEstimator> remainingWorkEstimator); estimator.ApplyBuildConfiguration( Mock.Of <DocumentServiceLeaseStoreManager>(), null, "something", "instanceName", new ChangeFeedLeaseOptions(), new ChangeFeedProcessorOptions(), ChangeFeedEstimatorCoreTests.GetMockedContainer("monitored")); }
public async Task StartAsync_TriggersDelegate() { const long remainingWork = 15; long estimationDelegateValue = 0; bool receivedEstimation = false; ChangesEstimationHandler estimationDelegate = (long estimation, CancellationToken token) => { estimationDelegateValue = estimation; receivedEstimation = true; return(Task.CompletedTask); }; Mock <DocumentServiceLeaseStoreManager> leaseStoreManager = new Mock <DocumentServiceLeaseStoreManager>(); leaseStoreManager.Setup(l => l.LeaseContainer).Returns(Mock.Of <DocumentServiceLeaseContainer>); leaseStoreManager.Setup(l => l.LeaseManager).Returns(Mock.Of <DocumentServiceLeaseManager>); leaseStoreManager.Setup(l => l.LeaseStore).Returns(Mock.Of <DocumentServiceLeaseStore>); leaseStoreManager.Setup(l => l.LeaseCheckpointer).Returns(Mock.Of <DocumentServiceLeaseCheckpointer>); ChangeFeedEstimatorCore estimator = ChangeFeedEstimatorCoreTests.CreateEstimator(estimationDelegate, out Mock <RemainingWorkEstimator> remainingWorkEstimator); estimator.ApplyBuildConfiguration( leaseStoreManager.Object, null, "something", "instanceName", new ChangeFeedLeaseOptions(), new ChangeFeedProcessorOptions(), ChangeFeedEstimatorCoreTests.GetMockedContainer("monitored")); remainingWorkEstimator.Setup(r => r.GetEstimatedRemainingWorkAsync(It.IsAny <CancellationToken>())).ReturnsAsync(remainingWork); await estimator.StartAsync(); int waitIterations = 0; // Failsafe in case someone breaks the estimator so this does not run forever while (!receivedEstimation && waitIterations++ < 3) { Thread.Sleep(TimeSpan.FromSeconds(10)); } Assert.AreEqual(remainingWork, estimationDelegateValue); }
public override ChangeFeedProcessorBuilder GetChangeFeedEstimatorBuilder( string processorName, ChangesEstimationHandler estimationDelegate, TimeSpan?estimationPeriod = null) { if (processorName == null) { throw new ArgumentNullException(nameof(processorName)); } if (estimationDelegate == null) { throw new ArgumentNullException(nameof(estimationDelegate)); } ChangeFeedEstimatorCore changeFeedEstimatorCore = new ChangeFeedEstimatorCore(estimationDelegate, estimationPeriod); return(new ChangeFeedProcessorBuilder( processorName: processorName, container: this, changeFeedProcessor: changeFeedEstimatorCore, applyBuilderConfiguration: changeFeedEstimatorCore.ApplyBuildConfiguration)); }
public void NullDelegateThrows() { ChangesEstimationHandler changesEstimationHandler = null; ChangeFeedEstimatorRunnerTests.CreateEstimator(changesEstimationHandler, out Mock <ChangeFeedEstimator> _); }
private static ChangeFeedEstimatorCore CreateEstimator(ChangesEstimationHandler estimationDelegate, out Mock <RemainingWorkEstimator> remainingWorkEstimator) { remainingWorkEstimator = new Mock <RemainingWorkEstimator>(); return(new ChangeFeedEstimatorCore(estimationDelegate, TimeSpan.FromSeconds(5), remainingWorkEstimator.Object)); }
public override ChangeFeedProcessorBuilder GetChangeFeedEstimatorBuilder(string processorName, ChangesEstimationHandler estimationDelegate, TimeSpan?estimationPeriod = null) => throw new NotImplementedException();
public override ChangeFeedProcessorBuilder GetChangeFeedEstimatorBuilder(string processorName, ChangesEstimationHandler estimationDelegate, TimeSpan?estimationPeriod = null) { return(GetChangeFeedEstimatorBuilderReturnValue); }