public class RequestHandler extends Object implements com.lmax.disruptor.EventHandler<RequestEvent>
The RequestHandler
is responsible for adding and removing Node
s as well as dispatching Service
management operations. Its main purpose though is to receive incoming CouchbaseRequest
s and dispatch them to the appropriate Node
s.
Constructor and Description |
---|
RequestHandler(CoreEnvironment environment,
Observable<ClusterConfig> configObservable,
com.lmax.disruptor.RingBuffer<ResponseEvent> responseBuffer)
Create a new
RequestHandler . |
Modifier and Type | Method and Description |
---|---|
Observable<LifecycleState> |
addNode(InetAddress hostname)
Add a
Node identified by its hostname. |
Observable<Service> |
addService(AddServiceRequest request)
Add the service to the node.
|
protected void |
checkFeaturesForRequest(CouchbaseRequest request,
BucketConfig config)
Checks, for a sub-set of
CouchbaseRequest , if the current environment has the necessary feature activated. |
protected Locator |
locator(CouchbaseRequest request)
Helper method to detect the correct locator for the given request type.
|
Node |
nodeBy(InetAddress hostname)
Returns the node by its hostname.
|
void |
onEvent(RequestEvent event,
long sequence,
boolean endOfBatch) |
Observable<ClusterConfig> |
reconfigure(ClusterConfig config)
Helper method which grabs the current configuration and checks if the node setup is out of sync.
|
Observable<LifecycleState> |
removeNode(InetAddress hostname)
Remove a
Node identified by its hostname. |
Observable<Service> |
removeService(RemoveServiceRequest request)
Remove a service from a node.
|
public RequestHandler(CoreEnvironment environment, Observable<ClusterConfig> configObservable, com.lmax.disruptor.RingBuffer<ResponseEvent> responseBuffer)
Create a new RequestHandler
.
public void onEvent(RequestEvent event, long sequence, boolean endOfBatch) throws Exception
onEvent
in interface com.lmax.disruptor.EventHandler<RequestEvent>
Exception
protected void checkFeaturesForRequest(CouchbaseRequest request, BucketConfig config)
Checks, for a sub-set of CouchbaseRequest
, if the current environment has the necessary feature activated. If not, throws an ServiceNotAvailableException
.
request
- the request to check.ServiceNotAvailableException
- if the request type needs a particular feature which isn’t activated.public Observable<LifecycleState> addNode(InetAddress hostname)
Add a Node
identified by its hostname.
hostname
- the hostname of the node.LifecycleState.CONNECTED
).public Observable<LifecycleState> removeNode(InetAddress hostname)
Remove a Node
identified by its hostname.
hostname
- the hostname of the node.LifecycleState.DISCONNECTED
).public 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 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(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 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.
Copyright © 2016 Couchbase, Inc.. All rights reserved.