use of com.creditease.agent.spi.ActionContext 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;
}
use of com.creditease.agent.spi.ActionContext 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.ActionContext in project uavstack by uavorg.
the class NotificationCenter method executeNotifyAction.
/**
* 执行NotifyAction
*
* @param actionSet
* @param event
*/
public void executeNotifyAction(Map<String, String> actionMap, NotificationEvent event) {
for (String actionkey : actionMap.keySet()) {
ActionContext ac = new ActionContext();
ac.putParam("event", event);
ac.putParam(NCConstant.ACTIONVALUE, actionMap.get(actionkey));
ac = engine.execute(actionkey, ac);
String stateStr = (ac.isSucessful() == true) ? "SUCCESS" : "FAIL";
if (log.isTraceEnable()) {
log.info(this, "NotificationTask Action[" + actionkey + "] " + stateStr);
}
}
}
use of com.creditease.agent.spi.ActionContext in project uavstack by uavorg.
the class ThreadAnalysisAction method sendMail.
private boolean sendMail(NotificationEvent notifyEvent) {
String address = getMailAddress(notifyEvent);
// 如果没有获取到地址,则返回不发送通知邮件
if (StringHelper.isEmpty(address)) {
if (log.isTraceEnable()) {
log.warn(this, "Threadanalysis notify mail Send FAIL as email addresses is EMPTY or INVALID!");
}
return false;
}
ActionContext ac = new ActionContext();
ac.putParam("event", notifyEvent);
ac.putParam(NCConstant.ACTIONVALUE, address);
ac.putParam("mailTemplatePath", "config/JTAmail.template");
ac.putParam("mailTitle", "【UAV预警】线程分析执行通知");
ac = engine.execute(NCConstant.ACTION4MAIL, ac);
return ac.isSucessful();
}
use of com.creditease.agent.spi.ActionContext in project uavstack by uavorg.
the class UpgradeOperationRecordConsumer method handleOperationRecord.
public void handleOperationRecord(String upgradeInfo) {
EndAction endAction = new EndAction(this.feature, null, null);
try {
parseOldUpgradeRecord(feature, upgradeInfo);
} catch (Exception e) {
if (log.isTraceEnable()) {
log.err(this, "Failed to parse upgrade record", e);
}
endAction.stopUpgradeProcess();
}
int length = this.recordList.size();
if (length <= 1) {
endAction.stopUpgradeProcess();
}
endAction = new EndAction(this.feature, this.upgradeContext, this.engine);
if (!upgradeContext.getFileLock()) {
if (log.isTraceEnable()) {
log.warn(this, "Failed to get upgrade file lock");
}
endAction.stopUpgradeProcess();
}
UpgradeOperationRecord record = this.recordList.get(length - 1);
if (upgradeContext.needRollback(record.getPhase())) {
if (upgradeContext.isUAVContext()) {
handleUAVOperationRecord(record, endAction);
} else {
handleThirdPartySoftwareOperationRecord(record);
}
return;
}
endAction.doAction(new ActionContext());
}
Aggregations