Beispiel #1
0
 getServerConnectionMetrics(IceMX.MetricsAdminPrx metrics, long expected)
 {
     try
     {
         IceMX.ConnectionMetrics s;
         long timestamp;
         s = (IceMX.ConnectionMetrics)metrics.getMetricsView("View", out timestamp)["Connection"][0];
         int nRetry = 30;
         while(s.sentBytes != expected && nRetry-- > 0)
         {
             // On some platforms, it's necessary to wait a little before obtaining the server metrics
             // to get an accurate sentBytes metric. The sentBytes metric is updated before the response
             // to the operation is sent and getMetricsView can be dispatched before the metric is really
             // updated.
             System.Threading.Thread.Sleep(100);
             s = (IceMX.ConnectionMetrics)metrics.getMetricsView("View", out timestamp)["Connection"][0];
         }
         return s;
     }
     catch(IceMX.UnknownMetricsView)
     {
         Debug.Assert(false);
         return null;
     }
 }
Beispiel #2
0
    testAttribute(IceMX.MetricsAdminPrx metrics, 
                  Ice.PropertiesAdminPrx props, 
                  UpdateCallbackI update,
                  string map, 
                  string attr,
                  string value,
#if COMPACT
                  Ice.VoidAction func)
Beispiel #3
0
 waitForCurrent(IceMX.MetricsAdminPrx metrics, string viewName, string map, int value)
 {
     while(true)
     {
         long timestamp;
         Dictionary<string, IceMX.Metrics[]> view = metrics.getMetricsView(viewName, out timestamp);
         test(view.ContainsKey(map));
         bool ok = true;
         foreach(IceMX.Metrics m in view[map])
         {
             if(m.current != value)
             {
                 ok = false;
                 break;
             }
         }
         if(ok)
         {
             break;
         }
         System.Threading.Thread.Sleep(50);
     }
 }
Beispiel #4
0
 static void checkFailure(IceMX.MetricsAdminPrx m, string map, string id, string failure, int count)
 {
     IceMX.MetricsFailures f = m.getMetricsFailures("View", map, id);
     if(!f.failures.ContainsKey(failure))
     {
         WriteLine("couldn't find failure `" + failure + "' for `" + id + "'");
         test(false);
     }
     if(count > 0 && f.failures[failure] != count)
     {
         Write("count for failure `" + failure + "' of `" + id + "' is different from expected: ");
         WriteLine(count + " != " + f.failures[failure]);
         test(false);
     }
 }
Beispiel #5
0
 static Dictionary<string, IceMX.Metrics> toMap(IceMX.Metrics[] mmap)
 {
     Dictionary<string, IceMX.Metrics> m = new Dictionary<string, IceMX.Metrics>();
     foreach(IceMX.Metrics e in mmap)
     {
         m.Add(e.id, e);
     }
     return m;
 }
Beispiel #6
0
 static void testAttribute(IceMX.MetricsAdminPrx metrics,
               Ice.PropertiesAdminPrx props,
               UpdateCallbackI update,
               string map,
               string attr,
               string value)
 {
     testAttribute(metrics, props, update, map, attr, value, ()=> {});
 }
Beispiel #7
0
    static void testAttribute(IceMX.MetricsAdminPrx metrics,
                  Ice.PropertiesAdminPrx props,
                  UpdateCallbackI update,
                  string map,
                  string attr,
                  string value,
                  System.Action func)
    {
        Dictionary<string, string> dict = new Dictionary<string, string>();
        dict.Add("IceMX.Metrics.View.Map." + map + ".GroupBy", attr);
        if(props.ice_getIdentity().category.Equals("client"))
        {
            props.setProperties(getClientProps(props, dict, map));
            update.waitForUpdate();
        }
        else
        {
            props.setProperties(getServerProps(props, dict, map));
            props.setProperties(new Dictionary<string, string>());
        }

        func();
        long timestamp;
        Dictionary<string, IceMX.Metrics[]> view = metrics.getMetricsView("View", out timestamp);
        if(!view.ContainsKey(map) || view[map].Length == 0)
        {
            if(value.Length > 0)
            {
                WriteLine("no map `" + map + "' for group by = `" + attr + "'");
                test(false);
            }
        }
        else if(!view[map][0].id.Equals(value))
        {
            WriteLine("invalid attribute value: " + attr + " = " + value + " got " + view[map][0].id);
            test(false);
        }

        dict.Clear();
        if(props.ice_getIdentity().category.Equals("client"))
        {
            props.setProperties(getClientProps(props, dict, map));
            update.waitForUpdate();
        }
        else
        {
            props.setProperties(getServerProps(props, dict, map));
            props.setProperties(new Dictionary<string, string>());
        }
    }