Search in sources :

Example 1 with BaseMonitorDataCatchWorker

use of com.creditease.agent.feature.monitoragent.datacatch.BaseMonitorDataCatchWorker in project uavstack by uavorg.

the class BaseDetector method addWorker.

/**
 * start a new data catch worker to one target appserver
 *
 * @param appServerInfo
 */
protected void addWorker(JVMAgentInfo appServerInfo) {
    String processId = appServerInfo.getId();
    String workerName = "MO-" + processId;
    if (this.workers.containsKey(workerName)) {
        /**
         * If the worker exists, just update the appServerInfo this is the hyperspace dark tech, hehe, hehe, hehe :)
         */
        if (this.cName.equals(this.workers.get(workerName).getDetectorName())) {
            this.workers.get(workerName).setAppServerInfo(appServerInfo);
        }
        return;
    }
    // start data catch worker
    // match JVM Type
    String jvmType = "unknown";
    String jvmTypeTmp = this.matchJVMType(appServerInfo);
    if (!StringHelper.isEmpty(jvmTypeTmp)) {
        jvmType = jvmTypeTmp;
    }
    BaseMonitorDataCatchWorker worker = newWoker(appServerInfo, workerName, jvmType);
    if (worker == null) {
        return;
    }
    int res = worker.start();
    if (res == -1) {
        worker.cancel();
        return;
    }
    /**
     * the app server with out UAV MonitorFramework
     */
    if (res == 0) {
        worker = newWoker(appServerInfo, workerName, "unknown");
        if (worker.start() == -1) {
            worker.cancel();
            return;
        }
    }
    this.getTimerWorkManager().scheduleWork(workerName, worker, 0, monitorInterval);
    // save this worker
    this.workers.put(workerName, worker);
    // save appserverinfo
    this.jvmAgentInfos.put(worker.getWorkerId(), appServerInfo);
    log.info(this, worker.getClass().getSimpleName() + "[" + workerName + "] started");
}
Also used : BaseMonitorDataCatchWorker(com.creditease.agent.feature.monitoragent.datacatch.BaseMonitorDataCatchWorker)

Example 2 with BaseMonitorDataCatchWorker

use of com.creditease.agent.feature.monitoragent.datacatch.BaseMonitorDataCatchWorker in project uavstack by uavorg.

the class BaseDetector method stop.

public void stop() {
    log.info(this, "AppServerMonitorDetector[" + this.cName + "] stopped");
    // cancel all worker timer
    for (BaseMonitorDataCatchWorker worker : workers.values()) {
        // cancel worker
        worker.cancel();
        this.jvmAgentInfos.remove(worker.getWorkerId());
        log.info(this, "MonitorDataCatchWorker[" + worker.getName() + "] stopped");
    }
    workers.clear();
}
Also used : BaseMonitorDataCatchWorker(com.creditease.agent.feature.monitoragent.datacatch.BaseMonitorDataCatchWorker)

Example 3 with BaseMonitorDataCatchWorker

use of com.creditease.agent.feature.monitoragent.datacatch.BaseMonitorDataCatchWorker in project uavstack by uavorg.

the class BaseDetector method newWoker.

/**
 * Create a new DataCatchWorker
 *
 * @param appServerInfo
 * @param workerName
 * @param jvmType
 * @return
 */
private BaseMonitorDataCatchWorker newWoker(JVMAgentInfo appServerInfo, String workerName, String jvmType) {
    BaseMonitorDataCatchWorker worker = null;
    String bmdcWorkerCls = workerTypeClsMap.get(jvmType);
    if (bmdcWorkerCls == null) {
        return worker;
    }
    worker = (BaseMonitorDataCatchWorker) ReflectionHelper.newInstance(bmdcWorkerCls, new Class<?>[] { String.class, String.class, JVMAgentInfo.class, BaseDetector.class }, new Object[] { workerName, this.feature, appServerInfo, this }, this.getConfigManager().getFeatureClassLoader(this.feature));
    return worker;
}
Also used : BaseMonitorDataCatchWorker(com.creditease.agent.feature.monitoragent.datacatch.BaseMonitorDataCatchWorker)

Example 4 with BaseMonitorDataCatchWorker

use of com.creditease.agent.feature.monitoragent.datacatch.BaseMonitorDataCatchWorker in project uavstack by uavorg.

the class BaseDetector method removeWorker.

public void removeWorker(String workName) {
    if (workName == null) {
        return;
    }
    if (this.workers.containsKey(workName)) {
        BaseMonitorDataCatchWorker worker = this.workers.remove(workName);
        worker.cancel();
        this.jvmAgentInfos.remove(worker.getWorkerId());
        log.info(this, "MonitorDataCatchWorker[" + worker.getName() + "] stopped");
    }
}
Also used : BaseMonitorDataCatchWorker(com.creditease.agent.feature.monitoragent.datacatch.BaseMonitorDataCatchWorker)

Example 5 with BaseMonitorDataCatchWorker

use of com.creditease.agent.feature.monitoragent.datacatch.BaseMonitorDataCatchWorker in project uavstack by uavorg.

the class JVMContainerOSDetector method workerExist.

/**
 * check if the worker for this appServer exist
 */
public boolean workerExist(String pid, String url, List<String> urlList) {
    String JVMAccessURL = url + UAV_MOF_ROOT;
    for (BaseMonitorDataCatchWorker worker : workers.values()) {
        JVMAgentInfo appServerInfo = jvmAgentInfos.get(worker.getWorkerId());
        if (appServerInfo != null && JVMAccessURL.equals((appServerInfo.getJVMAccessURL()))) {
            urlList.clear();
            if (!pid.equals(appServerInfo.getId())) {
                // remove worker whose JVMAccessURL is the same but pid changes(usually restart)
                removeWorker(worker.getName());
                urlList.add(url);
            }
            return true;
        }
    }
    urlList.add(url);
    return false;
}
Also used : BaseMonitorDataCatchWorker(com.creditease.agent.feature.monitoragent.datacatch.BaseMonitorDataCatchWorker) JVMAgentInfo(com.creditease.agent.helpers.jvmtool.JVMAgentInfo)

Aggregations

BaseMonitorDataCatchWorker (com.creditease.agent.feature.monitoragent.datacatch.BaseMonitorDataCatchWorker)5 JVMAgentInfo (com.creditease.agent.helpers.jvmtool.JVMAgentInfo)1