예제 #1
0
        private static void Run(IConfigurationRoot config)
        {
            var protocol = config["protocol"] ?? string.Empty;

            if (!protocol.Equals("h2c", StringComparison.OrdinalIgnoreCase))
            {
                throw new InvalidOperationException("Only h2c is supported by C-core benchmark server.");
            }

            var address = config.CreateBindingAddress();

            Console.WriteLine($"Starting C-core server listening on {address.Host}:{address.Port}");

            Server server = new Server
            {
                Services =
                {
                    BenchmarkService.BindService(new BenchmarkServiceImpl())
                },
                Ports =
                {
                    // C-core benchmarks currently only support insecure (h2c)
                    { address.Host, address.Port, ServerCredentials.Insecure }
                }
            };

            server.Start();

            Console.WriteLine("Started!");
            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
        }
예제 #2
0
        /// <summary>
        /// Creates a started server runner.
        /// </summary>
        public static IServerRunner CreateStarted(ServerConfig config)
        {
            Grpc.Core.Utils.Preconditions.CheckArgument(config.ServerType == ServerType.ASYNC_SERVER);
            var credentials = config.SecurityParams != null?TestCredentials.CreateSslServerCredentials() : ServerCredentials.Insecure;

            // TODO: qps_driver needs to setup payload properly...
            int responseSize = config.PayloadConfig != null ? config.PayloadConfig.SimpleParams.RespSize : 0;
            var server       = new Server
            {
                Services = { BenchmarkService.BindService(new BenchmarkServiceImpl(responseSize)) },
                Ports    = { new ServerPort(config.Host, config.Port, credentials) }
            };

            server.Start();
            return(new ServerRunnerImpl(server));
        }
예제 #3
0
        /// <summary>
        /// Creates a started server runner.
        /// </summary>
        public static IServerRunner CreateStarted(ServerConfig config)
        {
            Logger.Debug("ServerConfig: {0}", config);
            var credentials = config.SecurityParams != null?TestCredentials.CreateSslServerCredentials() : ServerCredentials.Insecure;

            if (config.AsyncServerThreads != 0)
            {
                Logger.Warning("ServerConfig.AsyncServerThreads is not supported for C#. Ignoring the value");
            }
            if (config.CoreLimit != 0)
            {
                Logger.Warning("ServerConfig.CoreLimit is not supported for C#. Ignoring the value");
            }
            if (config.CoreList.Count > 0)
            {
                Logger.Warning("ServerConfig.CoreList is not supported for C#. Ignoring the value");
            }

            ServerServiceDefinition service = null;

            if (config.ServerType == ServerType.AsyncServer)
            {
                GrpcPreconditions.CheckArgument(config.PayloadConfig == null,
                                                "ServerConfig.PayloadConfig shouldn't be set for BenchmarkService based server.");
                service = BenchmarkService.BindService(new BenchmarkServiceImpl());
            }
            else if (config.ServerType == ServerType.AsyncGenericServer)
            {
                var genericService = new GenericServiceImpl(config.PayloadConfig.BytebufParams.RespSize);
                service = GenericService.BindHandler(genericService.StreamingCall);
            }
            else
            {
                throw new ArgumentException("Unsupported ServerType");
            }

            var channelOptions = new List <ChannelOption>(config.ChannelArgs.Select((arg) => arg.ToChannelOption()));
            var server         = new Server(channelOptions)
            {
                Services = { service },
                Ports    = { new ServerPort("[::]", config.Port, credentials) }
            };

            server.Start();
            return(new ServerRunnerImpl(server));
        }
예제 #4
0
        public static void Main(string[] args)
        {
            var config = new ConfigurationBuilder()
                         .AddJsonFile("hosting.json", optional: true)
                         .AddEnvironmentVariables(prefix: "ASPNETCORE_")
                         .AddCommandLine(args)
                         .Build();

            var protocol = config["protocol"] ?? string.Empty;

            if (!protocol.Equals("h2c", StringComparison.OrdinalIgnoreCase))
            {
                throw new InvalidOperationException("Only h2c is supported by C-core benchmark server.");
            }

            var endpoint = config.CreateIPEndPoint();
            var host     = endpoint.Address.ToString();

            Console.WriteLine($"Starting C-core server listening on {host}:{endpoint.Port}");

            Server server = new Server
            {
                Services =
                {
                    BenchmarkService.BindService(new BenchmarkServiceImpl())
                },
                Ports =
                {
                    // C-core benchmarks currently only support insecure (h2c)
                    { host, endpoint.Port, ServerCredentials.Insecure }
                }
            };

            server.Start();

            Console.WriteLine("Started!");
            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
        }