Search in sources :

Example 6 with IActionEngine

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

the class SlowOperDataCollectHandler method handle.

@Override
public void handle(CollectDataFrame frame) {
    if (this.log.isDebugEnable()) {
        this.log.debug(this, frame.toJSONString());
    }
    BulkRequestBuilder bulkRequest = client.getClient().prepareBulk();
    String appUUID = frame.getTarget();
    // 从uuid中获取appid
    String appid = appUUID.split("---")[1];
    for (Line line : frame.getLines()) {
        String content = line.getContent();
        try {
            // 提取epinfo
            StringBuilder builder = new StringBuilder();
            int headPoint = 0;
            for (int i = 0; i < content.length(); i++) {
                char item = content.charAt(i);
                if (item == ';') {
                    headPoint++;
                    if (headPoint == 3) {
                        break;
                    }
                } else {
                    if (headPoint > 1) {
                        builder.append(item);
                    }
                }
            }
            String epinfo = builder.toString();
            // 若epinfo为数字则说明为方法级
            if (DataConvertHelper.toInt(epinfo, -1) != -1) {
                epinfo = "method";
            }
            IActionEngine engine = this.getActionEngineMgr().getActionEngine("SlowOperActionEngine");
            ActionContext ac = new ActionContext();
            ac.putParam("content", content);
            ac.putParam("appid", appid);
            engine.execute(epinfo, ac);
            SlowOperSpan span = (SlowOperSpan) ac.getParam("span");
            pushSpanToBulkRequest(appUUID, frame.getAppgroup(), span, bulkRequest, (String) ac.getParam("protocolType"));
        } catch (Exception e) {
            // 防止有不合法的协议报文出现
            this.log.err(this, "unsupported protocol,content is" + frame.toJSONString(), e);
        }
    }
    BulkResponse bulkResponse = bulkRequest.get();
    if (bulkResponse.hasFailures()) {
        log.err(this, "INSERT InvokeChain Data to ES FAIL: " + bulkResponse.buildFailureMessage());
    }
}
Also used : Line(com.creditease.agent.apm.api.CollectDataFrame.Line) SlowOperSpan(com.creditease.uav.invokechain.data.SlowOperSpan) BulkResponse(org.elasticsearch.action.bulk.BulkResponse) BulkRequestBuilder(org.elasticsearch.action.bulk.BulkRequestBuilder) ActionContext(com.creditease.agent.spi.ActionContext) IActionEngine(com.creditease.agent.spi.IActionEngine)

Example 7 with IActionEngine

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

the class LogAgent method start.

@Override
public void start() {
    /**
     * start LogCatchScheduleWorker
     *
     * timing to run logCatcher
     */
    this.getConfigManager().registerComponent(this.feature, "LogDataLog", super.log);
    LogCatchScheduleWorker catcher = new LogCatchScheduleWorker("LogCatchScheduleWorker", this.feature);
    String interval = this.getConfigManager().getFeatureConfiguration(this.feature, "interval");
    this.getTimerWorkManager().scheduleWork("LogCatchScheduleWorker", catcher, 0, DataConvertHelper.toLong(interval, 3000));
    if (log.isTraceEnable()) {
        log.info(this, "ApplicationServer LogCatchScheduleWorker started");
    }
    TailLogContext.getInstance().put("selfLog.enable", this.getConfigManager().getFeatureConfiguration(this.feature, "selfLog.enable"));
    /**
     * start AppServerLogPublishWorker
     *
     * when logCatcher processes data done, AppServerLogPublishWorker publishes logData
     */
    log.info(this, "LogAgent LogDataFrame.enable: " + this.getConfigManager().getFeatureConfiguration(this.feature, "LogDataFrame.enable"));
    TailLogContext.getInstance().put("LogDataFrame.enable", this.getConfigManager().getFeatureConfiguration(this.feature, "LogDataFrame.enable"));
    if (TailLogContext.getInstance().getBoolean("LogDataFrame.enable")) {
        AppServerLogPublishWorkerByStream aplcbs = new AppServerLogPublishWorkerByStream("AppServerLogPublishWorker", this.feature);
        logCatchWorkerThread = new Thread(aplcbs);
    } else {
        AppServerLogPublishWorker aplc = new AppServerLogPublishWorker("AppServerLogPublishWorker", this.feature);
        logCatchWorkerThread = new Thread(aplc);
    }
    logCatchWorkerThread.start();
    if (log.isTraceEnable()) {
        log.info(this, "ApplicationServer LogPublishWorker started");
    }
    /**
     * TailFileProcess will process existingInodes in Muti-Thread Model
     */
    log.info(this, "LogAgent Muti Thread enabled:" + this.getConfigManager().getFeatureConfiguration(this.feature, "MutiThread.enable"));
    TailLogContext.getInstance().put("MutiThread.enable", this.getConfigManager().getFeatureConfiguration(this.feature, "MutiThread.enable"));
    TailLogContext.getInstance().put("MutiThread.thread.max", this.getConfigManager().getFeatureConfiguration(this.feature, "MutiThread.thread.max"));
    if (TailLogContext.getInstance().getBoolean("MutiThread.enable")) {
        executor = this.getForkjoinWorkerMgr().newForkjoinWorker("TailLogProcessPoolWorker", this.feature, TailLogContext.getInstance().getInteger("MutiThread.thread.max"));
    }
    /**
     * regist node ctrl action
     */
    IActionEngine engine = this.getActionEngineMgr().getActionEngine("NodeOperActionEngine");
    new LogNodeOperAction("logstragety", feature, engine);
    loadLogCfg();
}
Also used : AppServerLogPublishWorkerByStream(com.creditease.agent.feature.logagent.AppServerLogPublishWorkerByStream) LogNodeOperAction(com.creditease.agent.feature.logagent.actions.LogNodeOperAction) AppServerLogPublishWorker(com.creditease.agent.feature.logagent.AppServerLogPublishWorker) IActionEngine(com.creditease.agent.spi.IActionEngine)

