Search in sources :

Example 1 with IActionEngine

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

the class SystemActionEngineMgr method newActionEngine.

@Override
public IActionEngine newActionEngine(String actionEngineID, String feature) {
    if (aeMap.containsKey(actionEngineID)) {
        shutdown(actionEngineID);
    }
    IActionEngine ae = new ActionEngine(actionEngineID, feature);
    aeMap.put(actionEngineID, ae);
    return ae;
}
Also used : ActionEngine(com.creditease.agent.spi.ActionEngine) IActionEngine(com.creditease.agent.spi.IActionEngine) IActionEngine(com.creditease.agent.spi.IActionEngine)

Example 2 with IActionEngine

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

the class SystemActionEngineMgr method shutdown.

private void shutdown(String actionEngineID, boolean removeAE) {
    if (aeMap.containsKey(actionEngineID)) {
        IActionEngine ae;
        if (removeAE) {
            ae = aeMap.remove(actionEngineID);
        } else {
            ae = aeMap.get(actionEngineID);
        }
        ae.clean();
        // unregister actionEngine
        ConfigurationManager.getInstance().unregisterComponent(((ActionEngine) ae).getFeature(), actionEngineID);
    }
}
Also used : IActionEngine(com.creditease.agent.spi.IActionEngine)

Example 3 with IActionEngine

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

the class HealthManager method start.

@Override
public void start() {
    // init cache manager
    String cacheServerAddress = this.getConfigManager().getFeatureConfiguration(this.feature, "store.addr");
    int minConcurrent = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.min"));
    int maxConcurrent = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.max"));
    int queueSize = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.bqsize"));
    String password = this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.pwd");
    CacheManager cm = CacheManagerFactory.build(cacheServerAddress, minConcurrent, maxConcurrent, queueSize, password);
    this.getConfigManager().registerComponent(this.feature, "HMCacheManager", cm);
    // start HealthManagerProfileDataLifeKeeper
    isStartLifeKeeper = Boolean.parseBoolean(this.getConfigManager().getFeatureConfiguration(this.feature, "lifekeeper.enable"));
    if (isStartLifeKeeper == true) {
        // init HealthManagerProfileDataLifeKeeper
        HealthManagerProfileDataLifeKeeper profileDataLifeKeepWorker = new HealthManagerProfileDataLifeKeeper("HealthManagerProfileDataLifeKeeper", this.feature);
        long interval = Long.parseLong(this.getConfigManager().getFeatureConfiguration(this.feature, "lifekeeper.interval"));
        long randomDely = new Random().nextInt(3) + 3;
        this.getTimerWorkManager().scheduleWorkInPeriod("HealthManagerProfileDataLifeKeeper", profileDataLifeKeepWorker, randomDely * 1000, interval);
        if (log.isTraceEnable()) {
            log.info(this, "HealthManagerProfileDataLifeKeeper started");
        }
    }
    /**
     * Start the DBStore service NOTE: this must be the first to start
     */
    buildDataStores(this.getConfigManager());
    // start all datastores
    DataStoreFactory.getInstance().startAll(this.feature);
    if (log.isTraceEnable()) {
        log.info(this, "HealthManager DataStore Factory started");
    }
    /**
     * Start the HealthManger Http service
     */
    int port = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.port"));
    int backlog = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.backlog"));
    int core = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.core"));
    int max = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.max"));
    int bqsize = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.bqsize"));
    healthServerListenWorker = new HealthManagerServerWorker("HealthMangerServerWorker", this.feature, "healthMangerHandlers");
    @SuppressWarnings({ "rawtypes", "unchecked" }) ThreadPoolExecutor exe = new ThreadPoolExecutor(core, max, 30000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(bqsize));
    healthServerListenWorker.start(exe, port, backlog);
    if (log.isTraceEnable()) {
        log.info(this, "HealthManager DataStore HttpServer started");
    }
    StandardMessagingBuilder smb = new StandardMessagingBuilder("HMCommonMsgBuilder", this.feature);
    try {
        smb.init("com.creditease.uav.feature.healthmanager.messaging.handlers");
    } catch (IOException e) {
        log.err(this, "Read msgtype2topic.properties FAILs, HealthManager can not START", e);
        return;
    }
    monitorDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Monitor.toString());
    notificationConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Notification.toString());
    profileDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Profile.toString());
    logDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Log.toString());
    nodeinfoDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.NodeInfo.toString());
    // start monitorDataConsumer
    if (monitorDataConsumer != null) {
        monitorDataConsumer.start();
        this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_MONITOR, monitorDataConsumer);
        if (log.isTraceEnable()) {
            log.info(this, "HealthManager MDFConsumer started");
        }
    }
    // start notificationConsumer
    if (this.notificationConsumer != null) {
        notificationConsumer.start();
        this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_NOTIFY, notificationConsumer);
        if (log.isTraceEnable()) {
            log.info(this, "HealthManager NotifyConsumer started");
        }
    }
    // start profileDataConsumer
    if (this.profileDataConsumer != null) {
        /**
         * INIT StandardProfileModelingEngine & StandardProfileModeler
         */
        IActionEngine engine = this.getActionEngineMgr().newActionEngine("StandardProfileModelingEngine", feature);
        new StandardProfileModeler("StandardProfileModeler", feature, engine);
        // start profile consumer
        profileDataConsumer.start();
        this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_PROFILE, profileDataConsumer);
        if (log.isTraceEnable()) {
            log.info(this, "HealthManager ProfileConsumer started");
        }
    }
    // start logDataConsumer
    if (this.logDataConsumer != null) {
        logDataConsumer.start();
        this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_LOG, logDataConsumer);
        if (log.isTraceEnable()) {
            log.info(this, "HealthManager LogConsumer started");
        }
    }
    // start nodeinfoDataConsumer
    if (nodeinfoDataConsumer != null) {
        nodeinfoDataConsumer.start();
        this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_NODE, nodeinfoDataConsumer);
        if (log.isTraceEnable()) {
            log.info(this, "HealthManager NodeInfoConsumer started");
        }
    }
}
Also used : StandardMessagingBuilder(org.uavstack.resources.common.messaging.StandardMessagingBuilder) HealthManagerServerWorker(com.creditease.uav.feature.healthmanager.HealthManagerServerWorker) IOException(java.io.IOException) IActionEngine(com.creditease.agent.spi.IActionEngine) HealthManagerProfileDataLifeKeeper(com.creditease.uav.feature.healthmanager.HealthManagerProfileDataLifeKeeper) Random(java.util.Random) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) CacheManager(com.creditease.uav.cache.api.CacheManager) StandardProfileModeler(com.creditease.agent.profile.api.StandardProfileModeler) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 4 with IActionEngine

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

