예제 #1
0
        public async Task <double> RunMainAsync()
        {
            Thread.Sleep(5000);
            var clt = new ClientStartup();

            using (var client = await clt.StartClientWithRetries())
            {
                var rand = new Random(DateTime.Now.Millisecond);

                // var addStatisticsGrain = client.AddStatisticsGrain<Student>();
                var grainsExecutivePool = new GrainsExecutivePool(client, 1);

                await grainsExecutivePool.LoadAssembly(typeof(RemoteExecutionTest));

                var context = new GenericGrainsContext();
                context.SetValue("Add", 1000);

                for (int i = 0; i < 30000; ++i)
                {
                    var ret = await grainsExecutivePool.ExecuteWithContext <decimal>(nameof(RemoteExecutionTest),
                                                                                     nameof(RemoteTestClass.RemoteExecutionTest.PowN), context, (decimal)3, (decimal)i);

                    Console.WriteLine($"RET: {ret}");
                }

                Console.ReadKey();

                return(0);
            }
        }
예제 #2
0
        public async Task <int> RunMainAsync()
        {
            try
            {
//#if DEBUG
//                Thread.Sleep(10000);
//#endif
                var clt = new ClientStartup();
                using (var client = await clt.StartClientWithRetries())
                {
                    var rand = new Random(DateTime.Now.Millisecond);

                    // var addStatisticsGrain = client.AddStatisticsGrain<Student>();
                    var addStatisticsGrainPool = new GrainsManageStatisticsPool <Student>(client, 150);
                    var cleanCount             = await addStatisticsGrainPool.Clean();

                    Console.WriteLine($"DEL RESULT: {cleanCount}");

                    Console.ReadKey();

                    for (int i = 0; i < 1000000; ++i)
                    {
                        var stud = new Student()
                        {
                            Name      = "Ivan",
                            Surname   = "Petrov",
                            Birthdate = DateTime.UtcNow.AddYears(-18 - rand.Next() % 15)
                        };

                        await addStatisticsGrainPool.Put(stud);

                        // Console.WriteLine($"student: {JsonConvert.SerializeObject(stud)}");
                    }

                    Console.WriteLine("Data was added... Getting statistics...");
                    //var getStatisticsGrain = client.GetStatisticsGrain<Student>();
                    var getStatisticsGrainPool = new GrainsGetStatisticsPool <Student>(client, 30);
                    var stat = await getStatisticsGrainPool.Get(t => t.Birthdate.Date.Year == 2000);

                    Console.WriteLine($"Data result : {stat.Count} students were born in 2000!");
                    Console.WriteLine($"======================================================");
                    Console.ReadKey();
                }

                return(0);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.ReadKey();
                return(1);
            }
        }