diff --git a/node/src/main/kotlin/com/r3corda/node/api/APIServer.kt b/node/src/main/kotlin/com/r3corda/node/api/APIServer.kt index 7e3979c16a..9883faab5f 100644 --- a/node/src/main/kotlin/com/r3corda/node/api/APIServer.kt +++ b/node/src/main/kotlin/com/r3corda/node/api/APIServer.kt @@ -11,6 +11,7 @@ import javax.ws.rs.GET import javax.ws.rs.Path import javax.ws.rs.Produces import javax.ws.rs.core.MediaType +import javax.ws.rs.core.Response /** * Top level interface to external interaction with the distributed ledger. @@ -30,6 +31,14 @@ interface APIServer { @Produces(MediaType.APPLICATION_JSON) 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 * to probably be later inflated by fetchLedgerTransactions() or fetchStates() although because immutable you can cache them diff --git a/node/src/main/kotlin/com/r3corda/node/internal/APIServerImpl.kt b/node/src/main/kotlin/com/r3corda/node/internal/APIServerImpl.kt index 4a8fd1f038..6f4eae6e6c 100644 --- a/node/src/main/kotlin/com/r3corda/node/internal/APIServerImpl.kt +++ b/node/src/main/kotlin/com/r3corda/node/internal/APIServerImpl.kt @@ -10,6 +10,7 @@ import com.r3corda.core.serialization.SerializedBytes import com.r3corda.node.api.* import java.time.LocalDateTime import java.util.* +import javax.ws.rs.core.Response import kotlin.reflect.KParameter 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 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 { // 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