ReconnectingCordaRPCOps

Wrapper over CordaRPCOps that handles exceptions when the node or the connection to the node fail.

All operations are retried on failure, except flow start operations that die before receiving a valid FlowHandle, in which case a CouldNotStartFlowException is thrown.

When calling methods that return a DataFeed like CordaRPCOps.vaultTrackBy, the returned DataFeed.updates object will no longer be a usable rx.Observable but an instance of ReconnectingObservable. The caller has to explicitly cast to ReconnectingObservable and call ReconnectingObservable.subscribe. If used as an rx.Observable it will just fail. The returned DataFeed.snapshot is the snapshot as it was when the feed was first retrieved.

Note: There is no guarantee that observations will not be lost.

This class is not a stable API. Any project that wants to use it, must copy and paste it.

Constructors

Link copied to clipboard
constructor(nodeHostAndPorts: List<NetworkHostAndPort>, username: String, password: String, rpcConfiguration: CordaRPCClientConfiguration, gracefulReconnect: GracefulReconnect = GracefulReconnect(), sslConfiguration: ClientRpcSslOptions? = null, classLoader: ClassLoader? = null, observersPool: ExecutorService)

Types

Link copied to clipboard
data class ReconnectingRPCConnection(val nodeHostAndPorts: List<NetworkHostAndPort>, val username: String, val password: String, val rpcConfiguration: CordaRPCClientConfiguration, val sslConfiguration: ClientRpcSslOptions? = null, val classLoader: ClassLoader?, val gracefulReconnect: GracefulReconnect = GracefulReconnect(), val observersPool: ExecutorService) : RPCConnection<CordaRPCOps>

Helper class useful for reconnecting to a Node.

Properties

Link copied to clipboard

Returns the network parameters the node is operating under.

Link copied to clipboard
open override val protocolVersion: Int

Returns the RPC protocol version. Exists since version 0 so guaranteed to be present.

Functions

Link copied to clipboard
open override fun acceptNewNetworkParameters(parametersHash: SecureHash)

Accept network parameters with given hash, hash is obtained through networkParametersFeed method. Information is sent back to the zone operator that the node accepted the parameters update - this process cannot be undone. Only parameters that are scheduled for update can be accepted, if different hash is provided this method will fail. Note: This operation may be restricted only to node administrators.

Link copied to clipboard
open override fun addVaultTransactionNote(txnId: SecureHash, txnNote: String)

Add note(s) to an existing Vault transaction.

Link copied to clipboard
open override fun attachmentExists(id: SecureHash): Boolean

Checks whether an attachment with the given hash is stored on the node.

Link copied to clipboard
open override fun clearNetworkMapCache()

Clear all network map data from local node cache. Notice that after invoking this method your node will lose network map data and effectively won't be able to start any flow with the peers until network map is downloaded again on next poll - from additional-node-infos directory or from network map server. It depends on the polling interval when it happens. You can also use refreshNetworkMapCache to force next fetch from network map server (not from directory - it will happen automatically). If you run local test deployment and want clear view of the network, you may want to clear also additional-node-infos directory, because cache can be repopulated from there.

Link copied to clipboard
fun close()
Link copied to clipboard
open override fun currentNodeTime(): Instant

Returns the node's current time.

Link copied to clipboard

Returns all finished flows that were started with a client ID for which the client ID mapping has not been removed. This version only returns the client ids for flows started by the same user currently calling finishedFlowsWithClientIds.

Link copied to clipboard

Returns all finished flows that were started with a client id by all RPC users for which the client ID mapping has not been removed.

Link copied to clipboard
Link copied to clipboard

Retrieve existing note(s) for a given Vault transaction.

Link copied to clipboard
open override fun isFlowsDrainingModeEnabled(): Boolean

Returns whether the flows draining mode is enabled.

Link copied to clipboard
open override fun isWaitingForShutdown(): Boolean

Returns whether the node is waiting for pending flows to complete before shutting down. Disabling draining mode cancels this state.

Link copied to clipboard
open override fun killFlow(id: StateMachineRunId): Boolean

Attempts to kill a flow. This is not a clean termination and should be reserved for exceptional cases such as stuck fibers.

Link copied to clipboard

Returns all parties currently visible on the network with their advertised services and an observable of future updates to the network.

Link copied to clipboard
open override fun networkMapSnapshot(): List<NodeInfo>

Returns all parties currently visible on the network with their advertised services.

Link copied to clipboard

Returns DataFeed object containing information on currently scheduled parameters update (null if none are currently scheduled) and observable with future update events. Any update that occurs before the deadline automatically cancels the current one. Only the latest update can be accepted. Note: This operation may be restricted only to node administrators.

