public class ViewConnection extends net.spy.memcached.compat.SpyObject implements Reconfigurable
ViewConnection
is responsible for managing and multiplexing
HTTP connections to Couchbase View endpoints.
It implements Reconfigurable
, which means that will be fed with
reconfiguration updates coming from the server side. This stream changes
the collection of HttpHost
s, which represent the view endpoints.Constructor and Description |
---|
ViewConnection(CouchbaseConnectionFactory cf,
java.util.List<java.net.InetSocketAddress> seedAddrs,
java.lang.String user,
java.lang.String password)
Boostrap the
ViewConnection s. |
Modifier and Type | Method and Description |
---|---|
void |
addOp(HttpOperation op)
Write an operation to the next
HttpHost . |
void |
reconfigure(Bucket bucket)
Updates the list of active
HttpHost s based on the incoming
Bucket configuration. |
boolean |
shutdown()
Shuts down the active
ViewConnection . |
void |
signalOutdatedConfig()
Helper method to signal an outdated config and potentially force a
refresh of the connection provider.
|
public ViewConnection(CouchbaseConnectionFactory cf, java.util.List<java.net.InetSocketAddress> seedAddrs, java.lang.String user, java.lang.String password) throws java.io.IOException
ViewConnection
s.
This will also start the reactor in a separate thread, waiting for requests
to be written.cf
- the configuration factory to access other parts of the system.seedAddrs
- the list of nodes to initially connect to.user
- the HTTP username for authentication purposes.password
- the HTTP password for authentication purposes.java.io.IOException
- if the IOReactor could not be created.public void addOp(HttpOperation op)
HttpHost
.
To make sure that the operations are distributed throughout the cluster,
the HttpHost
is changed every time a new operation is added. Since
the getNextNode()
method increments the HttpHost
index and
calculates the modulo, the nodes are selected in a round-robin fashion.
Also, the target host will be added directly, so that a DNS lookup is
avoided, potentially causing delays and timeouts.op
- the operation to schedule.public void signalOutdatedConfig()
public boolean shutdown() throws java.io.IOException
ViewConnection
.java.io.IOException
- if the reactor cannot be shut down properly.public void reconfigure(Bucket bucket)
HttpHost
s based on the incoming
Bucket
configuration.
If the node is in the bucket configuration, but has no active vbuckets
assigned to it, it will not be added as an active node (because it will
not return useful results without partitions assigned). Also, a node
will be removed if during reconfiguration it is determined that all
partitions have been movd away from it.reconfigure
in interface Reconfigurable
bucket
- the updated bucket configuration.Copyright © 2006-2009 Dustin Sallings, 2009-2012 Couchbase, Inc.