Class LedgerClient
- All Implemented Interfaces:
Closeable,AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classMSG_AUTH was refused: by the engine (LedgerClient.LedgerProtocolException.statusCode()35, ERR_PERMISSION, with the engine's reason) or by the client before anything was sent (LedgerClient.LedgerProtocolException.statusCode()null: empty, too long, or a cleartext credential without the opt-in).static classstatic classA reply that is not a successful answer, as distinct from a transport failure.static final classThe engine answered a non-success status: a RESP_ERROR frame carrying its status, or the declined item of a single write.static final classA connect, TLS handshake, write or read did not finish in time.static classstatic final classThe call was refused before anything was sent: no connection (a failure or timeout closed it, or it was never opened).static final recordSocket timeouts, in milliseconds.static final recordstatic final recordstatic final recordstatic final record -
Field Summary
FieldsModifier and TypeFieldDescriptionStatuses that are transient but leave the outcome UNKNOWN: the write may have committed (contracts/status-codes.env, classambiguous): 12 ERR_QUORUM_TIMEOUT, which a leader that lost quorum or leadership mid-write answers without knowing the outcome.static final intA create of an existing (ledger, currency, id) whose CREATION attributes differ (an identical retry answers OK_DUPLICATE).static final intThe transfer's amount exceeds the ledger's max_txn_amount cap — a durable business decline; replaying the identity returns it.static final intAn export page from a partition-group member was refused; the sub-code (64-75) is in the export response header, not a status.static final intThis node no longer retains the transfer's history record: its history retention purged it (point lookups).static final intA membership change was refused by the leader's strict reconfig check: the PROPOSED voters have no live, caught-up quorum right now.static final intStatuses that are the same answer on every node and every retry: the request itself was refused (conflicts, malformed, not permitted, breaks a ledger rule).static final intCeiling on the pipeline window, matching LEDGERD_MAX_PIPELINE_DEPTH in the C SDK.static final intstatic final intstatic final intreserve-expiry: commit/rollback of a reservation that lapsed past its deadline (the hold was released; it resolved to phase EXPIRED = 3).static final intR3-M4: split overloaded ERR_CONFIG into specific codesstatic final intstatic final intstatic final intEngine-owned reject reason codes.static final int45 and 46 are reserved for TxnRecord v2 (a retry with different fields; the effective_ts window).static final intStatuses that mean the server shed load or hit a transient failure and NOTHING was written: back off and retry with the SAME identity (txnId / transfer id); the engine's duplicate check makes the retry safe whichever attempt landed.static final intstatic final byteExplicit-reject transfer flag (TXN_FLAG_REJECT): the engine fixes the recorded result_code to ERR_UPSTREAM_REJECTED (41); the caller's own classification is RejectCreate.reasonCode, recorded verbatim. -
Constructor Summary
ConstructorsConstructorDescriptionLedgerClient(String host, int port, int timeoutMs) Legacy form:timeoutMsbounds connect, read and write alike.LedgerClient(String host, int port, int timeoutMs, boolean useIso20022RefSize) LedgerClient(String host, int port, int timeoutMs, boolean useIso20022RefSize, LedgerClient.TlsOptions tlsOptions) LedgerClient(String host, int port, int timeoutMs, boolean useIso20022RefSize, LedgerClient.TlsOptions tlsOptions, boolean allowPlaintext) LedgerClient(String host, int port, LedgerClient.Timeouts timeouts) Explicit timeouts; TLS and the plaintext opt-in from the environment.LedgerClient(String host, int port, LedgerClient.Timeouts timeouts, boolean useIso20022RefSize, LedgerClient.TlsOptions tlsOptions) LedgerClient(String host, int port, LedgerClient.Timeouts timeouts, boolean useIso20022RefSize, LedgerClient.TlsOptions tlsOptions, boolean allowPlaintext) -
Method Summary
Modifier and TypeMethodDescriptionvoidactivateFeature(int featureId) Activate a cluster capability flag (requires cluster-admin), e.g. history purge (feature id 3).static voidassertAccepted(Models.TransferResult result) static voidassertAccepted(Models.TransferResult result, boolean allowDuplicate) authenticate(Auth credential) Send one MSG_AUTH on the open connection, switching its principal for every later request.static LedgerClient.TxnStatusclassifyResult(Models.TransferResult result) static LedgerClient.TxnStatusclassifyStatusCode(int statusCode) voidZero and forget the reconnect credential; later connections are anonymous.voidclose()commitBatch(List<String> transferIds) commitBatch(List<String> transferIds, int pipelineDepth) As commitBatch, keepingpipelineDepthbatch frames in flight on this connection.commitByKey(long sourceId, int ledgerId, int currency, String txnId) voidconnect()Dial (or re-dial) the server.voidcreateAccount(Models.AccountCreate account) Rides MSG_CREATE_ACCOUNT_BATCH with one item (the single-op message is retired).createCurrency(Models.CurrencyInstance request) createLedger(Models.LedgerInstance request) createSource(Models.SourceInstance request) static StringderiveTransferId(long sourceId, int ledgerId, int currency, String txnId) static StringderiveTransferId(long sourceId, int ledgerId, int currency, String txnId, boolean useIso20022RefSize) static StringderiveTransferId(long sourceId, long ledgerId, long currency, String txnId, boolean useIso20022RefSize) As above, with ledger and currency as plain u32 values (a ledger id up toCodec.LEDGER_ID_CLIENT_MAX).static byte[]deriveTransferIdBytes(long sourceId, int ledgerId, int currency, String txnId) static byte[]deriveTransferIdBytes(long sourceId, int ledgerId, int currency, String txnId, boolean useIso20022RefSize) static byte[]deriveTransferIdBytes(long sourceId, long ledgerId, long currency, String txnId, boolean useIso20022RefSize) getAccountHistory(Models.AccountKey key, long afterTimestamp, int limit) Balance of the account named bykey= (ledgerId, currency, id).getBalance(Models.AccountKey key, long minBatchSeq) getBalance(AccountKey)with a read-your-writes token: a non-zerominBatchSeq(e.g. a write's batch_seq) makes the server answer only once it has applied through it; 0 is a plain read.getCurrency(int numeric) shortInspect the current session-wide default frame flags.getHistory(Models.AccountKey key, long afterSeq, int limit) getHistory(Models.AccountKey key, long afterSeq, int afterIndex, int limit) Paged account history resuming after the composite cursor (afterSeq, afterIndex).getLedger(int ledgerId) getSource(int numeric) getTransaction(String transferId) getTransactionByKey(long sourceId, int ledgerId, int currency, String txnId) getTransactionByTransferId(byte[] transferId) Return the human-readable build identity of the connected daemon — the same string thattuladbd --versionprints.booleanWhether this client currently holds a socket.voidledgerAddSource(int ledgerId, int sourceNumeric) ledgerListSources(int ledgerId) voidledgerRemoveSource(int ledgerId, int sourceNumeric) voidledgerSetExpiry(int ledgerId, long reserveTtlNs) Set (or clear, with 0) a ledger's 2PC reservation TTL, in NANOSECONDS.voidledgerSetMaxAmount(int ledgerId, long maxTxnAmount) Set (or clear, with 0) a ledger's per-transaction amount cap.listAccountBalances(int ledgerId, long accountHi, long accountLo) Every balance business id(accountHi, accountLo)holds within ONE ledger: one row per currency, ordered by currency.listAccounts(int offset, int limit) listPending(long afterSeq, int limit) listPending(long afterSeq, int afterIndex, int limit) listRejected(long afterSeq, int limit) listRejected(long afterSeq, int afterIndex, int limit) listTransfers(long afterSeq, int limit) listTransfers(long afterSeq, int afterIndex, int limit) List transfers resuming after the composite cursor (afterSeq, afterIndex).listTransfersExtended(int maxRecords, int pageLimit, boolean includePending) listWrappedTransactions(int maxRecords, int pageLimit, boolean includePending) voidping()intintpromoteStandby(String group) Ask the leader to promote the best caught-up standby learner ingroupto voter (per-lane catch-up verified).voidreconfig(byte[] configPayload) Submit a serialised ClusterConfig to the leader (control-plane, Raft §4).voidDial again if a failure dropped the connection; a no-op while connected.reject(Models.RejectCreate reject) rejectByKey(long sourceId, int currency, String txnId) rejectByKey(long sourceId, int currency, String txnId, long amount) rejectByKey(long sourceId, int currency, String txnId, long amount, int ledgerId, int reasonCode, Object custom) rejectByKey(long sourceId, int currency, String txnId, long amount, int ledgerId, long debitHi, long debitLo, long creditHi, long creditLo, int reasonCode, Object custom) static booleanrejectReasonIsEngine(long reasonCode) True iff the engine wrote the reason, rather than a caller.reserve(Models.TransferCreate transfer) reserveBatch(List<Models.TransferCreate> transfers) reserveBatch(List<Models.TransferCreate> transfers, int pipelineDepth) As reserveBatch, keepingpipelineDepthbatch frames in flight on this connection.rollbackBatch(List<String> transferIds) rollbackBatch(List<String> transferIds, int pipelineDepth) As rollbackBatch, keepingpipelineDepthbatch frames in flight on this connection.rollbackByKey(long sourceId, int ledgerId, int currency, String txnId) searchTransactions(Models.TxnSearch search) voidsetAccountActive(Models.AccountKey key, boolean active) Toggle ACCT_INACTIVE on the account named bykey.setCurrencyActive(int numeric, boolean active) voidsetDefaultFlags(short flags) Set the session-wide default frame flags.voidsetPipelineDepth(int depth) Set the default number of batch frames in flight for the*Batchcalls.setSourceActive(int numeric, boolean active) static booleanstatusIsAmbiguous(int statusCode) True iffstatusCodemay have committed (seeAMBIGUOUS_STATUSES).static booleanstatusIsFinal(int statusCode) True iffstatusCodeis a deterministic verdict (seeFINAL_STATUSES).static booleanstatusIsRetryable(int statusCode) True iffstatusCodeis transient: back off and retry with the same identity; nothing was written (seeRETRYABLE_STATUSES).static StringstatusName(int statusCode) tieredCommit(String transferId) tieredCommitBatch(List<String> transferIds) tieredCommitBatch(List<String> transferIds, int pipelineDepth) As tieredCommitBatch, keepingpipelineDepthbatch frames in flight on this connection.tieredCommitByKey(long sourceId, int ledgerId, int currency, String txnId) tieredReserve(Models.TieredTransferCreate transfer) tieredReserveBatch(List<Models.TieredTransferCreate> transfers) tieredReserveBatch(List<Models.TieredTransferCreate> transfers, int pipelineDepth) As tieredReserveBatch, keepingpipelineDepthbatch frames in flight on this connection.tieredRollback(String transferId) tieredRollbackBatch(List<String> transferIds) tieredRollbackBatch(List<String> transferIds, int pipelineDepth) As tieredRollbackBatch, keepingpipelineDepthbatch frames in flight on this connection.tieredRollbackByKey(long sourceId, int ledgerId, int currency, String txnId) tieredTransfer(Models.TieredTransferCreate transfer) tieredTransferBatch(List<Models.TieredTransferCreate> transfers) tieredTransferBatch(List<Models.TieredTransferCreate> transfers, int pipelineDepth) As tieredTransferBatch, keepingpipelineDepthbatch frames in flight on this connection.timeouts()transfer(Models.TransferCreate transfer) transferBatch(List<Models.TransferCreate> transfers) transferBatch(List<Models.TransferCreate> transfers, int pipelineDepth) As transferBatch, keepingpipelineDepthbatch frames in flight on this connection.voidtransferLeadership(int targetNodeId) Ask the leader to gracefully transfer leadership totargetNodeId(Raft §3.10).voidupdateAccountLimitHigh(Models.AccountKey key, long limitHigh) voidupdateAccountLimitLow(Models.AccountKey key, long limitLow) booleanWhether transfer ids use the ISO 20022 reference size (ids derived by key follow it).Authenticate every connection this client opens with MSG_AUTH (seeAuth):connect()and everyreconnect()send it right after the TCP connect / TLS handshake, before any request, and fail withLedgerClient.LedgerAuthExceptionif the engine refuses it.
-
Field Details
-
TXN_FLAG_REJECT
public static final byte TXN_FLAG_REJECTExplicit-reject transfer flag (TXN_FLAG_REJECT): the engine fixes the recorded result_code to ERR_UPSTREAM_REJECTED (41); the caller's own classification is RejectCreate.reasonCode, recorded verbatim.- See Also:
-
ERR_UPSTREAM_REJECTED
public static final int ERR_UPSTREAM_REJECTED- See Also:
-
ERR_AMOUNT_EXCEEDS_MAX
public static final int ERR_AMOUNT_EXCEEDS_MAXThe transfer's amount exceeds the ledger's max_txn_amount cap — a durable business decline; replaying the identity returns it.- See Also:
-
ERR_HISTORY_PURGED
public static final int ERR_HISTORY_PURGEDThis node no longer retains the transfer's history record: its history retention purged it (point lookups). The money effect and idempotency are unaffected; look the record up in the export destination. Permanent on this node, but retention is per node, so the answer can differ by node: another node may still return the record, or answer ERR_NOT_FOUND (9). Below a node's purge floor NOT_FOUND and this status both mean "not retained here", so NOT_FOUND there does not prove the transfer never existed.- See Also:
-
ERR_ACCOUNT_CONFLICT
public static final int ERR_ACCOUNT_CONFLICTA create of an existing (ledger, currency, id) whose CREATION attributes differ (an identical retry answers OK_DUPLICATE). Also answered while the engine's create guard holds the same id under another key. Deterministic: every node and every retry say the same.- See Also:
-
RESERVED_45
public static final int RESERVED_4545 and 46 are reserved for TxnRecord v2 (a retry with different fields; the effective_ts window). Never returned until v2 lands.- See Also:
-
RESERVED_46
public static final int RESERVED_46- See Also:
-
ERR_EXPORT_GROUP_CONFLICT
public static final int ERR_EXPORT_GROUP_CONFLICTAn export page from a partition-group member was refused; the sub-code (64-75) is in the export response header, not a status. Not retryable, except sub-code 71 (retry against the leader), so it is not inFINAL_STATUSES: the status alone cannot tell 71 apart.- See Also:
-
ERR_RECONFIG_NO_QUORUM
public static final int ERR_RECONFIG_NO_QUORUMA membership change was refused by the leader's strict reconfig check: the PROPOSED voters have no live, caught-up quorum right now. Nothing was proposed. Retryable once enough of them are up, so it is not inFINAL_STATUSES.- See Also:
-
FINAL_STATUSES
Statuses that are the same answer on every node and every retry: the request itself was refused (conflicts, malformed, not permitted, breaks a ledger rule).SmartLedgerClientreturns them at once instead of re-routing and retrying. Mirrors the C SDK's ledgerd_status_is_final. ERR_CONFIG (19) is deliberately NOT final: the engine also answers it for transient, never-executed cases. NOT_FOUND (9) is not final either: a lagging node may not have the record yet. -
RETRYABLE_STATUSES
Statuses that mean the server shed load or hit a transient failure and NOTHING was written: back off and retry with the SAME identity (txnId / transfer id); the engine's duplicate check makes the retry safe whichever attempt landed. Mirrors the C SDK's ledgerd_status_is_retryable and contracts/status-codes.env (classretryable). A status in neither this set norFINAL_STATUSES(NOT_FOUND, ERR_CONFIG, an inactive account, an unknown code...) depends on state that can change:SmartLedgerClientstill retries it after a leader refresh, but a caller retrying by hand should look at the status first. -
AMBIGUOUS_STATUSES
Statuses that are transient but leave the outcome UNKNOWN: the write may have committed (contracts/status-codes.env, classambiguous): 12 ERR_QUORUM_TIMEOUT, which a leader that lost quorum or leadership mid-write answers without knowing the outcome. Retry only with the SAME identity (txnId, transfer id, an explicit ledger id), whose replay answers the original's outcome (OK_DUPLICATE if it landed). Never resend an operation with no identity:SmartLedgerClientreturns it with a message starting "outcome unknown". -
REJECT_REASON_ENGINE_BASE
public static final int REJECT_REASON_ENGINE_BASEEngine-owned reject reason codes.rejectReasonCodeis normally YOUR taxonomy, recorded verbatim on an explicit reject; the top of the u32 space is reserved for the engine so an engine-originated decline carries a reason no caller can collide with (a caller supplying one is refused). Encoding:0xFFFF0000 | status.- See Also:
-
REJECT_REASON_AMOUNT_EXCEEDS_MAX
public static final int REJECT_REASON_AMOUNT_EXCEEDS_MAX- See Also:
-
REJECT_ERR_WIRE_PARSE
public static final int REJECT_ERR_WIRE_PARSER3-M4: split overloaded ERR_CONFIG into specific codes. - REJECT_ERR_WIRE_PARSE: wire-level decode failed (short payload, malformed batch). The request as sent is broken; the client needs to fix the payload, not resend it. - REJECT_ERR_WRONG_MODE: the ledger mode doesn't allow this operation (e.g. tiered op against a default ledger). The remaining REJECT_ERR_CONFIG=19 cases are genuine server- side config validation errors. See engine include/ledger_types.h for the canonical contract.- See Also:
-
REJECT_ERR_WRONG_MODE
public static final int REJECT_ERR_WRONG_MODE- See Also:
-
REJECT_ERR_DEADLINE_EXCEEDED
public static final int REJECT_ERR_DEADLINE_EXCEEDED- See Also:
-
REJECT_ERR_RESERVE_EXPIRED
public static final int REJECT_ERR_RESERVE_EXPIREDreserve-expiry: commit/rollback of a reservation that lapsed past its deadline (the hold was released; it resolved to phase EXPIRED = 3).- See Also:
-
TXN_BATCH_MAX
public static final int TXN_BATCH_MAX- See Also:
-
MAX_PIPELINE_DEPTH
public static final int MAX_PIPELINE_DEPTHCeiling on the pipeline window, matching LEDGERD_MAX_PIPELINE_DEPTH in the C SDK. The send loop pushes the whole window before reading any of it, so an unbounded depth deadlocks: once the server's receive buffer and our send buffer are both full, the server blocks writing responses nobody is reading while we block writing requests it cannot accept -- and the io lock is held throughout. Depth only buys round-trip overlap, which saturates long before this ceiling.- See Also:
-
MAX_RESPONSE_PAYLOAD_BYTES
public static final int MAX_RESPONSE_PAYLOAD_BYTES- See Also:
-
-
Constructor Details
-
LedgerClient
Legacy form:timeoutMsbounds connect, read and write alike. -
LedgerClient
Explicit timeouts; TLS and the plaintext opt-in from the environment. -
LedgerClient
public LedgerClient(String host, int port, LedgerClient.Timeouts timeouts, boolean useIso20022RefSize, LedgerClient.TlsOptions tlsOptions) -
LedgerClient
-
LedgerClient
public LedgerClient(String host, int port, int timeoutMs, boolean useIso20022RefSize, LedgerClient.TlsOptions tlsOptions) -
LedgerClient
public LedgerClient(String host, int port, int timeoutMs, boolean useIso20022RefSize, LedgerClient.TlsOptions tlsOptions, boolean allowPlaintext) - Parameters:
allowPlaintext- accept cleartext ledger traffic to a non-loopback host. The other constructors read TULADB_CLIENT_ALLOW_PLAINTEXT instead; this one puts the choice at the call site, where a code review can see it.
-
LedgerClient
public LedgerClient(String host, int port, LedgerClient.Timeouts timeouts, boolean useIso20022RefSize, LedgerClient.TlsOptions tlsOptions, boolean allowPlaintext)
-
-
Method Details
-
statusIsFinal
public static boolean statusIsFinal(int statusCode) True iffstatusCodeis a deterministic verdict (seeFINAL_STATUSES). -
statusIsAmbiguous
public static boolean statusIsAmbiguous(int statusCode) True iffstatusCodemay have committed (seeAMBIGUOUS_STATUSES). -
statusIsRetryable
public static boolean statusIsRetryable(int statusCode) True iffstatusCodeis transient: back off and retry with the same identity; nothing was written (seeRETRYABLE_STATUSES). Use it to pick which items of a batch reply to resubmit. -
rejectReasonIsEngine
public static boolean rejectReasonIsEngine(long reasonCode) True iff the engine wrote the reason, rather than a caller. -
useIso20022RefSize
public boolean useIso20022RefSize()Whether transfer ids use the ISO 20022 reference size (ids derived by key follow it). -
connect
Dial (or re-dial) the server. Replaces any current connection, and re-opens a client that wasclosed.Bounded end to end: the TCP connect by
LedgerClient.Timeouts.connectMs(), the TLS handshake as described onLedgerClient.Timeouts. A miss throwsLedgerClient.LedgerTimeoutException.- Throws:
IOException
-
reconnect
Dial again if a failure dropped the connection; a no-op while connected.Any I/O failure or timeout closes the connection (a late reply must not be read as the next request's), and every later call then fails with "client is not connected" until this or
connect()runs. Unlikeconnect(), this refuses to bring back a client its ownerclosed, so a wrapper that reconnects on its own cannot resurrect a client that is being shut down.- Throws:
IOException
-
timeouts
-
withAuth
Authenticate every connection this client opens with MSG_AUTH (seeAuth):connect()and everyreconnect()send it right after the TCP connect / TLS handshake, before any request, and fail withLedgerClient.LedgerAuthExceptionif the engine refuses it. Setup-only: call it beforeconnect(). The credential is copied; callclearAuth()to zero the client's copy.A credential the client will not send (empty, too long, or cleartext without
Auth.allowInsecure(boolean)) fails the connect before anything goes on the wire. -
clearAuth
public void clearAuth()Zero and forget the reconnect credential; later connections are anonymous. -
authenticate
Send one MSG_AUTH on the open connection, switching its principal for every later request. One-shot: a reconnect replayswithAuth(com.tuladb.Auth)'s credential, not this one. A rejection throwsLedgerClient.LedgerAuthExceptionand leaves the connection open (the engine drops any earlier identity).- Throws:
IOException
-
setDefaultFlags
public void setDefaultFlags(short flags) Set the session-wide default frame flags. Currently the only meaningful value isProtocol.WIRE_FLAG_ALLOW_FOLLOWER_READ(0x08), which lets a connected follower serve reads locally when it has read-quorum visibility and has applied the caller's own prior writes. Server silently ignores the bit on writes, so it is safe to leave set across a long-lived session. -
getDefaultFlags
public short getDefaultFlags()Inspect the current session-wide default frame flags. -
getVersion
Return the human-readable build identity of the connected daemon — the same string thattuladbd --versionprints. Format: "tuladbd\nbuild: - Throws:
IOException
-
ping
- Throws:
IOException
-
transferLeadership
Ask the leader to gracefully transfer leadership totargetNodeId(Raft §3.10). The leader validates the target is a caught-up voter, sends it CTRL_TIMEOUT_NOW and steps down; the election may still be in flight when this returns. Must be sent to the leader (a follower returns an error). Throws on failure (not leader, target not a voter, target lagging).- Throws:
IOException
-
activateFeature
Activate a cluster capability flag (requires cluster-admin), e.g. history purge (feature id 3). Reservation expiry needs no activation: the engine always has it on, and activatingProtocol.FEATURE_RESERVE_EXPIRYanswers OK without writing anything.The leader replicates the activation and every voter must advertise SUPPORTED first, so this fails closed on a mixed-version cluster.
- Throws:
IOException
-
ledgerSetExpiry
Set (or clear, with 0) a ledger's 2PC reservation TTL, in NANOSECONDS. Admin op (ledger-operator), replicated, new-reserves-only: a reserve taken after this observes the new TTL, one already pending keeps the deadline stamped at its own reserve time. Reservation expiry is always on in the engine: no feature activation is needed.- Throws:
IOException
-
ledgerSetMaxAmount
Set (or clear, with 0) a ledger's per-transaction amount cap. Admin op (ledger-operator), replicated, new-transfers-only. Over-cap transfers decline durably with status 42 (ERR_AMOUNT_EXCEEDS_MAX).- Throws:
IOException
-
reconfig
Submit a serialised ClusterConfig to the leader (control-plane, Raft §4).configPayloadis the on-wire ClusterConfig (header + members); the leader picks single-server vs joint consensus by the voter-set delta and only ACKs after the change is quorum-committed and applied. Must be sent to the leader. Throws on failure (e.g. not leader, unsafe transition).- Throws:
IOException
-
promoteStandby
Ask the leader to promote the best caught-up standby learner ingroupto voter (per-lane catch-up verified). Returns the promoted node id. Throws on failure (e.g. not leader, no caught-up standby).- Throws:
IOException
-
createLedger
- Throws:
IOException
-
getLedger
- Throws:
IOException
-
listLedgers
- Throws:
IOException
-
ledgerAddSource
- Throws:
IOException
-
ledgerRemoveSource
- Throws:
IOException
-
ledgerListSources
- Throws:
IOException
-
createSource
- Throws:
IOException
-
getSource
- Throws:
IOException
-
listSources
- Throws:
IOException
-
setSourceActive
- Throws:
IOException
-
setAccountActive
Toggle ACCT_INACTIVE on the account named bykey. Raises on an unknown key (never another key's account) or a closed account.- Throws:
IOException
-
createCurrency
- Throws:
IOException
-
getCurrency
- Throws:
IOException
-
listCurrencies
- Throws:
IOException
-
setCurrencyActive
- Throws:
IOException
-
createAccount
Rides MSG_CREATE_ACCOUNT_BATCH with one item (the single-op message is retired). An identical existing account answers OK, so re-creating it succeeds; any other item status throwsLedgerClient.LedgerProtocolExceptioncarrying that status (e.g. ERR_ACCOUNT_CONFLICT).- Throws:
IOException
-
updateAccountLimitLow
- Throws:
IOException
-
updateAccountLimitHigh
- Throws:
IOException
-
listAccounts
- Throws:
IOException
-
transfer
- Throws:
IOException
-
reserve
- Throws:
IOException
-
commit
- Throws:
IOException
-
rollback
- Throws:
IOException
-
commitByKey
public Models.TransferResult commitByKey(long sourceId, int ledgerId, int currency, String txnId) throws IOException - Throws:
IOException
-
rollbackByKey
public Models.TransferResult rollbackByKey(long sourceId, int ledgerId, int currency, String txnId) throws IOException - Throws:
IOException
-
reject
- Throws:
IOException
-
rejectByKey
public Models.TransferResult rejectByKey(long sourceId, int currency, String txnId) throws IOException - Throws:
IOException
-
rejectByKey
public Models.TransferResult rejectByKey(long sourceId, int currency, String txnId, long amount) throws IOException - Throws:
IOException
-
rejectByKey
public Models.TransferResult rejectByKey(long sourceId, int currency, String txnId, long amount, int ledgerId, int reasonCode, Object custom) throws IOException - Throws:
IOException
-
rejectByKey
public Models.TransferResult rejectByKey(long sourceId, int currency, String txnId, long amount, int ledgerId, long debitHi, long debitLo, long creditHi, long creditLo, int reasonCode, Object custom) throws IOException - Throws:
IOException
-
transferBatch
public List<Models.TransferResult> transferBatch(List<Models.TransferCreate> transfers) throws IOException - Throws:
IOException
-
transferBatch
public List<Models.TransferResult> transferBatch(List<Models.TransferCreate> transfers, int pipelineDepth) throws IOException As transferBatch, keepingpipelineDepthbatch frames in flight on this connection.- Throws:
IOException
-
reserveBatch
public List<Models.TransferResult> reserveBatch(List<Models.TransferCreate> transfers) throws IOException - Throws:
IOException
-
reserveBatch
public List<Models.TransferResult> reserveBatch(List<Models.TransferCreate> transfers, int pipelineDepth) throws IOException As reserveBatch, keepingpipelineDepthbatch frames in flight on this connection.- Throws:
IOException
-
commitBatch
- Throws:
IOException
-
commitBatch
public List<Models.TransferResult> commitBatch(List<String> transferIds, int pipelineDepth) throws IOException As commitBatch, keepingpipelineDepthbatch frames in flight on this connection.- Throws:
IOException
-
rollbackBatch
- Throws:
IOException
-
rollbackBatch
public List<Models.TransferResult> rollbackBatch(List<String> transferIds, int pipelineDepth) throws IOException As rollbackBatch, keepingpipelineDepthbatch frames in flight on this connection.- Throws:
IOException
-
tieredTransferBatch
public List<Models.TieredTransferResult> tieredTransferBatch(List<Models.TieredTransferCreate> transfers) throws IOException - Throws:
IOException
-
tieredTransferBatch
public List<Models.TieredTransferResult> tieredTransferBatch(List<Models.TieredTransferCreate> transfers, int pipelineDepth) throws IOException As tieredTransferBatch, keepingpipelineDepthbatch frames in flight on this connection.- Throws:
IOException
-
tieredReserveBatch
public List<Models.TieredTransferResult> tieredReserveBatch(List<Models.TieredTransferCreate> transfers) throws IOException - Throws:
IOException
-
tieredReserveBatch
public List<Models.TieredTransferResult> tieredReserveBatch(List<Models.TieredTransferCreate> transfers, int pipelineDepth) throws IOException As tieredReserveBatch, keepingpipelineDepthbatch frames in flight on this connection.- Throws:
IOException
-
tieredCommitBatch
public List<Models.TieredTransferResult> tieredCommitBatch(List<String> transferIds) throws IOException - Throws:
IOException
-
tieredCommitBatch
public List<Models.TieredTransferResult> tieredCommitBatch(List<String> transferIds, int pipelineDepth) throws IOException As tieredCommitBatch, keepingpipelineDepthbatch frames in flight on this connection.- Throws:
IOException
-
tieredRollbackBatch
public List<Models.TieredTransferResult> tieredRollbackBatch(List<String> transferIds) throws IOException - Throws:
IOException
-
tieredRollbackBatch
public List<Models.TieredTransferResult> tieredRollbackBatch(List<String> transferIds, int pipelineDepth) throws IOException As tieredRollbackBatch, keepingpipelineDepthbatch frames in flight on this connection.- Throws:
IOException
-
tieredTransfer
public Models.TieredTransferResult tieredTransfer(Models.TieredTransferCreate transfer) throws IOException - Throws:
IOException
-
tieredReserve
public Models.TieredTransferResult tieredReserve(Models.TieredTransferCreate transfer) throws IOException - Throws:
IOException
-
tieredCommit
- Throws:
IOException
-
tieredRollback
- Throws:
IOException
-
tieredCommitByKey
public Models.TieredTransferResult tieredCommitByKey(long sourceId, int ledgerId, int currency, String txnId) throws IOException - Throws:
IOException
-
tieredRollbackByKey
public Models.TieredTransferResult tieredRollbackByKey(long sourceId, int ledgerId, int currency, String txnId) throws IOException - Throws:
IOException
-
getBalance
Balance of the account named bykey= (ledgerId, currency, id).- Throws:
IOException
-
getBalance
getBalance(AccountKey)with a read-your-writes token: a non-zerominBatchSeq(e.g. a write's batch_seq) makes the server answer only once it has applied through it; 0 is a plain read.- Throws:
IOException
-
listAccountBalances
public List<Models.AccountBalance> listAccountBalances(int ledgerId, long accountHi, long accountLo) throws IOException Every balance business id(accountHi, accountLo)holds within ONE ledger: one row per currency, ordered by currency. Never crosses a ledger; an id with no account in the ledger answers an empty list.- Throws:
IOException
-
getTransaction
- Throws:
IOException
-
getTransactionByTransferId
- Throws:
IOException
-
getTransactionByKey
public Models.TxnRecord getTransactionByKey(long sourceId, int ledgerId, int currency, String txnId) throws IOException - Throws:
IOException
-
getHistory
public List<Models.TxnRecord> getHistory(Models.AccountKey key, long afterSeq, int limit) throws IOException - Throws:
IOException
-
getHistory
public List<Models.TxnRecord> getHistory(Models.AccountKey key, long afterSeq, int afterIndex, int limit) throws IOException Paged account history resuming after the composite cursor (afterSeq, afterIndex). A batch shares one batch_seq across all its records, so a batch larger than one page must resume mid-batch on afterIndex or its overflow rows are re-emitted; afterIndex 0 resumes at the batch start (the legacy behaviour). Same contract aslistTransfers(long, int, int).- Throws:
IOException
-
getAccountHistory
public List<Models.AccountMetadataEvent> getAccountHistory(Models.AccountKey key, long afterTimestamp, int limit) throws IOException - Throws:
IOException
-
getClusterStatus
- Throws:
IOException
-
listTransfers
- Throws:
IOException
-
listPending
- Throws:
IOException
-
listRejected
- Throws:
IOException
-
listTransfers
public List<Models.TxnRecord> listTransfers(long afterSeq, int afterIndex, int limit) throws IOException List transfers resuming after the composite cursor (afterSeq, afterIndex). A batch shares one batch_seq across all of its records, so a batch larger than one page must resume mid-batch on batchIndex or its overflow rows are silently dropped (H1). Set both from the last row of the previous page.- Throws:
IOException
-
listPending
public List<Models.TxnRecord> listPending(long afterSeq, int afterIndex, int limit) throws IOException - Throws:
IOException
-
listRejected
public List<Models.TxnRecord> listRejected(long afterSeq, int afterIndex, int limit) throws IOException - Throws:
IOException
-
searchTransactions
- Throws:
IOException
-
listTransfersExtended
public List<Models.TxnRecord> listTransfersExtended(int maxRecords, int pageLimit, boolean includePending) throws IOException - Throws:
IOException
-
listWrappedTransactions
public List<LedgerClient.WrappedTxn> listWrappedTransactions(int maxRecords, int pageLimit, boolean includePending) throws IOException - Throws:
IOException
-
statusName
-
classifyStatusCode
-
classifyResult
-
assertAccepted
-
assertAccepted
-
deriveTransferIdBytes
-
deriveTransferIdBytes
public static byte[] deriveTransferIdBytes(long sourceId, int ledgerId, int currency, String txnId, boolean useIso20022RefSize) -
deriveTransferId
-
deriveTransferId
-
deriveTransferId
public static String deriveTransferId(long sourceId, long ledgerId, long currency, String txnId, boolean useIso20022RefSize) As above, with ledger and currency as plain u32 values (a ledger id up toCodec.LEDGER_ID_CLIENT_MAX). Theintforms read their arguments unsigned, so(int) 3_000_000_000Lworks there too. -
deriveTransferIdBytes
public static byte[] deriveTransferIdBytes(long sourceId, long ledgerId, long currency, String txnId, boolean useIso20022RefSize) -
isConnected
public boolean isConnected()Whether this client currently holds a socket. A pool handing out long-lived clients needs to know when one has been reset by a transport failure: the socket is dropped on any such error, and without this the pool keeps returning a client whose every call fails with "client is not connected" until the process restarts. True here means a socket exists, not that the peer is still there -- a connection the peer has since closed reports true until the next I/O proves otherwise, which then resets it and makes this false. Never blocks: it does not take the io lock, which a call in flight holds for its whole round trip. A pool checks this on every hand-out; behind the lock, every request waited for the frame on the wire just to learn the socket was still there, and under load that queue -- not the engine -- set the throughput. -
pipelineDepth
public int pipelineDepth() -
setPipelineDepth
public void setPipelineDepth(int depth) Set the default number of batch frames in flight for the*Batchcalls. -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-