当前位置: 首页>>代码示例>>C#>>正文


C# CommandProcessorContext.Completed方法代码示例

本文整理汇总了C#中CommandProcessorContext.Completed方法的典型用法代码示例。如果您正苦于以下问题:C# CommandProcessorContext.Completed方法的具体用法?C# CommandProcessorContext.Completed怎么用?C# CommandProcessorContext.Completed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommandProcessorContext的用法示例。


在下文中一共展示了CommandProcessorContext.Completed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public bool Execute(CommandProcessorContext context, string[] args)
        {
            var fromOffset = 0;
            int maxRecordCount = int.MaxValue;

            if (args.Length > 0)
            {
                if (args.Length > 2)
                {
                    context.Log.Info("More arguments: {0}", args.Length);
                    return false;
                }

                int.TryParse(args[0], out fromOffset);
                if (args.Length > 1)
                    int.TryParse(args[1], out maxRecordCount);
            }

            context.IsAsync();

            var result = _reader.ReadAll(fromOffset, maxRecordCount);
            var dataRecords = result as DataRecord[] ?? result.ToArray();
            context.Log.Info("Read {0} records{1}", dataRecords.Length, dataRecords.Length > 0 ? ":" : ".");
            foreach (var record in dataRecords)
            {
                context.Log.Info("  stream-id: {0}, data: {0}", record.Key, Encoding.UTF8.GetString(record.Data));
            }

            var nextOffset = dataRecords.Length > 0 ? dataRecords.Last().NextOffset : 0;
            context.Log.Info("Next stream offset: {0}", nextOffset);

            context.Completed();
            return true;
        }
开发者ID:AigizK,项目名称:lokad-data-platform,代码行数:34,代码来源:ReadProcessor.cs

示例2: Execute

        public bool Execute(CommandProcessorContext context, string[] args)
        {
            var eventStreamId = "default stream";
            var expectedVersion = -1;
            var data = "default-data";

            if (args.Length > 0)
            {
                if (args.Length != 3)
                {
                    context.Log.Info("More arguments: {0}",args.Length);
                    return false;
                }

                eventStreamId = args[0];
                int.TryParse(args[1], out expectedVersion);
                data = args[2];
            }

            context.IsAsync();

            context.Client.JsonClient.Post<ClientDto.WriteEvent>("/stream", new ClientDto.WriteEvent()
            {
                Data = Encoding.UTF8.GetBytes(data),
                Stream = eventStreamId,
                ExpectedVersion = expectedVersion
            });

            context.Completed();
            return true;
        }
开发者ID:AigizK,项目名称:lokad-data-platform,代码行数:31,代码来源:WriteProccessor.cs

示例3: Execute

        public bool Execute(CommandProcessorContext context, string[] args)
        {
            context.IsAsync();

            long total = 0;
            int count = 0;

            var threads = new List<Task>();

            int threadCount = 5;
            var size = 1000;

            if (args.Length > 0)
                int.TryParse(args[0], out threadCount);
            if (args.Length > 1)
                int.TryParse(args[1], out size);

            var global = Stopwatch.StartNew();
            for (int t = 0; t < threadCount; t++)
            {

                var task = Task.Factory.StartNew(() =>
                    {
                        var watch = Stopwatch.StartNew();
                        for (int i = 0; i < size; i++)
                        {
                            context.Client.JsonClient.Post<ClientDto.WriteEvent>("/stream", new ClientDto.WriteEvent()
                                {
                                    Data = Encoding.UTF8.GetBytes("This is some test message to load the server"),
                                    Stream = "name",
                                    ExpectedVersion = -1
                                });

                            //client.Get<ClientDto.WriteEvent>("/stream/name");
                        }

                        Interlocked.Add(ref total, watch.Elapsed.Ticks);
                        Interlocked.Add(ref count, size);

                    }, TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness);
                threads.Add(task);
            }
            Task.WaitAll(threads.ToArray());
            context.Completed();
            context.Log.Info("{0} per second", count / global.Elapsed.TotalSeconds);
            PerfUtils.LogTeamCityGraphData(string.Format("{0}-latency-ms", Key), (int)(count / global.Elapsed.TotalSeconds));
            return true;
        }
开发者ID:AigizK,项目名称:lokad-data-platform,代码行数:48,代码来源:WriteEventsFloodProcessor.cs


注:本文中的CommandProcessorContext.Completed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。