Interface Endpoint
- All Superinterfaces:
Stateful<EndpointState>
- All Known Implementing Classes:
AnalyticsEndpoint
,BackupEndpoint
,BaseEndpoint
,EventingEndpoint
,KeyValueEndpoint
,ManagerEndpoint
,QueryEndpoint
,SearchEndpoint
,ViewEndpoint
Note that while this interface has been around since the 1.x days, it has been changed up quite a bit to make it simpler and provide more functionality based on real world experience with the first iteration.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
connect()
Instruct thisEndpoint
to connect.context()
Returns the context for this endpoint.Returns diagnostics information for this endpoint.void
Instruct thisEndpoint
to disconnect.boolean
If new requests can be written to this endpointReturns the failure reason of the last connect attempt, if any.long
Returns the timestamp when the endpoint was last connected successfully (nanoseconds).long
Holds the timestamp of the last response received (or 0 if no request ever sent).long
If this endpoint has one or more outstanding requests.boolean
On this endpointdisconnect()
has been called on.Returns the remote hostname this endpoint is connected to (without the port).int
Returns the remotePort this endpoint is connected to.send
(R request) Sends the request into thisEndpoint
.
-
Method Details
-
connect
void connect()Instruct thisEndpoint
to connect.This method is async and will return immediately. Use the other methods available to inspect the current state of the endpoint, signaling potential successful connection attempts.
-
disconnect
void disconnect()Instruct thisEndpoint
to disconnect.This method is async and will return immediately. Use the other methods available to inspect the current state of the endpoint, signaling potential successful disconnection attempts.
-
send
Sends the request into thisEndpoint
.Note that there is no guarantee that the request will actually dispatched, based on the state this endpoint is in.
- Parameters:
request
- the request to send.
-
freeToWrite
boolean freeToWrite()If new requests can be written to this endpoint- Returns:
- true if free, false otherwise.
-
outstandingRequests
long outstandingRequests()If this endpoint has one or more outstanding requests.- Returns:
- the number of outstanding requests
-
lastResponseReceived
long lastResponseReceived()Holds the timestamp of the last response received (or 0 if no request ever sent).- Returns:
- the timestamp of the last response received, in nanoseconds.
-
lastConnectedAt
long lastConnectedAt()Returns the timestamp when the endpoint was last connected successfully (nanoseconds).- Returns:
- the timestamp when the endpoint was last connected, in nanoseconds.
-
diagnostics
EndpointDiagnostics diagnostics()Returns diagnostics information for this endpoint. -
internalDiagnostics
-
receivedDisconnectSignal
boolean receivedDisconnectSignal()On this endpointdisconnect()
has been called on.This is different from an endpoint just being disconnected on the remote side and continuing reconnect attempts. Once this returns true, it is never coming back.
- Returns:
- true if
disconnect()
has been called.
-
context
EndpointContext context()Returns the context for this endpoint.- Returns:
- the context.
-
remoteHostname
String remoteHostname()Returns the remote hostname this endpoint is connected to (without the port). -
remotePort
int remotePort()Returns the remotePort this endpoint is connected to. -
lastConnectAttemptFailure
Throwable lastConnectAttemptFailure()Returns the failure reason of the last connect attempt, if any.- Returns:
- returns the last failure reason, or null if connected properly or never attempted.
-