Пример #1
0
 static void Main(string[] args)
 {
     HttpClusterApi.AddHost("*", Host25, Host29);
     HttpClusterApi.GetUrlNode("employee.*").Add(Host26).Add(Host27).Add(Host30, 0);
     HttpClusterApi.AddHost("customer.*", Host28, Host29);
     HttpClusterApi.AddHost("orders.*", Host25, Host29);
     DataService = HttpClusterApi.Create <IDataService>();
     for (int i = 0; i < 10; i++)
     {
         OnTest();
     }
     while (true)
     {
         System.Threading.Thread.Sleep(1000);
         Console.Write(HttpClusterApi.Stats());
     }
 }
Пример #2
0
 public void LoadStatus(Url[] urls, Url url)
 {
     if (!mInLoadStatus)
     {
         mInLoadStatus = true;
         try
         {
             if (httpClusterApi == null)
             {
                 httpClusterApi = new BeetleX.FastHttpApi.Clients.HttpClusterApi();
                 httpClusterApi.AddHost("*", Name);
                 serverStatus = httpClusterApi.Create <IServerStatus>();
             }
             var result = serverStatus.Get();
             result.Name = this.Name;
             Cpu         = result.Cpu;
             Memory      = result.Memory / 1024;
             long total = 0, per = 0;
             if (url.Name == "*")
             {
                 foreach (var item in result.Actions)
                 {
                     bool match = false;
                     foreach (var u in urls)
                     {
                         if (u == url)
                         {
                             continue;
                         }
                         if (Regex.IsMatch(item.Url, u.Name, RegexOptions.IgnoreCase))
                         {
                             match = true;
                             break;
                         }
                     }
                     if (!match)
                     {
                         total += item.Requests;
                         per   += item.RequestsPer;
                     }
                 }
             }
             else
             {
                 foreach (var item in result.Actions)
                 {
                     if (Regex.IsMatch(item.Url, url.Name, RegexOptions.IgnoreCase))
                     {
                         total += item.Requests;
                         per   += item.RequestsPer;
                     }
                 }
             }
             TotalRequest = total;
             RequestPer   = per;
             Status       = result;
         }
         catch (Exception e_)
         {
             LoadStatusError = e_;
         }
         finally
         {
             mInLoadStatus = false;
         }
     }
 }