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