Corda 3.1-发现哪些节点已关闭且无法运行 [英] Corda 3.1 - discovering which nodes are down and not operating

查看:40
本文介绍了Corda 3.1-发现哪些节点已关闭且无法运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于 Corda 3.1 的问题,并使用网络映射来查看节点是否已启动-通常将其用于该节点是一个好主意吗?

I have a question regarding Corda 3.1 and using the network map for the purpose of seeing if node is up - is it generally a good idea to use it for that ?

从这些注释中 https://docs.corda.net/network-map.html#http-network-map-protocol ,因为对网络地图参与者数据进行了轮询(以防我们的缓存数据过期),因此在技术上应该可以做到这一点.您能看到以这种方式实现此功能的任何弊端吗?

From these notes https://docs.corda.net/network-map.html#http-network-map-protocol as there is a polling of the network map participants data (in case that our cached data expired) it should be technically possible to do that. Could you see any drawbacks of implementing this in that way ?

如果节点配置了compatibleZoneURL配置,则它首先将自己签名的NodeInfo上载到服务器(并且每次在启动时更改),然后继续下载整个网络图.网络图由NodeInfo哈希列表组成.节点定期轮询网络映射(基于HTTP缓存到期标头),然后下载并缓存所有新条目.不再存在的条目将从节点的缓存中删除.

If the node is configured with the compatibilityZoneURL config then it first uploads its own signed NodeInfo to the server (and each time it changes on startup) and then proceeds to download the entire network map. The network map consists of a list of NodeInfo hashes. The node periodically polls for the network map (based on the HTTP cache expiry header) and any new entries are downloaded and cached. Entries which no longer exist are deleted from the node’s cache.

推荐答案

将网络地图用作活动服务不是一个好主意.

It is not a good idea to use the network map as a liveness service.

该网络确实具有事件范围参数.如果节点的脱机时间超过事件范围参数指定的时间长度,则会从网络映射中弹出该节点.但是,事件范围通常为几天(例如30天).

The network does have an event horizon parameter. If the node is offline for longer than the length of time specified by the event horizon parameter, it is ejected from the network map. However, the event horizon would usually be days (e.g. 30 days).

相反,您可以使用Telnet之类的工具来ping节点的P2P端口.如果您运行 telnet< node host>< P2P端口> 并且该节点已启动,您会看到类似以下内容的

Instead, you can just ping the node's P2P port using a tool like Telnet. If you run telnet <node host> <P2P port> and the node is up, you'll see something like:

Trying ::1...
Connected to localhost.
Escape character is '^]'.

如果节点关闭,您将看到类似以下内容的

If the node is down, you'll see something like:

Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host

或者,如果要从流中自动检查活动性,则可以定义一个子流,如下所示.该流将返回一个布尔值,指示网络上的给定方是否离线.

Alternatively, if you want to check liveness automatically from within a flow, you can define a subflow like the one below. This flow will return a boolean indicating whether a given party on the network is offline.

@InitiatingFlow
class IsLiveFlow(val otherPartyName: CordaX500Name) : FlowLogic<Boolean>() {

    @Suspendable
    override fun call(): Boolean {
        val otherPartyInfo = serviceHub.networkMapCache.getNodeByLegalName(otherPartyName)!!
        val otherPartyP2PAddress = otherPartyInfo.addresses.single()
        return try {
            Socket().use { socket ->
                socket.connect(InetSocketAddress(otherPartyP2PAddress.host, otherPartyP2PAddress.port), 1000)
                true
            }
        } catch (e: IOException) {
            false
        }
    }
}

这篇关于Corda 3.1-发现哪些节点已关闭且无法运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