Search in sources :

Example 21 with CacheManager

use of com.creditease.uav.cache.api.CacheManager in project uavstack by uavorg.

the class InvokeChainProcessServer method start.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void start() {
    // init cache manager
    String cacheServerAddress = this.getConfigManager().getFeatureConfiguration(this.feature, "store.addr");
    int minConcurrent = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.min"), 10);
    int maxConcurrent = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.max"), 50);
    int queueSize = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.bqsize"), 5);
    String password = this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.pwd");
    CacheManager cm = CacheManagerFactory.build(cacheServerAddress, minConcurrent, maxConcurrent, queueSize, password);
    this.getConfigManager().registerComponent(this.feature, "IVCCacheManager", cm);
    // init ES Client
    String esAddrStr = this.getConfigManager().getFeatureConfiguration(this.feature, "es.addr");
    String clusterName = this.getConfigManager().getFeatureConfiguration(this.feature, "es.clustername");
    ESClient client = new ESClient(esAddrStr, clusterName);
    this.getConfigManager().registerComponent(this.feature, "ESClient", client);
    // register invokechain index mgr
    new InvokeChainIndexMgr("InvokeChainIndexMgr", feature);
    // register slowoper index mgr
    new SlowOperIndexMgr("SlowOperIndexMgr", feature);
    // register invokechain collect handler
    new InvokeChainDataCollectHandler("JQ_IVC_CollectHandler", feature);
    // 注册重调用链action engine
    this.getActionEngineMgr().newActionEngine("SlowOperActionEngine", feature);
    // register slowoper collect handler
    new SlowOperDataCollectHandler("JQ_SLW_CollectHandler", feature);
    // run InvokeChainQueryServerWorker
    boolean isStartQueryServer = DataConvertHelper.toBoolean(this.getConfigManager().getFeatureConfiguration(this.feature, "http.enable"), true);
    if (isStartQueryServer == true) {
        int port = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.port"), 7799);
        int backlog = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.backlog"), 10);
        int core = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.core"), 10);
        int max = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.max"), 100);
        int bqsize = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.bqsize"), 10);
        ivcQueryServerWorker = new InvokeChainQueryServerWorker("InvokeChainQueryServerWorker", feature, "qhandlers");
        ThreadPoolExecutor executor = new ThreadPoolExecutor(core, max, 30, TimeUnit.SECONDS, new ArrayBlockingQueue(bqsize));
        ivcQueryServerWorker.start(executor, port, backlog);
        if (log.isTraceEnable()) {
            log.info(this, "InvokeChainQueryServerWorker started");
        }
    }
}
Also used : SlowOperDataCollectHandler(com.creditease.uav.invokechain.collect.SlowOperDataCollectHandler) InvokeChainQueryServerWorker(com.creditease.uav.invokechain.http.InvokeChainQueryServerWorker) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) ESClient(com.creditease.uav.elasticsearch.client.ESClient) CacheManager(com.creditease.uav.cache.api.CacheManager) InvokeChainDataCollectHandler(com.creditease.uav.invokechain.collect.InvokeChainDataCollectHandler) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 22 with CacheManager

use of com.creditease.uav.cache.api.CacheManager in project uavstack by uavorg.

the class DoTestMain method main.

public static void main(String[] args) {
    SystemLogger.init("DEBUG", true, 5);
    String ip = "localhost:6379";
    CacheManager.build(ip, 0, 0, 0);
    CacheManager cm = CacheManager.instance();
    Map<String, String> hash = new HashMap<String, String>();
    hash.put("age", "1");
    hash.put("name", "zz");
    cm.del("test", "123");
    // "1#360121199403085855#774889"
    cm.putHash("test", "123", hash, 3600, TimeUnit.SECONDS);
    ThreadHelper.suspend(500);
    Map<String, String> m = cm.getHashAll("test", "123");
    System.out.println(m);
}
Also used : HashMap(java.util.HashMap) CacheManager(com.creditease.uav.cache.api.CacheManager)

Example 23 with CacheManager

use of com.creditease.uav.cache.api.CacheManager in project uavstack by uavorg.

the class RedisService method aredistest.

