use of com.creditease.uav.datastore.api.DataStoreMsg in project uavstack by uavorg.
the class DoTestProfileData method testquerytMongoDB.
@SuppressWarnings("rawtypes")
public static void testquerytMongoDB() {
// String[] fileName = { "DSAggregatequery.json", "DSAggregatequeryGtLt.json", "DSAggregatequeryMKV.json",
// "DSAggregatequeryRegex_GtInOR.json", "DSAggregatequeryRegex.json", "DSAggregatequeryRegexInOR.json",
// "DSAggregatequeryRegexMKVInOR.json", "DSfind.json" };
String[] fileName = { "DSfind.json" };
// "DSAggregatequeryMKV.json", "DSAggregatequeryRegex_GtInOR.json",
// "DSAggregatequeryRegex.json", "DSAggregatequeryRegexInOR.json",
// "DSAggregatequeryRegexMKVInOR.json" ,"DSfind.json" };
// String[] fileName = { "group.json" };
long total = 0;
for (int i = 0; i < fileName.length; i++) {
// System.out.println("test query : " + fileName[i]);
String query = DataStoreUnitTest.getData(queryJsonDir + fileName[i]);
DataStoreMsg request = new DataStoreMsg();
request.put(DataStoreProtocol.MONGO_QUERY_SQL, query.toString());
request.put(DataStoreProtocol.MONGO_COLLECTION_NAME, HealthManagerConstants.MONGO_COLLECTION_PROFILE);
DataStoreConnection obj = new DataStoreConnection(userName, password, dbName, serverlist, DataStoreType.MONGODB);
AbstractDataStore store = DataStoreFactory.getInstance().build(HealthManagerConstants.DataStore_Profile, obj, new ProfileDataAdpater(), "");
store.start();
long start = System.currentTimeMillis();
@SuppressWarnings("unchecked") List<Object> list = store.doQuery(request);
long stop = System.currentTimeMillis();
total = total + (stop - start);
StringBuffer sb = new StringBuffer();
sb.append("query " + fileName[i] + ": " + (stop - start));
try {
fileWrite(sb);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
store.stop();
DataStoreUnitTest.printTestResult("MongoDB:" + fileName[i], list, queryJsonDir);
}
StringBuffer sb = new StringBuffer();
sb.append("query total: " + total);
try {
fileWrite(sb);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of com.creditease.uav.datastore.api.DataStoreMsg in project uavstack by uavorg.
the class HealthManager method exchange.
@SuppressWarnings("rawtypes")
@Override
public Object exchange(String eventKey, Object... data) {
log.info(this, "HM got exchange event");
if (null == data) {
log.err(this, "the exchange data is empty");
return null;
}
DataStoreMsg msg = (DataStoreMsg) data[0];
AbstractDataStore dataStore = DataStoreFactory.getInstance().get((String) msg.get(DataStoreProtocol.DATASTORE_NAME));
Object rst = null;
switch(eventKey) {
case HealthManagerConstants.QUERY:
rst = dataStore.doQuery(msg);
return rst;
case HealthManagerConstants.INSERT:
rst = dataStore.doUpdate(msg);
return rst;
case HealthManagerConstants.UPDATE:
rst = dataStore.doUpdate(msg);
return rst;
}
throw new RuntimeException("Exchange Event [" + eventKey + "] handle FAIL: data=" + data);
}
use of com.creditease.uav.datastore.api.DataStoreMsg in project uavstack by uavorg.
the class DoTestLogData method testInsertHBase.
// {"MT_Log":"[{time:1462329007990,host:\"09-201211070016\",ip:\"127.0.0.1\",svrid:\"F:/testenv/apache-tomcat-7.0.65::E:/eclipse/workspace3/.metadata/.plugins/org.eclipse.wst.server.core/tmp1\",tag:\"L\",frames:{\"com.creditease.uav.monitorframework.buildFat,F:/temp/log/FAT_log1.txt\":
/**
* [ { "time": 1456293824385, "host": "09-201509070105", "ip": "127.0.0.1", "svrid":
* "D:/UAV/apache-tomcat-6.0.41::D:/eclipseProject/.metadata/.plugins/org.eclipse.wst.server.core/tmp0", "tag": "L",
* "frames": { "WebTest": [ { "content": "[CE] aaaaa" } ] } } ]
*/
@SuppressWarnings("unchecked")
public static void testInsertHBase() {
// MongoDBHandler
DataStoreMsg msg = new DataStoreMsg();
String rawData = DataStoreUnitTest.getData(insertJson);
msg.put(MonitorDataFrame.MessageType.Log.toString(), rawData);
msg.put(DataStoreProtocol.HBASE_TABLE_NAME, HealthManagerConstants.HBASE_TABLE_LOGDATA);
List<String> servers = DataConvertHelper.toList(zklist, ",");
DataStoreConnection obj = new DataStoreConnection(null, null, null, servers, DataStoreType.HBASE);
obj.putContext(DataStoreProtocol.HBASE_ZK_QUORUM, zklist);
obj.putContext(DataStoreProtocol.HBASE_QUERY_CACHING, caching);
obj.putContext(DataStoreProtocol.HBASE_QUERY_MAXRESULTSIZE, maxResultSize);
obj.putContext(DataStoreProtocol.HBASE_QUERY_REVERSE, true);
obj.putContext(DataStoreProtocol.HBASE_QUERY_PAGESIZE, 3000);
AbstractDataStore<Connection> store = DataStoreFactory.getInstance().build(HealthManagerConstants.DataStore_Log, obj, new LogDataAdapter(), "");
store.start();
boolean rst = store.doInsert(msg);
store.stop();
DataStoreUnitTest.printTestResult("testInsertHBase", rst);
}
use of com.creditease.uav.datastore.api.DataStoreMsg in project uavstack by uavorg.
the class DoTestLogData method testQueryHBase.
/**
* { "starttime": 145629382438, "endtime": 145629382438, //optional "ip": "127.0.0.1", "svrid":
* "D:/UAV/apache-tomcat-6.0.41::D:/eclipseProject/.metadata/.plugins/org.eclipse.wst.server.core/tmp0", "appid":
* "sms" }
*/
@SuppressWarnings("unchecked")
public static void testQueryHBase() {
DataStoreMsg msg = new DataStoreMsg();
msg.put(DataStoreProtocol.HBASE_QUERY_JSON_KEY, queryJson);
List<String> servers = DataConvertHelper.toList(zklist, ",");
DataStoreConnection obj = new DataStoreConnection(null, null, null, servers, DataStoreType.HBASE);
obj.putContext(DataStoreProtocol.HBASE_ZK_QUORUM, zklist);
obj.putContext(DataStoreProtocol.HBASE_QUERY_CACHING, caching);
obj.putContext(DataStoreProtocol.HBASE_QUERY_MAXRESULTSIZE, maxResultSize);
AbstractDataStore<Connection> store = DataStoreFactory.getInstance().build(HealthManagerConstants.DataStore_Log, obj, new LogDataAdapter(), "");
store.start();
List<String> rst = store.doQuery(msg);
store.stop();
DataStoreUnitTest.printTestResult("testqueryHBase", rst, queryJson);
}
use of com.creditease.uav.datastore.api.DataStoreMsg in project uavstack by uavorg.
the class DoTestNotifyData4Mongo method testInsertNotifyMongoDB.
@SuppressWarnings({ "rawtypes" })
public static void testInsertNotifyMongoDB() {
DataStoreMsg msg = new DataStoreMsg();
// MongoDBHandler
String rawData = DataStoreUnitTest.getData(insertJson);
msg.put(MonitorDataFrame.MessageType.Notification.toString(), rawData);
msg.put(DataStoreProtocol.MONGO_COLLECTION_NAME, HealthManagerConstants.MONGO_COLLECTION_NOTIFY);
DataStoreConnection obj = new DataStoreConnection(userName, password, dbName, serverlist, DataStoreType.MONGODB);
AbstractDataStore store = DataStoreFactory.getInstance().build(HealthManagerConstants.DataStore_Notification, obj, new NotifyDataAdpater(), "");
store.start();
boolean rst = store.doInsert(msg);
store.stop();
DataStoreUnitTest.printTestResult("testInsertNotifyMongoDB", rst);
}
Aggregations