mirror of
https://github.com/corda/corda.git
synced 2025-06-01 15:10:54 +00:00
node: make AbstractNode's networkMapRegistrationFuture non-nullable
This commit is contained in:
parent
8ea8ec435e
commit
53bd5c2287
@ -1,6 +1,8 @@
|
|||||||
package com.r3corda.node.internal
|
package com.r3corda.node.internal
|
||||||
|
|
||||||
import com.codahale.metrics.MetricRegistry
|
import com.codahale.metrics.MetricRegistry
|
||||||
|
import com.google.common.util.concurrent.Futures
|
||||||
|
import com.google.common.util.concurrent.JdkFutureAdapters
|
||||||
import com.google.common.util.concurrent.ListenableFuture
|
import com.google.common.util.concurrent.ListenableFuture
|
||||||
import com.google.common.util.concurrent.SettableFuture
|
import com.google.common.util.concurrent.SettableFuture
|
||||||
import com.r3corda.core.RunOnCallerThread
|
import com.r3corda.core.RunOnCallerThread
|
||||||
@ -47,6 +49,7 @@ import java.security.KeyPair
|
|||||||
import java.time.Clock
|
import java.time.Clock
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import java.util.concurrent.CompletableFuture
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A base node implementation that can be customised either for production (with real implementations that do real
|
* A base node implementation that can be customised either for production (with real implementations that do real
|
||||||
@ -109,9 +112,9 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
|
|||||||
var isPreviousCheckpointsPresent = false
|
var isPreviousCheckpointsPresent = false
|
||||||
private set
|
private set
|
||||||
|
|
||||||
/** Completes once the node has successfully registered with the network map service. Null until [start] returns. */
|
/** Completes once the node has successfully registered with the network map service */
|
||||||
@Volatile var networkMapRegistrationFuture: ListenableFuture<Unit>? = null
|
val networkMapRegistrationSettableFuture: SettableFuture<Unit> = SettableFuture.create()
|
||||||
private set
|
val networkMapRegistrationFuture: ListenableFuture<Unit> = networkMapRegistrationSettableFuture
|
||||||
|
|
||||||
/** Set to true once [start] has been successfully called. */
|
/** Set to true once [start] has been successfully called. */
|
||||||
@Volatile var started = false
|
@Volatile var started = false
|
||||||
@ -145,7 +148,7 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
|
|||||||
CashBalanceAsMetricsObserver(services)
|
CashBalanceAsMetricsObserver(services)
|
||||||
|
|
||||||
startMessagingService()
|
startMessagingService()
|
||||||
networkMapRegistrationFuture = registerWithNetworkMap()
|
networkMapRegistrationSettableFuture.setFuture(registerWithNetworkMap())
|
||||||
isPreviousCheckpointsPresent = checkpointStorage.checkpoints.any()
|
isPreviousCheckpointsPresent = checkpointStorage.checkpoints.any()
|
||||||
smm.start()
|
smm.start()
|
||||||
started = true
|
started = true
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.r3corda.node.internal.testing
|
package com.r3corda.node.internal.testing
|
||||||
|
|
||||||
|
import com.google.common.base.Function
|
||||||
import com.google.common.util.concurrent.Futures
|
import com.google.common.util.concurrent.Futures
|
||||||
import com.google.common.util.concurrent.ListenableFuture
|
import com.google.common.util.concurrent.ListenableFuture
|
||||||
import com.r3corda.core.node.CityDatabase
|
import com.r3corda.core.node.CityDatabase
|
||||||
@ -213,6 +214,8 @@ abstract class Simulation(val runAsync: Boolean,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val networkInitialisationFinished: ListenableFuture<Unit> = Futures.transform(Futures.allAsList(network.nodes.map { it.networkMapRegistrationFuture }), Function { })
|
||||||
|
|
||||||
fun start(): ListenableFuture<Unit> {
|
fun start(): ListenableFuture<Unit> {
|
||||||
network.startNodes()
|
network.startNodes()
|
||||||
// Wait for all the nodes to have finished registering with the network map service.
|
// Wait for all the nodes to have finished registering with the network map service.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user