mirror of
https://github.com/corda/corda.git
synced 2025-01-31 16:35:43 +00:00
Allow HA topic in zookeeper to be configurable and test it.
This commit is contained in:
parent
478558bd8a
commit
7cb6ed74d1
@ -192,7 +192,7 @@ class BridgeIntegrationTest {
|
||||
val bridgeFolder = tempFolder.root.toPath()
|
||||
val bridgeConfigResource = "/net/corda/bridge/hawithfloat/bridge/bridge.conf"
|
||||
val bridgeConfig = createAndLoadConfigFromResource(bridgeFolder, bridgeConfigResource)
|
||||
assertEquals(BridgeHAConfigImpl("zk://localhost:11105", 10), bridgeConfig.haConfig)
|
||||
assertEquals(BridgeHAConfigImpl("zk://localhost:11105", 20, "/custom/bridge/ha"), bridgeConfig.haConfig)
|
||||
bridgeConfig.createBridgeKeyStores(DUMMY_BANK_A_NAME)
|
||||
createNetworkParams(bridgeFolder)
|
||||
val floatFolder = tempFolder.root.toPath() / "float"
|
||||
@ -226,7 +226,7 @@ class BridgeIntegrationTest {
|
||||
assertEquals(true, bridge.active)
|
||||
assertEquals(true, float.active)
|
||||
assertEquals(true, serverListening("localhost", 10005))
|
||||
val higherPriorityClient = ZkClient("localhost:11105", "/bridge/ha", "Test", 5)
|
||||
val higherPriorityClient = ZkClient("localhost:11105", "/custom/bridge/ha", "Test", 5)
|
||||
higherPriorityClient.start()
|
||||
higherPriorityClient.requestLeadership() // should win leadership and kick out our bridge
|
||||
assertEquals(false, bridgeStateFollower.next())
|
||||
|
@ -87,6 +87,7 @@ interface BridgeInnerConfiguration {
|
||||
interface BridgeHAConfig {
|
||||
val haConnectionString: String
|
||||
val haPriority: Int
|
||||
val haTopic: String
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,7 +51,7 @@ data class FloatOuterConfigurationImpl(override val floatAddress: NetworkHostAnd
|
||||
override val expectedCertificateSubject: CordaX500Name,
|
||||
override val customSSLConfiguration: BridgeSSLConfigurationImpl?) : FloatOuterConfiguration
|
||||
|
||||
data class BridgeHAConfigImpl(override val haConnectionString: String, override val haPriority: Int = 10) : BridgeHAConfig
|
||||
data class BridgeHAConfigImpl(override val haConnectionString: String, override val haPriority: Int = 10, override val haTopic: String = "/bridge/ha") : BridgeHAConfig
|
||||
|
||||
data class BridgeConfigurationImpl(
|
||||
override val baseDirectory: Path,
|
||||
|
@ -45,7 +45,7 @@ class ExternalMasterElectionService(val conf: BridgeConfiguration,
|
||||
val info = ManagementFactory.getRuntimeMXBean()
|
||||
val pid = info.name.split("@").firstOrNull() // TODO Java 9 has better support for this
|
||||
val nodeId = "$hostName:$pid"
|
||||
val leaderElector = ZkClient(zkConf, "/bridge/ha", nodeId, leaderPriority)
|
||||
val leaderElector = ZkClient(zkConf, conf.haConfig!!.haTopic, nodeId, leaderPriority)
|
||||
haElector = leaderElector
|
||||
val listener = object : CordaLeaderListener {
|
||||
override fun notLeader() {
|
||||
|
@ -18,4 +18,6 @@ bridgeInnerConfig : {
|
||||
networkParametersPath = network-parameters
|
||||
haConfig : {
|
||||
haConnectionString = "zk://localhost:11105"
|
||||
haPriority = 20
|
||||
haTopic = "/custom/bridge/ha"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user