Class Connection
- All Implemented Interfaces:
AutoCloseable
The Java twin of Python's biopb.tensor.Connection. It holds the live
TensorFlightClient, the URL it dials and, when it has none, why. It
caches nothing else: the catalog, health and sources are the plane's to
answer, asked on the client.
Where the plane is comes from, in order: $BIOPB_TENSOR_URL, then the
control (docs/discovery-contract.md), which also brings the plane up.
An address from anywhere but the control is dialed with an explicit token or
$BIOPB_TENSOR_TOKEN, never with the control's credential file.
connect() blocks on the network. Not thread-safe to call from two
threads at once; readers on other threads see the previous client
until the new one is ready.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConnection(TlsPinStore pins) A connection whose first-use pins go topinsinstead of the file the Python SDK shares, e.g. -
Method Summary
Modifier and TypeMethodDescriptionclient()The live client, or null until aconnect()succeeds (and again after one fails).voidclose()Close the client, if any.booleanconnect()connect(String, String, Duration)with the control naming the plane.booleanDial the data plane; true whenclientis ready to use.Why the lastconnect()failed, phrased for the person who has to fix it; empty on success.url()The address last dialed, or null.
-
Field Details
-
START_TIMEOUT
How longconnect()waits for a plane it was told is coming up.
-
-
Constructor Details
-
Connection
public Connection() -
Connection
A connection whose first-use pins go topinsinstead of the file the Python SDK shares, e.g.TlsPinStore.inMemory()to keep none on disk.
-
-
Method Details
-
client
The live client, or null until aconnect()succeeds (and again after one fails). -
url
The address last dialed, or null. -
lastMessage
Why the lastconnect()failed, phrased for the person who has to fix it; empty on success. -
connect
public boolean connect()connect(String, String, Duration)with the control naming the plane. -
connect
Dial the data plane; true whenclientis ready to use. Never throws.With no
url,$BIOPB_TENSOR_URLor else the control names the plane. Aurlis dialed as given, withtokenand nothing else.A plane the control named is waited on through
timeout, since the control may have just started it; one named anywhere else is not, except through a scan it reports asSTARTING.- Parameters:
url- the plane to dial, or null to discover ittoken- the bearer token forurl; ignored when discovering
-
close
public void close()Close the client, if any.- Specified by:
closein interfaceAutoCloseable
-