Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
zookeeper-demo
提交
feb435fd
Z
zookeeper-demo
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
zookeeper-demo
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zookeeper-demo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
feb435fd
编写于
5月 15, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:使用springboot来封装
上级
bd3706d5
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
77 addition
and
2 deletion
+77
-2
pom.xml
pom.xml
+5
-0
src/test/java/com/kwan/shuyu/crud/CuratorTest_02_Create.java
src/test/java/com/kwan/shuyu/crud/CuratorTest_02_Create.java
+1
-1
src/test/java/com/kwan/shuyu/crud/CuratorTest_03_Create.java
src/test/java/com/kwan/shuyu/crud/CuratorTest_03_Create.java
+5
-0
src/test/java/com/kwan/shuyu/crud/CuratorTest_04_Create.java
src/test/java/com/kwan/shuyu/crud/CuratorTest_04_Create.java
+5
-0
src/test/java/com/kwan/shuyu/crud/CuratorTest_05_Get.java
src/test/java/com/kwan/shuyu/crud/CuratorTest_05_Get.java
+6
-1
src/test/java/com/kwan/shuyu/crud/CuratorTest_06_Get.java
src/test/java/com/kwan/shuyu/crud/CuratorTest_06_Get.java
+5
-0
src/test/java/com/kwan/shuyu/crud/CuratorTest_07_Get.java
src/test/java/com/kwan/shuyu/crud/CuratorTest_07_Get.java
+5
-0
src/test/java/com/kwan/shuyu/crud/CuratorTest_08_Set.java
src/test/java/com/kwan/shuyu/crud/CuratorTest_08_Set.java
+5
-0
src/test/java/com/kwan/shuyu/crud/CuratorTest_09_Set.java
src/test/java/com/kwan/shuyu/crud/CuratorTest_09_Set.java
+5
-0
src/test/java/com/kwan/shuyu/crud/CuratorTest_10_Delete.java
src/test/java/com/kwan/shuyu/crud/CuratorTest_10_Delete.java
+5
-0
src/test/java/com/kwan/shuyu/crud/CuratorTest_11_Delete.java
src/test/java/com/kwan/shuyu/crud/CuratorTest_11_Delete.java
+5
-0
src/test/java/com/kwan/shuyu/crud/CuratorTest_12_Delete.java
src/test/java/com/kwan/shuyu/crud/CuratorTest_12_Delete.java
+5
-0
src/test/java/com/kwan/shuyu/crud/CuratorTest_13_Delete.java
src/test/java/com/kwan/shuyu/crud/CuratorTest_13_Delete.java
+5
-0
src/test/java/com/kwan/shuyu/watch/Watcher_01_NodeCache.java
src/test/java/com/kwan/shuyu/watch/Watcher_01_NodeCache.java
+5
-0
src/test/java/com/kwan/shuyu/watch/Watcher_02_PathChildrenCache.java
...va/com/kwan/shuyu/watch/Watcher_02_PathChildrenCache.java
+5
-0
src/test/java/com/kwan/shuyu/watch/Watcher_03_TreeCache.java
src/test/java/com/kwan/shuyu/watch/Watcher_03_TreeCache.java
+5
-0
未找到文件。
pom.xml
浏览文件 @
feb435fd
...
...
@@ -16,6 +16,11 @@
<artifactId>
spring-boot-starter
</artifactId>
<version>
2.0.6.RELEASE
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<version>
2.0.1.RELEASE
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
...
...
src/test/java/com/kwan/shuyu/crud/CuratorTest_02_Create.java
浏览文件 @
feb435fd
...
...
@@ -32,7 +32,7 @@ public class CuratorTest_02_Create {
public
void
testCreate2
()
throws
Exception
{
//基本创建
//如果创建节点,没有指定数据,则默认将当前客户端的ip作为数据存储
String
path
=
client
.
create
().
forPath
(
"/app
5
"
);
String
path
=
client
.
create
().
forPath
(
"/app
34
"
);
System
.
out
.
println
(
path
);
}
}
\ No newline at end of file
src/test/java/com/kwan/shuyu/crud/CuratorTest_03_Create.java
浏览文件 @
feb435fd
...
...
@@ -3,7 +3,10 @@ package com.kwan.shuyu.crud;
import
org.apache.curator.framework.CuratorFramework
;
import
org.apache.zookeeper.CreateMode
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
/**
* 设置节点的类型
...
...
@@ -12,6 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith
(
SpringRunner
.
class
)
public
class
CuratorTest_03_Create
{
@Autowired
...
...
src/test/java/com/kwan/shuyu/crud/CuratorTest_04_Create.java
浏览文件 @
feb435fd
...
...
@@ -2,7 +2,10 @@ package com.kwan.shuyu.crud;
import
org.apache.curator.framework.CuratorFramework
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
/**
* 创建多级节点
...
...
@@ -11,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith
(
SpringRunner
.
class
)
public
class
CuratorTest_04_Create
{
@Autowired
...
...
src/test/java/com/kwan/shuyu/crud/CuratorTest_05_Get.java
浏览文件 @
feb435fd
...
...
@@ -2,7 +2,10 @@ package com.kwan.shuyu.crud;
import
org.apache.curator.framework.CuratorFramework
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
/**
* 查询数据
...
...
@@ -11,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith
(
SpringRunner
.
class
)
public
class
CuratorTest_05_Get
{
@Autowired
...
...
@@ -25,7 +30,7 @@ public class CuratorTest_05_Get {
@Test
public
void
testGet1
()
throws
Exception
{
//1. 查询数据:get
byte
[]
data
=
client
.
getData
().
forPath
(
"/app
1
"
);
byte
[]
data
=
client
.
getData
().
forPath
(
"/app
5
"
);
System
.
out
.
println
(
new
String
(
data
));
}
}
\ No newline at end of file
src/test/java/com/kwan/shuyu/crud/CuratorTest_06_Get.java
浏览文件 @
feb435fd
...
...
@@ -2,7 +2,10 @@ package com.kwan.shuyu.crud;
import
org.apache.curator.framework.CuratorFramework
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
java.util.List
;
...
...
@@ -13,6 +16,8 @@ import java.util.List;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith
(
SpringRunner
.
class
)
public
class
CuratorTest_06_Get
{
@Autowired
...
...
src/test/java/com/kwan/shuyu/crud/CuratorTest_07_Get.java
浏览文件 @
feb435fd
...
...
@@ -3,7 +3,10 @@ package com.kwan.shuyu.crud;
import
org.apache.curator.framework.CuratorFramework
;
import
org.apache.zookeeper.data.Stat
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
/**
* 查询节点状态信息
...
...
@@ -12,6 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith
(
SpringRunner
.
class
)
public
class
CuratorTest_07_Get
{
@Autowired
...
...
src/test/java/com/kwan/shuyu/crud/CuratorTest_08_Set.java
浏览文件 @
feb435fd
...
...
@@ -2,7 +2,10 @@ package com.kwan.shuyu.crud;
import
org.apache.curator.framework.CuratorFramework
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
/**
* 基本修改数据
...
...
@@ -11,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith
(
SpringRunner
.
class
)
public
class
CuratorTest_08_Set
{
@Autowired
...
...
src/test/java/com/kwan/shuyu/crud/CuratorTest_09_Set.java
浏览文件 @
feb435fd
...
...
@@ -3,7 +3,10 @@ package com.kwan.shuyu.crud;
import
org.apache.curator.framework.CuratorFramework
;
import
org.apache.zookeeper.data.Stat
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
/**
* 根据版本修改
...
...
@@ -12,6 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith
(
SpringRunner
.
class
)
public
class
CuratorTest_09_Set
{
@Autowired
...
...
src/test/java/com/kwan/shuyu/crud/CuratorTest_10_Delete.java
浏览文件 @
feb435fd
...
...
@@ -2,7 +2,10 @@ package com.kwan.shuyu.crud;
import
org.apache.curator.framework.CuratorFramework
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
/**
* 删除单个节点
...
...
@@ -11,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith
(
SpringRunner
.
class
)
public
class
CuratorTest_10_Delete
{
@Autowired
...
...
src/test/java/com/kwan/shuyu/crud/CuratorTest_11_Delete.java
浏览文件 @
feb435fd
...
...
@@ -2,7 +2,10 @@ package com.kwan.shuyu.crud;
import
org.apache.curator.framework.CuratorFramework
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
/**
* 删除带有子节点的节点
...
...
@@ -11,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith
(
SpringRunner
.
class
)
public
class
CuratorTest_11_Delete
{
@Autowired
...
...
src/test/java/com/kwan/shuyu/crud/CuratorTest_12_Delete.java
浏览文件 @
feb435fd
...
...
@@ -2,7 +2,10 @@ package com.kwan.shuyu.crud;
import
org.apache.curator.framework.CuratorFramework
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
/**
* 必须成功的删除:为了防止网络抖动。本质就是重试。
...
...
@@ -11,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith
(
SpringRunner
.
class
)
public
class
CuratorTest_12_Delete
{
@Autowired
...
...
src/test/java/com/kwan/shuyu/crud/CuratorTest_13_Delete.java
浏览文件 @
feb435fd
...
...
@@ -4,7 +4,10 @@ import org.apache.curator.framework.CuratorFramework;
import
org.apache.curator.framework.api.BackgroundCallback
;
import
org.apache.curator.framework.api.CuratorEvent
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
/**
* 删除回调:inBackground
...
...
@@ -13,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith
(
SpringRunner
.
class
)
public
class
CuratorTest_13_Delete
{
@Autowired
...
...
src/test/java/com/kwan/shuyu/watch/Watcher_01_NodeCache.java
浏览文件 @
feb435fd
...
...
@@ -4,7 +4,10 @@ import org.apache.curator.framework.CuratorFramework;
import
org.apache.curator.framework.recipes.cache.NodeCache
;
import
org.apache.curator.framework.recipes.cache.NodeCacheListener
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
/**
* Watcher监听
...
...
@@ -13,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 10:29
*/
@SpringBootTest
@RunWith
(
SpringRunner
.
class
)
public
class
Watcher_01_NodeCache
{
@Autowired
...
...
src/test/java/com/kwan/shuyu/watch/Watcher_02_PathChildrenCache.java
浏览文件 @
feb435fd
...
...
@@ -5,7 +5,10 @@ import org.apache.curator.framework.recipes.cache.PathChildrenCache;
import
org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent
;
import
org.apache.curator.framework.recipes.cache.PathChildrenCacheListener
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
/**
* Watcher监听
...
...
@@ -14,6 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 10:29
*/
@SpringBootTest
@RunWith
(
SpringRunner
.
class
)
public
class
Watcher_02_PathChildrenCache
{
@Autowired
...
...
src/test/java/com/kwan/shuyu/watch/Watcher_03_TreeCache.java
浏览文件 @
feb435fd
...
...
@@ -5,7 +5,10 @@ import org.apache.curator.framework.recipes.cache.TreeCache;
import
org.apache.curator.framework.recipes.cache.TreeCacheEvent
;
import
org.apache.curator.framework.recipes.cache.TreeCacheListener
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
/**
* Watcher监听
...
...
@@ -14,6 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 10:29
*/
@SpringBootTest
@RunWith
(
SpringRunner
.
class
)
public
class
Watcher_03_TreeCache
{
@Autowired
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录