the class ProfileDataMessageHandler method pushLatestProfileDataToCacheCenter.

/**
 * 推送最新的ProfileData到缓存中心
 *
 * @param profileString
 */
private List<String> pushLatestProfileDataToCacheCenter(String profileString) {
    /**
     * setup ProfileDataMessageHandler as IStandardProfileModelListener for StandardProfileModeler
     */
    ISystemActionEngineMgr engineMgr = (ISystemActionEngineMgr) ConfigurationManager.getInstance().getComponent("Global", "ISystemActionEngineMgr");
    IActionEngine engine = engineMgr.getActionEngine("StandardProfileModelingEngine");
    StandardProfileModeler modeler = (StandardProfileModeler) ConfigurationManager.getInstance().getComponent("healthmanager", "StandardProfileModeler");
    modeler.setListener(this);
    cm.beginBatch();
    List<String> monitorDataFrames = JSONHelper.toObjectArray(profileString, String.class);
    List<String> newMDFs = new ArrayList<String>();
    for (String mdfStr : monitorDataFrames) {
        MonitorDataFrame mdf = new MonitorDataFrame(mdfStr);
        ActionContext ac = new ActionContext();
        ac.putParam(MonitorDataFrame.class, mdf);
        ac.putParam("NewMDFList", newMDFs);
        ac.putParam("MDFString", mdfStr);
        engine.execute("StandardProfileModeler", ac);
    }
    cm.submitBatch();
    return newMDFs;
}
Also used : ISystemActionEngineMgr(com.creditease.agent.spi.ISystemActionEngineMgr) ArrayList(java.util.ArrayList) StandardProfileModeler(com.creditease.agent.profile.api.StandardProfileModeler) MonitorDataFrame(com.creditease.agent.monitor.api.MonitorDataFrame) ActionContext(com.creditease.agent.spi.ActionContext) IActionEngine(com.creditease.agent.spi.IActionEngine)

