예제 #1
0
        static async Task Main(string[] args)
        {
            _ = new PerformanceCounterListener();

            IUdpBootstrap bootstrap = UdpFactory.Bootstrap();

            bootstrap.ConfigurationGlobalOptions(options => { });
            bootstrap.ConfigurationGlobalFilter((pipeline) =>
            {
                pipeline.Add(new UdpFilter_2());
            });
            await bootstrap.BuildAsync();

            IUdpChannel s_channel = await bootstrap.CreateChannelAsync();

            await s_channel.StartAsync(s_p);

            IUdpChannel c_channel = await bootstrap.CreateChannelAsync();

            await c_channel.StartAsync(c_p);

            int count = 0;

            byte[] com        = System.Text.Encoding.UTF8.GetBytes("send::::::::");
            byte[] countBytes = System.Text.Encoding.UTF8.GetBytes($"{count}___1");
            while (true)
            {
                string str = Console.ReadLine();
                if (str == "")
                {
                    for (int i = 0; i < 1000; i++)
                    {
                        M.session.Write(Program.s_p, com);
                        M.session.Write(Program.s_p, countBytes);
                        await M.session.FlushAsync();
                    }

                    count++;
                    //for (int i = 1; i <= 100; i++)
                    //{
                    //    for (int j = 1; j <= 5; j++)
                    //    {
                    //        string com = $"{count}____{i}______{j}";
                    //        var bytes = System.Text.Encoding.UTF8.GetBytes(com);
                    //        M.session.Write(Program.s_p, bytes);
                    //    }

                    //    await M.session.FlushAsync();
                    //}
                }
                else if (str == "c")
                {
                    await M.session.CloseAsync();
                }
                else if (str == "s")
                {
                    return;
                }
            }
        }
예제 #2
0
        public static ClusterBuilder UsePerformanceCounters(this ClusterBuilder configuration, string applicationName, bool install = false)
        {
            Ensure.IsNotNull(configuration, "configuration");

            if (install)
            {
                PerformanceCounterListener.Install();
            }

            return(configuration.AddListener(new PerformanceCounterListener(applicationName)));
        }
예제 #3
0
        /// <summary>
        /// Configures the cluster builder to use performance counters.
        /// </summary>
        /// <param name="builder">The cluster builder.</param>
        /// <param name="applicationName">The name of the application.</param>
        /// <param name="install">if set to <c>true</c> install the performance counters first.</param>
        /// <returns>A reconfigured cluster builder.</returns>
        public static ClusterBuilder UsePerformanceCounters(this ClusterBuilder builder, string applicationName, bool install = false)
        {
            Ensure.IsNotNull(builder, "builder");

            if (install)
            {
                PerformanceCounterListener.InstallPerformanceCounters();
            }

            return(builder.AddListener(new PerformanceCounterListener(applicationName)));
        }