示例#1
0
文件: BrokerHost.cs 项目: pepipe/ISEL
        private static void CheckKVSLoad(BrokerService brokerService)
        {
            List<String> servers = brokerService.GetKVSList();
            KVSClient kvs;

            if (servers.Count == 0)
            {
                Console.WriteLine("There aren't any KVS servers register in Broker.");
                return;
            }

            int i = 0;
            foreach(String address in servers)
            {
                kvs = new KVSClient("KVSService", address);
                try
                {
                    Console.WriteLine("Server {0} has {1} pairs.", i, kvs.GetTotalPairsStored());
                }catch(EndpointNotFoundException)
                {
                    Console.WriteLine("Problem with the KVS: {0}. Removing it from server list.", address);
                    brokerService.DeregisterServer(address);
                }

                ++i;
            }
        }
示例#2
0
文件: BrokerHost.cs 项目: pepipe/ISEL
 private static void CheckClients(BrokerService brokerService)
 {
     Console.WriteLine("Server has {0} clients",brokerService.Users.Count);
     Console.WriteLine("The clients are:");
     foreach(string client in brokerService.Users)
     {
         Console.WriteLine("Name: {0}", client);
     }
 }
示例#3
0
文件: BrokerHost.cs 项目: pepipe/ISEL
        private static void RunMenu(BrokerService brokerService)
        {
            Console.WriteLine();

            int option = -1;
            do
            {
                Console.WriteLine("[ 1 ] Check how many KVS are register");
                Console.WriteLine("[ 2 ] Check KVS server load");
                Console.WriteLine("[ 3 ] Check clients name");
                Console.WriteLine("[ 0 ] Close Broker");
                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:
                        CheckKVSCount(brokerService);
                        break;
                    case 2:
                        CheckKVSLoad(brokerService);
                        break;
                    case 3:
                        CheckClients(brokerService);
                        break;
                    case 0:
                        ExitBroker();
                        break;

                    default:
                        Console.WriteLine("Please choose one of the options");
                        break;
                }
                Console.ReadKey();
                Console.Clear();
            }
            while (option != 0);
        }
示例#4
0
文件: BrokerHost.cs 项目: pepipe/ISEL
 private static void CheckKVSCount(BrokerService brokerService)
 {
     Console.WriteLine("KVS registered: " + brokerService.CountKVS());
 }
示例#5
0
文件: BrokerHost.cs 项目: pepipe/ISEL
        private static BrokerService StartBroker()
        {
            BrokerService brokerService = new BrokerService();
            //ServiceHost host = new ServiceHost(typeof(BrokerService));
            ServiceHost host = new ServiceHost(brokerService);

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

            return brokerService;
        }