Search in sources :

Example 1 with JobGroupInfo

use of com.jeesuite.scheduler.model.JobGroupInfo in project jeesuite-libs by vakinge.

the class SchedulerMonitor method getAllJobGroups.

public List<JobGroupInfo> getAllJobGroups() {
    // zk registry
    List<JobGroupInfo> result = new ArrayList<>();
    List<String> groupNames = getGroups();
    if (groupNames == null)
        return result;
    for (String groupName : groupNames) {
        JobGroupInfo groupInfo = getJobGroupInfo(groupName);
        if (groupInfo != null) {
            result.add(groupInfo);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) JobGroupInfo(com.jeesuite.scheduler.model.JobGroupInfo)

Example 2 with JobGroupInfo

use of com.jeesuite.scheduler.model.JobGroupInfo in project jeesuite-libs by vakinge.

the class SchedulerMonitor method getJobGroupInfo.

public JobGroupInfo getJobGroupInfo(String groupName) {
    if (StringUtils.isBlank(groupName)) {
        logger.warn("getJobGroupInfo groupName is required");
        return null;
    }
    JobGroupInfo groupInfo = new JobGroupInfo();
    groupInfo.setName(groupName);
    // 
    String path = ZkJobRegistry.ROOT + groupName;
    List<String> children = zkClient.getChildren(path);
    for (String child : children) {
        if ("nodes".equals(child)) {
            path = ZkJobRegistry.ROOT + groupName + "/nodes";
            groupInfo.setClusterNodes(zkClient.getChildren(path));
        } else {
            path = ZkJobRegistry.ROOT + groupName + "/" + child;
            Object data = zkClient.readData(path);
            if (data != null) {
                JobConfig jobConfig = JsonUtils.toObject(data.toString(), JobConfig.class);
                groupInfo.getJobs().add(jobConfig);
            }
        }
    }
    if (groupInfo.getClusterNodes().size() > 0) {
        return groupInfo;
    }
    return null;
}
Also used : JobGroupInfo(com.jeesuite.scheduler.model.JobGroupInfo) JobConfig(com.jeesuite.scheduler.model.JobConfig)

Aggregations

JobGroupInfo (com.jeesuite.scheduler.model.JobGroupInfo)2 JobConfig (com.jeesuite.scheduler.model.JobConfig)1 ArrayList (java.util.ArrayList)1