Search in sources :

Example 1 with LogDataAdapter

use of com.creditease.uav.feature.healthmanager.datastore.adaptors.LogDataAdapter in project uavstack by uavorg.

the class HealthManager method buildDataStores.

private void buildDataStores(IConfigurationManager icm) {
    // log
    String logKey = MonitorDataFrame.MessageType.Log.toString();
    // monitor
    String monitorKey = MonitorDataFrame.MessageType.Monitor.toString();
    // profile
    String profileKey = MonitorDataFrame.MessageType.Profile.toString();
    // notification
    String notifyKey = MonitorDataFrame.MessageType.Notification.toString();
    // nodeinfo
    String nodeinfoKey = MonitorDataFrame.MessageType.NodeInfo.toString();
    String caching = icm.getFeatureConfiguration(this.feature, logKey + ".ds.cache");
    String maxResultSize = icm.getFeatureConfiguration(this.feature, logKey + ".ds.maxResultSize");
    String reverse = icm.getFeatureConfiguration(this.feature, logKey + ".ds.reverse");
    String psize = icm.getFeatureConfiguration(this.feature, logKey + ".ds.pagesize");
    Map<String, Object> lctx = new HashMap<String, Object>();
    lctx.put(DataStoreProtocol.HBASE_QUERY_CACHING, caching);
    lctx.put(DataStoreProtocol.HBASE_QUERY_MAXRESULTSIZE, maxResultSize);
    lctx.put(DataStoreProtocol.HBASE_QUERY_REVERSE, DataConvertHelper.toBoolean(Boolean.valueOf(reverse), true));
    lctx.put(DataStoreProtocol.HBASE_QUERY_PAGESIZE, DataConvertHelper.toLong(Long.valueOf(psize), 3000));
    // build log ds
    buildDataStore(icm, logKey, DataStoreType.HBASE, new LogDataAdapter(), lctx);
    Map<String, Object> mctx = new HashMap<String, Object>();
    mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXPERROUTE, DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.maxPerRoute"), 10));
    mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXROUTE, DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.maxRoute"), 50));
    mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_SOTIMEOUT, DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.soTimeout"), 5000));
    mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_CONNTIMEOUT, DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.connTimeout"), 5000));
    mctx.put(DataStoreProtocol.OPENTSDB_CLIENT_REQTIMEOUT, DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, monitorKey + ".ds.reqTimeout"), 5000));
    // build monitor ds
    buildDataStore(icm, monitorKey, DataStoreType.OPENTSDB, new MonitorDataAdapter(), mctx);
    // build profile ds
    buildDataStore(icm, profileKey, DataStoreType.MONGODB, new ProfileDataAdpater(), null);
    // build notify ds
    buildDataStore(icm, notifyKey, DataStoreType.MONGODB, new NotifyDataAdpater(), null);
    Map<String, Object> nctx = new HashMap<String, Object>();
    nctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXPERROUTE, DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.maxPerRoute"), 10));
    nctx.put(DataStoreProtocol.OPENTSDB_CLIENT_MAXROUTE, DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.maxRoute"), 50));
    nctx.put(DataStoreProtocol.OPENTSDB_CLIENT_SOTIMEOUT, DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.soTimeout"), 5000));
    nctx.put(DataStoreProtocol.OPENTSDB_CLIENT_CONNTIMEOUT, DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.connTimeout"), 5000));
    nctx.put(DataStoreProtocol.OPENTSDB_CLIENT_REQTIMEOUT, DataConvertHelper.toInt(icm.getFeatureConfiguration(this.feature, nodeinfoKey + ".ds.reqTimeout"), 5000));
    // build nodeinfo ds
    buildDataStore(icm, nodeinfoKey, DataStoreType.OPENTSDB, new NodeInfoDataAdapter(), nctx);
}
Also used : MonitorDataAdapter(com.creditease.uav.feature.healthmanager.datastore.adaptors.MonitorDataAdapter) NotifyDataAdpater(com.creditease.uav.feature.healthmanager.datastore.adaptors.NotifyDataAdpater) HashMap(java.util.HashMap) NodeInfoDataAdapter(com.creditease.uav.feature.healthmanager.datastore.adaptors.NodeInfoDataAdapter) LogDataAdapter(com.creditease.uav.feature.healthmanager.datastore.adaptors.LogDataAdapter) ProfileDataAdpater(com.creditease.uav.feature.healthmanager.datastore.adaptors.ProfileDataAdpater)

Example 2 with LogDataAdapter

use of com.creditease.uav.feature.healthmanager.datastore.adaptors.LogDataAdapter 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);
}
Also used : DataStoreConnection(com.creditease.uav.datastore.api.DataStoreConnection) DataStoreConnection(com.creditease.uav.datastore.api.DataStoreConnection) Connection(org.apache.hadoop.hbase.client.Connection) DataStoreMsg(com.creditease.uav.datastore.api.DataStoreMsg) LogDataAdapter(com.creditease.uav.feature.healthmanager.datastore.adaptors.LogDataAdapter)

Example 3 with LogDataAdapter

use of com.creditease.uav.feature.healthmanager.datastore.adaptors.LogDataAdapter 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);
}
Also used : DataStoreConnection(com.creditease.uav.datastore.api.DataStoreConnection) DataStoreConnection(com.creditease.uav.datastore.api.DataStoreConnection) Connection(org.apache.hadoop.hbase.client.Connection) DataStoreMsg(com.creditease.uav.datastore.api.DataStoreMsg) LogDataAdapter(com.creditease.uav.feature.healthmanager.datastore.adaptors.LogDataAdapter)

Aggregations

LogDataAdapter (com.creditease.uav.feature.healthmanager.datastore.adaptors.LogDataAdapter)3 DataStoreConnection (com.creditease.uav.datastore.api.DataStoreConnection)2 DataStoreMsg (com.creditease.uav.datastore.api.DataStoreMsg)2 Connection (org.apache.hadoop.hbase.client.Connection)2 MonitorDataAdapter (com.creditease.uav.feature.healthmanager.datastore.adaptors.MonitorDataAdapter)1 NodeInfoDataAdapter (com.creditease.uav.feature.healthmanager.datastore.adaptors.NodeInfoDataAdapter)1 NotifyDataAdpater (com.creditease.uav.feature.healthmanager.datastore.adaptors.NotifyDataAdpater)1 ProfileDataAdpater (com.creditease.uav.feature.healthmanager.datastore.adaptors.ProfileDataAdpater)1 HashMap (java.util.HashMap)1