Search in sources :

Example 11 with JobConfig

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

the class ZkJobRegistry method unregister.

@Override
public synchronized void unregister(String jobName) {
    JobConfig config = schedulerConfgs.get(jobName);
    String path = getPath(config);
    if (zkClient.getChildren(nodeStateParentPath).size() == 1) {
        zkClient.delete(path);
        logger.info("all node is closed ,delete path:" + path);
    }
}
Also used : JobConfig(com.jeesuite.scheduler.model.JobConfig)

Example 12 with JobConfig

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

the class ZkJobRegistry method rebalanceJobNode.

/**
 * 重新分配执行节点
 * @param nodes
 */
private synchronized void rebalanceJobNode(List<String> nodes) {
    while (updatingStatus) ;
    Collection<JobConfig> jobs = schedulerConfgs.values();
    int nodeIndex = 0;
    for (JobConfig job : jobs) {
        String nodeId = nodes.get(nodeIndex++);
        if (!StringUtils.equals(job.getCurrentNodeId(), nodeId)) {
            job.setCurrentNodeId(nodeId);
            logger.info("rebalance Job[{}-{}] To Node[{}] ", job.getGroupName(), job.getJobName(), nodeId);
        }
        if (nodeIndex >= nodes.size()) {
            nodeIndex = 0;
        }
        // 
        updateJobConfig(job);
    }
}
Also used : JobConfig(com.jeesuite.scheduler.model.JobConfig)

Aggregations

JobConfig (com.jeesuite.scheduler.model.JobConfig)12 AbstractJob (com.jeesuite.scheduler.AbstractJob)1 JobGroupInfo (com.jeesuite.scheduler.model.JobGroupInfo)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1 IZkDataListener (org.I0Itec.zkclient.IZkDataListener)1 ZkClient (org.I0Itec.zkclient.ZkClient)1 ZkConnection (org.I0Itec.zkclient.ZkConnection)1 CronExpression (org.quartz.CronExpression)1 SchedulerException (org.quartz.SchedulerException)1 TriggerKey (org.quartz.TriggerKey)1