Search in sources :

Example 11 with AgentFeatureComponent

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

the class SystemStarter method startComponent.

/**
 * @param featureName
 * @param cl
 * @param components
 */
private void startComponent(String featureName, ClassLoader cl, String[] components) {
    for (String component : components) {
        try {
            // load component class
            Class<?> componentClass = cl.loadClass(component);
            // check if component class extends AgentFeatureComponent
            if (!AgentFeatureComponent.class.isAssignableFrom(componentClass)) {
                continue;
            }
            // get constructor
            Constructor<?> con = componentClass.getConstructor(new Class<?>[] { String.class, String.class });
            // new component instance
            AgentFeatureComponent afc = (AgentFeatureComponent) con.newInstance(new Object[] { componentClass.getSimpleName(), featureName });
            // start the component
            afc.start();
            log.info(this, "start feature [" + featureName + "] component [" + component + "] SUCCESS");
        } catch (RuntimeException e) {
            log.err(this, "start feature [" + featureName + "] component [" + component + "] FAILs ", e);
        } catch (Exception e) {
            log.err(this, "start feature [" + featureName + "] component [" + component + "] FAILs ", e);
        }
    }
}
Also used : AgentFeatureComponent(com.creditease.agent.spi.AgentFeatureComponent)

Example 12 with AgentFeatureComponent

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

the class CollectNodeOperAction method doAction.

@Override
public void doAction(ActionContext context) throws Exception {
    AgentFeatureComponent afc = (AgentFeatureComponent) getConfigManager().getComponent("collectclient", "CollectDataAgent");
    if (afc == null) {
        return;
    }
    UAVHttpMessage data = (UAVHttpMessage) context.getParam("msg");
    String cmd = data.getRequest().get("cmd");
    if ("add".equals(cmd)) {
        afc.exchange("collectdata.add", data.getRequest().get("task"));
    } else if ("del".equals(cmd)) {
        afc.exchange("collectdata.del", data.getRequest().get("task"));
    } else if ("status".equals(cmd)) {
        String status = (String) afc.exchange("collectdata.status", cmd);
        data.putResponse(UAVHttpMessage.RESULT, status);
    }
}
Also used : UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage) AgentFeatureComponent(com.creditease.agent.spi.AgentFeatureComponent)

Example 13 with AgentFeatureComponent

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

the class LogDataMessageHandler method handle.

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

Example 14 with AgentFeatureComponent

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

the class SystemStarter method stop.

public void stop() {
    Set<Object> components = this.configMgr.getComponents();
    for (Object component : components) {
        if (AgentFeatureComponent.class.isAssignableFrom(component.getClass())) {
            AgentFeatureComponent afc = (AgentFeatureComponent) component;
            try {
                afc.stop();
                // this.configMgr.unregisterComponent(afc.getFeature(), afc.getName());
                log.info(this, "stop feature [" + afc.getFeature() + "] component [" + afc.getName() + "] SUCCESS");
            } catch (Exception e) {
                log.err(this, "stop feature [" + afc.getFeature() + "] component [" + afc.getName() + "] FAILs ", e);
            }
        } else if (AgentResourceComponent.class.isAssignableFrom(component.getClass())) {
            AgentResourceComponent arc = (AgentResourceComponent) component;
            try {
                arc.releaseResource();
                // this.configMgr.unregisterComponent(arc.getFeature(), arc.getClass().getSimpleName());
                log.info(this, "stop resource [" + arc.getFeature() + "] component [" + arc.getName() + "] SUCCESS");
            } catch (Exception e) {
                log.err(this, "stop resource [" + arc.getFeature() + "] component [" + arc.getName() + "] FAILs ", e);
            }
        }
    }
    if (sysInvokerMgr != null) {
        sysInvokerMgr.shutdown();
        this.configMgr.unregisterComponent("Global", "ISystemInvokerMgr");
        log.info(this, "System Invoker Manager shutdown");
    }
    if (sysForkjoinWorkerMgr != null) {
        sysForkjoinWorkerMgr.shutdown();
        this.configMgr.unregisterComponent("Global", "I1NQueueWorkerMgr");
        log.info(this, "System ForkjoinWorker Manager shutdown");
    }
    if (sys1nQueueWorkerMgr != null) {
        sys1nQueueWorkerMgr.shutdown();
        this.configMgr.unregisterComponent("Global", "I1NQueueWorkerMgr");
        log.info(this, "System 1+N QueueWorker Manager shutdown");
    }
    if (sysActionEngineMgr != null) {
        sysActionEngineMgr.shutdown();
        this.configMgr.unregisterComponent("Global", "ISystemActionEngineMgr");
        log.info(this, "System ActionEngine Manager shutdown");
    }
    if (timerWorkManager != null) {
        timerWorkManager.shutdown();
        this.configMgr.unregisterComponent("Global", "ITimerWorkManager");
        log.info(this, "System Timer Manager shutdown");
    }
    log.info(this, "CreditEase Agent Server stopped");
}
Also used : AgentResourceComponent(com.creditease.agent.spi.AgentResourceComponent) AgentFeatureComponent(com.creditease.agent.spi.AgentFeatureComponent)

Example 15 with AgentFeatureComponent

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

the class SystemStarter method uninstallFeature.

/**
 * uninstallFeature
 *
 * @param featureName
 * @return
 */
public boolean uninstallFeature(String featureName) {
    for (Object afcObj : this.configMgr.getComponents()) {
        if (!AgentFeatureComponent.class.isAssignableFrom(afcObj.getClass())) {
            continue;
        }
        AgentFeatureComponent afcAC = (AgentFeatureComponent) afcObj;
        String f = afcAC.getFeature();
        if (f.equalsIgnoreCase(featureName)) {
            try {
                // stop
                afcAC.stop();
            // unregister
            // this.configMgr.unregisterComponent(afcAC.getFeature(), afcAC.getName());
            } catch (Exception e) {
                log.err(this, "stop feature[" + f + "] component[" + afcAC.getName() + "] FAIL.", e);
                return false;
            }
        }
    }
    // 卸载feaure classloader
    this.configMgr.unsetFeatureClassLoader(featureName);
    return true;
}
Also used : 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