mirror of
https://github.com/corda/corda.git
synced 2025-06-05 00:50:52 +00:00
Introduced node status; published via JMX
This commit is contained in:
parent
6252217bb6
commit
b76fc7de59
@ -1,6 +1,7 @@
|
|||||||
package net.corda.node.internal
|
package net.corda.node.internal
|
||||||
|
|
||||||
import co.paralleluniverse.fibers.instrument.Retransform
|
import co.paralleluniverse.fibers.instrument.Retransform
|
||||||
|
import com.codahale.metrics.Gauge
|
||||||
import com.codahale.metrics.MetricRegistry
|
import com.codahale.metrics.MetricRegistry
|
||||||
import com.google.common.collect.MutableClassToInstanceMap
|
import com.google.common.collect.MutableClassToInstanceMap
|
||||||
import com.google.common.util.concurrent.MoreExecutors
|
import com.google.common.util.concurrent.MoreExecutors
|
||||||
@ -383,6 +384,15 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
|
|||||||
|
|
||||||
protected val keyStoreHandler = KeyStoreHandler(configuration, cryptoService)
|
protected val keyStoreHandler = KeyStoreHandler(configuration, cryptoService)
|
||||||
|
|
||||||
|
enum class NodeStatus {
|
||||||
|
WAITING_TO_START,
|
||||||
|
STARTING,
|
||||||
|
STARTED,
|
||||||
|
STOPPING
|
||||||
|
}
|
||||||
|
|
||||||
|
private var nodeStatus = NodeStatus.WAITING_TO_START
|
||||||
|
|
||||||
private fun <T : Any> T.tokenize(): T {
|
private fun <T : Any> T.tokenize(): T {
|
||||||
tokenizableServices?.add(this as? SerializeAsToken ?:
|
tokenizableServices?.add(this as? SerializeAsToken ?:
|
||||||
throw IllegalStateException("${this::class.java} is expected to be extending from SerializeAsToken"))
|
throw IllegalStateException("${this::class.java} is expected to be extending from SerializeAsToken"))
|
||||||
@ -524,6 +534,12 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
|
|||||||
Node.printBasicNodeInfo("CorDapp schemas synchronised")
|
Node.printBasicNodeInfo("CorDapp schemas synchronised")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setNodeStatus(st : NodeStatus) {
|
||||||
|
log.info("Node status update: [$nodeStatus] -> [$st]")
|
||||||
|
nodeStatus = st
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Suppress("ComplexMethod")
|
@Suppress("ComplexMethod")
|
||||||
open fun start(): S {
|
open fun start(): S {
|
||||||
check(started == null) { "Node has already been started" }
|
check(started == null) { "Node has already been started" }
|
||||||
@ -533,9 +549,12 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
|
|||||||
}
|
}
|
||||||
nodeLifecycleEventsDistributor.distributeEvent(NodeLifecycleEvent.BeforeNodeStart(nodeServicesContext))
|
nodeLifecycleEventsDistributor.distributeEvent(NodeLifecycleEvent.BeforeNodeStart(nodeServicesContext))
|
||||||
log.info("Node starting up ...")
|
log.info("Node starting up ...")
|
||||||
|
setNodeStatus(NodeStatus.STARTING)
|
||||||
|
|
||||||
|
initialiseJolokia()
|
||||||
|
monitoringService.metrics.register(MetricRegistry.name("Node", "Status"), Gauge { nodeStatus })
|
||||||
|
|
||||||
val trustRoots = initKeyStores()
|
val trustRoots = initKeyStores()
|
||||||
initialiseJolokia()
|
|
||||||
|
|
||||||
schemaService.mappedSchemasWarnings().forEach {
|
schemaService.mappedSchemasWarnings().forEach {
|
||||||
val warning = it.toWarning()
|
val warning = it.toWarning()
|
||||||
@ -658,6 +677,7 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
|
|||||||
log.warn("Not distributing events as NetworkMap is not ready")
|
log.warn("Not distributing events as NetworkMap is not ready")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setNodeStatus(NodeStatus.STARTED)
|
||||||
return resultingNodeInfo
|
return resultingNodeInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1050,6 +1070,8 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
|
|||||||
|
|
||||||
open fun stop() {
|
open fun stop() {
|
||||||
|
|
||||||
|
setNodeStatus(NodeStatus.STOPPING)
|
||||||
|
|
||||||
nodeLifecycleEventsDistributor.distributeEvent(NodeLifecycleEvent.StateMachineStopped(nodeServicesContext))
|
nodeLifecycleEventsDistributor.distributeEvent(NodeLifecycleEvent.StateMachineStopped(nodeServicesContext))
|
||||||
nodeLifecycleEventsDistributor.distributeEvent(NodeLifecycleEvent.BeforeNodeStop(nodeServicesContext))
|
nodeLifecycleEventsDistributor.distributeEvent(NodeLifecycleEvent.BeforeNodeStop(nodeServicesContext))
|
||||||
|
|
||||||
|
@ -580,14 +580,12 @@ open class Node(configuration: NodeConfiguration,
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun start(): NodeInfo {
|
override fun start(): NodeInfo {
|
||||||
|
registerJmxReporter(services.monitoringService.metrics)
|
||||||
registerDefaultExceptionHandler()
|
registerDefaultExceptionHandler()
|
||||||
initialiseSerialization()
|
initialiseSerialization()
|
||||||
val nodeInfo: NodeInfo = super.start()
|
val nodeInfo: NodeInfo = super.start()
|
||||||
nodeReadyFuture.thenMatch({
|
nodeReadyFuture.thenMatch({
|
||||||
serverThread.execute {
|
serverThread.execute {
|
||||||
|
|
||||||
registerJmxReporter(services.monitoringService.metrics)
|
|
||||||
|
|
||||||
_startupComplete.set(Unit)
|
_startupComplete.set(Unit)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user