Address PR 207 comments

This commit is contained in:
Andras Slemmer 2017-02-02 11:44:18 +00:00
parent de63f90745
commit 4afd404db4
3 changed files with 7 additions and 11 deletions

View File

@ -112,9 +112,10 @@ interface CordaRPCOps : RPCOps {
fun currentNodeTime(): Instant fun currentNodeTime(): Instant
/** /**
* Returns whether the node has registered with the network map. * Returns an Observable emitting a single Unit once the node is registered with the network map.
*/ */
fun isRegisteredWithNetworkMap(): Boolean @RPCReturnsObservables
fun waitUntilRegisteredWithNetworkMap(): Observable<Unit>
// TODO These need rethinking. Instead of these direct calls we should have a way of replicating a subset of // TODO These need rethinking. Instead of these direct calls we should have a way of replicating a subset of
// the node's state locally and query that directly. // the node's state locally and query that directly.

View File

@ -334,7 +334,7 @@ open class DriverDSL(
client.start(ArtemisMessagingComponent.NODE_USER, ArtemisMessagingComponent.NODE_USER) client.start(ArtemisMessagingComponent.NODE_USER, ArtemisMessagingComponent.NODE_USER)
return@poll client.proxy() return@poll client.proxy()
} catch(e: Exception) { } catch(e: Exception) {
log.error("Retrying query node info at $nodeAddress") log.error("Exception $e, Retrying RPC connection at $nodeAddress")
null null
} }
} }
@ -380,12 +380,8 @@ open class DriverDSL(
registerProcess(processFuture) registerProcess(processFuture)
return processFuture.flatMap { process -> return processFuture.flatMap { process ->
establishRpc(messagingAddress, configuration).flatMap { rpc -> establishRpc(messagingAddress, configuration).flatMap { rpc ->
poll(executorService, "$name to register with the network map") { rpc.waitUntilRegisteredWithNetworkMap().toFuture().map {
if (rpc.isRegisteredWithNetworkMap()) { NodeHandle(rpc.nodeIdentity(), rpc, configuration, process)
NodeHandle(rpc.nodeIdentity(), rpc, configuration, process)
} else {
null
}
} }
} }
} }

View File

@ -111,8 +111,7 @@ class CordaRPCOpsImpl(
} }
} }
override fun isRegisteredWithNetworkMap() = services.networkMapCache.mapServiceRegistered.isDone override fun waitUntilRegisteredWithNetworkMap() = services.networkMapCache.mapServiceRegistered.toObservable()
override fun partyFromKey(key: CompositeKey) = services.identityService.partyFromKey(key) override fun partyFromKey(key: CompositeKey) = services.identityService.partyFromKey(key)
override fun partyFromName(name: String) = services.identityService.partyFromName(name) override fun partyFromName(name: String) = services.identityService.partyFromName(name)