Example 8 with IActionEngine

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

the class NodeOperCtrlHandler method handle.

@Override
public void handle(UAVHttpMessage data) {
    long curTS = System.currentTimeMillis();
    String intent = data.getIntent();
    if (isCheckSec == true) {
        Long ts = actionLimits.get(intent);
        if (ts != null && curTS - ts < 1000 && (!"loadnodepro".equalsIgnoreCase(intent) && !"chgsyspro".equalsIgnoreCase(intent))) {
            data.putResponse("rs", "该节点上的操作[" + intent + "]1秒内只能进行一次");
            return;
        }
        actionLimits.put(intent, curTS);
    }
    if (log.isDebugEnable()) {
        log.debug(this, "NodeOperation[" + intent + "] START: request=" + JSONHelper.toString(data.getRequest()));
    }
    IActionEngine engine = this.getActionEngineMgr().getActionEngine("NodeOperActionEngine");
    ActionContext ac = new ActionContext();
    ac.putParam("msg", data);
    engine.execute(data.getIntent(), ac);
    if (log.isDebugEnable()) {
        log.debug(this, "NodeOperation[" + intent + "] END: response=" + JSONHelper.toString(data.getResponseAsJsonString()));
    }
}
Also used : ActionContext(com.creditease.agent.spi.ActionContext) IActionEngine(com.creditease.agent.spi.IActionEngine)

Example 9 with IActionEngine

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

the class CollectDataAgent method start.

@Override
public void start() {
    // init position file. If file is not exists, create it
    String rootMetaPath = this.getConfigManager().getContext(IConfigurationManager.METADATAPATH) + "collectdata";
    IOHelper.createFolder(rootMetaPath);
    positionFilePath = rootMetaPath + File.separator + POSITION_FILE;
    taskFilePath = rootMetaPath + File.separator + TASK_FILE;
    initFiles(new String[] { positionFilePath, taskFilePath });
    // register CollectNodeOperAction
    IActionEngine engine = this.getActionEngineMgr().getActionEngine("NodeOperActionEngine");
    new CollectNodeOperAction("collectdata", feature, engine);
    // init DataCollector
    dc = new DataCollector(DataCollector.class.getName(), feature);
    List<CollectTask> tasks = loadTasks();
    dc.init(tasks);
    dc.loadPositions(IOHelper.readTxtFile(positionFilePath, "UTF-8"));
    // start data scaner
    long scanInterval = DataConvertHelper.toLong(getConfigManager().getFeatureConfiguration(feature, "interval"), 3000L);
    FileScanScheduler scanner = new FileScanScheduler(FileScanScheduler.class.getName(), feature);
    getTimerWorkManager().scheduleWork(FileScanScheduler.class.getName(), scanner, 0, scanInterval);
    // write position file scheduler
    long writePosDelay = DataConvertHelper.toLong(getConfigManager().getFeatureConfiguration(feature, "writeposdelay"), 5000L);
    long writePosInterval = DataConvertHelper.toLong(getConfigManager().getFeatureConfiguration(feature, "writeposinterval"), 3000L);
    PositionPersistence position = new PositionPersistence(PositionPersistence.class.getName(), feature);
    getTimerWorkManager().scheduleWork(PositionPersistence.class.getName(), position, writePosDelay, writePosInterval);
    // check idle file scheduler
    long idleCheckerDelay = DataConvertHelper.toLong(getConfigManager().getFeatureConfiguration(feature, "idlecheckerdelay"), 120000L);
    long idleCheckerInterval = DataConvertHelper.toLong(getConfigManager().getFeatureConfiguration(feature, "idlecheckerinterval"), 5000L);
    IdleFileChecker idleChecker = new IdleFileChecker(IdleFileChecker.class.getName(), feature);
    getTimerWorkManager().scheduleWork(IdleFileChecker.class.getName(), idleChecker, idleCheckerDelay, idleCheckerInterval);
    log.info(this, "CollectDataAgent Started. Config: interval=" + scanInterval);
}
Also used : CollectNodeOperAction(com.creditease.uav.collect.client.actions.CollectNodeOperAction) DataCollector(com.creditease.uav.collect.client.collectdata.DataCollector) IActionEngine(com.creditease.agent.spi.IActionEngine) CollectTask(com.creditease.uav.collect.client.collectdata.CollectTask)

Example 10 with IActionEngine

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

the class ThreadAnalysisAgent method start.

@Override
public void start() {
    actionEngine = getActionEngineMgr().newActionEngine("JTAActionEngine", feature);
    new DumpThreadAction("DumpThreadAction", feature, actionEngine);
    new CountCtrlAction("CountCtrlAction", feature, actionEngine);
    new SuspendAction("SuspendAction", feature, actionEngine);
    // setup actions
    IActionEngine engine = this.getActionEngineMgr().getActionEngine("NodeOperActionEngine");
    new ThreadAnalysisAction("threadanalysis", feature, engine);
}
Also used : DumpThreadAction(com.creditease.uav.threadanalysis.client.action.DumpThreadAction) CountCtrlAction(com.creditease.uav.threadanalysis.client.action.CountCtrlAction) SuspendAction(com.creditease.uav.threadanalysis.client.action.SuspendAction) ThreadAnalysisAction(com.creditease.uav.threadanalysis.client.action.ThreadAnalysisAction) IActionEngine(com.creditease.agent.spi.IActionEngine)

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