Search in sources :

Example 6 with JobNodePath

use of com.dangdang.ddframe.job.lite.internal.storage.JobNodePath in project elastic-job by dangdangdotcom.

the class JobSettingsAPIImpl method updateJobSettings.

@Override
public void updateJobSettings(final JobSettings jobSettings) {
    JobNodePath jobNodePath = new JobNodePath(jobSettings.getJobName());
    regCenter.update(jobNodePath.getConfigNodePath(), LiteJobConfigurationGsonFactory.toJsonForObject(jobSettings));
}
Also used : JobNodePath(com.dangdang.ddframe.job.lite.internal.storage.JobNodePath)

Example 7 with JobNodePath

use of com.dangdang.ddframe.job.lite.internal.storage.JobNodePath in project elastic-job by dangdangdotcom.

the class JobStatisticsAPIImpl method getJobServer.

private ServerInfo getJobServer(final String jobName, final String serverIp) {
    ServerInfo result = new ServerInfo();
    JobNodePath jobNodePath = new JobNodePath(jobName);
    result.setJobName(jobName);
    result.setIp(serverIp);
    result.setHostName(regCenter.get(jobNodePath.getServerNodePath(serverIp, "hostName")));
    result.setSharding(regCenter.get(jobNodePath.getServerNodePath(serverIp, "sharding")));
    result.setStatus(getServerStatus(jobName, serverIp));
    return result;
}
Also used : ServerInfo(com.dangdang.ddframe.job.lite.lifecycle.domain.ServerInfo) JobNodePath(com.dangdang.ddframe.job.lite.internal.storage.JobNodePath)

Example 8 with JobNodePath

use of com.dangdang.ddframe.job.lite.internal.storage.JobNodePath in project elastic-job by dangdangdotcom.

the class JobStatisticsAPIImpl method getServers.

@Override
public Collection<ServerInfo> getServers(final String jobName) {
    JobNodePath jobNodePath = new JobNodePath(jobName);
    List<String> serverIps = regCenter.getChildrenKeys(jobNodePath.getServerNodePath());
    Collection<ServerInfo> result = new ArrayList<>(serverIps.size());
    for (String each : serverIps) {
        result.add(getJobServer(jobName, each));
    }
    return result;
}
Also used : ServerInfo(com.dangdang.ddframe.job.lite.lifecycle.domain.ServerInfo) ArrayList(java.util.ArrayList) JobNodePath(com.dangdang.ddframe.job.lite.internal.storage.JobNodePath)

Example 9 with JobNodePath

use of com.dangdang.ddframe.job.lite.internal.storage.JobNodePath in project elastic-job by dangdangdotcom.

the class JobStatisticsAPIImpl method getJobBriefInfo.

@Override
public JobBriefInfo getJobBriefInfo(final String jobName) {
    JobNodePath jobNodePath = new JobNodePath(jobName);
    JobBriefInfo result = new JobBriefInfo();
    result.setJobName(jobName);
    String liteJobConfigJson = regCenter.get(jobNodePath.getConfigNodePath());
    if (null == liteJobConfigJson) {
        return null;
    }
    LiteJobConfiguration liteJobConfig = LiteJobConfigurationGsonFactory.fromJson(liteJobConfigJson);
    result.setJobType(liteJobConfig.getTypeConfig().getJobType().name());
    result.setDescription(liteJobConfig.getTypeConfig().getCoreConfig().getDescription());
    result.setStatus(getJobStatus(jobName));
    result.setCron(liteJobConfig.getTypeConfig().getCoreConfig().getCron());
    return result;
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) JobBriefInfo(com.dangdang.ddframe.job.lite.lifecycle.domain.JobBriefInfo) JobNodePath(com.dangdang.ddframe.job.lite.internal.storage.JobNodePath)

Example 10 with JobNodePath

use of com.dangdang.ddframe.job.lite.internal.storage.JobNodePath in project elastic-job by dangdangdotcom.

the class ServerStatisticsAPIImpl method getAllServersBriefInfo.

@Override
public Collection<ServerBriefInfo> getAllServersBriefInfo() {
    Map<String, String> serverHostMap = new HashMap<>();
    Collection<String> aliveServers = new ArrayList<>();
    Collection<String> crashedServers = new ArrayList<>();
    List<String> jobs = regCenter.getChildrenKeys("/");
    for (String jobName : jobs) {
        JobNodePath jobNodePath = new JobNodePath(jobName);
        List<String> servers = regCenter.getChildrenKeys(jobNodePath.getServerNodePath());
        for (String server : servers) {
            serverHostMap.put(server, regCenter.get(jobNodePath.getServerNodePath(server, "hostName")));
            if (!regCenter.isExisted(jobNodePath.getServerNodePath(server, "shutdown")) && regCenter.isExisted(jobNodePath.getServerNodePath(server, "status"))) {
                aliveServers.add(server);
            } else {
                crashedServers.add(server);
            }
        }
    }
    List<ServerBriefInfo> result = new ArrayList<>(serverHostMap.size());
    for (Map.Entry<String, String> entry : serverHostMap.entrySet()) {
        result.add(getServerBriefInfo(aliveServers, crashedServers, entry.getKey(), entry.getValue()));
    }
    Collections.sort(result);
    return result;
}
Also used : HashMap(java.util.HashMap) ServerBriefInfo(com.dangdang.ddframe.job.lite.lifecycle.domain.ServerBriefInfo) ArrayList(java.util.ArrayList) JobNodePath(com.dangdang.ddframe.job.lite.internal.storage.JobNodePath) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

JobNodePath (com.dangdang.ddframe.job.lite.internal.storage.JobNodePath)12 ArrayList (java.util.ArrayList)5 ServerInfo (com.dangdang.ddframe.job.lite.lifecycle.domain.ServerInfo)4 LiteJobConfiguration (com.dangdang.ddframe.job.lite.config.LiteJobConfiguration)2 ExecutionInfo (com.dangdang.ddframe.job.lite.lifecycle.domain.ExecutionInfo)1 JobBriefInfo (com.dangdang.ddframe.job.lite.lifecycle.domain.JobBriefInfo)1 JobSettings (com.dangdang.ddframe.job.lite.lifecycle.domain.JobSettings)1 ServerBriefInfo (com.dangdang.ddframe.job.lite.lifecycle.domain.ServerBriefInfo)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1