From 935183e5f627c6226d05a33e07daec492c2722f1 Mon Sep 17 00:00:00 2001 From: JackSun-Developer Date: Tue, 13 Oct 2020 21:06:27 +0800 Subject: [PATCH] [ISSUE #3576] [Enhancement] Adding the destroy lifecycle method on NamingMaintainService --- .../alibaba/nacos/api/naming/NamingMaintainService.java | 6 ++++++ .../nacos/client/naming/NacosNamingMaintainService.java | 4 ++++ .../nacos/test/naming/NamingMaintainService_ITCase.java | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/com/alibaba/nacos/api/naming/NamingMaintainService.java b/api/src/main/java/com/alibaba/nacos/api/naming/NamingMaintainService.java index 8dfc24a91fe..abcb5969ba4 100644 --- a/api/src/main/java/com/alibaba/nacos/api/naming/NamingMaintainService.java +++ b/api/src/main/java/com/alibaba/nacos/api/naming/NamingMaintainService.java @@ -167,4 +167,10 @@ void updateService(String serviceName, String groupName, float protectThreshold, */ void updateService(Service service, AbstractSelector selector) throws NacosException; + /** + * Shutdown the resource service. + * + * @throws NacosException exception. + */ + void shutDown() throws NacosException; } diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingMaintainService.java b/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingMaintainService.java index f44e41b640a..bb618a41559 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingMaintainService.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingMaintainService.java @@ -173,4 +173,8 @@ public void updateService(Service service, AbstractSelector selector) throws Nac serverProxy.updateService(service, selector); } + @Override + public void shutDown() throws NacosException { + serverProxy.shutdown(); + } } diff --git a/test/src/test/java/com/alibaba/nacos/test/naming/NamingMaintainService_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/naming/NamingMaintainService_ITCase.java index 047d40c23fb..d59dd9e59cb 100644 --- a/test/src/test/java/com/alibaba/nacos/test/naming/NamingMaintainService_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/naming/NamingMaintainService_ITCase.java @@ -29,6 +29,7 @@ import com.alibaba.nacos.api.selector.NoneSelector; import com.alibaba.nacos.sys.utils.ApplicationUtils; import com.alibaba.nacos.test.BaseTest; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -163,5 +164,10 @@ public void deleteService() throws NacosException { Assert.assertTrue(namingMaintainService.deleteService(serviceName)); } - + + @After + public void tearDown() throws NacosException { + namingMaintainService.shutDown(); + namingService.shutDown(); + } }