Search in sources :

Example 1 with ProfileDataAdpater

use of com.creditease.uav.feature.healthmanager.datastore.adaptors.ProfileDataAdpater 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 ProfileDataAdpater

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

the class DoTestProfileData method testInsertMongoDB.

@SuppressWarnings({ "rawtypes" })
public static void testInsertMongoDB() {
    // MongoDBHandler
    DataStoreMsg msg = new DataStoreMsg();
    String rawData = DataStoreUnitTest.getData(insertJson);
    msg.put(MonitorDataFrame.MessageType.Profile.toString(), rawData);
    msg.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.doInsert(msg);
    for (int i = 0; i < 1; i++) {
        boolean rst = store.doInsert(msg);
        if (false == rst)
            break;
    }
    long stop = System.currentTimeMillis();
    StringBuffer sb = new StringBuffer();
    sb.append("insert time : " + (stop - start));
    try {
        fileWrite(sb);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    store.stop();
// DataStoreUnitTest.printTestResult("testInsertMongoDB",rst);
}
Also used : DataStoreConnection(com.creditease.uav.datastore.api.DataStoreConnection) DataStoreMsg(com.creditease.uav.datastore.api.DataStoreMsg) IOException(java.io.IOException) AbstractDataStore(com.creditease.uav.datastore.core.AbstractDataStore) ProfileDataAdpater(com.creditease.uav.feature.healthmanager.datastore.adaptors.ProfileDataAdpater)

Example 3 with ProfileDataAdpater

use of com.creditease.uav.feature.healthmanager.datastore.adaptors.ProfileDataAdpater 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();
    }
}
Also used : DataStoreMsg(com.creditease.uav.datastore.api.DataStoreMsg) IOException(java.io.IOException) ProfileDataAdpater(com.creditease.uav.feature.healthmanager.datastore.adaptors.ProfileDataAdpater) DataStoreConnection(com.creditease.uav.datastore.api.DataStoreConnection) AbstractDataStore(com.creditease.uav.datastore.core.AbstractDataStore)

Example 4 with ProfileDataAdpater

use of com.creditease.uav.feature.healthmanager.datastore.adaptors.ProfileDataAdpater 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);
    }
}
Also used : DataStoreConnection(com.creditease.uav.datastore.api.DataStoreConnection) DataStoreMsg(com.creditease.uav.datastore.api.DataStoreMsg) IOException(java.io.IOException) AbstractDataStore(com.creditease.uav.datastore.core.AbstractDataStore) ProfileDataAdpater(com.creditease.uav.feature.healthmanager.datastore.adaptors.ProfileDataAdpater)

Aggregations

ProfileDataAdpater (com.creditease.uav.feature.healthmanager.datastore.adaptors.ProfileDataAdpater)4 DataStoreConnection (com.creditease.uav.datastore.api.DataStoreConnection)3 DataStoreMsg (com.creditease.uav.datastore.api.DataStoreMsg)3 AbstractDataStore (com.creditease.uav.datastore.core.AbstractDataStore)3 IOException (java.io.IOException)3 LogDataAdapter (com.creditease.uav.feature.healthmanager.datastore.adaptors.LogDataAdapter)1 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 HashMap (java.util.HashMap)1