import java.io.FileInputStream; import org.apache.hadoop.conf.Configuration; import org.zillion.util.log.LogUtil; import com.saga.compute.util.DB.DBOperate; import com.saga.compute.util.common.Constant; import com.sagacloud.json.JSONObject; import com.zillion.database.agent.ZillionAgent; public class TestInsert { public static void main(String[] arsg) throws Exception { String resource = "/hbase-site.xml"; Configuration configuration = new Configuration(); LogUtil.info(LogUtil.GetPath()); configuration.addResource(new FileInputStream(LogUtil.GetPath() + resource)); String zookeeper_connectionAddress = "zookeeper1:2181,zookeeper2:2181,zookeeper3:2181"; int zookeeper_sessionTimeout = 300000; Constant.agent = new ZillionAgent(configuration, zookeeper_connectionAddress, zookeeper_sessionTimeout); Constant.agent.Start(); // JSONObject InsertObject_detail = new JSONObject(); // InsertObject_detail.put("building", "4301050001"); // InsertObject_detail.put("compute_round", 1l); // InsertObject_detail.put("meter", "1001"); // InsertObject_detail.put("funcid", 0l); // InsertObject_detail.put("data_time", "20170102000000"); // InsertObject_detail.put("label2", 0l); // InsertObject_detail.put("meter_cleaned2", 1111.22); // // JSONObject wrapperObject = new JSONObject(); // wrapperObject.put("QueryType", "insert"); // wrapperObject.put("Database", "db_wanda"); // wrapperObject.put("Datatable", "fjd_1_computedetail"); // wrapperObject.put("InsertObject", InsertObject_detail); // Constant.agent.Query(wrapperObject); JSONObject deleteObject = new JSONObject(); deleteObject.put("building", "4301050001"); deleteObject.put("meter", "1001"); deleteObject.put("funcid", 0l); String[] time_periods = { "5min", "15min", "1h", "1d" }; for (String timePeriod : time_periods) { deleteObject.put("time_period", timePeriod); JSONObject range = new JSONObject(); range.put("$gte", "20170105000000"); range.put("$lte", "20170106000000"); deleteObject.put("data_time", range); DBOperate.Instance().deleteData(deleteObject, "fjd_0_near"); } System.exit(0); } }