@GET
@Path("aredistest")
@Produces(MediaType.TEXT_HTML + ";charset=utf-8")
public String aredistest() {
    SystemLogger.init("DEBUG", true, 0);
    System.out.println("TEST aredis ======================================================");
    CacheManager cm = CacheManagerFactory.build("localhost:6379", 1, 5, 5);
    cm.put("TEST", "foo", "bar");
    String v = cm.get("TEST", "foo");
    System.out.println(v);
    cm.shutdown();
    return "aredistest";
}
Also used : CacheManager(com.creditease.uav.cache.api.CacheManager) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 24 with CacheManager

use of com.creditease.uav.cache.api.CacheManager in project uavstack by uavorg.

the class TestRestService method testAredis.

@POST
@Path("testAredis")
public void testAredis(String jsonString) {
    SystemLogger.init("DEBUG", true, 0);
    CacheManager cm = CacheManagerFactory.build("localhost:6379", 1, 5, 5);
    cm.put("TEST", "foo", "bar");
    cm.get("TEST", "foo");
    cm.lpush("TEST", "lll", "a");
    cm.lpush("TEST", "lll", "b");
    cm.lpush("TEST", "lll", "c");
    cm.lpop("TEST", "lll");
    cm.lpop("TEST", "lll");
    cm.lpop("TEST", "lll");
    cm.putHash("TEST", "mmm", "abc", "123");
    cm.putHash("TEST", "mmm", "def", "456");
    cm.getHashAll("TEST", "mmm");
    cm.del("TEST", "foo");
    cm.del("TEST", "lll");
    cm.del("TEST", "mmm");
    cm.shutdown();
}
Also used : CacheManager(com.creditease.uav.cache.api.CacheManager) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 25 with CacheManager

use of com.creditease.uav.cache.api.CacheManager in project uavstack by uavorg.

the class TestRestService method testAredis.

@POST
@Path("testAredis")
public void testAredis(String jsonString) {
    SystemLogger.init("DEBUG", true, 0);
    CacheManager cm = CacheManagerFactory.build("localhost:6379", 1, 5, 5);
    cm.put("TEST", "foo", "bar");
    cm.get("TEST", "foo");
    cm.lpush("TEST", "lll", "a");
    cm.lpush("TEST", "lll", "b");
    cm.lpush("TEST", "lll", "c");
    cm.lpop("TEST", "lll");
    cm.lpop("TEST", "lll");
    cm.lpop("TEST", "lll");
    cm.putHash("TEST", "mmm", "abc", "123");
    cm.putHash("TEST", "mmm", "def", "456");
    cm.getHashAll("TEST", "mmm");
    cm.del("TEST", "foo");
    cm.del("TEST", "lll");
    cm.del("TEST", "mmm");
    cm.shutdown();
}
Also used : CacheManager(com.creditease.uav.cache.api.CacheManager) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

CacheManager (com.creditease.uav.cache.api.CacheManager)26 IOException (java.io.IOException)6 HashMap (java.util.HashMap)4 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)4 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)4 Path (javax.ws.rs.Path)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 ESClient (com.creditease.uav.elasticsearch.client.ESClient)2 RuntimeNotifySliceMgr (com.creditease.uav.feature.runtimenotify.RuntimeNotifySliceMgr)2 Slice (com.creditease.uav.feature.runtimenotify.Slice)2 StrategyJudgement (com.creditease.uav.feature.runtimenotify.StrategyJudgement)2 RuntimeNotifyStrategyMgr (com.creditease.uav.feature.runtimenotify.scheduler.RuntimeNotifyStrategyMgr)2 Random (java.util.Random)2 GET (javax.ws.rs.GET)2 POST (javax.ws.rs.POST)2 Produces (javax.ws.rs.Produces)2 StandardMessagingBuilder (org.uavstack.resources.common.messaging.StandardMessagingBuilder)2 HeartBeatQueryListenWorker (com.creditease.agent.feature.hbagent.HeartBeatQueryListenWorker)1 HeartBeatServerLifeKeeper (com.creditease.agent.feature.hbagent.HeartBeatServerLifeKeeper)1