未验证 提交 839d6054 编写于 作者: W Wenjun Ruan 提交者: GitHub

fix dead server cannot stop (#6046)

上级 04720b32
...@@ -47,6 +47,7 @@ import org.apache.curator.framework.recipes.locks.InterProcessMutex; ...@@ -47,6 +47,7 @@ import org.apache.curator.framework.recipes.locks.InterProcessMutex;
import org.apache.curator.retry.ExponentialBackoffRetry; import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.curator.utils.CloseableUtils; import org.apache.curator.utils.CloseableUtils;
import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooDefs; import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.data.ACL; import org.apache.zookeeper.data.ACL;
...@@ -195,12 +196,7 @@ public class ZookeeperRegistry implements Registry { ...@@ -195,12 +196,7 @@ public class ZookeeperRegistry implements Registry {
@Override @Override
public void remove(String key) { public void remove(String key) {
delete(key);
try {
client.delete().deletingChildrenIfNeeded().forPath(key);
} catch (Exception e) {
throw new RegistryException("zookeeper remove error", e);
}
} }
@Override @Override
...@@ -269,6 +265,9 @@ public class ZookeeperRegistry implements Registry { ...@@ -269,6 +265,9 @@ public class ZookeeperRegistry implements Registry {
client.delete() client.delete()
.deletingChildrenIfNeeded() .deletingChildrenIfNeeded()
.forPath(nodePath); .forPath(nodePath);
} catch (KeeperException.NoNodeException ignore) {
// the node is not exist, we can believe the node has been removed
} catch (Exception e) { } catch (Exception e) {
throw new RegistryException("zookeeper delete key error", e); throw new RegistryException("zookeeper delete key error", e);
} }
......
...@@ -181,6 +181,7 @@ public class WorkerServer implements IStoppable { ...@@ -181,6 +181,7 @@ public class WorkerServer implements IStoppable {
this.nettyRemotingServer.close(); this.nettyRemotingServer.close();
this.workerRegistryClient.unRegistry(); this.workerRegistryClient.unRegistry();
this.alertClientService.close(); this.alertClientService.close();
this.springApplicationContext.close();
} catch (Exception e) { } catch (Exception e) {
logger.error("worker server stop exception ", e); logger.error("worker server stop exception ", e);
} }
......
...@@ -49,6 +49,7 @@ public class RetryReportTaskStatusThread implements Runnable { ...@@ -49,6 +49,7 @@ public class RetryReportTaskStatusThread implements Runnable {
public void start(){ public void start(){
Thread thread = new Thread(this,"RetryReportTaskStatusThread"); Thread thread = new Thread(this,"RetryReportTaskStatusThread");
thread.setDaemon(true);
thread.start(); thread.start();
} }
......
...@@ -123,6 +123,7 @@ public class WorkerManagerThread implements Runnable { ...@@ -123,6 +123,7 @@ public class WorkerManagerThread implements Runnable {
public void start() { public void start() {
Thread thread = new Thread(this, this.getClass().getName()); Thread thread = new Thread(this, this.getClass().getName());
thread.setDaemon(true);
thread.start(); thread.start();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册