master moved from bdd858219b0c to b7b01f7b39c7

2 new revisions:

Revision: 037948c75dde
Author:   Sergey Vetyutnev <[email protected]>
Date:     Fri Sep 13 15:48:26 2013 UTC
Log:      Updating statistics project for TCAP statistic
http://code.google.com/p/jss7/source/detail?r=037948c75dde

Revision: b7b01f7b39c7
Author:   Sergey Vetyutnev <[email protected]>
Date:     Fri Sep 13 15:54:21 2013 UTC
Log:      Merge remote-tracking branch 'origin/cap44'
http://code.google.com/p/jss7/source/detail?r=b7b01f7b39c7

==============================================================================
Revision: 037948c75dde
Author:   Sergey Vetyutnev <[email protected]>
Date:     Fri Sep 13 15:48:26 2013 UTC
Log:      Updating statistics project for TCAP statistic
http://code.google.com/p/jss7/source/detail?r=037948c75dde

Modified:
/statistics/src/main/java/org/mobicents/protocols/ss7/statistics/StatCounterCollectionImpl.java /statistics/src/main/java/org/mobicents/protocols/ss7/statistics/StatDataCollection.java /statistics/src/main/java/org/mobicents/protocols/ss7/statistics/StatDataCollectorLongImpl.java /statistics/src/main/java/org/mobicents/protocols/ss7/statistics/StringLongMap.java

