jetcd

Jetcd is a java etcd v2 client

Лицензия

Лицензия

Категории

Категории

jetcd Данные Базы данных
Группа

Группа

com.lindzh
Идентификатор

Идентификатор

jetcd
Последняя версия

Последняя версия

1.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

jetcd
Jetcd is a java etcd v2 client
Ссылка на сайт

Ссылка на сайт

http://maven.apache.org
Система контроля версий

Система контроля версий

https://github.com/lindzh/jetcd

Скачать jetcd

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.lindzh/jetcd/ -->
<dependency>
    <groupId>com.lindzh</groupId>
    <artifactId>jetcd</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.lindzh/jetcd/
implementation 'com.lindzh:jetcd:1.0.1'
// https://jarcasting.com/artifacts/com.lindzh/jetcd/
implementation ("com.lindzh:jetcd:1.0.1")
'com.lindzh:jetcd:jar:1.0.1'
<dependency org="com.lindzh" name="jetcd" rev="1.0.1">
  <artifact name="jetcd" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.lindzh', module='jetcd', version='1.0.1')
)
libraryDependencies += "com.lindzh" % "jetcd" % "1.0.1"
[com.lindzh/jetcd "1.0.1"]

Зависимости

compile (6)

Идентификатор библиотеки Тип Версия
log4j : log4j jar 1.2.16
com.fasterxml.jackson.core : jackson-core jar 2.2.0
com.fasterxml.jackson.core : jackson-annotations jar 2.2.0
com.fasterxml.jackson.core : jackson-databind jar 2.2.0
org.apache.httpcomponents : httpclient jar 4.3.5
org.apache.httpcomponents : httpasyncclient jar 4.0.2

Модули Проекта

Данный проект не имеет модулей.

a simple etcd client for java

watch auto notify for change,easy to use


model


maven 引入依赖

<dependency>
  <groupId>com.lindzh</groupId>
  <artifactId>jetcd</artifactId>
  <version>1.0.1</version>
</dependency>

simple setting config operation

	String key = "/testKey";
	EtcdResult result = client.get(key);
	result = client.set(key, "11111111");
	result = client.set(key, null, 10);
	Thread.sleep(11000);
	result = client.get(key);
	result = client.set(key, "222222");
	result = client.get(key);
	result = client.del(key);
	result = client.get(key);

cas operation

String key = "/testCas";
client.cas(key, "testCas-1", false);
EtcdResult result = client.get(key);
client.cas(key, "testCas-2", false);
result = client.get(key);
client.cas(key, "testCas-2", true);
result = client.get(key);

use watch call back for change notify

String key = "/testCallback";
EtcdResult result = client.get(key);
result = client.set(key, "11111111", false);
result = client.get(key);
System.out.println("set:" +JSONUtils.toJSON(result));
client.watch(key, new EtcdWatchCallback() {
	public void onChange(EtcdChangeResult future) {
		EtcdResult etcdResult = future.getResult();
		if(etcdResult!=null){
			System.out.println("change:" +JSONUtils.toJSON(etcdResult));
		}
	}
});

dir operation

String dirKey = "/dirTestKey";
//delete dir
EtcdResult result = client.delDir(dirKey, true);
//create dir
result = client.dir(dirKey);
//add sub dir
result = client.dir(dirKey+"/subdir1");
result = client.dir(dirKey+"/subdir2");
result = client.children(dirKey, true, false);
result = client.delDir(dirKey+"/subdir2", true);
result = client.children(dirKey, true, false);
result = client.delDir(dirKey, true);
result = client.children(dirKey, true, false);

suquence ordered queue for lock

String queue = "/testQueue";
//queue name is a directory
client.delDir(queue, true);
EtcdResult result = client.queue(queue, "job1");
result = client.queue(queue, "job2");
EtcdResult job2 = result;
result = client.queue(queue, "job3");
String delJob3 = result.getNode().getKey();
result = client.children(queue, true, true);
result = client.queue(queue, "job-ttl",10);
result = client.children(queue, true, true);
Thread.currentThread().sleep(10000);
result = client.children(queue, true, true);
//set key ttl
EtcdResult etcdResult = client.set(job2.getNode().getKey(), job2.getNode().getValue(), 6);
Thread.currentThread().sleep(10000);
result = client.children(queue, true, true);
client.del(delJob3);
result = client.children(queue, true, true);

Версии библиотеки

Версия
1.0.1