mirror of
https://github.com/corda/corda.git
synced 2025-03-14 00:06:45 +00:00
Address remaining PR review comments.
This commit is contained in:
parent
ccd5f5fd5b
commit
f013c1dcb7
@ -23,8 +23,10 @@ import net.corda.core.transactions.SignedTransaction
|
||||
import net.corda.core.utilities.NetworkHostAndPort
|
||||
import net.corda.core.utilities.contextLogger
|
||||
import java.io.InputStream
|
||||
import java.net.URL
|
||||
import java.security.PublicKey
|
||||
import java.time.Instant
|
||||
import javax.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM
|
||||
|
||||
class CordaRPCProxyClient(private val targetHostAndPort: NetworkHostAndPort) : CordaRPCOps {
|
||||
|
||||
@ -64,6 +66,14 @@ class CordaRPCProxyClient(private val targetHostAndPort: NetworkHostAndPort) : C
|
||||
return doGet(targetHostAndPort, "network-map-snapshot")
|
||||
}
|
||||
|
||||
override fun partiesFromName(query: String, exactMatch: Boolean): Set<Party> {
|
||||
return doPost(targetHostAndPort, "parties-from-name", query.serialize().bytes)
|
||||
}
|
||||
|
||||
override fun registeredFlows(): List<String> {
|
||||
return doGet(targetHostAndPort, "registered-flows")
|
||||
}
|
||||
|
||||
override fun stateMachinesSnapshot(): List<StateMachineInfo> {
|
||||
TODO("not implemented")
|
||||
}
|
||||
@ -192,14 +202,6 @@ class CordaRPCProxyClient(private val targetHostAndPort: NetworkHostAndPort) : C
|
||||
TODO("not implemented")
|
||||
}
|
||||
|
||||
override fun partiesFromName(query: String, exactMatch: Boolean): Set<Party> {
|
||||
return doPost(targetHostAndPort, "parties-from-name", query.serialize().bytes)
|
||||
}
|
||||
|
||||
override fun registeredFlows(): List<String> {
|
||||
return doGet(targetHostAndPort, "registered-flows")
|
||||
}
|
||||
|
||||
override fun nodeInfoFromParty(party: AbstractParty): NodeInfo? {
|
||||
TODO("not implemented")
|
||||
}
|
||||
@ -225,17 +227,17 @@ class CordaRPCProxyClient(private val targetHostAndPort: NetworkHostAndPort) : C
|
||||
}
|
||||
|
||||
private inline fun <reified T : Any> doPost(hostAndPort: NetworkHostAndPort, path: String, payload: ByteArray) : T {
|
||||
val url = java.net.URL("http://$hostAndPort/rpc/$path")
|
||||
val url = URL("http://$hostAndPort/rpc/$path")
|
||||
val connection = url.openHttpConnection().apply {
|
||||
doOutput = true
|
||||
requestMethod = "POST"
|
||||
setRequestProperty("Content-Type", javax.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM)
|
||||
setRequestProperty("Content-Type", APPLICATION_OCTET_STREAM)
|
||||
outputStream.write(payload)
|
||||
}
|
||||
return connection.responseAs()
|
||||
}
|
||||
|
||||
private inline fun <reified T : Any> doGet(hostAndPort: NetworkHostAndPort, path: String): T {
|
||||
return java.net.URL("http://$hostAndPort/rpc/$path").openHttpConnection().responseAs()
|
||||
return URL("http://$hostAndPort/rpc/$path").openHttpConnection().responseAs()
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ class RPCProxyServer(hostAndPort: NetworkHostAndPort, val webService: RPCProxyWe
|
||||
server.start()
|
||||
}
|
||||
catch(e: Exception) {
|
||||
log.info("Failed to start RPC Proxy server: ${e.message}")
|
||||
log.error("Failed to start RPC Proxy server: ${e.message}", e)
|
||||
return false
|
||||
}
|
||||
log.info("RPC Proxy web services started on $hostAndPort with ${webService.javaClass.simpleName}}")
|
||||
|
@ -4,6 +4,7 @@ import net.corda.core.internal.checkOkResponse
|
||||
import net.corda.core.internal.openHttpConnection
|
||||
import net.corda.core.utilities.NetworkHostAndPort
|
||||
import org.junit.Test
|
||||
import java.net.URL
|
||||
|
||||
class RPCProxyServerTest {
|
||||
|
||||
@ -20,6 +21,6 @@ class RPCProxyServerTest {
|
||||
}
|
||||
|
||||
private fun RPCProxyServer.doGet(path: String) {
|
||||
return java.net.URL("http://$rpcProxyHostAndPort/rpc/$path").openHttpConnection().checkOkResponse()
|
||||
return URL("http://$rpcProxyHostAndPort/rpc/$path").openHttpConnection().checkOkResponse()
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ import org.junit.Assert.assertTrue
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import java.net.URL
|
||||
|
||||
class RPCProxyWebServiceTest {
|
||||
|
||||
@ -323,6 +324,6 @@ class RPCProxyWebServiceTest {
|
||||
}
|
||||
|
||||
private inline fun <reified T : Any> doGet(path: String): T {
|
||||
return java.net.URL("http://$hostAndPort/rpc/$path").openHttpConnection().responseAs()
|
||||
return URL("http://$hostAndPort/rpc/$path").openHttpConnection().responseAs()
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
DISTRO_DIR=$1
|
||||
PORT="${2:-13000}"
|
||||
TMPDIR="${TMPDIR:-/tmp}"
|
||||
|
||||
if [ ! -d "$DISTRO_DIR" ]; then
|
||||
echo "Must specify location of Corda distribution (directory does not exist: $DISTRO_DIR)"
|
||||
@ -38,5 +39,5 @@ $(ls ${DISTRO_DIR}/proxy/*.jar | tr '\n' ':'):\
|
||||
$(ls ${DISTRO_DIR}/apps/*.jar | tr '\n' ':') \
|
||||
net.corda.behave.service.proxy.RPCProxyServerKt ${PORT} &> rpcproxy-${PORT}.log &
|
||||
|
||||
echo $! > /tmp/rpcProxy-pid-${PORT}
|
||||
echo "RPCProxyServer PID: $(cat /tmp/rpcProxy-pid-${PORT})"
|
||||
echo $! > ${TMPDIR}/rpcProxy-pid-${PORT}
|
||||
echo "RPCProxyServer PID: $(cat ${TMPDIR}/rpcProxy-pid-${PORT})"
|
||||
|
Loading…
x
Reference in New Issue
Block a user