Link copied to clipboard

Returns Node's NodeDiagnosticInfo, including the version details as well as the information about installed CorDapps.

Link copied to clipboard
open override fun nodeInfo(): NodeInfo

Returns Node's NodeInfo, assuming this will not change while the node is running.

Link copied to clipboard
open override fun nodeInfoFromParty(party: AbstractParty): NodeInfo?

Returns a node's info from the network map cache, where known. Notice that when there are more than one node for a given name (in case of distributed services) first service node found will be returned.

Link copied to clipboard
open override fun notaryIdentities(): List<Party>

Returns network's notary identities, assuming this will not change while the node is running.

Link copied to clipboard
open override fun notaryPartyFromX500Name(x500Name: CordaX500Name): Party?

Get a notary identity by name.

Link copied to clipboard
open override fun openAttachment(id: SecureHash): InputStream

Download an attachment JAR by ID.

Link copied to clipboard
open override fun partiesFromName(query: String, exactMatch: Boolean): Set<Party>

Returns a list of candidate matches for a given string, with optional fuzzy(ish) matching. Fuzzy matching may get smarter with time e.g. to correct spelling errors, so you should not hard-code indexes into the results but rather show them via a user interface and let the user pick the one they wanted.

Link copied to clipboard
open override fun partyFromKey(key: PublicKey): Party?

Returns the Party corresponding to the given key, if found.

Link copied to clipboard
fun CordaRPCOps.pendingFlowsCount(): DataFeed<Int, <Error class: unknown class><Int, Int>>

Returns a DataFeed of the number of pending flows. The Observable for the updates will complete the moment all pending flows will have terminated.

Link copied to clipboard

Queries attachments metadata

Link copied to clipboard

Reattach to an existing flow that was started with startFlowDynamicWithClientId and has a clientId.

Link copied to clipboard
open override fun refreshNetworkMapCache()

Poll network map server if available for the network map. Notice that you need to have compatibilityZone or networkServices configured. This is normally done automatically on the regular time interval, but you may wish to have the fresh view of network earlier.

Link copied to clipboard
open override fun registeredFlows(): List<String>

Enumerates the class names of the flows that this node knows about.

Link copied to clipboard
open override fun removeClientId(clientId: String): Boolean

Removes a flow's clientId to result/ exception mapping. If the mapping is of a running flow, then the mapping will not get removed. This version will only remove flow's that were started by the same user currently calling removeClientId.

Link copied to clipboard
open override fun removeClientIdAsAdmin(clientId: String): Boolean

Removes a flow's clientId to result/ exception mapping. If the mapping is of a running flow, then the mapping will not get removed. This version can be called for all client ids, ignoring which user originally started a flow with clientId.

Link copied to clipboard
fun runFlowWithLogicalRetry(runFlow: (CordaRPCOps) -> StateMachineRunId, hasFlowStarted: (CordaRPCOps) -> Boolean, onFlowConfirmed: () -> Unit = {}, timeout: Duration = 4.seconds)

This function runs a flow and retries until it completes successfully.

Link copied to clipboard
open override fun setFlowsDrainingModeEnabled(enabled: Boolean)

Sets the value of the node's flows draining mode. If this mode is enabled, the node will reject new flows through RPC, ignore scheduled flows, and do not process initial session messages, meaning that P2P counterparties will not be able to initiate new flows involving the node.

Link copied to clipboard
open override fun shutdown()

Shuts the node down. Returns immediately. This does not wait for flows to be completed.

Link copied to clipboard
inline fun <T, R : FlowLogic<T>> CordaRPCOps.startFlow(flowConstructor: () -> R): FlowHandle<T>
inline fun <T, A, R : FlowLogic<T>> CordaRPCOps.startFlow(flowConstructor: (A) -> R, arg0: A): FlowHandle<T>
inline fun <T, A, B, C, R : FlowLogic<T>> CordaRPCOps.startFlow(flowConstructor: (A, B, C) -> R, arg0: A, arg1: B, arg2: C): FlowHandle<T>
inline fun <T, A, B, C, D, R : FlowLogic<T>> CordaRPCOps.startFlow(flowConstructor: (A, B, C, D) -> R, arg0: A, arg1: B, arg2: C, arg3: D): FlowHandle<T>
inline fun <T, A, B, C, D, E, R : FlowLogic<T>> CordaRPCOps.startFlow(flowConstructor: (A, B, C, D, E) -> R, arg0: A, arg1: B, arg2: C, arg3: D, arg4: E): FlowHandle<T>
inline fun <T, A, B, C, D, E, F, R : FlowLogic<T>> CordaRPCOps.startFlow(flowConstructor: (A, B, C, D, E, F) -> R, arg0: A, arg1: B, arg2: C, arg3: D, arg4: E, arg5: F): FlowHandle<T>

