Interface Endpoint
-
- All Superinterfaces:
Stateful<EndpointState>
- All Known Implementing Classes:
AnalyticsEndpoint,BaseEndpoint,EventingEndpoint,KeyValueEndpoint,ManagerEndpoint,QueryEndpoint,SearchEndpoint,ViewEndpoint
public interface Endpoint extends Stateful<EndpointState>
The parent interface for all endpoints.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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidconnect()Instruct thisEndpointto connect.EndpointContextcontext()Returns the context for this endpoint.EndpointDiagnosticsdiagnostics()Returns diagnostics information for this endpoint.voiddisconnect()Instruct thisEndpointto disconnect.booleanfreeToWrite()If new requests can be written to this endpointlonglastConnectedAt()Returns the timestamp when the endpoint was last connected successfully (nanoseconds).longlastResponseReceived()Holds the timestamp of the last response received (or 0 if no request ever sent).longoutstandingRequests()If this endpoint has one or more outstanding requests.booleanreceivedDisconnectSignal()On this endpointdisconnect()has been called on.StringremoteHostname()Returns the remote hostname this endpoint is connected to (without the port).intremotePort()Returns the remotePort this endpoint is connected to.<R extends Request<? extends Response>>
voidsend(R request)Sends the request into thisEndpoint.
-
-
-
Method Detail
-
connect
void connect()
Instruct thisEndpointto 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 thisEndpointto 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
<R extends Request<? extends Response>> void send(R request)
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.
-
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.
-
-