chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r783442 [5/5] - in /hadoop/chukwa/trunk: ./ contrib/chukwa-pig/ ivy/ lib/ src/java/org/apache/hadoop/chukwa/database/ src/java/org/apache/hadoop/chukwa/datacollection/adaptor/ src/java/org/apache/hadoop/chukwa/rest/ src/java/org/apache/hado...
Date Wed, 10 Jun 2009 18:31:26 GMT
Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/database/TestDatabaseSetup.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/database/TestDatabaseSetup.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/database/TestDatabaseSetup.java
(added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/database/TestDatabaseSetup.java
Wed Jun 10 18:31:05 2009
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.chukwa.database;
+
+import java.io.*;
+import java.sql.*;
+import java.util.*;
+import org.apache.hadoop.chukwa.util.DatabaseWriter;
+import org.apache.hadoop.chukwa.database.TableCreator;
+
+public class TestDatabaseSetup {
+    public long[] timeWindow = {7, 30, 91, 365, 3650};
+    public String[] tables = {"system_metrics","disk","cluster_system_metrics","cluster_disk","mr_job","mr_task","dfs_namenode","dfs_datanode","dfs_fsnamesystem","dfs_throughput","hadoop_jvm","hadoop_mapred","hdfs_usage"};
+    public String cluster = "demo";
+    public long current = Calendar.getInstance().getTimeInMillis();
+
+    public void setUpDatabase() {
+	System.setProperty("CLUSTER","demo");
+	DatabaseWriter db = new DatabaseWriter(cluster);
+	String buffer = "";
+	File aFile = new File(System.getenv("CHUKWA_CONF_DIR")
+			      + File.separator + "database_create_tables.sql");
+	buffer = readFile(aFile);
+	String tables[] = buffer.split(";");
+	for(String table : tables) {
+	    if(table.length()>5) {
+		db.execute(table);
+	    }
+	}
+	db.close();
+	for(int i=0;i<timeWindow.length;i++) {
+	    TableCreator tc = new TableCreator();
+	    long start = current;
+	    long end = current + (timeWindow[i]*1440*60*1000);
+	    tc.createTables(start, end);
+	}
+    }
+    
+    public void tearDownDatabase() {
+	DatabaseWriter db = null;
+	try {
+	    db = new DatabaseWriter(cluster);
+	    ResultSet rs = db.query("show tables");
+	    ArrayList<String> list = new ArrayList<String>();
+	    while(rs.next()) {
+		String table = rs.getString(1);
+		list.add(table);
+	    }
+	    for(String table : list) {
+		db.execute("drop table "+table);
+	    }
+	} catch(Throwable ex) {
+	} finally {
+	    if(db!=null) {
+		db.close();
+	    }
+	}
+    }
+
+    public String readFile(File aFile) {
+	StringBuffer contents = new StringBuffer();
+	try {
+	    BufferedReader input = new BufferedReader(new FileReader(aFile));
+	    try {
+		String line = null; // not declared within while loop
+		while ((line = input.readLine()) != null) {
+		    contents.append(line);
+		    contents.append(System.getProperty("line.separator"));
+		}
+	    } finally {
+		input.close();
+	    }
+	} catch (IOException ex) {
+	    ex.printStackTrace();
+	}
+	return contents.toString();
+    }
+    
+}
+

Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseBaseTestCase.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseBaseTestCase.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseBaseTestCase.java
(added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseBaseTestCase.java
Wed Jun 10 18:31:05 2009
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.chukwa.rest;
+
+import java.util.*;
+import java.sql.*;
+import java.text.SimpleDateFormat;
+import org.apache.commons.logging.*;
+import org.apache.hadoop.chukwa.database.*;
+import org.apache.hadoop.chukwa.util.*;
+import org.apache.hadoop.chukwa.database.TestDatabaseSetup;
+
+import junit.framework.TestCase;
+
+import com.sun.jersey.api.client.*;
+import com.sun.jersey.api.client.filter.*;
+
+public class TestDatabaseBaseTestCase extends TestCase {
+    public static String DATE_FORMAT_NOW="yyy-MM-dd HH:mm:ss";
+    public Timestamp time;
+    public String tableName;
+    public String dateString;
+    public String insertString;
+    public String deleteString;
+    WebResource resource;
+    Client client;
+    public TestDatabaseSetup dbSetup = new TestDatabaseSetup();
+
+    public TestDatabaseBaseTestCase() {
+	Calendar calendar = Calendar.getInstance();
+	this.time = new Timestamp(calendar.getTimeInMillis());
+	SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
+	this.dateString = sdf.format(this.time.getTime());
+	client = Client.create();
+	resource = client.resource("http://localhost:8080/chukwa/v1/");
+	resource.addFilter(new LoggingFilter());
+	System.err.println("done logging filter");
+    }
+
+    protected String getCluster() {
+	// insert record into database	
+	String cluster=System.getProperty("CLUSTER", "");
+	if (cluster.compareTo("")==0)  {
+	    ClusterConfig cc=new ClusterConfig();
+	    Iterator<String> keys = cc.getClusters();
+	    if (keys.hasNext()) {
+		cluster=keys.next();
+	    }
+	    System.setProperty("CLUSTER",cluster);
+	}
+
+        if (cluster == null) {
+	    cluster = "demo";
+	}
+
+	return cluster;
+    }
+
+    protected void setUp() {
+	dbSetup.setUpDatabase();
+	String cluster = getCluster();
+	DatabaseWriter dbw = new DatabaseWriter(cluster);
+	long startTime = this.time.getTime();
+	long endTime = this.time.getTime();
+
+	String query=this.insertString;
+	Macro mp = new Macro(startTime, endTime, query, null);
+	query = mp.toString();
+	try {
+	    dbw.execute(query);
+	} catch (Exception e) {
+	    System.err.println(e.toString());
+	}
+    }
+
+    protected void tearDown() {
+	/*
+	dbSetup.tearDownDatabase();
+	*/
+    }
+
+    // check the return string for the specified format
+
+    protected void checkXML(String string) {
+	System.err.println("xml:"+string);
+	assertTrue(string.indexOf("item")>=0);
+    }
+    
+    protected void checkJson(String string) {
+	System.err.println("json:"+string);
+	assertTrue(string.indexOf("{")>=0);
+    }
+
+    protected void checkCsv(String string) {
+	System.err.println("csv:"+string);
+	assertTrue((string.toLowerCase().indexOf("timestamp")>=0) || 
+		   (string.toLowerCase().indexOf("job")>=0));
+    }
+}

Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseClientTraceTest.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseClientTraceTest.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseClientTraceTest.java
(added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseClientTraceTest.java
Wed Jun 10 18:31:05 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.chukwa.rest;
+
+import junit.framework.TestCase;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.chukwa.database.DatabaseConfig;
+import org.apache.hadoop.chukwa.database.Macro;
+import org.apache.hadoop.chukwa.util.DatabaseWriter;
+
+public class TestDatabaseClientTraceTest extends TestDatabaseBaseTestCase {
+    /* testing setup */
+    public TestDatabaseClientTraceTest() {
+	super();
+	this.tableName="ClientTrace";
+	this.insertString="insert into [ClientTrace] ("+
+	    "timestamp, local_hdfs_read, intra_rack_hdfs_read, inter_rack_hdfs_read, local_hdfs_write,
intra_rack_hdfs_write, inter_rack_hdfs_write, local_mapred_shuffle, intra_rack_mapred_shuffle,
inter_rack_mapred_shuffle"+
+	    ") values (\""+this.dateString+"\", 1,2,3,4,5,6,7,8,9)";
+	this.deleteString="delete from [ClientTrace] where "+
+	    "timestamp=\""+this.dateString+"\"";
+    }
+
+    /* run the test */
+    public void test() { 
+	// test xml
+	String string = resource.path("client_trace/timestamp/"+time.getTime()).accept("application/xml").get(String.class);
+	checkXML(string);
+
+	string = resource.path("client_trace/timestamp/"+time.getTime()).accept("application/json").get(String.class);
+	checkJson(string);
+
+	string = resource.path("client_trace/timestamp/"+time.getTime()).accept("text/csv").get(String.class);
+	checkCsv(string);
+    }
+}

Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseClusterDiskTest.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseClusterDiskTest.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseClusterDiskTest.java
(added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseClusterDiskTest.java
Wed Jun 10 18:31:05 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.chukwa.rest;
+
+import junit.framework.TestCase;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.chukwa.database.DatabaseConfig;
+import org.apache.hadoop.chukwa.database.Macro;
+import org.apache.hadoop.chukwa.util.DatabaseWriter;
+
+public class TestDatabaseClusterDiskTest extends TestDatabaseBaseTestCase {
+    /* testing setup */
+    public TestDatabaseClusterDiskTest() {
+	super();
+	this.tableName="client_disk";
+	this.insertString="insert into [cluster_disk] ("+
+	    "timestamp, mount, used, available, used_percent"+
+	    ") values (\""+this.dateString+"\", \"mount\", 1,2,3)";
+	this.deleteString="delete from [cluster_disk] where "+
+	    "timestamp=\""+this.dateString+"\" and mount=\"mount\" ";
+    }
+
+    /* run the test */
+    public void test() { 
+	// test xml
+	String string = resource.path("cluster_disk/timestamp/"+time.getTime()).accept("application/xml").get(String.class);
+	checkXML(string);
+
+	string = resource.path("cluster_disk/timestamp/"+time.getTime()).accept("application/json").get(String.class);
+	checkJson(string);
+
+	string = resource.path("cluster_disk/timestamp/"+time.getTime()).accept("text/csv").get(String.class);
+	checkCsv(string);
+    }
+}

Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseClusterHadoopRpcTest.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseClusterHadoopRpcTest.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseClusterHadoopRpcTest.java
(added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseClusterHadoopRpcTest.java
Wed Jun 10 18:31:05 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.chukwa.rest;
+
+import junit.framework.TestCase;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.chukwa.database.DatabaseConfig;
+import org.apache.hadoop.chukwa.database.Macro;
+import org.apache.hadoop.chukwa.util.DatabaseWriter;
+
+public class TestDatabaseClusterHadoopRpcTest extends TestDatabaseBaseTestCase {
+    /* testing setup */
+    public TestDatabaseClusterHadoopRpcTest() {
+	super();
+	this.tableName="cluster_hadoop_rpc";
+	this.insertString="insert into [cluster_hadoop_rpc] ("+
+	    "timestamp, host, rpc_processing_time_avg_time"+
+	    ") values (\""+this.dateString+"\", 1, 2)";
+	this.deleteString="delete from [cluster_hadoop_rpc] where "+
+	    "timestamp=\""+this.dateString+"\" ";
+    }
+
+    /* run the test */
+    public void test() { 
+	// test xml
+	String string = resource.path("cluster_hadoop_rpc/timestamp/"+time.getTime()).accept("application/xml").get(String.class);
+	checkXML(string);
+
+	string = resource.path("cluster_hadoop_rpc/timestamp/"+time.getTime()).accept("application/json").get(String.class);
+	checkJson(string);
+
+	string = resource.path("cluster_hadoop_rpc/timestamp/"+time.getTime()).accept("text/csv").get(String.class);
+	checkCsv(string);
+    }
+}

Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsDataNodeTest.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsDataNodeTest.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsDataNodeTest.java
(added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsDataNodeTest.java
Wed Jun 10 18:31:05 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.chukwa.rest;
+
+import junit.framework.TestCase;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.chukwa.database.DatabaseConfig;
+import org.apache.hadoop.chukwa.database.Macro;
+import org.apache.hadoop.chukwa.util.DatabaseWriter;
+
+public class TestDatabaseDfsDataNodeTest extends TestDatabaseBaseTestCase {
+    /* testing setup */
+    public TestDatabaseDfsDataNodeTest() {
+	super();
+	this.tableName="dfs_datanode";
+	this.insertString="insert into [dfs_datanode] ("+
+	    "timestamp, host, block_reports_avg_time"+
+	    ") values (\""+this.dateString+"\", \"host\", 1)";
+	this.deleteString="delete from [dfs_datanode] where "+
+	    "timestamp=\""+this.dateString+"\" and host=\"host\" ";
+    }
+
+    /* run the test */
+    public void test() { 
+	// test xml
+	String string = resource.path("dfs_datanode/timestamp/"+time.getTime()).accept("application/xml").get(String.class);
+	checkXML(string);
+
+	string = resource.path("dfs_datanode/timestamp/"+time.getTime()).accept("application/json").get(String.class);
+	checkJson(string);
+
+	string = resource.path("dfs_datanode/timestamp/"+time.getTime()).accept("text/csv").get(String.class);
+	checkCsv(string);
+    }
+}

Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsFsNameSystemTest.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsFsNameSystemTest.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsFsNameSystemTest.java
(added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsFsNameSystemTest.java
Wed Jun 10 18:31:05 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.chukwa.rest;
+
+import junit.framework.TestCase;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.chukwa.database.DatabaseConfig;
+import org.apache.hadoop.chukwa.database.Macro;
+import org.apache.hadoop.chukwa.util.DatabaseWriter;
+
+public class TestDatabaseDfsFsNameSystemTest extends TestDatabaseBaseTestCase {
+    /* testing setup */
+    public TestDatabaseDfsFsNameSystemTest() {
+	super();
+	this.tableName="dfs_fsnamesystem";
+	this.insertString="insert into [dfs_fsnamesystem] ("+
+	    "timestamp, host, blocks_total"+
+	    ") values (\""+this.dateString+"\", \"host\", 1)";
+	this.deleteString="delete from [dfs_fsnamesystem] where "+
+	    "timestamp=\""+this.dateString+"\" and host=\"host\" ";
+    }
+
+    /* run the test */
+    public void test() { 
+	// test xml
+	String string = resource.path("dfs_fsnamesystem/timestamp/"+time.getTime()).accept("application/xml").get(String.class);
+	checkXML(string);
+
+	string = resource.path("dfs_fsnamesystem/timestamp/"+time.getTime()).accept("application/json").get(String.class);
+	checkJson(string);
+
+	string = resource.path("dfs_fsnamesystem/timestamp/"+time.getTime()).accept("text/csv").get(String.class);
+	checkCsv(string);
+    }
+}

Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsNameNodeTest.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsNameNodeTest.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsNameNodeTest.java
(added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsNameNodeTest.java
Wed Jun 10 18:31:05 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.chukwa.rest;
+
+import junit.framework.TestCase;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.chukwa.database.DatabaseConfig;
+import org.apache.hadoop.chukwa.database.Macro;
+import org.apache.hadoop.chukwa.util.DatabaseWriter;
+
+public class TestDatabaseDfsNameNodeTest extends TestDatabaseBaseTestCase {
+    /* testing setup */
+    public TestDatabaseDfsNameNodeTest() {
+	super();
+	this.tableName="dfs_namenode";
+	this.insertString="insert into [dfs_namenode] ("+
+	    "timestamp, host, add_block_ops"+
+	    ") values (\""+this.dateString+"\", \"host\", 1)";
+	this.deleteString="delete from [dfs_namenode] where "+
+	    "timestamp=\""+this.dateString+"\" and host=\"host\" ";
+    }
+
+    /* run the test */
+    public void test() { 
+	// test xml
+	String string = resource.path("dfs_namenode/timestamp/"+time.getTime()).accept("application/xml").get(String.class);
+	checkXML(string);
+
+	string = resource.path("dfs_namenode/timestamp/"+time.getTime()).accept("application/json").get(String.class);
+	checkJson(string);
+
+	string = resource.path("dfs_namenode/timestamp/"+time.getTime()).accept("text/csv").get(String.class);
+	checkCsv(string);
+    }
+}

Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsThroughputTest.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsThroughputTest.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsThroughputTest.java
(added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDfsThroughputTest.java
Wed Jun 10 18:31:05 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.chukwa.rest;
+
+import junit.framework.TestCase;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.chukwa.database.DatabaseConfig;
+import org.apache.hadoop.chukwa.database.Macro;
+import org.apache.hadoop.chukwa.util.DatabaseWriter;
+
+public class TestDatabaseDfsThroughputTest extends TestDatabaseBaseTestCase {
+    /* testing setup */
+    public TestDatabaseDfsThroughputTest() {
+	super();
+	this.tableName="dfs_throughput";
+	this.insertString="insert into [dfs_throughput] ("+
+	    "timestamp, host, block_reports_avg_time"+
+	    ") values (\""+this.dateString+"\", 1,2)";
+	this.deleteString="delete from [dfs_throughput] where "+
+	    "timestamp=\""+this.dateString+"\" ";
+    }
+
+    /* run the test */
+    public void test() { 
+	// test xml
+	String string = resource.path("dfs_throughput/timestamp/"+time.getTime()).accept("application/xml").get(String.class);
+	checkXML(string);
+
+	string = resource.path("dfs_throughput/timestamp/"+time.getTime()).accept("application/json").get(String.class);
+	checkJson(string);
+
+	string = resource.path("dfs_throughput/timestamp/"+time.getTime()).accept("text/csv").get(String.class);
+	checkCsv(string);
+    }
+}

Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDiskTest.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDiskTest.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDiskTest.java (added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseDiskTest.java Wed
Jun 10 18:31:05 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.chukwa.rest;
+
+import junit.framework.TestCase;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.chukwa.database.DatabaseConfig;
+import org.apache.hadoop.chukwa.database.Macro;
+import org.apache.hadoop.chukwa.util.DatabaseWriter;
+
+public class TestDatabaseDiskTest extends TestDatabaseBaseTestCase {
+    /* testing setup */
+    public TestDatabaseDiskTest() {
+	super();
+	this.tableName="disk";
+	this.insertString="insert into [disk] ("+
+	    "timestamp, host, mount, used"+
+	    ") values (\""+this.dateString+"\", \"host\", \"mount\",1)";
+	this.deleteString="delete from [Disk] where "+
+	    "timestamp=\""+this.dateString+"\" and host=\"host\" and mount=\"mount\"";
+    }
+
+    /* run the test */
+    public void test() { 
+	// test xml
+	String string = resource.path("disk/timestamp/"+time.getTime()).accept("application/xml").get(String.class);
+	checkXML(string);
+
+	string = resource.path("disk/timestamp/"+time.getTime()).accept("application/json").get(String.class);
+	checkJson(string);
+
+	string = resource.path("disk/timestamp/"+time.getTime()).accept("text/csv").get(String.class);
+	checkCsv(string);
+    }
+}

Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseHadoopJvmTest.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseHadoopJvmTest.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseHadoopJvmTest.java
(added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseHadoopJvmTest.java
Wed Jun 10 18:31:05 2009
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.chukwa.rest;
+
+import junit.framework.TestCase;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.chukwa.database.DatabaseConfig;
+import org.apache.hadoop.chukwa.database.Macro;
+import org.apache.hadoop.chukwa.util.DatabaseWriter;
+
+public class TestDatabaseHadoopJvmTest extends TestDatabaseBaseTestCase {
+    /* testing setup */
+    public TestDatabaseHadoopJvmTest() {
+	super();
+	this.tableName="hadoop_jvm";
+	this.insertString="insert into [hadoop_jvm] ("+
+	    "timestamp, host, process_name, gc_timemillis, gc_count, log_error, log_fatal, log_info,
log_warn, mem_heap_committed_m, mem_heap_used_m, mem_non_heap_committed_m, mem_non_heap_used_m,
threads_blocked, threads_new, threads_runnable, threads_terminated, threads_timed_waiting,
threads_waiting"+
+	    ") values (\""+this.dateString+"\", \"host\", \"process\",1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)";
+	this.deleteString="delete from [hadoop_jvm] where "+
+	    "timestamp=\""+this.dateString+"\" and host=\"host\" and process_name=\"process\"";
+    }
+
+    /* run the test */
+    public void test() { 
+	System.err.println("start test");
+	// test xml
+	try {
+	    String string = resource.path("hadoop_jvm/timestamp/"+time.getTime()).accept("application/xml").get(String.class);
+	    checkXML(string);
+	    
+	    string = resource.path("hadoop_jvm/timestamp/"+time.getTime()).accept("application/json").get(String.class);
+	    checkJson(string);
+	    
+	    string = resource.path("hadoop_jvm/timestamp/"+time.getTime()).accept("text/csv").get(String.class);
+	    checkCsv(string);
+	} catch (Exception e) {
+	    System.err.println("error:"+e.toString());
+	}
+    }
+}

Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseHadoopRpcTest.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseHadoopRpcTest.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseHadoopRpcTest.java
(added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseHadoopRpcTest.java
Wed Jun 10 18:31:05 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.chukwa.rest;
+
+import junit.framework.TestCase;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.chukwa.database.DatabaseConfig;
+import org.apache.hadoop.chukwa.database.Macro;
+import org.apache.hadoop.chukwa.util.DatabaseWriter;
+
+public class TestDatabaseHadoopRpcTest extends TestDatabaseBaseTestCase {
+    /* testing setup */
+    public TestDatabaseHadoopRpcTest() {
+	super();
+	this.tableName="hadoop_rpc";
+	this.insertString="insert into [hadoop_rpc] ("+
+	    "timestamp, host, rpc_processing_time_avg_time"+
+	    ") values (\""+this.dateString+"\", \"host\", 1)";
+	this.deleteString="delete from [hadoop_rpc] where "+
+	    "timestamp=\""+this.dateString+"\" and host=\"host\" ";
+    }
+
+    /* run the test */
+    public void test() { 
+	// test xml
+	String string = resource.path("hadoop_rpc/timestamp/"+time.getTime()).accept("application/xml").get(String.class);
+	checkXML(string);
+
+	string = resource.path("hadoop_rpc/timestamp/"+time.getTime()).accept("application/json").get(String.class);
+	checkJson(string);
+
+	string = resource.path("hadoop_rpc/timestamp/"+time.getTime()).accept("text/csv").get(String.class);
+	checkCsv(string);
+    }
+}

Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseMrJobConfTest.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseMrJobConfTest.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseMrJobConfTest.java
(added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseMrJobConfTest.java
Wed Jun 10 18:31:05 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.chukwa.rest;
+
+import junit.framework.TestCase;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.chukwa.database.DatabaseConfig;
+import org.apache.hadoop.chukwa.database.Macro;
+import org.apache.hadoop.chukwa.util.DatabaseWriter;
+
+public class TestDatabaseMrJobConfTest extends TestDatabaseBaseTestCase {
+    /* testing setup */
+    public TestDatabaseMrJobConfTest() {
+	super();
+	this.tableName="mr_job_conf";
+	this.insertString="insert into [mr_job_conf] ("+
+	    "ts, job_id"+
+	    ") values (\""+this.dateString+"\", \""+time.getTime()+"\")";
+	this.deleteString="delete from [mr_job_conf] where "+
+	    "job_id=\""+time.getTime()+"\" ";
+    }
+
+    /* run the test */
+    public void test() { 
+	// test xml
+	String string = resource.path("mr_job_conf/job_id/"+time.getTime()).accept("application/xml").get(String.class);
+	checkXML(string);
+
+	string = resource.path("mr_job_conf/job_id/"+time.getTime()).accept("application/json").get(String.class);
+	checkJson(string);
+
+	string = resource.path("mr_job_conf/job_id/"+time.getTime()).accept("text/csv").get(String.class);
+	checkCsv(string);
+    }
+}

Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseMrJobTest.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseMrJobTest.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseMrJobTest.java
(added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseMrJobTest.java
Wed Jun 10 18:31:05 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.chukwa.rest;
+
+import junit.framework.TestCase;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.chukwa.database.DatabaseConfig;
+import org.apache.hadoop.chukwa.database.Macro;
+import org.apache.hadoop.chukwa.util.DatabaseWriter;
+
+public class TestDatabaseMrJobTest extends TestDatabaseBaseTestCase {
+    /* testing setup */
+    public TestDatabaseMrJobTest() {
+	super();
+	this.tableName="mr_job";
+	this.insertString="insert into [mr_job] ("+
+	    "job_id,submit_time,launch_time,finish_time"+
+	    ") values (\""+time.getTime()+"\",\""+this.dateString+"\",\""+this.dateString+"\",\""+this.dateString+"\")";
+	this.deleteString="delete from [mr_job] where "+
+	    "job_id=\""+time.getTime()+"\" ";
+    }
+
+    /* run the test */
+    public void test() { 
+	// test xml
+	String string = resource.path("mr_job/job_id/"+time.getTime()).accept("application/xml").get(String.class);
+	checkXML(string);
+
+	string = resource.path("mr_job/job_id/"+time.getTime()).accept("application/json").get(String.class);
+	checkJson(string);
+
+	string = resource.path("mr_job/job_id/"+time.getTime()).accept("text/csv").get(String.class);
+	checkCsv(string);
+    }
+}

Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseMrTaskTest.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseMrTaskTest.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseMrTaskTest.java
(added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseMrTaskTest.java
Wed Jun 10 18:31:05 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.chukwa.rest;
+
+import junit.framework.TestCase;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.chukwa.database.DatabaseConfig;
+import org.apache.hadoop.chukwa.database.Macro;
+import org.apache.hadoop.chukwa.util.DatabaseWriter;
+
+public class TestDatabaseMrTaskTest extends TestDatabaseBaseTestCase {
+    /* testing setup */
+    public TestDatabaseMrTaskTest() {
+	super();
+	this.tableName="mr_task";
+	this.insertString="insert into [mr_task] ("+
+	    "task_id, start_time,finish_time,shuffle_finished,sort_finished"+
+	    ") values (\""+time.getTime()+"\",\""+this.dateString+"\",\""+this.dateString+"\",\""+this.dateString+"\",\""+this.dateString+"\")";
+	this.deleteString="delete from [MrTask] where "+
+	    "timestamp=\""+time.getTime()+"\" ";
+    }
+
+    /* run the test */
+    public void test() { 
+	// test xml
+	String string = resource.path("mr_task/task_id/"+time.getTime()).accept("application/xml").get(String.class);
+	checkXML(string);
+
+	string = resource.path("mr_task/task_id/"+time.getTime()).accept("application/json").get(String.class);
+	checkJson(string);
+
+	string = resource.path("mr_task/task_id/"+time.getTime()).accept("text/csv").get(String.class);
+	checkCsv(string);
+    }
+}

Added: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseSystemMetricsTest.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseSystemMetricsTest.java?rev=783442&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseSystemMetricsTest.java
(added)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/rest/TestDatabaseSystemMetricsTest.java
Wed Jun 10 18:31:05 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.chukwa.rest;
+
+import junit.framework.TestCase;
+
+import java.util.*;
+import java.sql.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.chukwa.database.DatabaseConfig;
+import org.apache.hadoop.chukwa.database.Macro;
+import org.apache.hadoop.chukwa.util.DatabaseWriter;
+
+public class TestDatabaseSystemMetricsTest extends TestDatabaseBaseTestCase {
+    /* testing setup */
+    public TestDatabaseSystemMetricsTest() {
+	super();
+	this.tableName="system_metrics";
+	this.insertString="insert into [system_metrics] ("+
+	    "timestamp, host"+
+	    ") values (\""+this.dateString+"\", \"host\")";
+	this.deleteString="delete from [system_metrics] where "+
+	    "timestamp=\""+this.dateString+"\" and host=\"host\" ";
+    }
+
+    /* run the test */
+    public void test() { 
+	// test xml
+	String string = resource.path("system_metrics/timestamp/"+time.getTime()).accept("application/xml").get(String.class);
+	checkXML(string);
+
+	string = resource.path("system_metrics/timestamp/"+time.getTime()).accept("application/json").get(String.class);
+	checkJson(string);
+
+	string = resource.path("system_metrics/timestamp/"+time.getTime()).accept("text/csv").get(String.class);
+	checkCsv(string);
+    }
+}

Modified: hadoop/chukwa/trunk/src/web/hicc/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/WEB-INF/web.xml?rev=783442&r1=783441&r2=783442&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/WEB-INF/web.xml (original)
+++ hadoop/chukwa/trunk/src/web/hicc/WEB-INF/web.xml Wed Jun 10 18:31:05 2009
@@ -26,4 +26,19 @@
         <servlet-name>Iframe</servlet-name> 
         <url-pattern>/iframe/*</url-pattern> 
     </servlet-mapping>
+
+    <servlet>
+      <servlet-name>REST_API</servlet-name>
+      <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer
+      </servlet-class>
+      <init-param>
+	<param-name>com.sun.jersey.config.property.packages</param-name>
+	<param-value>org.apache.hadoop.chukwa.rest.actions</param-value>
+      </init-param>
+      <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet-mapping>
+      <servlet-name>REST_API</servlet-name>
+      <url-pattern>/v1/*</url-pattern>
+    </servlet-mapping>    
 </web-app>



Mime
View raw message