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());
}
}
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();
}
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()));
}
}
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);
}
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);
}
Aggregations