private async Task SetTask(IHDictionary <string, string> dictionary, SemaphoreSlim started, int id) { var i = 0; while (!_stop) { i++; // put new value and update last state // note: the value in the map/Near Cache is *always* larger or equal to valuePut // assertion: valueMap >= valuePut await dictionary.SetAsync(Key, i.ToString()).CAF(); _valuePut = i; // ensure we have a value if (i == 1) { started.Release(); } // check if we see our last update var valueStr = await dictionary.GetAsync(Key).CAF(); if (valueStr == null) { continue; // ignore nulls (?) } var valueInt = int.Parse(valueStr); if (valueInt == i) { continue; // match = ok } _assertionViolationCount++; Logger.LogWarning($"Err: set {i} but got {valueInt}."); // maybe it needs a bit of time? await Task.Delay(200).CAF(); // test again and stop if really lost valueStr = await dictionary.GetAsync(Key).CAF(); valueInt = int.Parse(valueStr); if (valueInt == i) { continue; // fixed } Logger.LogWarning($"Err: still getting {valueInt} instead of {i}."); // maybe it needs a lot of time? // in non-strict, we'll give it plenty // abort all _stop = true; } Logger.LogInformation($"AddOrUpdate task {id} performed {i} operations."); }
public async Task GetJsonValue_Succeeded() { var value = new HazelcastJsonValue("{ \"age\": 20 }"); await _dictionary.SetAsync("key-1", value); var result = await _dictionary.GetAsync("key-1"); Assert.AreEqual(value, result); }
private async Task GetTask(IHDictionary <string, string> dictionary, int id) { var n = 0; while (!_stop) { n++; // get the value var valueStr = await dictionary.GetAsync(Key).CAF(); // that should never happen! Assert.That(valueStr, Is.Not.Null); // parse the value (to get some CPU load) var valueInt = int.Parse(valueStr); Assert.AreEqual(valueInt.ToString(), valueStr); // slow down await Task.Delay(100).CAF(); } Logger.LogInformation($"Get task {id} performed {n} operations."); }
public async Task Setup() { _dictionary = await Client.GetDictionaryAsync <object, object>(CreateUniqueName()); _ = await _dictionary.GetAsync(new object()); }