public class RequestHandler extends java.lang.Object implements com.lmax.disruptor.EventHandler<RequestEvent>
The RequestHandler
handles the overall concept of Node
s and manages them concurrently.
Constructor and Description |
---|
RequestHandler(CoreEnvironment environment,
rx.Observable<ClusterConfig> configObservable,
com.lmax.disruptor.RingBuffer<ResponseEvent> responseBuffer)
Create a new
RequestHandler . |
Modifier and Type | Method and Description |
---|---|
rx.Observable<LifecycleState> |
addNode(java.net.InetAddress hostname)
Add a
Node identified by its hostname. |
rx.Observable<Service> |
addService(AddServiceRequest request)
Add the service to the node.
|
protected Locator |
locator(CouchbaseRequest request)
Helper method to detect the correct locator for the given request type.
|
Node |
nodeBy(java.net.InetAddress hostname)
Returns the node by its hostname.
|
void |
onEvent(RequestEvent event,
long sequence,
boolean endOfBatch) |
rx.Observable<ClusterConfig> |
reconfigure(ClusterConfig config)
Helper method which grabs the current configuration and checks if the node setup is out of sync.
|
rx.Observable<LifecycleState> |
removeNode(java.net.InetAddress hostname)
Remove a
Node identified by its hostname. |
rx.Observable<Service> |
removeService(RemoveServiceRequest request)
Remove a service from a node.
|
public RequestHandler(CoreEnvironment environment, rx.Observable<ClusterConfig> configObservable, com.lmax.disruptor.RingBuffer<ResponseEvent> responseBuffer)
Create a new RequestHandler
.
public void onEvent(RequestEvent event, long sequence, boolean endOfBatch) throws java.lang.Exception
onEvent
in interface com.lmax.disruptor.EventHandler<RequestEvent>
java.lang.Exception
public rx.Observable<LifecycleState> addNode(java.net.InetAddress hostname)
Add a Node
identified by its hostname.
hostname
- the hostname of the node.LifecycleState.CONNECTED
).public rx.Observable<LifecycleState> removeNode(java.net.InetAddress hostname)
Remove a Node
identified by its hostname.
hostname
- the hostname of the node.LifecycleState.DISCONNECTED
).public rx.Observable<Service> addService(AddServiceRequest request)
Add the service to the node.
request
- the request which contains infos about the service and node to add.public rx.Observable<Service> removeService(RemoveServiceRequest request)
Remove a service from a node.
request
- the request which contains infos about the service and node to remove.public Node nodeBy(java.net.InetAddress hostname)
Returns the node by its hostname.
hostname
- the hostname of the node.protected Locator locator(CouchbaseRequest request)
Helper method to detect the correct locator for the given request type.
public rx.Observable<ClusterConfig> reconfigure(ClusterConfig config)
Helper method which grabs the current configuration and checks if the node setup is out of sync.
This method is always called when a new configuration arrives and it will try to sync the actual node and service setup with the one proposed by the configuration.