Skip to content

Commit

Permalink
Fixed #272.
Browse files Browse the repository at this point in the history
  • Loading branch information
haocao committed Apr 11, 2017
1 parent 02789b2 commit 31633eb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions elastic-job-doc/content/post/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ weight=1

1. [ISSUE #266](https://github.com/dangdangdotcom/elastic-job/issues/266) Elastic-Job-Lite启动脚本指定端口无效
1. [ISSUE #269](https://github.com/dangdangdotcom/elastic-job/issues/269) EventTrace失败记录不受采样率影响并且记录失败时间
1. [ISSUE #272](https://github.com/dangdangdotcom/elastic-job/issues/272) Elastic-Job-Lite界面作业维度,只有全部服务器被禁用时,才应显示为被禁用

## 2.1.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,14 @@ private JobStatus getJobStatus(final String jobName) {
if (!instances.containsAll(shardingInstances) || shardingInstances.isEmpty()) {
return JobStatus.SHARDING_ERROR;
}
for (String each : regCenter.getChildrenKeys(jobNodePath.getServerNodePath())) {
List<String> serversPath = regCenter.getChildrenKeys(jobNodePath.getServerNodePath());
int disabledServerCount = 0;
for (String each : serversPath) {
if ("DISABLED".equals(regCenter.get(jobNodePath.getServerNodePath(each)))) {
return JobStatus.DISABLED;
disabledServerCount++;
}
}
return JobStatus.OK;
return disabledServerCount == serversPath.size() ? JobStatus.DISABLED : JobStatus.OK;
}

private int getJobInstanceCount(final String jobName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void assertGetJobsTotalCount() {
}

@Test
public void assertGetJobBriefInfo() {
public void assertGetOKJobBriefInfo() {
when(regCenter.getChildrenKeys("/")).thenReturn(Lists.newArrayList("test_job"));
when(regCenter.get("/test_job/config")).thenReturn(LifecycleJsonConstants.getSimpleJobJson("test_job", "desc"));
when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("ip1", "ip2"));
Expand All @@ -73,12 +73,27 @@ public void assertGetJobBriefInfo() {
assertThat(jobBrief.getStatus(), is(JobStatus.OK));
}

@Test
public void assertGetOKJobBriefInfoWithPartialDisabledServer() {
when(regCenter.getChildrenKeys("/")).thenReturn(Lists.newArrayList("test_job"));
when(regCenter.get("/test_job/config")).thenReturn(LifecycleJsonConstants.getSimpleJobJson("test_job", "desc"));
when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("ip1", "ip2"));
when(regCenter.get("/test_job/servers/ip1")).thenReturn("DISABLED");
when(regCenter.getChildrenKeys("/test_job/instances")).thenReturn(Arrays.asList("ip1@-@defaultInstance", "ip2@-@defaultInstance"));
when(regCenter.getChildrenKeys("/test_job/sharding")).thenReturn(Arrays.asList("0", "1"));
when(regCenter.get("/test_job/sharding/0/instance")).thenReturn("ip1@-@defaultInstance");
when(regCenter.get("/test_job/sharding/1/instance")).thenReturn("ip2@-@defaultInstance");
JobBriefInfo jobBrief = jobStatisticsAPI.getJobBriefInfo("test_job");
assertThat(jobBrief.getStatus(), is(JobStatus.OK));
}

@Test
public void assertGetDisabledJobBriefInfo() {
when(regCenter.getChildrenKeys("/")).thenReturn(Lists.newArrayList("test_job"));
when(regCenter.get("/test_job/config")).thenReturn(LifecycleJsonConstants.getSimpleJobJson("test_job", "desc"));
when(regCenter.getChildrenKeys("/test_job/servers")).thenReturn(Arrays.asList("ip1", "ip2"));
when(regCenter.get("/test_job/servers/ip1")).thenReturn("DISABLED");
when(regCenter.get("/test_job/servers/ip2")).thenReturn("DISABLED");
when(regCenter.getChildrenKeys("/test_job/instances")).thenReturn(Arrays.asList("ip1@-@defaultInstance", "ip2@-@defaultInstance"));
when(regCenter.getChildrenKeys("/test_job/sharding")).thenReturn(Arrays.asList("0", "1"));
when(regCenter.get("/test_job/sharding/0/instance")).thenReturn("ip1@-@defaultInstance");
Expand Down

0 comments on commit 31633eb

Please sign in to comment.