java jsonobject.get()_Java JsonObject.getLong方法代码示例

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类

private EtcdData(final Class> clazz) {

this.clazz = clazz;

this.logger = Annal.get(clazz);

// Read configuration

final JsonObject config = NODE.read();

if (config.containsKey(KEY)) {

final JsonObject root = config.getJsonObject(KEY);

// Verify the data

Fn.flingUp(() -> Fn.shuntZero(() -> Ruler.verify(KEY, root), root),

LOGGER);

if (root.containsKey(TIMEOUT)) {

this.timeout = root.getLong(TIMEOUT);

}

if (root.containsKey(MICRO)) {

this.application = root.getString(MICRO);

}

// Nodes

if (root.containsKey(NODES)) {

this.config.addAll(root.getJsonArray(NODES));

}

LOGGER.info(Info.ETCD_TIMEOUT,

this.application, this.timeout, this.config.size());

}

Fn.flingUp(this.config.isEmpty(), this.logger,

EtcdConfigEmptyException.class, this.clazz);

final Set uris = new HashSet<>();

final ConcurrentMap networks

= new ConcurrentHashMap<>();

Observable.fromIterable(this.config)

.filter(Objects::nonNull)

.map(item -> (JsonObject) item)

.filter(item -> item.containsKey(PORT) && item.containsKey(HOST))

.map(item -> {

final Integer port = item.getInteger(PORT);

final String host = item.getString(HOST);

networks.put(port, host);

return "http://" + host + ":" + port;

})

.map(URI::create)

.subscribe(uris::add);

// Network checking

networks.forEach((port, host) ->

Fn.flingUp(!Net.isReach(host, port), LOGGER,

EtcdNetworkException.class, getClass(), host, port));

LOGGER.info(Info.ETCD_NETWORK);

this.client = new EtcdClient(uris.toArray(new URI[]{}));

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值