inline fun <T, A, B, R : FlowLogic<T>> CordaRPCOps.startFlow(flowConstructor: (A, B) -> R, arg0: A, arg1: B): FlowHandle<T>

Extension function for type safe invocation of flows from Kotlin, for example:

Link copied to clipboard
open override fun <T> startFlowDynamic(logicType: Class<out FlowLogic<T>>, vararg args: Any?): FlowHandle<T>

Start the given flow with the given arguments. logicType must be annotated with net.corda.core.flows.StartableByRPC.

Link copied to clipboard
open override fun <T> startFlowDynamicWithClientId(clientId: String, logicType: Class<out FlowLogic<T>>, vararg args: Any?): FlowHandleWithClientId<T>

Start the given flow with the given arguments and a clientId.

Link copied to clipboard
inline fun <T, R : FlowLogic<T>> CordaRPCOps.startFlowWithClientId(clientId: String, flowConstructor: () -> R): FlowHandleWithClientId<T>

Extension function for type safe invocation of flows from Kotlin, with clientId.

inline fun <T, A, R : FlowLogic<T>> CordaRPCOps.startFlowWithClientId(clientId: String, flowConstructor: (A) -> R, arg0: A): FlowHandleWithClientId<T>
inline fun <T, A, B, R : FlowLogic<T>> CordaRPCOps.startFlowWithClientId(clientId: String, flowConstructor: (A, B) -> R, arg0: A, arg1: B): FlowHandleWithClientId<T>
inline fun <T, A, B, C, R : FlowLogic<T>> CordaRPCOps.startFlowWithClientId(clientId: String, flowConstructor: (A, B, C) -> R, arg0: A, arg1: B, arg2: C): FlowHandleWithClientId<T>
inline fun <T, A, B, C, D, R : FlowLogic<T>> CordaRPCOps.startFlowWithClientId(clientId: String, flowConstructor: (A, B, C, D) -> R, arg0: A, arg1: B, arg2: C, arg3: D): FlowHandleWithClientId<T>
inline fun <T, A, B, C, D, E, R : FlowLogic<T>> CordaRPCOps.startFlowWithClientId(clientId: String, flowConstructor: (A, B, C, D, E) -> R, arg0: A, arg1: B, arg2: C, arg3: D, arg4: E): FlowHandleWithClientId<T>
inline fun <T, A, B, C, D, E, F, R : FlowLogic<T>> CordaRPCOps.startFlowWithClientId(clientId: String, flowConstructor: (A, B, C, D, E, F) -> R, arg0: A, arg1: B, arg2: C, arg3: D, arg4: E, arg5: F): FlowHandleWithClientId<T>
Link copied to clipboard
inline fun <T, R : FlowLogic<T>> CordaRPCOps.startTrackedFlow(flowConstructor: () -> R): FlowProgressHandle<T>

Extension function for type safe invocation of flows from Kotlin, with progress tracking enabled.

inline fun <T, A, R : FlowLogic<T>> CordaRPCOps.startTrackedFlow(flowConstructor: (A) -> R, arg0: A): FlowProgressHandle<T>
inline fun <T, A, B, R : FlowLogic<T>> CordaRPCOps.startTrackedFlow(flowConstructor: (A, B) -> R, arg0: A, arg1: B): FlowProgressHandle<T>
inline fun <T, A, B, C, R : FlowLogic<T>> CordaRPCOps.startTrackedFlow(flowConstructor: (A, B, C) -> R, arg0: A, arg1: B, arg2: C): FlowProgressHandle<T>
inline fun <T, A, B, C, D, R : FlowLogic<T>> CordaRPCOps.startTrackedFlow(flowConstructor: (A, B, C, D) -> R, arg0: A, arg1: B, arg2: C, arg3: D): FlowProgressHandle<T>
inline fun <T, A, B, C, D, E, R : FlowLogic<T>> CordaRPCOps.startTrackedFlow(flowConstructor: (A, B, C, D, E) -> R, arg0: A, arg1: B, arg2: C, arg3: D, arg4: E): FlowProgressHandle<T>
inline fun <T, A, B, C, D, E, F, R : FlowLogic<T>> CordaRPCOps.startTrackedFlow(flowConstructor: (A, B, C, D, E, F) -> R, arg0: A, arg1: B, arg2: C, arg3: D, arg4: E, arg5: F): FlowProgressHandle<T>
Link copied to clipboard
open override fun <T> startTrackedFlowDynamic(logicType: Class<out FlowLogic<T>>, vararg args: Any?): FlowProgressHandle<T>

