mirror of
https://github.com/corda/corda.git
synced 2025-06-22 17:09:00 +00:00
Added an endpoint that allows querying for status of node.
This commit is contained in:
committed by
Andras Slemmer
parent
03e2852880
commit
36a0ff0503
@ -11,6 +11,7 @@ import javax.ws.rs.GET
|
|||||||
import javax.ws.rs.Path
|
import javax.ws.rs.Path
|
||||||
import javax.ws.rs.Produces
|
import javax.ws.rs.Produces
|
||||||
import javax.ws.rs.core.MediaType
|
import javax.ws.rs.core.MediaType
|
||||||
|
import javax.ws.rs.core.Response
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Top level interface to external interaction with the distributed ledger.
|
* Top level interface to external interaction with the distributed ledger.
|
||||||
@ -30,6 +31,14 @@ interface APIServer {
|
|||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
fun serverTime(): LocalDateTime
|
fun serverTime(): LocalDateTime
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report whether this node is started up or not
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("status")
|
||||||
|
@Produces(MediaType.TEXT_PLAIN)
|
||||||
|
fun status(): Response
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query your "local" states (containing only outputs involving you) and return the hashes & indexes associated with them
|
* Query your "local" states (containing only outputs involving you) and return the hashes & indexes associated with them
|
||||||
* to probably be later inflated by fetchLedgerTransactions() or fetchStates() although because immutable you can cache them
|
* to probably be later inflated by fetchLedgerTransactions() or fetchStates() although because immutable you can cache them
|
||||||
|
@ -10,6 +10,7 @@ import com.r3corda.core.serialization.SerializedBytes
|
|||||||
import com.r3corda.node.api.*
|
import com.r3corda.node.api.*
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import javax.ws.rs.core.Response
|
||||||
import kotlin.reflect.KParameter
|
import kotlin.reflect.KParameter
|
||||||
import kotlin.reflect.jvm.javaType
|
import kotlin.reflect.jvm.javaType
|
||||||
|
|
||||||
@ -17,6 +18,14 @@ class APIServerImpl(val node: AbstractNode) : APIServer {
|
|||||||
|
|
||||||
override fun serverTime(): LocalDateTime = LocalDateTime.now(node.services.clock)
|
override fun serverTime(): LocalDateTime = LocalDateTime.now(node.services.clock)
|
||||||
|
|
||||||
|
override fun status(): Response {
|
||||||
|
return if(node.started) {
|
||||||
|
Response.ok("started").build()
|
||||||
|
} else {
|
||||||
|
Response.status(Response.Status.SERVICE_UNAVAILABLE).entity("not started").build()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun queryStates(query: StatesQuery): List<StateRef> {
|
override fun queryStates(query: StatesQuery): List<StateRef> {
|
||||||
// We're going to hard code two options here for now and assume that all LinearStates are deals
|
// We're going to hard code two options here for now and assume that all LinearStates are deals
|
||||||
// Would like to maybe move to a model where we take something like a JEXL string, although don't want to develop
|
// Would like to maybe move to a model where we take something like a JEXL string, although don't want to develop
|
||||||
|
Reference in New Issue
Block a user