Search in sources :

Example 16 with AgentFeatureComponent

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

the class LogProfileDataNotifyHandler method handle.

@Override
public void handle(MonitorDataFrame profileData) {
    /**
     * find out the logagent feature component and exchange the MDF
     */
    AgentFeatureComponent afc = (AgentFeatureComponent) this.getConfigManager().getComponent("logagent", "LogAgent");
    /**
     * NOTE:both JMX and Http Scan supported
     */
    DetectorManager asmd = (DetectorManager) this.getConfigManager().getComponent(this.feature, "AppServerMonitorDetector_TimerWorker");
    if (null != afc && null != asmd) {
        JVMAgentInfo jvmAgentInfo = asmd.getJVMAgentInfo(profileData.getServerId());
        if (null == jvmAgentInfo) {
            log.warn(this, "can't find jvm agent info for serverid [" + profileData.getServerId() + "], the jvm may be dead.");
            return;
        }
        afc.exchange("logagent.profiledata.notify", profileData, jvmAgentInfo);
    } else {
        log.warn(this, "can't find agent feature component [logagent], this feature may not start. LogAgent-null(" + (afc == null) + "), DetectorManager-null(" + (asmd == null) + ")");
    }
}
Also used : JVMAgentInfo(com.creditease.agent.helpers.jvmtool.JVMAgentInfo) DetectorManager(com.creditease.agent.feature.monitoragent.detect.DetectorManager) AgentFeatureComponent(com.creditease.agent.spi.AgentFeatureComponent)

Example 17 with AgentFeatureComponent

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

the class LogNodeOperAction method doAction.

@Override
public void doAction(ActionContext context) throws Exception {
    AgentFeatureComponent afc = (AgentFeatureComponent) getConfigManager().getComponent(feature, "LogAgent");
    if (afc == null) {
        return;
    }
    UAVHttpMessage data = (UAVHttpMessage) context.getParam("msg");
    String strategy = data.getRequest("strategy");
    try {
        afc.exchange("logagent.strategy", strategy);
        data.putResponse("rs", "OK");
    } catch (Exception e) {
        log.err(this, "exchange logagent strategy FAILED. " + strategy, e);
        data.putResponse("rs", "ERR");
        data.putResponse("msg", "设置日志抓取策略出错!");
    }
}
Also used : UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage) AgentFeatureComponent(com.creditease.agent.spi.AgentFeatureComponent)

Example 18 with AgentFeatureComponent

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

the class RuntimeDataMessageHandler method handle.

@Override
public void handle(Message msg) {
    String dataStream = msg.getParam(getMsgTypeName());
    AgentFeatureComponent rn = (AgentFeatureComponent) ConfigurationManager.getInstance().getComponent("runtimenotify", "RuntimeNotifyCatcher");
    if (rn != null) {
        rn.exchange("runtime.notify", dataStream, false);
    }
}
Also used : AgentFeatureComponent(com.creditease.agent.spi.AgentFeatureComponent)

Example 19 with AgentFeatureComponent

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

the class NotificationMessageHandler method handle.

@Override
public void handle(Message msg) {
    super.handle(msg);
    // exchange msg to NotifyCenter
    AgentFeatureComponent afc = (AgentFeatureComponent) ConfigurationManager.getInstance().getComponent("notifycenter", "NotificationCenter");
    if (null != afc) {
        String notifyDataArrayStr = msg.getParam(getMsgTypeName());
        afc.exchange("notify.center.put", notifyDataArrayStr);
    }
}
Also used : AgentFeatureComponent(com.creditease.agent.spi.AgentFeatureComponent)

Example 20 with AgentFeatureComponent

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

the class MOFCtrlAction method doCollectFiles.

/**
 * Do Action which require Collect Client
 *
 * @param data
 * @param response
 * @param collectAct
 */
@SuppressWarnings("unchecked")
private void doCollectFiles(UAVHttpMessage data, final StringBuilder response, String rootPath) {
    AgentFeatureComponent afc = (AgentFeatureComponent) this.getConfigManager().getComponent("collectclient", "CollectDataAgent");
    if (afc == null) {
        data.putResponse("rs", "ERR");
        data.putResponse("msg", "归集客户端未启动");
        return;
    }
    String collectAct = data.getRequest("collectact");
    Map<String, String> respObj = JSONHelper.toObject(response.toString(), Map.class);
    File rootFile = new File(respObj.get(rootPath));
    String filePattern = rootFile.getAbsolutePath().replace("\\", "/") + "/" + data.getRequest("file") + ".0.log";
    String appUUID = data.getRequest("appuuid");
    String mqTopic = data.getRequest("mq");
    String collectTasks = "{\"tasks\": [ {\"target\": \"" + appUUID + "\", \"action\": \"" + mqTopic + "\", \"file\": \"" + filePattern + "\", \"topic\":\"" + mqTopic + "\"} ]}";
    afc.exchange(collectAct, collectTasks);
    data.putResponse("rs", "OK");
    data.putResponse("msg", respObj.get("rs"));
}
Also used : File(java.io.File) AgentFeatureComponent(com.creditease.agent.spi.AgentFeatureComponent)

Aggregations

AgentFeatureComponent (com.creditease.agent.spi.AgentFeatureComponent)25 Map (java.util.Map)6 HashMap (java.util.HashMap)5 LinkedHashMap (java.util.LinkedHashMap)4 OSProcess (com.creditease.agent.helpers.osproc.OSProcess)3 List (java.util.List)3 UAVHttpMessage (com.creditease.agent.http.api.UAVHttpMessage)2 ArrayList (java.util.ArrayList)2 NodeInfo (com.creditease.agent.feature.hbagent.node.NodeInfo)1 DetectorManager (com.creditease.agent.feature.monitoragent.detect.DetectorManager)1 JVMAgentInfo (com.creditease.agent.helpers.jvmtool.JVMAgentInfo)1 MonitorDataFrame (com.creditease.agent.monitor.api.MonitorDataFrame)1 AgentResourceComponent (com.creditease.agent.spi.AgentResourceComponent)1 DataStoreMsg (com.creditease.uav.datastore.api.DataStoreMsg)1 Message (com.creditease.uav.messaging.api.Message)1 MessageProducer (com.creditease.uav.messaging.api.MessageProducer)1 File (java.io.File)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1