chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r1042253 - /incubator/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/bean/Series.java
Date Sat, 04 Dec 2010 22:30:45 GMT
Author: eyang
Date: Sat Dec  4 22:30:44 2010
New Revision: 1042253

URL: http://svn.apache.org/viewvc?rev=1042253&view=rev
Log:
CHUKWA-474. Replaced JSON library with JSON-Simple. (Eric Yang)


Modified:
    incubator/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/bean/Series.java

Modified: incubator/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/bean/Series.java
URL: http://svn.apache.org/viewvc/incubator/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/bean/Series.java?rev=1042253&r1=1042252&r2=1042253&view=diff
==============================================================================
--- incubator/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/bean/Series.java (original)
+++ incubator/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/bean/Series.java Sat Dec
 4 22:30:44 2010
@@ -13,9 +13,8 @@ import javax.xml.bind.annotation.XmlValu
 import org.apache.hadoop.chukwa.datastore.ChukwaHBaseStore;
 import org.apache.hadoop.chukwa.util.ExceptionUtil;
 import org.apache.log4j.Logger;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.FIELD)
@@ -28,20 +27,20 @@ public class Series {
     series = new JSONObject();
     try {
       series.put("name", name);
-    } catch (JSONException e) {
+    } catch (Exception e) {
       log.error(ExceptionUtil.getStackTrace(e));
     }
   }
   
   public void add(long x, double y) {
     try {
-    if(!series.has("data")) {
+    if(!series.containsKey("data")) {
       series.put("data", new JSONArray());
     }
     JSONArray xy = new JSONArray();
-    xy.put(x);
-    xy.put(y);
-    series.getJSONArray("data").put(xy);
+    xy.add(x);
+    xy.add(y);
+    ((JSONArray)series.get("data")).add(xy);
     } catch(Exception e) {
       log.error(ExceptionUtil.getStackTrace(e));
     }



Mime
View raw message