Start the given flow with the given arguments, returning an Observable with a single observation of the result of running the flow. logicType must be annotated with net.corda.core.flows.StartableByRPC.

Returns a snapshot list of existing state machine id - recorded transaction hash mappings, and a stream of future such mappings as well.

Returns a snapshot list of existing state machine id - recorded transaction hash mappings.

Link copied to clipboard

Returns a data feed of currently in-progress state machine infos and an observable of future state machine adds/removes.

Link copied to clipboard

Returns a list of currently in-progress state machine infos.

Link copied to clipboard
open override fun terminate(drainPendingFlows: Boolean)

Shuts the node down. Returns immediately.

Link copied to clipboard
open override fun uploadAttachment(jar: InputStream): SecureHash

Uploads a jar to the node, returns it's hash.

Link copied to clipboard
open override fun uploadAttachmentWithMetadata(jar: InputStream, uploader: String, filename: String): SecureHash

Uploads a jar including metadata to the node, returns it's hash.

Link copied to clipboard
open override fun <T : ContractState> vaultQuery(contractStateType: Class<out T>): Vault.Page<T>
Link copied to clipboard
open override fun <T : ContractState> vaultQueryBy(criteria: QueryCriteria, paging: PageSpecification, sorting: Sort, contractStateType: Class<out T>): Vault.Page<T>

Returns a snapshot of vault states for a given query criteria (and optional order and paging specification)

Link copied to clipboard
inline fun <T : ContractState> CordaRPCOps.vaultQueryBy(criteria: QueryCriteria = QueryCriteria.VaultQueryCriteria(), paging: PageSpecification = PageSpecification(), sorting: Sort = Sort(emptySet())): Vault.Page<T>
Link copied to clipboard
open override fun <T : ContractState> vaultQueryByCriteria(criteria: QueryCriteria, contractStateType: Class<out T>): Vault.Page<T>
Link copied to clipboard
open override fun <T : ContractState> vaultQueryByWithPagingSpec(contractStateType: Class<out T>, criteria: QueryCriteria, paging: PageSpecification): Vault.Page<T>
Link copied to clipboard
open override fun <T : ContractState> vaultQueryByWithSorting(contractStateType: Class<out T>, criteria: QueryCriteria, sorting: Sort): Vault.Page<T>
Link copied to clipboard
open override fun <T : ContractState> vaultTrack(contractStateType: Class<out T>): DataFeed<Vault.Page<T>, Vault.Update<T>>
Link copied to clipboard
open override fun <T : ContractState> vaultTrackBy(criteria: QueryCriteria, paging: PageSpecification, sorting: Sort, contractStateType: Class<out T>): DataFeed<Vault.Page<T>, Vault.Update<T>>

Returns a snapshot (as per queryBy) and an observable of future updates to the vault for the given query criteria.

Link copied to clipboard
inline fun <T : ContractState> CordaRPCOps.vaultTrackBy(criteria: QueryCriteria = QueryCriteria.VaultQueryCriteria(), paging: PageSpecification = PageSpecification(), sorting: Sort = Sort(emptySet())): DataFeed<Vault.Page<T>, Vault.Update<T>>
Link copied to clipboard
open override fun <T : ContractState> vaultTrackByCriteria(contractStateType: Class<out T>, criteria: QueryCriteria): DataFeed<Vault.Page<T>, Vault.Update<T>>
Link copied to clipboard
open override fun <T : ContractState> vaultTrackByWithPagingSpec(contractStateType: Class<out T>, criteria: QueryCriteria, paging: PageSpecification): DataFeed<Vault.Page<T>, Vault.Update<T>>
Link copied to clipboard
open override fun <T : ContractState> vaultTrackByWithSorting(contractStateType: Class<out T>, criteria: QueryCriteria, sorting: Sort): DataFeed<Vault.Page<T>, Vault.Update<T>>
Link copied to clipboard
fun CordaRPCOps.waitForShutdown(): <Error class: unknown class><Unit>
Link copied to clipboard

Returns a CordaFuture which completes when the node has registered wih the network map service. It can also complete with an exception if it is unable to.

Link copied to clipboard
open override fun wellKnownPartyFromAnonymous(party: AbstractParty): Party?

Returns the well known identity from an abstract party. This is intended to resolve the well known identity from a confidential identity, however it transparently handles returning the well known identity back if a well known identity is passed in.

Link copied to clipboard
open override fun wellKnownPartyFromX500Name(x500Name: CordaX500Name): Party?

Returns the Party with the X.500 principal as it's Party.name.