mirror of
https://github.com/corda/corda.git
synced 2025-04-06 19:07:08 +00:00
Retire findTokenizableService. (#2036)
This commit is contained in:
parent
052124bbe0
commit
6a569fb3f1
@ -377,12 +377,6 @@ abstract class AbstractNode(val configuration: NodeConfiguration,
|
||||
return service
|
||||
}
|
||||
|
||||
fun <T : Any> findTokenizableService(clazz: Class<T>): T? {
|
||||
return tokenizableServices.firstOrNull { clazz.isAssignableFrom(it.javaClass) }?.let { uncheckedCast(it) }
|
||||
}
|
||||
|
||||
inline fun <reified T : Any> findTokenizableService() = findTokenizableService(T::class.java)
|
||||
|
||||
private fun handleCustomNotaryService(service: NotaryService) {
|
||||
runOnStop += service::stop
|
||||
service.start()
|
||||
@ -614,7 +608,7 @@ abstract class AbstractNode(val configuration: NodeConfiguration,
|
||||
|
||||
protected open fun makeBFTCluster(notaryKey: PublicKey, bftSMaRtConfig: BFTSMaRtConfiguration): BFTSMaRt.Cluster {
|
||||
return object : BFTSMaRt.Cluster {
|
||||
override fun waitUntilAllReplicasHaveInitialized() {
|
||||
override fun waitUntilAllReplicasHaveInitialized(notaryService: BFTNonValidatingNotaryService) {
|
||||
log.warn("A BFT replica may still be initializing, in which case the upcoming consensus change may cause it to spin.")
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class BFTNonValidatingNotaryService(override val services: ServiceHubInternal,
|
||||
log.info("BFT SMaRt replica $replicaId is running.")
|
||||
}
|
||||
}
|
||||
BFTSMaRt.Client(it, replicaId, cluster)
|
||||
BFTSMaRt.Client(it, replicaId, cluster, this)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,10 +72,10 @@ object BFTSMaRt {
|
||||
|
||||
interface Cluster {
|
||||
/** Avoid bug where a replica fails to start due to a consensus change during the BFT startup sequence. */
|
||||
fun waitUntilAllReplicasHaveInitialized()
|
||||
fun waitUntilAllReplicasHaveInitialized(notaryService: BFTNonValidatingNotaryService)
|
||||
}
|
||||
|
||||
class Client(config: BFTSMaRtConfig, private val clientId: Int, private val cluster: Cluster) : SingletonSerializeAsToken() {
|
||||
class Client(config: BFTSMaRtConfig, private val clientId: Int, private val cluster: Cluster, private val notaryService: BFTNonValidatingNotaryService) : SingletonSerializeAsToken() {
|
||||
companion object {
|
||||
private val log = loggerFor<Client>()
|
||||
}
|
||||
@ -106,7 +106,7 @@ object BFTSMaRt {
|
||||
fun commitTransaction(transaction: Any, otherSide: Party): ClusterResponse {
|
||||
require(transaction is FilteredTransaction || transaction is SignedTransaction) { "Unsupported transaction type: ${transaction.javaClass.name}" }
|
||||
awaitClientConnectionToCluster()
|
||||
cluster.waitUntilAllReplicasHaveInitialized()
|
||||
cluster.waitUntilAllReplicasHaveInitialized(notaryService)
|
||||
val requestBytes = CommitRequest(transaction, otherSide).serialize().bytes
|
||||
val responseBytes = proxy.invokeOrdered(requestBytes)
|
||||
return responseBytes.deserialize<ClusterResponse>()
|
||||
|
@ -210,7 +210,7 @@ class NodeInterestRatesTest {
|
||||
internals.registerInitiatedFlow(NodeInterestRates.FixQueryHandler::class.java)
|
||||
internals.registerInitiatedFlow(NodeInterestRates.FixSignHandler::class.java)
|
||||
database.transaction {
|
||||
internals.findTokenizableService(NodeInterestRates.Oracle::class.java)!!.knownFixes = TEST_DATA
|
||||
services.cordaService(NodeInterestRates.Oracle::class.java).knownFixes = TEST_DATA
|
||||
}
|
||||
}
|
||||
val tx = makePartialTX()
|
||||
|
@ -60,7 +60,7 @@ abstract class Simulation(val networkSendManuallyPumped: Boolean,
|
||||
registerInitiatedFlow(NodeInterestRates.FixSignHandler::class.java)
|
||||
javaClass.classLoader.getResourceAsStream("net/corda/irs/simulation/example.rates.txt").use {
|
||||
database.transaction {
|
||||
findTokenizableService(NodeInterestRates.Oracle::class.java)!!.uploadFixes(it.reader().readText())
|
||||
services.cordaService(NodeInterestRates.Oracle::class.java).uploadFixes(it.reader().readText())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -323,13 +323,12 @@ class MockNetwork(defaultParameters: MockNetworkParameters = MockNetworkParamete
|
||||
|
||||
override fun makeBFTCluster(notaryKey: PublicKey, bftSMaRtConfig: BFTSMaRtConfiguration): BFTSMaRt.Cluster {
|
||||
return object : BFTSMaRt.Cluster {
|
||||
override fun waitUntilAllReplicasHaveInitialized() {
|
||||
override fun waitUntilAllReplicasHaveInitialized(notaryService: BFTNonValidatingNotaryService) {
|
||||
val clusterNodes = mockNet.nodes.filter { notaryKey in it.started!!.info.legalIdentities.map { it.owningKey } }
|
||||
if (clusterNodes.size != bftSMaRtConfig.clusterAddresses.size) {
|
||||
throw IllegalStateException("Unable to enumerate all nodes in BFT cluster.")
|
||||
}
|
||||
clusterNodes.forEach {
|
||||
val notaryService = it.findTokenizableService(BFTNonValidatingNotaryService::class.java)!!
|
||||
notaryService.waitUntilReplicaHasInitialized()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user