コード例 #1
0
        public async Task QueryOnNumberProperty_Succeeded()
        {
            await FillAsync();

            var result = await _map.GetValuesAsync(Predicates.LessThan("age", 20));

            Assert.AreEqual(19, result.Count);
        }
コード例 #2
0
        private static async Task RunTask(IHazelcastClient client, CancellationToken token, int id, int entryCount, ILogger logger)
        {
            logger.LogInformation($"Thread {id}: start");

            IHMap <string, string> map = null;

            while (!token.IsCancellationRequested)
            {
                try
                {
                    map = await client.GetMapAsync <string, string>("soak1").ConfigureAwait(false);

                    break;
                }
                catch (Exception ex)
                {
                    logger.LogError($"Thread {id} failed to acquire the map ({ex.GetType().Name}: {ex.Message}), abort");
                    return;
                }
            }

            logger.LogInformation($"Thread {id}: acquired the map");

            while (!token.IsCancellationRequested)
            {
                try
                {
                    var key       = RandomProvider.Random.Next(0, entryCount).ToString();
                    var operation = RandomProvider.Random.Next(0, 100);
                    if (operation < 30)
                    {
                        await map.GetAsync(key).ConfigureAwait(false);
                    }
                    else if (operation < 60)
                    {
                        await map.PutAsync(key, RandomProvider.Random.Next().ToString()).ConfigureAwait(false);
                    }
                    else if (operation < 80)
                    {
                        await map.GetValuesAsync(Predicates.Value().IsBetween(0, 10)).ConfigureAwait(false);
                    }
                    else
                    {
                        await map.ExecuteAsync(new UpdateEntryProcessor(key), key).ConfigureAwait(false);
                    }

                    _reports[id] += 1;
                }
                catch (Exception ex)
                {
                    logger.LogError($"Thead {id} caught {ex.GetType().Name}: {ex.Message}");
                }
            }
        }