[vlma-devel] commit: Following of 500955f6486a12cc404f6af1281f5cbcf72ade84. ( Adrien Grand )

git version control git at videolan.org
Wed Oct 29 22:25:26 CET 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Wed Oct 29 22:25:04 2008 +0100| [0dcdba752bd883676d65e5e77785f7f19311f021] | committer: Adrien Grand 

Following of 500955f6486a12cc404f6af1281f5cbcf72ade84.

> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=0dcdba752bd883676d65e5e77785f7f19311f021
---

 .../java/org/videolan/vlma/VLMaServiceImpl.java    |    3 ---
 .../videolan/vlma/retriever/HttpDataRetriever.java |    6 +++++-
 .../videolan/vlma/retriever/SnmpDataRetriever.java |   16 ++++++++++++++--
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/vlma-core/src/main/java/org/videolan/vlma/VLMaServiceImpl.java b/vlma-core/src/main/java/org/videolan/vlma/VLMaServiceImpl.java
index 5cf538b..720aad1 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/VLMaServiceImpl.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/VLMaServiceImpl.java
@@ -219,9 +219,6 @@ public class VLMaServiceImpl implements VLMaService {
             Data data = entry.getKey();
             Object value = entry.getValue();
 
-            if(value == null) {
-                value = 0;
-            }
             try {
                 if(Data.TRAFFIC_IN.equals(data) || Data.TRAFFIC_OUT.equals(data)) {
                     sample.setValue(data.name().toLowerCase(), (Long)value);
diff --git a/vlma-core/src/main/java/org/videolan/vlma/retriever/HttpDataRetriever.java b/vlma-core/src/main/java/org/videolan/vlma/retriever/HttpDataRetriever.java
index 2d9ae67..528aaec 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/retriever/HttpDataRetriever.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/retriever/HttpDataRetriever.java
@@ -39,7 +39,11 @@ public class HttpDataRetriever implements DataRetriever {
     public Map<Data, Object> retrieve(Server server) {
         Map<Data, Object> result = new HashMap<Data, Object>();
         for(Data data : Data.values()) {
-            result.put(data, 0);
+            if(Data.TRAFFIC_IN.equals(data) || Data.TRAFFIC_OUT.equals(data)) {
+                result.put(data, 0L);
+            } else {
+                result.put(data, 0d);
+            }
         }
         try {
             URL url = new URL("http://" + server.getIp().getHostName() + ":"
diff --git a/vlma-core/src/main/java/org/videolan/vlma/retriever/SnmpDataRetriever.java b/vlma-core/src/main/java/org/videolan/vlma/retriever/SnmpDataRetriever.java
index 0e40eaa..871d233 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/retriever/SnmpDataRetriever.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/retriever/SnmpDataRetriever.java
@@ -46,11 +46,23 @@ public class SnmpDataRetriever implements DataRetriever {
     public Map<Data, Object> retrieve(Server server) {
         Map<Data, Object> result = new HashMap<Data, Object>();
         for(Data data : Data.values()) {
+            Object value;
             try {
-                result.put(data, get(server, data));
+                String stringValue = get(server, data);
+                if(Data.TRAFFIC_IN.equals(data) || Data.TRAFFIC_OUT.equals(data)) {
+                    value = Long.parseLong(stringValue);
+                } else {
+                    value = Double.parseDouble(stringValue);
+                }
+                result.put(data, value);
             } catch(Exception e) {
-                result.put(data, 0);
+                if(Data.TRAFFIC_IN.equals(data) || Data.TRAFFIC_OUT.equals(data)) {
+                    value = 0L;
+                } else {
+                    value = 0d;
+                }
             }
+            result.put(data, value);
         }
         return result;
     }



More information about the vlma-devel mailing list