Search in sources :

Example 6 with I1NQueueWorker

use of com.creditease.agent.spi.I1NQueueWorker in project uavstack by uavorg.

the class NotificationCenter method start.

@Override
public void start() {
    engine = this.getActionEngineMgr().newActionEngine("NotifyActionEngine", feature);
    // init actions
    new SMSAction(NCConstant.ACTION4SMS, this.feature, engine);
    String mailProvider = this.getConfigManager().getFeatureConfiguration(this.feature, "nc.notify.mail.provider");
    if (StringHelper.isEmpty(mailProvider) || "CEMail".equals(mailProvider)) {
        new CEMailAction(NCConstant.ACTION4MAIL, this.feature, engine);
    }
    if ("JavaMail".equals(mailProvider)) {
        new JavaMailAction(NCConstant.ACTION4MAIL, this.feature, engine);
    }
    new HttpCallAction(NCConstant.ACTION4HTTP, this.feature, engine);
    new PushNotifyEventAction(NCConstant.ACTION4PUSHNTF, this.feature, engine);
    new ThreadAnalysisAction(NCConstant.ACTION4THREADANALYSIS, this.feature, engine);
    String cacheServerAddress = this.getConfigManager().getFeatureConfiguration(this.feature, "nc.cache.addr");
    String password = this.getConfigManager().getFeatureConfiguration(this.feature, "nc.cache.concurrent.pwd");
    int minConcurrent = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "nc.cache.concurrent.min"), 10);
    int maxConcurrent = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "nc.cache.concurrent.max"), 20);
    int queueSize = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "nc.cache.concurrent.bqsize"), 10);
    // cache manager
    cm = CacheManagerFactory.build(cacheServerAddress, minConcurrent, maxConcurrent, queueSize, password);
    this.getConfigManager().registerComponent(this.feature, "NCCacheManager", cm);
    new NCEventStatusManager("EventStatusManager", this.feature, cm);
    // start I1NQueueWorkerMgr
    int coreSize = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "inqw.coreSize"), 10);
    int maxSize = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "inqw.maxSize"), 10);
    int bQueueSize = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "inqw.bQueueSize"), 10000);
    int keepAliveTimeout = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "inqw.keepAliveTimeout"), 10000);
    I1NQueueWorkerMgr mgt = this.get1NQueueWorkerMgr();
    I1NQueueWorker INqueueworker = mgt.newQueueWorker(NCConstant.NC1NQueueWorkerName, this.feature, coreSize, maxSize, bQueueSize, keepAliveTimeout);
    notifyCenter_inqw = Executors.newSingleThreadExecutor();
    notifyCenter_inqw.execute(INqueueworker);
    if (log.isTraceEnable()) {
        log.info(this, NCConstant.NC1NQueueWorkerName + " started");
    }
    NCJudgementEngine = this.getActionEngineMgr().newActionEngine("NCJudgementEngine", feature);
    // start NCJudgementWorker
    NCJudgementWorker ncj = new NCJudgementWorker("NCJudgementWorker", this.feature, "notifycenterhandlers");
    notifyCenter_ncj = Executors.newSingleThreadExecutor();
    notifyCenter_ncj.execute(ncj);
    if (log.isTraceEnable()) {
        log.info(this, "NCJudgementWorker started");
    }
    // Start the NC Http service
    int port = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.port"), 8766);
    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"), 50);
    int bqsize = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.bqsize"), 10);
    ncServerListenWorker = new NCHttpServerWorker("NCHttpServerWorker", this.feature, "nchttpHandler");
    @SuppressWarnings({ "rawtypes", "unchecked" }) ThreadPoolExecutor exe = new ThreadPoolExecutor(core, max, 30000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(bqsize));
    ncServerListenWorker.start(exe, port, backlog);
    if (log.isTraceEnable()) {
        log.info(this, "NCHttpServerWorker started");
    }
}
Also used : PushNotifyEventAction(com.creditease.agent.feature.notifycenter.actions.PushNotifyEventAction) NCJudgementWorker(com.creditease.agent.feature.notifycenter.NCJudgementWorker) NCEventStatusManager(com.creditease.agent.feature.notifycenter.NCEventStatusManager) SMSAction(com.creditease.agent.feature.notifycenter.actions.SMSAction) JavaMailAction(com.creditease.agent.feature.notifycenter.actions.JavaMailAction) I1NQueueWorker(com.creditease.agent.spi.I1NQueueWorker) I1NQueueWorkerMgr(com.creditease.agent.spi.I1NQueueWorkerMgr) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) CEMailAction(com.creditease.agent.feature.notifycenter.actions.CEMailAction) HttpCallAction(com.creditease.agent.feature.notifycenter.actions.HttpCallAction) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ThreadAnalysisAction(com.creditease.agent.feature.notifycenter.actions.ThreadAnalysisAction) NCHttpServerWorker(com.creditease.agent.feature.notifycenter.NCHttpServerWorker)

Aggregations

I1NQueueWorker (com.creditease.agent.spi.I1NQueueWorker)6 RuntimeNotifySliceMgr (com.creditease.uav.feature.runtimenotify.RuntimeNotifySliceMgr)2 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 NCEventStatusManager (com.creditease.agent.feature.notifycenter.NCEventStatusManager)1 NCHttpServerWorker (com.creditease.agent.feature.notifycenter.NCHttpServerWorker)1 NCJudgementWorker (com.creditease.agent.feature.notifycenter.NCJudgementWorker)1 CEMailAction (com.creditease.agent.feature.notifycenter.actions.CEMailAction)1 HttpCallAction (com.creditease.agent.feature.notifycenter.actions.HttpCallAction)1 JavaMailAction (com.creditease.agent.feature.notifycenter.actions.JavaMailAction)1 PushNotifyEventAction (com.creditease.agent.feature.notifycenter.actions.PushNotifyEventAction)1 SMSAction (com.creditease.agent.feature.notifycenter.actions.SMSAction)1 ThreadAnalysisAction (com.creditease.agent.feature.notifycenter.actions.ThreadAnalysisAction)1 Abstract1NTask (com.creditease.agent.spi.Abstract1NTask)1 HttpMessage (com.creditease.agent.spi.HttpMessage)1 I1NQueueWorkerMgr (com.creditease.agent.spi.I1NQueueWorkerMgr)1 CacheManager (com.creditease.uav.cache.api.CacheManager)1 NotifyStrategy (com.creditease.uav.feature.runtimenotify.NotifyStrategy)1 Slice (com.creditease.uav.feature.runtimenotify.Slice)1 StrategyJudgement (com.creditease.uav.feature.runtimenotify.StrategyJudgement)1