Permalink
Browse files

Merge branch 'master' of github.com:voldemort/voldemort

  • Loading branch information...
2 parents a0ea680 + aee112d commit 700117ff82f18bfe5302ce356a136722b82af745 Chinmay Soman committed Jan 13, 2012
View
@@ -13,12 +13,10 @@
<classpathentry kind="src" path="contrib/krati/src/java"/>
<classpathentry kind="src" path="contrib/krati/test"/>
<classpathentry kind="src" path="contrib/collections/src/java"/>
- <classpathentry kind="src" path="contrib/collections/test"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="src" path="contrib/collections/test"/>
<classpathentry kind="lib" path="lib/catalina-ant.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
<classpathentry kind="lib" path="lib/commons-dbcp-1.2.2.jar"/>
- <classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
<classpathentry kind="lib" path="lib/colt-1.2.0.jar"/>
<classpathentry kind="lib" path="contrib/hadoop-store-builder/lib/commons-cli-2.0-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="contrib/hadoop-store-builder/lib/hadoop-0.20.2-core.jar"/>
@@ -51,5 +49,10 @@
<classpathentry kind="lib" path="lib/mockito-all-1.8.5.jar"/>
<classpathentry kind="lib" path="lib/avro-1.4.0.jar"/>
<classpathentry kind="lib" path="lib/libthrift-0.5.0.jar"/>
+ <classpathentry kind="lib" path="lib/compress-lzf-0.9.1.jar"/>
+ <classpathentry kind="lib" path="lib/snappy-0.2.jar"/>
+ <classpathentry kind="lib" path="lib/httpclient-4.1.2.jar" />
+ <classpathentry kind="lib" path="lib/httpcore-4.1.2.jar" />
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="output" path="classes"/>
</classpath>
View
@@ -6,6 +6,7 @@ dist
*.iws
*#
.#*
+test-output
node.id
rebalancing.slave.list
server.state
@@ -1,4 +1,4 @@
-#Fri Sep 18 15:20:52 BST 2009
+#Fri Dec 30 14:37:10 PST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
@@ -149,9 +149,12 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
View
@@ -16,9 +16,9 @@
# limitations under the License.
#
-if [ $# -gt 1 ];
+if [ $# -gt 2 ];
then
- echo 'USAGE: bin/voldemort-server.sh [voldemort_home]'
+ echo 'USAGE: bin/voldemort-server.sh [voldemort_home] [voldemort_config_dir]'
exit 1
fi
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
@@ -22,15 +22,16 @@
import java.util.Collection;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpVersion;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.cookie.CookiePolicy;
-import org.apache.commons.httpclient.params.HttpClientParams;
-import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
-import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.apache.http.HttpVersion;
+import org.apache.http.client.params.CookiePolicy;
+import org.apache.http.client.params.HttpClientParams;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
+import org.apache.http.impl.conn.SchemeRegistryFactory;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpProtocolParams;
import voldemort.client.protocol.RequestFormatFactory;
import voldemort.client.protocol.RequestFormatType;
@@ -42,6 +43,7 @@
import voldemort.store.http.HttpStore;
import voldemort.store.metadata.MetadataStore;
import voldemort.utils.ByteArray;
+import voldemort.utils.VoldemortIOUtils;
/**
* A {@link voldemort.client.StoreClientFactory StoreClientFactory} that creates
@@ -55,31 +57,33 @@
private static final String VOLDEMORT_USER_AGENT = "vldmrt/0.01";
- private final HttpClient httpClient;
+ private final DefaultHttpClient httpClient;
private final RequestFormatFactory requestFormatFactory;
private final boolean reroute;
public HttpStoreClientFactory(ClientConfig config) {
super(config);
- HostConfiguration hostConfig = new HostConfiguration();
- hostConfig.getParams().setParameter("http.protocol.version", HttpVersion.HTTP_1_1);
- MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
- this.httpClient = new HttpClient(connectionManager);
- this.httpClient.setHostConfiguration(hostConfig);
- HttpClientParams clientParams = this.httpClient.getParams();
- clientParams.setConnectionManagerTimeout(config.getConnectionTimeout(TimeUnit.MILLISECONDS));
- clientParams.setSoTimeout(config.getSocketTimeout(TimeUnit.MILLISECONDS));
- clientParams.setParameter(HttpMethodParams.RETRY_HANDLER,
- new DefaultHttpMethodRetryHandler(0, false));
- clientParams.setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
- clientParams.setParameter("http.useragent", VOLDEMORT_USER_AGENT);
- HttpConnectionManagerParams managerParams = this.httpClient.getHttpConnectionManager()
- .getParams();
- managerParams.setConnectionTimeout(config.getConnectionTimeout(TimeUnit.MILLISECONDS));
- managerParams.setMaxTotalConnections(config.getMaxTotalConnections());
- managerParams.setStaleCheckingEnabled(false);
- managerParams.setMaxConnectionsPerHost(httpClient.getHostConfiguration(),
- config.getMaxConnectionsPerNode());
+ ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(SchemeRegistryFactory.createDefault(),
+ config.getConnectionTimeout(TimeUnit.MILLISECONDS),
+ TimeUnit.MILLISECONDS);
+ mgr.setMaxTotal(config.getMaxTotalConnections());
+ mgr.setDefaultMaxPerRoute(config.getMaxConnectionsPerNode());
+
+ this.httpClient = new DefaultHttpClient(mgr);
+ HttpParams clientParams = this.httpClient.getParams();
+
+ HttpProtocolParams.setUserAgent(clientParams, VOLDEMORT_USER_AGENT);
+ HttpProtocolParams.setVersion(clientParams, HttpVersion.HTTP_1_1);
+
+ HttpConnectionParams.setConnectionTimeout(clientParams,
+ config.getConnectionTimeout(TimeUnit.MILLISECONDS));
+ HttpConnectionParams.setSoTimeout(clientParams,
+ config.getSocketTimeout(TimeUnit.MILLISECONDS));
+ HttpConnectionParams.setStaleCheckingEnabled(clientParams, false);
+
+ this.httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
+ HttpClientParams.setCookiePolicy(clientParams, CookiePolicy.IGNORE_COOKIES);
+
this.reroute = config.getRoutingTier().equals(RoutingTier.SERVER);
this.requestFormatFactory = new RequestFormatFactory();
}
@@ -137,6 +141,7 @@ protected void validateUrl(URI url) {
public void close() {
super.close();
// should timeout connections on its own
+ VoldemortIOUtils.closeQuietly(this.httpClient);
}
}
@@ -48,6 +48,7 @@
private static final long serialVersionUID = 1;
public static final String VOLDEMORT_HOME_VAR_NAME = "VOLDEMORT_HOME";
+ public static final String VOLDEMORT_CONFIG_DIR = "VOLDEMORT_CONFIG_DIR";
private static final String VOLDEMORT_NODE_ID_VAR_NAME = "VOLDEMORT_NODE_ID";
public static int VOLDEMORT_DEFAULT_ADMIN_PORT = 6660;
@@ -398,17 +399,33 @@ public static VoldemortConfig loadFromEnvironmentVariable() {
+ VoldemortConfig.VOLDEMORT_HOME_VAR_NAME
+ " has been defined, set it!");
- return loadFromVoldemortHome(voldemortHome);
+ String voldemortConfigDir = System.getenv(VoldemortConfig.VOLDEMORT_CONFIG_DIR);
+ if(voldemortConfigDir != null) {
+ if(!Utils.isReadableDir(voldemortConfigDir))
+ throw new ConfigurationException("Attempt to load configuration from VOLDEMORT_CONFIG_DIR, "
+ + voldemortConfigDir
+ + " failed. That is not a readable directory.");
+ }
+ return loadFromVoldemortHome(voldemortHome, voldemortConfigDir);
}
public static VoldemortConfig loadFromVoldemortHome(String voldemortHome) {
+ String voldemortConfigDir = voldemortHome + File.separator + "config";
+ return loadFromVoldemortHome(voldemortHome, voldemortConfigDir);
+
+ }
+
+ public static VoldemortConfig loadFromVoldemortHome(String voldemortHome,
+ String voldemortConfigDir) {
if(!Utils.isReadableDir(voldemortHome))
throw new ConfigurationException("Attempt to load configuration from VOLDEMORT_HOME, "
+ voldemortHome
+ " failed. That is not a readable directory.");
- String propertiesFile = voldemortHome + File.separator + "config" + File.separator
- + "server.properties";
+ if(voldemortConfigDir == null) {
+ voldemortConfigDir = voldemortHome + File.separator + "config";
+ }
+ String propertiesFile = voldemortConfigDir + File.separator + "server.properties";
if(!Utils.isReadableFile(propertiesFile))
throw new ConfigurationException(propertiesFile
+ " is not a readable configuration file.");
@@ -417,6 +434,7 @@ public static VoldemortConfig loadFromVoldemortHome(String voldemortHome) {
try {
properties = new Props(new File(propertiesFile));
properties.put("voldemort.home", voldemortHome);
+ properties.put("metadata.directory", voldemortConfigDir);
} catch(IOException e) {
throw new ConfigurationException(e);
}
@@ -48,9 +48,11 @@ public void init(String[] args) throws Exception {
config = VoldemortConfig.loadFromEnvironmentVariable();
else if(args.length == 1)
config = VoldemortConfig.loadFromVoldemortHome(args[0]);
+ else if(args.length == 2)
+ config = VoldemortConfig.loadFromVoldemortHome(args[0], args[1]);
else
croak("USAGE: java " + VoldemortJsvcDaemon.class.getName()
- + " [voldemort_home_dir]");
+ + " [voldemort_home_dir] [voldemort_config_dir]");
} catch(Exception e) {
logger.error(e);
croak("Error while loading configuration: " + e.getMessage());
@@ -286,8 +286,11 @@ public static void main(String[] args) throws Exception {
config = VoldemortConfig.loadFromEnvironmentVariable();
else if(args.length == 1)
config = VoldemortConfig.loadFromVoldemortHome(args[0]);
+ else if(args.length == 2)
+ config = VoldemortConfig.loadFromVoldemortHome(args[0], args[1]);
else
- croak("USAGE: java " + VoldemortServer.class.getName() + " [voldemort_home_dir]");
+ croak("USAGE: java " + VoldemortServer.class.getName()
+ + " [voldemort_home_dir] [voldemort_config_dir]");
} catch(Exception e) {
logger.error(e);
Utils.croak("Error while loading configuration: " + e.getMessage());
Oops, something went wrong.

0 comments on commit 700117f

Please sign in to comment.