use of com.creditease.agent.spi.IActionEngine in project uavstack by uavorg.
the class SystemActionEngineMgr method newActionEngine.
@Override
public IActionEngine newActionEngine(String actionEngineID, String feature) {
if (aeMap.containsKey(actionEngineID)) {
shutdown(actionEngineID);
}
IActionEngine ae = new ActionEngine(actionEngineID, feature);
aeMap.put(actionEngineID, ae);
return ae;
}
use of com.creditease.agent.spi.IActionEngine in project uavstack by uavorg.
the class SystemActionEngineMgr method shutdown.
private void shutdown(String actionEngineID, boolean removeAE) {
if (aeMap.containsKey(actionEngineID)) {
IActionEngine ae;
if (removeAE) {
ae = aeMap.remove(actionEngineID);
} else {
ae = aeMap.get(actionEngineID);
}
ae.clean();
// unregister actionEngine
ConfigurationManager.getInstance().unregisterComponent(((ActionEngine) ae).getFeature(), actionEngineID);
}
}
use of com.creditease.agent.spi.IActionEngine in project uavstack by uavorg.
the class HealthManager method start.
@Override
public void start() {
// init cache manager
String cacheServerAddress = this.getConfigManager().getFeatureConfiguration(this.feature, "store.addr");
int minConcurrent = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.min"));
int maxConcurrent = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.max"));
int queueSize = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.bqsize"));
String password = this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.pwd");
CacheManager cm = CacheManagerFactory.build(cacheServerAddress, minConcurrent, maxConcurrent, queueSize, password);
this.getConfigManager().registerComponent(this.feature, "HMCacheManager", cm);
// start HealthManagerProfileDataLifeKeeper
isStartLifeKeeper = Boolean.parseBoolean(this.getConfigManager().getFeatureConfiguration(this.feature, "lifekeeper.enable"));
if (isStartLifeKeeper == true) {
// init HealthManagerProfileDataLifeKeeper
HealthManagerProfileDataLifeKeeper profileDataLifeKeepWorker = new HealthManagerProfileDataLifeKeeper("HealthManagerProfileDataLifeKeeper", this.feature);
long interval = Long.parseLong(this.getConfigManager().getFeatureConfiguration(this.feature, "lifekeeper.interval"));
long randomDely = new Random().nextInt(3) + 3;
this.getTimerWorkManager().scheduleWorkInPeriod("HealthManagerProfileDataLifeKeeper", profileDataLifeKeepWorker, randomDely * 1000, interval);
if (log.isTraceEnable()) {
log.info(this, "HealthManagerProfileDataLifeKeeper started");
}
}
/**
* Start the DBStore service NOTE: this must be the first to start
*/
buildDataStores(this.getConfigManager());
// start all datastores
DataStoreFactory.getInstance().startAll(this.feature);
if (log.isTraceEnable()) {
log.info(this, "HealthManager DataStore Factory started");
}
/**
* Start the HealthManger Http service
*/
int port = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.port"));
int backlog = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.backlog"));
int core = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.core"));
int max = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.max"));
int bqsize = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.bqsize"));
healthServerListenWorker = new HealthManagerServerWorker("HealthMangerServerWorker", this.feature, "healthMangerHandlers");
@SuppressWarnings({ "rawtypes", "unchecked" }) ThreadPoolExecutor exe = new ThreadPoolExecutor(core, max, 30000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(bqsize));
healthServerListenWorker.start(exe, port, backlog);
if (log.isTraceEnable()) {
log.info(this, "HealthManager DataStore HttpServer started");
}
StandardMessagingBuilder smb = new StandardMessagingBuilder("HMCommonMsgBuilder", this.feature);
try {
smb.init("com.creditease.uav.feature.healthmanager.messaging.handlers");
} catch (IOException e) {
log.err(this, "Read msgtype2topic.properties FAILs, HealthManager can not START", e);
return;
}
monitorDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Monitor.toString());
notificationConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Notification.toString());
profileDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Profile.toString());
logDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.Log.toString());
nodeinfoDataConsumer = smb.buildConsumer(MonitorDataFrame.MessageType.NodeInfo.toString());
// start monitorDataConsumer
if (monitorDataConsumer != null) {
monitorDataConsumer.start();
this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_MONITOR, monitorDataConsumer);
if (log.isTraceEnable()) {
log.info(this, "HealthManager MDFConsumer started");
}
}
// start notificationConsumer
if (this.notificationConsumer != null) {
notificationConsumer.start();
this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_NOTIFY, notificationConsumer);
if (log.isTraceEnable()) {
log.info(this, "HealthManager NotifyConsumer started");
}
}
// start profileDataConsumer
if (this.profileDataConsumer != null) {
/**
* INIT StandardProfileModelingEngine & StandardProfileModeler
*/
IActionEngine engine = this.getActionEngineMgr().newActionEngine("StandardProfileModelingEngine", feature);
new StandardProfileModeler("StandardProfileModeler", feature, engine);
// start profile consumer
profileDataConsumer.start();
this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_PROFILE, profileDataConsumer);
if (log.isTraceEnable()) {
log.info(this, "HealthManager ProfileConsumer started");
}
}
// start logDataConsumer
if (this.logDataConsumer != null) {
logDataConsumer.start();
this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_LOG, logDataConsumer);
if (log.isTraceEnable()) {
log.info(this, "HealthManager LogConsumer started");
}
}
// start nodeinfoDataConsumer
if (nodeinfoDataConsumer != null) {
nodeinfoDataConsumer.start();
this.getConfigManager().registerComponent(this.feature, HealthManagerConstants.COMSUMER_NODE, nodeinfoDataConsumer);
if (log.isTraceEnable()) {
log.info(this, "HealthManager NodeInfoConsumer started");
}
}
}
use of com.creditease.agent.spi.IActionEngine 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.IActionEngine in project uavstack by uavorg.
the class NodeOperAgent method start.
@Override
public void start() {
IActionEngine engine = this.getActionEngineMgr().getActionEngine("NodeOperActionEngine");
// setup actions
new MOFInstallMgtAction("installmof", feature, engine);
new MOFInstallMgtAction("uninstallmof", feature, engine);
new MSCPGeneralAction("fstart", feature, engine);
new MSCPGeneralAction("fstop", feature, engine);
new MSCPGeneralAction("killproc", feature, engine);
new MSCPGeneralAction("kill", feature, engine);
new MSCPGeneralAction("shutdown", feature, engine);
new MSCPGeneralAction("chgsyspro", feature, engine);
new MSCPGeneralAction("loadnodepro", feature, engine);
new MSCPGeneralAction("chgnodepro", feature, engine);
new MSCPGeneralAction("watch", feature, engine);
new MSCPGeneralAction("unwatch", feature, engine);
new MSCPGeneralAction("upgrade", feature, engine);
new MSCPGeneralAction("restart", feature, engine);
new MSCPGeneralAction("stopuav", feature, engine);
new MOFCtrlAction("ctrlmof", feature, engine);
// start HeartBeatServerListenWorker
nodeOperHttpServer = new NodeOperHttpServer("NodeOperHttpServer", this.feature, "nodeophandlers");
int port = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.port"), 10101);
int backlog = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.backlog"), 10);
int core = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.core"), 5);
int max = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.max"), 10);
int bqsize = DataConvertHelper.toInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.bqsize"), 10);
@SuppressWarnings({ "rawtypes", "unchecked" }) ThreadPoolExecutor exe = new ThreadPoolExecutor(core, max, 30000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(bqsize));
/**
* if the node ctrl server port conflicts, the node process will exit
*/
nodeOperHttpServer.start(exe, port, backlog, true);
if (log.isTraceEnable()) {
log.info(this, "NodeOperHttpServer started");
}
}
Aggregations