public void RetrierUnitTest_FailIfThrottled() { var ctx = make_prr_ctx( 1, 10, null, new Amazon.Kinesis.Model.PutRecordsResponse() { FailedRecordCount = 1, Records = new List <Amazon.Kinesis.Model.PutRecordsResultEntry>() { new Amazon.Kinesis.Model.PutRecordsResultEntry() { ErrorCode = "ProvisionedThroughputExceededException", ErrorMessage = "..." } } }, DateTime.Now, DateTime.Now.AddMilliseconds(5) ); var config = new KPLNETInterface.KPLNETConfiguration(); config.failIfThrottled = true; int count = 0; Retrier retrier = new Retrier( config, (ur) => { count++; var attempts = ur.Attempts(); Assert.AreEqual(attempts.Count, 1); Assert.IsFalse(attempts[0].Success()); Assert.AreEqual(attempts[0].Error_code(), "ProvisionedThroughputExceededException"); Assert.AreEqual(attempts[0].Error_message(), "..."); }, (ur) => { Assert.Fail("Retry should not be called"); }, (dt) => { Assert.Fail("Shard map invalidate should not be called"); }); retrier.put(ctx); Assert.AreEqual(count, 10); }
public Aggregator make_aggregator(bool shard_map_down = false, FlushCallback cb = null, KPLNETInterface.KPLNETConfiguration config = null) { if (cb == null) { cb = (kr) => { } } ; if (config == null) { config = new KPLNETInterface.KPLNETConfiguration(); config.aggregationMaxCount = (ulong)kCountLimit; } return(new Aggregator(new IoServiceExecutor(4), new MockShardMap(shard_map_down), cb, config)); }
public void AggregatorUnitTest_AggregationDisabled() { var config = new KPLNETInterface.KPLNETConfiguration(); config.aggregationEnabled = false; var aggregator = make_aggregator(false, (kr) => { }, config); for (int i = 0; i < 100; i++) { var ur = TestUtil.make_user_record("pk", TestUtil.random_string(new Random().Next(100)), TestUtil.random_BigInt(new Random().Next(10)), 100000, "MyStream", 0); var kr = aggregator.put(ur); Assert.IsNotNull(kr); TestUtil.verify_unaggregated(ur, kr); } }
Limiter make_limiter(Callback cb, Callback expired_cb = null) { if (expired_cb == null) { expired_cb = (kr) => { } } ; var executor = new KPLNET.Utils.IoServiceExecutor(2); var config = new KPLNETInterface.KPLNETConfiguration(); config.rateLimit = 100; return(new Limiter( executor, cb, expired_cb, config)); }