NOTICK Close node handles to reduce memory usage (#6557)

Note in theory this shouldn't make a difference, however given the pass rate of this PR I figure it's worth trying.
This commit is contained in:
Ross Nicoll 2020-08-05 08:54:28 +01:00 committed by GitHub
parent de5568854c
commit ff5bdcb559
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -157,8 +157,9 @@ class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneP
epoch = 3,
modifiedTime = Instant.ofEpochMilli(random63BitValue())).addNotary(notary)
val alice = startNodeAndRunFlagDay(paramsWithNewNotary)
eventually { assertEquals(paramsWithNewNotary, alice.rpc.networkParameters) }
startNodeAndRunFlagDay(paramsWithNewNotary).use { alice ->
eventually { assertEquals(paramsWithNewNotary, alice.rpc.networkParameters) }
}
}
}
@ -200,8 +201,9 @@ class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneP
epoch = 3,
modifiedTime = Instant.ofEpochMilli(random63BitValue()),
maxMessageSize = oldParams.maxMessageSize + 1)
val alice = startNodeAndRunFlagDay(paramsWithUpdatedMaxMessageSize)
eventually { assertThatThrownBy { alice.rpc.networkParameters }.hasMessageContaining("Connection failure detected") }
startNodeAndRunFlagDay(paramsWithUpdatedMaxMessageSize).use { alice ->
eventually { assertThatThrownBy { alice.rpc.networkParameters }.hasMessageContaining("Connection failure detected") }
}
}
}
@ -219,8 +221,9 @@ class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneP
epoch = 3,
modifiedTime = Instant.ofEpochMilli(random63BitValue()),
maxMessageSize = oldParams.maxMessageSize + 1).addNotary(notary)
val alice = startNodeAndRunFlagDay(paramsWithUpdatedMaxMessageSizeAndNotary)
eventually { assertThatThrownBy { alice.rpc.networkParameters }.hasMessageContaining("Connection failure detected") }
startNodeAndRunFlagDay(paramsWithUpdatedMaxMessageSizeAndNotary).use { alice ->
eventually { assertThatThrownBy { alice.rpc.networkParameters }.hasMessageContaining("Connection failure detected") }
}
}
}
@ -246,24 +249,25 @@ class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneP
compatibilityZone = compatibilityZone,
notarySpecs = emptyList()
) {
val aliceNode = startNode(providedName = ALICE_NAME, devMode = false).getOrThrow()
assertDownloadedNetworkParameters(aliceNode)
aliceNode.onlySees(aliceNode.nodeInfo)
startNode(providedName = ALICE_NAME, devMode = false).getOrThrow().use { aliceNode ->
assertDownloadedNetworkParameters(aliceNode)
aliceNode.onlySees(aliceNode.nodeInfo)
val bobNode = startNode(providedName = BOB_NAME, devMode = false).getOrThrow()
// Wait for network map client to poll for the next update.
Thread.sleep(cacheTimeout.toMillis() * 2)
// Wait for network map client to poll for the next update.
Thread.sleep(cacheTimeout.toMillis() * 2)
startNode(providedName = BOB_NAME, devMode = false).getOrThrow().use { bobNode ->
bobNode.onlySees(aliceNode.nodeInfo, bobNode.nodeInfo)
aliceNode.onlySees(aliceNode.nodeInfo, bobNode.nodeInfo)
bobNode.onlySees(aliceNode.nodeInfo, bobNode.nodeInfo)
aliceNode.onlySees(aliceNode.nodeInfo, bobNode.nodeInfo)
networkMapServer.removeNodeInfo(aliceNode.nodeInfo)
networkMapServer.removeNodeInfo(aliceNode.nodeInfo)
// Wait for network map client to poll for the next update.
Thread.sleep(cacheTimeout.toMillis() * 2)
// Wait for network map client to poll for the next update.
Thread.sleep(cacheTimeout.toMillis() * 2)
bobNode.onlySees(bobNode.nodeInfo)
bobNode.onlySees(bobNode.nodeInfo)
}
}
}
}
@ -275,24 +279,25 @@ class NetworkMapTest(var initFunc: (URL, NetworkMapServer) -> CompatibilityZoneP
notarySpecs = emptyList(),
systemProperties = mapOf("net.corda.node.internal.nodeinfo.publish.interval" to 1.seconds.toString())
) {
val aliceNode = startNode(providedName = ALICE_NAME, devMode = false).getOrThrow()
val aliceNodeInfo = aliceNode.nodeInfo.serialize().hash
assertThat(networkMapServer.networkMapHashes()).contains(aliceNodeInfo)
networkMapServer.removeNodeInfo(aliceNode.nodeInfo)
var maxRemoveRetries = 5
// Try to remove multiple times in case the network map republishes just in between the removal and the check.
while (aliceNodeInfo in networkMapServer.networkMapHashes()) {
startNode(providedName = ALICE_NAME, devMode = false).getOrThrow().use { aliceNode ->
val aliceNodeInfo = aliceNode.nodeInfo.serialize().hash
assertThat(networkMapServer.networkMapHashes()).contains(aliceNodeInfo)
networkMapServer.removeNodeInfo(aliceNode.nodeInfo)
if (maxRemoveRetries-- == 0) {
throw AssertionError("Could not remove Node info.")
}
}
// Wait until the node info is republished.
Thread.sleep(2000)
assertThat(networkMapServer.networkMapHashes()).contains(aliceNodeInfo)
var maxRemoveRetries = 5
// Try to remove multiple times in case the network map republishes just in between the removal and the check.
while (aliceNodeInfo in networkMapServer.networkMapHashes()) {
networkMapServer.removeNodeInfo(aliceNode.nodeInfo)
if (maxRemoveRetries-- == 0) {
throw AssertionError("Could not remove Node info.")
}
}
// Wait until the node info is republished.
Thread.sleep(2000)
assertThat(networkMapServer.networkMapHashes()).contains(aliceNodeInfo)
}
}
}