Permalink
Browse files

Merge branch 'adminclient-refactoring' of github.com:voldemort/voldem…

…ort into adminclient-refactoring
  • Loading branch information...
2 parents bd364e3 + cfb8b9f commit 699360582e6a4931e6e0825de1de4884ef364bc6 @bbansal bbansal committed Dec 16, 2009
View
@@ -10,3 +10,4 @@ node.id
rebalancing.slave.list
server.state
.version
+.temp
@@ -85,18 +85,24 @@
private Cluster cluster;
/**
- * Create an instance of Admin Client given a bootstrap server URL. The
+ * Create an instance of AdminClient given a bootstrap server URL. The
* bootstrap URL is used to get the cluster metadata.
*
- * @param bootstrapURL URL pointing to the boostrap node
- * @param config Configuration for a Voldemort client (not specific to Admin
- * API)
+ * @param bootstrapURL URL pointing to the bootstrap node
+ * @param adminClientConfig Configuration for AdminClient specifying client
+ * parameters eg. <br>
+ * <ul>
+ * <t>
+ * <li>number of threads</li>
+ * <li>number of sockets per node</li>
+ * <li>socket buffer size</li>
+ * </ul>
*/
- public AdminClient(String bootstrapURL, ClientConfig config) {
- config.setBootstrapUrls(bootstrapURL);
- this.cluster = getClusterFromBootstrapURL(bootstrapURL, config);
+ public AdminClient(String bootstrapURL, AdminClientConfig adminClientConfig) {
+ adminClientConfig.setBootstrapUrls(bootstrapURL);
+ this.cluster = getClusterFromBootstrapURL(bootstrapURL, adminClientConfig);
this.errorMapper = new ErrorCodeMapper();
- this.pool = createSocketPool(config);
+ this.pool = createSocketPool(adminClientConfig);
this.networkClassLoader = new NetworkClassLoader(Thread.currentThread()
.getContextClassLoader());
}
@@ -106,13 +112,19 @@ public AdminClient(String bootstrapURL, ClientConfig config) {
*
* @param cluster Initialized cluster object, describing the nodes we wish
* to contact
- * @param config Configuration for a Voldemort client (not specific to Admin
- * API)
+ * @param adminClientConfig Configuration for AdminClient specifying client
+ * parameters eg. <br>
+ * <ul>
+ * <t>
+ * <li>number of threads</li>
+ * <li>number of sockets per node</li>
+ * <li>socket buffer size</li>
+ * </ul>
*/
- public AdminClient(Cluster cluster, ClientConfig config) {
+ public AdminClient(Cluster cluster, AdminClientConfig adminClientConfig) {
this.cluster = cluster;
this.errorMapper = new ErrorCodeMapper();
- this.pool = createSocketPool(config);
+ this.pool = createSocketPool(adminClientConfig);
this.networkClassLoader = new NetworkClassLoader(Thread.currentThread()
.getContextClassLoader());
}
@@ -166,15 +178,13 @@ private SocketPool createSocketPool(ClientConfig config) {
* <li>Client performs a handshake with the server (sending in the update
* entries request with a store name and a {@link VoldemortFilter} instance.
* </li>
- * <li>While
- *
- * @param entryIterator has entries, the client will keep sending the
- * updates one after another to the server, buffering the data,
- * without waiting for a response from the server.</li> <li>After
- * iteration is complete, send an end of stream message, force a
- * flush of the buffer, check the response on the server to check if
- * a {@link VoldemortException} has occured.</li>
- * </ol>
+ * <li>While entryIterator has entries, the client will keep sending the
+ * updates one after another to the server, buffering the data, without
+ * waiting for a response from the server.</li>
+ * <li>After iteration is complete, send an end of stream message, force a
+ * flush of the buffer, check the response on the server to check if a
+ * {@link VoldemortException} has occured.</li>
+ * </ol>
*
* @param nodeId Id of the remote node (where we wish to update the entries)
* @param storeName Store name for the entries
@@ -0,0 +1,47 @@
+package voldemort.client.protocol.admin;
+
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import voldemort.client.ClientConfig;
+import voldemort.utils.Props;
+
+/**
+ * Client Configuration properties for {@link AdminClient} extends standard
+ * {@link ClientConfig}<br>
+ * Sets better <b><i>default</i></b> values for properties used by
+ * {@link AdminClient}.
+ *
+ * @author bbansal
+ *
+ */
+public class AdminClientConfig extends ClientConfig {
+
+ // sets better default for AdminClient
+ public AdminClientConfig() {
+ super(new Properties());
+
+ }
+
+ public AdminClientConfig(Properties properties) {
+ super(properties);
+
+ Props props = new Props(properties);
+ // set better defaults for AdminClient
+
+ if(!props.containsKey(ClientConfig.CONNECTION_TIMEOUT_MS_PROPERTY))
+ this.setConnectionTimeout(60, TimeUnit.SECONDS);
+
+ if(!props.containsKey(ClientConfig.SOCKET_TIMEOUT_MS_PROPERTY))
+ this.setSocketTimeout(24 * 60 * 60, TimeUnit.SECONDS);
+
+ if(!props.containsKey(ClientConfig.SOCKET_BUFFER_SIZE_PROPERTY))
+ this.setSocketBufferSize(16 * 1024 * 1024);
+
+ if(!props.containsKey(ClientConfig.MAX_CONNECTIONS_PER_NODE_PROPERTY))
+ this.setMaxConnectionsPerNode(3);
+
+ if(!props.containsKey(ClientConfig.MAX_THREADS_PROPERTY))
+ this.setMaxThreads(8);
+ }
+}
Oops, something went wrong.

0 comments on commit 6993605

Please sign in to comment.