diff --git a/elastic-job-doc/content/post/release_notes.md b/elastic-job-doc/content/post/release_notes.md index ea80eb219d..08989f5eeb 100644 --- a/elastic-job-doc/content/post/release_notes.md +++ b/elastic-job-doc/content/post/release_notes.md @@ -9,7 +9,12 @@ weight=1 ## 2.0.4-SNAPSHOT +### 缺陷修正 + +1. [ISSUE #189](https://github.com/dangdangdotcom/elastic-job/issues/189) 管理后台执行失效操作,但任务还在执行 + ### 功能提升 + 1. [ISSUE #187](https://github.com/dangdangdotcom/elastic-job/issues/187) ShardingContext中增加taskId属性,供业务方使用 ## 2.0.3 diff --git a/elastic-job-lite/elastic-job-lite-core/src/main/java/com/dangdang/ddframe/job/lite/internal/sharding/ShardingService.java b/elastic-job-lite/elastic-job-lite-core/src/main/java/com/dangdang/ddframe/job/lite/internal/sharding/ShardingService.java index dd22de0d37..012d1640ec 100644 --- a/elastic-job-lite/elastic-job-lite-core/src/main/java/com/dangdang/ddframe/job/lite/internal/sharding/ShardingService.java +++ b/elastic-job-lite/elastic-job-lite-core/src/main/java/com/dangdang/ddframe/job/lite/internal/sharding/ShardingService.java @@ -98,6 +98,7 @@ public boolean isNeedSharding() { public void shardingIfNecessary() { List availableShardingServers = serverService.getAvailableShardingServers(); if (availableShardingServers.isEmpty()) { + clearShardingInfo(); return; } if (!isNeedSharding()) { diff --git a/elastic-job-lite/elastic-job-lite-core/src/test/java/com/dangdang/ddframe/job/lite/internal/sharding/ShardingServiceTest.java b/elastic-job-lite/elastic-job-lite-core/src/test/java/com/dangdang/ddframe/job/lite/internal/sharding/ShardingServiceTest.java index f2c93f7c0e..6fc89bbc2f 100644 --- a/elastic-job-lite/elastic-job-lite-core/src/test/java/com/dangdang/ddframe/job/lite/internal/sharding/ShardingServiceTest.java +++ b/elastic-job-lite/elastic-job-lite-core/src/test/java/com/dangdang/ddframe/job/lite/internal/sharding/ShardingServiceTest.java @@ -113,9 +113,13 @@ public void assertShardingWhenUnnecessary() { @Test public void assertShardingWithoutAvailableServers() { + when(serverService.getAllServers()).thenReturn(Arrays.asList("ip1", "ip2")); when(serverService.getAvailableShardingServers()).thenReturn(Collections.emptyList()); shardingService.shardingIfNecessary(); verify(serverService).getAvailableShardingServers(); + verify(serverService).getAllServers(); + verify(jobNodeStorage).removeJobNodeIfExisted("servers/ip1/sharding"); + verify(jobNodeStorage).removeJobNodeIfExisted("servers/ip2/sharding"); verify(jobNodeStorage, times(0)).isJobNodeExisted("leader/sharding/necessary"); }