mirror of
https://github.com/corda/corda.git
synced 2024-12-19 13:08:04 +00:00
Querying of node and webserver now uses infinite retries to avoid any race conditions.
This commit is contained in:
parent
d2ebcbfab0
commit
a5f6fb9479
@ -328,19 +328,14 @@ open class DriverDSL(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun queryNodeInfo(nodeAddress: HostAndPort, sslConfig: SSLConfiguration): NodeInfo? {
|
private fun queryNodeInfo(nodeAddress: HostAndPort, sslConfig: SSLConfiguration): NodeInfo? {
|
||||||
var retries = 0
|
while (true) try {
|
||||||
while (retries < 5) try {
|
|
||||||
val client = CordaRPCClient(nodeAddress, sslConfig)
|
val client = CordaRPCClient(nodeAddress, sslConfig)
|
||||||
client.start(ArtemisMessagingComponent.NODE_USER, ArtemisMessagingComponent.NODE_USER)
|
client.start(ArtemisMessagingComponent.NODE_USER, ArtemisMessagingComponent.NODE_USER)
|
||||||
val rpcOps = client.proxy(timeout = Duration.of(15, ChronoUnit.SECONDS))
|
val rpcOps = client.proxy(timeout = Duration.of(15, ChronoUnit.SECONDS))
|
||||||
return rpcOps.nodeIdentity()
|
return rpcOps.nodeIdentity()
|
||||||
} catch(e: Exception) {
|
} catch(e: Exception) {
|
||||||
log.error("Retrying query node info at $nodeAddress")
|
log.error("Retrying query node info at $nodeAddress")
|
||||||
retries++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.error("Could not query node info after $retries retries")
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun startNode(providedName: String?, advertisedServices: Set<ServiceInfo>,
|
override fun startNode(providedName: String?, advertisedServices: Set<ServiceInfo>,
|
||||||
@ -425,21 +420,15 @@ open class DriverDSL(
|
|||||||
}
|
}
|
||||||
val url = URL(protocol + configuration.webAddress.toString() + "/api/status")
|
val url = URL(protocol + configuration.webAddress.toString() + "/api/status")
|
||||||
val client = OkHttpClient.Builder().connectTimeout(5, TimeUnit.SECONDS).readTimeout(60, TimeUnit.SECONDS).build()
|
val client = OkHttpClient.Builder().connectTimeout(5, TimeUnit.SECONDS).readTimeout(60, TimeUnit.SECONDS).build()
|
||||||
val retries = 50
|
|
||||||
|
|
||||||
for (i in 0..retries) {
|
while (true) try {
|
||||||
try {
|
val response = client.newCall(Request.Builder().url(url).build()).execute()
|
||||||
val response = client.newCall(Request.Builder().url(url).build()).execute()
|
if (response.isSuccessful && (response.body().string() == "started")) {
|
||||||
if (response.isSuccessful && (response.body().string() == "started")) {
|
return configuration.webAddress
|
||||||
return configuration.webAddress
|
|
||||||
}
|
|
||||||
} catch(e: ConnectException) {
|
|
||||||
log.debug("Retrying webserver info at ${configuration.webAddress}")
|
|
||||||
}
|
}
|
||||||
|
} catch(e: ConnectException) {
|
||||||
|
log.debug("Retrying webserver info at ${configuration.webAddress}")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.error("Could not query node info after $retries retries")
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun startWebserver(handle: NodeHandle): ListenableFuture<HostAndPort> {
|
override fun startWebserver(handle: NodeHandle): ListenableFuture<HostAndPort> {
|
||||||
|
Loading…
Reference in New Issue
Block a user