forked from apache/dubbo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apache#762 from chickenlj:bugfix#685_registrycache
* Optimize(AbstractRegistry) registry cache, one registry file per 'registry & application', avoid reload (apache#685). * Fixed apache#692 optimize zookeeper operation in service export/reference process: check already exists before create
- Loading branch information
Showing
5 changed files
with
71 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...rc/test/java/com/alibaba/dubbo/remoting/zookeeper/curator/CuratorZookeeperClientTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.alibaba.dubbo.remoting.zookeeper.curator; | ||
|
||
import com.alibaba.dubbo.common.URL; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author ken.lj | ||
* @date 2017/10/16 | ||
*/ | ||
public class CuratorZookeeperClientTest { | ||
|
||
@Test | ||
public void testCheckExists() { | ||
CuratorZookeeperClient curatorClient = new CuratorZookeeperClient(URL.valueOf("zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService")); | ||
String path = "/dubbo/com.alibaba.dubbo.demo.DemoService/providers"; | ||
curatorClient.create(path, false); | ||
Assert.assertTrue(curatorClient.checkExists(path)); | ||
Assert.assertFalse(curatorClient.checkExists(path + "/noneexits")); | ||
} | ||
|
||
/** | ||
* create checkExists 性能測試 | ||
*/ | ||
@Test | ||
public void testCreate() { | ||
CuratorZookeeperClient curatorClient = new CuratorZookeeperClient(URL.valueOf("zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService")); | ||
String path = "/dubbo/com.alibaba.dubbo.demo.DemoService/providers"; | ||
curatorClient.create(path, false); | ||
|
||
// 重复create 100次,耗时 | ||
long startTime = System.nanoTime(); | ||
for (int i = 0; i < 100; i++) { | ||
curatorClient.create(path, true); | ||
} | ||
System.out.println("create cost: " + (System.nanoTime() - startTime) / 1000 / 1000); | ||
|
||
// 判断100次,耗时 | ||
startTime = System.nanoTime(); | ||
for (int i = 0; i < 100; i++) { | ||
curatorClient.checkExists(path); | ||
} | ||
System.out.println("judge cost: " + (System.nanoTime() - startTime) / 1000 / 1000); | ||
} | ||
} |