=======================================
--- /statistics/src/main/java/org/mobicents/protocols/ss7/statistics/StatCounterCollectionImpl.java Fri Sep 6 13:37:29 2013 UTC +++ /statistics/src/main/java/org/mobicents/protocols/ss7/statistics/StatCounterCollectionImpl.java Fri Sep 13 15:48:26 2013 UTC
@@ -50,54 +50,66 @@

     @Override
     public void clearDeadCampaignes(Date lastTime) {
-        ArrayList<String> toDel = new ArrayList<String>();
-        for (String s : coll.keySet()) {
-            StatDataCollectorAbstractImpl d = coll.get(s);
-            if (d.getSessionStartTime().before(lastTime)) {
-                toDel.add(s);
+        synchronized (this) {
+            ArrayList<String> toDel = new ArrayList<String>();
+            for (String s : coll.keySet()) {
+                StatDataCollectorAbstractImpl d = coll.get(s);
+                if (d.getSessionStartTime().before(lastTime)) {
+                    toDel.add(s);
+                }
+            }
+            for (String s : toDel) {
+                coll.remove(s);
             }
         }
-        for (String s : toDel) {
-            coll.remove(s);
-        }
     }

     @Override
     public StatResult restartAndGet(String campaignName) {
-        StatDataCollectorAbstractImpl sdc = coll.get(campaignName);
-        if (sdc != null) {
-            return sdc.restartAndGet();
-        } else {
-            switch (type) {
-            case MIN:
-                sdc = new StatDataCollectorMin(campaignName);
-                break;
-            case MAX:
-                sdc = new StatDataCollectorMax(campaignName);
-                break;
-            }
+        synchronized (this) {
+            StatDataCollectorAbstractImpl sdc = coll.get(campaignName);
             if (sdc != null) {
-                coll.put(campaignName, sdc);
-//                if (newVal != null)
-//                    sdc.updateData(newVal);
+                return sdc.restartAndGet();
+            } else {
+                switch (type) {
+                case MIN:
+                    sdc = new StatDataCollectorMin(campaignName);
+                    sdc.reset();
+                    break;
+                case MAX:
+                    sdc = new StatDataCollectorMax(campaignName);
+                    sdc.reset();
+                    break;
+                case StringLongMap:
+                    sdc = new StringLongMap(campaignName);
+                    sdc.reset();
+                    break;
+                }
+                if (sdc != null) {
+                    coll.put(campaignName, sdc);
+                }
+                return null;
             }
-            return null;
         }
     }

     @Override
     public void updateData(long newVal) {
-        for (String s : coll.keySet()) {
-            StatDataCollectorAbstractImpl d = coll.get(s);
-            d.updateData(newVal);
+        synchronized (this) {
+            for (String s : coll.keySet()) {
+                StatDataCollectorAbstractImpl d = coll.get(s);
+                d.updateData(newVal);
+            }
         }
     }

     @Override
     public void updateData(String newVal) {
-        for (String s : coll.keySet()) {
-            StatDataCollectorAbstractImpl d = coll.get(s);
-            d.updateData(newVal);
+        synchronized (this) {
+            for (String s : coll.keySet()) {
+                StatDataCollectorAbstractImpl d = coll.get(s);
+                d.updateData(newVal);
+            }
         }
     }

=======================================
--- /statistics/src/main/java/org/mobicents/protocols/ss7/statistics/StatDataCollection.java Fri Sep 6 13:37:29 2013 UTC +++ /statistics/src/main/java/org/mobicents/protocols/ss7/statistics/StatDataCollection.java Fri Sep 13 15:48:26 2013 UTC
@@ -45,6 +45,20 @@
             return c;
         }
     }
+
+ public StatCounterCollection unregisterStatCounterCollector(String counterName) {
+        synchronized (this) {
+            StatCounterCollection c = coll.remove(counterName);
+            return c;
+        }
+    }
+
+ public StatCounterCollection getStatCounterCollector(String counterName) {
+        synchronized (this) {
+            StatCounterCollection c = coll.get(counterName);
+            return c;
+        }
+    }

     public void clearDeadCampaignes(Date lastTime) {
         synchronized (this) {
@@ -56,31 +70,34 @@
     }

public StatResult restartAndGet(String counterName, String campaignName) {
+        StatCounterCollection scc;
         synchronized (this) {
-            StatCounterCollection scc = this.coll.get(counterName);
-            if (scc != null) {
-                return scc.restartAndGet(campaignName);
-            } else {
-                return null;
-            }
+            scc = this.coll.get(counterName);
+        }
+        if (scc != null) {
+            return scc.restartAndGet(campaignName);
+        } else {
+            return null;
         }
     }

     public void updateData(String counterName, long newVal) {
+        StatCounterCollection scc;
         synchronized (this) {
-            StatCounterCollection scc = this.coll.get(counterName);
-            if (scc != null) {
-                scc.updateData(newVal);
-            }
+            scc = this.coll.get(counterName);
+        }
+        if (scc != null) {
+            scc.updateData(newVal);
         }
     }

     public void updateData(String counterName, String newVal) {
+        StatCounterCollection scc;
         synchronized (this) {
-            StatCounterCollection scc = this.coll.get(counterName);
-            if (scc != null) {
-                scc.updateData(newVal);
-            }
+            scc = this.coll.get(counterName);
+        }
+        if (scc != null) {
+            scc.updateData(newVal);
         }
     }
 }
=======================================
--- /statistics/src/main/java/org/mobicents/protocols/ss7/statistics/StatDataCollectorLongImpl.java Fri Sep 6 13:37:29 2013 UTC +++ /statistics/src/main/java/org/mobicents/protocols/ss7/statistics/StatDataCollectorLongImpl.java Fri Sep 13 15:48:26 2013 UTC
@@ -42,6 +42,7 @@
     public StatResult restartAndGet() {
         StatResultLong res = new StatResultLong(val);
         this.sessionStartTime = new Date();
+        this.reset();
         return res;
     }

=======================================
--- /statistics/src/main/java/org/mobicents/protocols/ss7/statistics/StringLongMap.java Fri Sep 6 13:37:29 2013 UTC +++ /statistics/src/main/java/org/mobicents/protocols/ss7/statistics/StringLongMap.java Fri Sep 13 15:48:26 2013 UTC
@@ -41,6 +41,7 @@
         synchronized (this) {
StatResultStringLongMap res = new StatResultStringLongMap(this.data);
             this.data = new FastMap<String, LongValue>();
+            this.reset();
             return res;
         }
     }

==============================================================================
Revision: b7b01f7b39c7
Author:   Sergey Vetyutnev <[email protected]>
Date:     Fri Sep 13 15:54:21 2013 UTC
Log:      Merge remote-tracking branch 'origin/cap44'
http://code.google.com/p/jss7/source/detail?r=b7b01f7b39c7


--

--- You received this message because you are subscribed to the Google Groups "mobicents-commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to