use of com.creditease.uav.datastore.api.DataStoreMsg in project uavstack by uavorg.
the class DoTestProfileData method testupdateMongoDB.
@SuppressWarnings({ "rawtypes", "unused" })
public static void testupdateMongoDB() {
for (int i = 0; i < updatefileName.length; i++) {
System.out.println("test update : " + updatefileName[i]);
String update = DataStoreUnitTest.getData(queryJsonDir + updatefileName[i]);
DataStoreMsg request = new DataStoreMsg();
request.put(DataStoreProtocol.MONGO_QUERY_SQL, update.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();
boolean rst = store.doUpdate(request);
long stop = System.currentTimeMillis();
StringBuffer sb = new StringBuffer();
sb.append("update " + updatefileName[i] + ": " + (stop - start));
try {
fileWrite(sb);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
store.stop();
// DataStoreUnitTest.printTestResult("MongoDB:"+updatefileName[i], rst);
}
}
use of com.creditease.uav.datastore.api.DataStoreMsg in project uavstack by uavorg.
the class HMDataStoreQueryHandler method handle.
@SuppressWarnings({ "rawtypes" })
@Override
public void handle(UAVHttpMessage data) {
String storeName = data.getRequest(DataStoreProtocol.DATASTORE_NAME);
AbstractDataStore store = DataStoreFactory.getInstance().get(storeName);
if (store != null) {
if (!store.isStarted()) {
store.start();
if (!store.isStarted()) {
String warnMsg = "DataStore[" + storeName + "] CAN NOT START.";
if (log.isTraceEnable()) {
log.warn(this, warnMsg);
}
// put err to response
data.putResponse(UAVHttpMessage.ERR, warnMsg);
return;
}
}
DataStoreMsg dsmsg = new DataStoreMsg();
// put all request params into DataStoreMsg for adaptor usage
dsmsg.putAll(data.getRequest());
List result = store.doQuery(dsmsg);
String jsonString = JSONHelper.toString(result);
// put result to response
data.putResponse(UAVHttpMessage.RESULT, jsonString);
} else {
String warnMsg = "DataStore[" + storeName + "] NO EXIST.";
if (log.isTraceEnable()) {
log.warn(this, warnMsg);
}
// put err to response
data.putResponse(UAVHttpMessage.ERR, warnMsg);
}
}
Aggregations