Example 5 with IActionEngine

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

the class NodeOperAgent method start.

@Override
public void start() {
    IActionEngine engine = this.getActionEngineMgr().getActionEngine("NodeOperActionEngine");
    // setup actions
    new MOFInstallMgtAction("installmof", feature, engine);
    new MOFInstallMgtAction("uninstallmof", feature, engine);
    new MSCPGeneralAction("fstart", feature, engine);
    new MSCPGeneralAction("fstop", feature, engine);
    new MSCPGeneralAction("killproc", feature, engine);
    new MSCPGeneralAction("kill", feature, engine);
    new MSCPGeneralAction("shutdown", feature, engine);
    new MSCPGeneralAction("chgsyspro", feature, engine);
    new MSCPGeneralAction("loadnodepro", feature, engine);
    new MSCPGeneralAction("chgnodepro", feature, engine);
    new MSCPGeneralAction("watch", feature, engine);
    new MSCPGeneralAction("unwatch", feature, engine);
    new MSCPGeneralAction("upgrade", feature, engine);
    new MSCPGeneralAction("restart", feature, engine);
    new MSCPGeneralAction("stopuav", feature, engine);
    new MOFCtrlAction("ctrlmof", feature, engine);
    // start HeartBeatServerListenWorker
    nodeOperHttpServer = new NodeOperHttpServer("NodeOperHttpServer", this.feature, "nodeophandlers");
    int port = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.port"), 10101);
    int backlog = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.backlog"), 10);
    int core = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.core"), 5);
    int max = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.max"), 10);
    int bqsize = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.bqsize"), 10);
    @SuppressWarnings({ "rawtypes", "unchecked" }) ThreadPoolExecutor exe = new ThreadPoolExecutor(core, max, 30000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(bqsize));
    /**
     * if the node ctrl server port conflicts, the node process will exit
     */
    nodeOperHttpServer.start(exe, port, backlog, true);
    if (log.isTraceEnable()) {
        log.info(this, "NodeOperHttpServer started");
    }
}
Also used : NodeOperHttpServer(com.creditease.agent.feature.nodeopagent.NodeOperHttpServer) MSCPGeneralAction(com.creditease.agent.feature.nodeopagent.actions.MSCPGeneralAction) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) MOFInstallMgtAction(com.creditease.agent.feature.nodeopagent.actions.MOFInstallMgtAction) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) IActionEngine(com.creditease.agent.spi.IActionEngine) MOFCtrlAction(com.creditease.agent.feature.nodeopagent.actions.MOFCtrlAction)

Aggregations

IActionEngine (com.creditease.agent.spi.IActionEngine)10 ActionContext (com.creditease.agent.spi.ActionContext)3 StandardProfileModeler (com.creditease.agent.profile.api.StandardProfileModeler)2 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 Line (com.creditease.agent.apm.api.CollectDataFrame.Line)1 AppServerLogPublishWorker (com.creditease.agent.feature.logagent.AppServerLogPublishWorker)1 AppServerLogPublishWorkerByStream (com.creditease.agent.feature.logagent.AppServerLogPublishWorkerByStream)1 LogNodeOperAction (com.creditease.agent.feature.logagent.actions.LogNodeOperAction)1 NodeOperHttpServer (com.creditease.agent.feature.nodeopagent.NodeOperHttpServer)1 MOFCtrlAction (com.creditease.agent.feature.nodeopagent.actions.MOFCtrlAction)1 MOFInstallMgtAction (com.creditease.agent.feature.nodeopagent.actions.MOFInstallMgtAction)1 MSCPGeneralAction (com.creditease.agent.feature.nodeopagent.actions.MSCPGeneralAction)1 MonitorDataFrame (com.creditease.agent.monitor.api.MonitorDataFrame)1 ActionEngine (com.creditease.agent.spi.ActionEngine)1 ISystemActionEngineMgr (com.creditease.agent.spi.ISystemActionEngineMgr)1 CacheManager (com.creditease.uav.cache.api.CacheManager)1 CollectNodeOperAction (com.creditease.uav.collect.client.actions.CollectNodeOperAction)1 CollectTask (com.creditease.uav.collect.client.collectdata.CollectTask)1 DataCollector (com.creditease.uav.collect.client.collectdata.DataCollector)1