示例#1
0
文件: KVSHost.cs 项目: pepipe/ISEL
        private static void RunMenu(KVSService kvsService)
        {
            Console.WriteLine();

            int option = -1;
            do
            {
                Console.WriteLine("[ 1 ] Check server load");
                Console.WriteLine("[ 0 ] Close KVS server");
                Console.WriteLine("-------------------------------------");
                Console.Write("Enter an option: ");

                try
                {
                    option = Int32.Parse(Console.ReadLine());
                }
                catch (Exception)
                {
                    Console.WriteLine("Please choose one of the options");
                    continue;
                }

                switch (option)
                {
                    case 1:
                        CheckLoad(kvsService);
                        break;

                    case 0:
                        ExitKVS();
                        break;

                    default:
                        Console.WriteLine("Please choose one of the options");
                        break;
                }
                Console.ReadKey();
                Console.Clear();
            }
            while (option != 0);
        }
示例#2
0
文件: KVSHost.cs 项目: pepipe/ISEL
 private static void CheckLoad(KVSService kvsService)
 {
     Console.WriteLine("This server has {0} pairs stored.", kvsService.GetTotalPairsStored());
 }
示例#3
0
文件: KVSHost.cs 项目: pepipe/ISEL
        private static KVSService StartKVS()
        {
            KVSService kvsService = new KVSService();
            ServiceHost host = new ServiceHost(kvsService);
            //ServiceHost host = new ServiceHost(typeof(KVSService));

            Console.WriteLine("Starting KVS server...\n");
            host.Open();
            DumpEndpoint(host.Description.Endpoints);
            Console.WriteLine("KVS started!\n");

            ServiceEndpoint se = host.Description.Endpoints.First<ServiceEndpoint>();
            m_KvsAddress = se.Address.ToString();

            try
            {
                RegisterOnBroker(m_KvsAddress);
            }catch(EndpointNotFoundException e)
            {
                Console.WriteLine("Broker is not initialized.");
                Console.WriteLine(e.Message);
            }

            return kvsService;
        }