- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中io.vertx.servicediscovery.backend.zookeeper.ZookeeperBackendService
类的一些代码示例,展示了ZookeeperBackendService
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperBackendService
类的具体详情如下:
包路径:io.vertx.servicediscovery.backend.zookeeper.ZookeeperBackendService
类名称:ZookeeperBackendService
暂无
代码示例来源:origin: io.vertx/vertx-service-discovery-backend-zookeeper
@Override
protected ServiceDiscoveryBackend createBackend() {
ZookeeperBackendService backend = new ZookeeperBackendService();
backend.init(vertx, new JsonObject()
.put("connection", server.getConnectString())
.put("baseSleepTimeBetweenRetries", 10)
.put("connectionTimeoutMs", 1000));
return backend;
}
代码示例来源:origin: vert-x3/vertx-service-discovery
Context context = Vertx.currentContext();
ensureConnected(x -> {
if (x.failed()) {
resultHandler.handle(Future.failedFuture(x.cause()));
} else {
getRecordById(context, uuid, record -> {
if (record == null) {
resultHandler.handle(Future.failedFuture("Unknown registration " + uuid));
.deletingChildrenIfNeeded()
.inBackground((curatorFramework, curatorEvent)
-> callback(context, record, resultHandler, curatorEvent))
.forPath(getPath(uuid));
} catch (Exception e) {
resultHandler.handle(Future.failedFuture(e));
代码示例来源:origin: vert-x3/vertx-service-discovery
@Override
public void remove(Record record, Handler<AsyncResult<Record>> resultHandler) {
Objects.requireNonNull(record.getRegistration(), "No registration id in the record");
remove(record.getRegistration(), resultHandler);
}
代码示例来源:origin: vert-x3/vertx-service-discovery
private void getRecordById(Context context, String uuid, Handler<Record> handler) {
ensureConnected(x -> {
if (x.failed()) {
handler.handle(null);
} else {
try {
client.getData()
.inBackground((curatorFramework, curatorEvent)
-> runOnContextIfPossible(context, () -> {
if (curatorEvent.getResultCode() == KeeperException.Code.OK.intValue()) {
JsonObject json
= new JsonObject(new String(curatorEvent.getData(), CHARSET));
handler.handle(new Record(json));
} else {
handler.handle(null);
}
}))
.forPath(getPath(uuid));
} catch (Exception e) {
handler.handle(null);
}
}
});
}
代码示例来源:origin: vert-x3/vertx-service-discovery
@Override
public void store(Record record, Handler<AsyncResult<Record>> resultHandler) {
if (record.getRegistration() != null) {
resultHandler.handle(Future.failedFuture("The record has already been registered"));
return;
}
String uuid = UUID.randomUUID().toString();
record.setRegistration(uuid);
String content = record.toJson().encode();
Context context = Vertx.currentContext();
ensureConnected(x -> {
if (x.failed()) {
resultHandler.handle(Future.failedFuture(x.cause()));
} else {
try {
client.create()
.creatingParentsIfNeeded()
.withMode(ephemeral ? CreateMode.EPHEMERAL : CreateMode.PERSISTENT)
.inBackground((curatorFramework, curatorEvent)
-> callback(context, record, resultHandler, curatorEvent))
.withUnhandledErrorListener((s, throwable)
-> resultHandler.handle(Future.failedFuture(throwable)))
.forPath(getPath(record.getRegistration()), content.getBytes(CHARSET));
} catch (Exception e) {
resultHandler.handle(Future.failedFuture(e));
}
}
});
}
代码示例来源:origin: vert-x3/vertx-service-discovery
@Override
public void getRecords(Handler<AsyncResult<List<Record>>> resultHandler) {
Context context = Vertx.currentContext();
ensureConnected(
x -> {
if (x.failed()) {
for (String child : children) {
Future<Record> future = Future.future();
getRecord(child, future.completer());
futures.add(future);
ar -> runOnContextIfPossible(context, () -> {
if (ar.failed()) {
resultHandler.handle(Future.failedFuture(ar.cause()));
代码示例来源:origin: vert-x3/vertx-service-discovery
private void callback(Context context, Record record, Handler<AsyncResult<Record>> resultHandler, CuratorEvent curatorEvent) {
runOnContextIfPossible(context, () -> {
if (curatorEvent.getResultCode() == KeeperException.Code.OK.intValue()) {
resultHandler.handle(Future.succeededFuture(record));
} else {
KeeperException.Code code =
KeeperException.Code.get(curatorEvent.getResultCode());
resultHandler.handle(Future.failedFuture(KeeperException.create(code)));
}
});
}
代码示例来源:origin: vert-x3/vertx-service-discovery
@Override
public void update(Record record, Handler<AsyncResult<Void>> resultHandler) {
Objects.requireNonNull(record.getRegistration(), "No registration id in the record");
Context context = Vertx.currentContext();
ensureConnected(x -> {
if (x.failed()) {
resultHandler.handle(Future.failedFuture(x.cause()));
} else {
try {
client.setData()
.inBackground((framework, event)
-> runOnContextIfPossible(context, () -> {
if (event.getResultCode() == KeeperException.Code.OK.intValue()) {
resultHandler.handle(Future.succeededFuture());
} else {
KeeperException.Code code = KeeperException.Code.get(event.getResultCode());
resultHandler.handle(Future.failedFuture(KeeperException.create(code)));
}
}))
.withUnhandledErrorListener((message, e) -> resultHandler.handle(Future.failedFuture(e)))
.forPath(getPath(record.getRegistration()),
record.toJson().encode().getBytes(CHARSET));
} catch (Exception e) {
resultHandler.handle(Future.failedFuture(e));
}
}
});
}
代码示例来源:origin: vert-x3/vertx-service-discovery
Context context = Vertx.currentContext();
ensureConnected(x -> {
if (x.failed()) {
handler.handle(Future.failedFuture(x.cause()));
client.getData()
.inBackground((fmk, curatorEvent)
-> runOnContextIfPossible(context, () -> {
if (curatorEvent.getResultCode() == KeeperException.Code.OK.intValue()) {
JsonObject json
.forPath(getPath(uuid));
} catch (Exception e) {
handler.handle(Future.failedFuture(e));
代码示例来源:origin: io.vertx/vertx-service-discovery-backend-zookeeper
@Override
protected ServiceDiscoveryBackend createBackend() {
ZookeeperBackendService backend = new ZookeeperBackendService();
backend.init(vertx, new JsonObject()
.put("connection", server.getConnectString())
.put("ephemeral", true)
.put("guaranteed", true)
.put("basePath", "/services/my-backend")
);
return backend;
}
}
代码示例来源:origin: vert-x3/vertx-service-discovery
@Override
protected ServiceDiscoveryBackend createBackend() {
ZookeeperBackendService backend = new ZookeeperBackendService();
backend.init(vertx, new JsonObject()
.put("connection", server.getConnectString())
.put("ephemeral", true)
.put("guaranteed", true)
.put("basePath", "/services/my-backend")
);
return backend;
}
}
代码示例来源:origin: vert-x3/vertx-service-discovery
@Override
protected ServiceDiscoveryBackend createBackend() {
ZookeeperBackendService backend = new ZookeeperBackendService();
backend.init(vertx, new JsonObject()
.put("connection", server.getConnectString())
.put("baseSleepTimeBetweenRetries", 10)
.put("connectionTimeoutMs", 1000));
return backend;
}
本文整理了Java中io.vertx.servicediscovery.backend.zookeeper.ZookeeperBackendService类的一些代码示例,展示了ZookeeperBa
我是一名优秀的程序员,十分优秀!