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));
}
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;
}
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;
}
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;
}
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;
}
Aggregations