Permalink
Browse files

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

  • Loading branch information...
2 parents 65ac0ce + 18819d7 commit 71c29d0a7fe2ff14fbcd0630a70e4a62ae01644d @readams readams committed Jun 22, 2009
Showing with 793 additions and 440 deletions.
  1. +1 −1 .classpath
  2. +16 −7 clients/python/voldemort.py
  3. BIN lib/{commons-pool-1.4.jar → commons-pool-1.5.1.jar}
  4. +1 −1 src/java/log4j.properties
  5. +0 −1 src/java/voldemort/VoldemortClientShell.java
  6. +17 −6 src/java/voldemort/client/AdminClient.java
  7. +3 −2 src/java/voldemort/client/ClientConfig.java
  8. +2 −3 src/java/voldemort/client/SocketStoreClientFactory.java
  9. +16 −8 src/java/voldemort/client/protocol/RequestFormatFactory.java
  10. +18 −11 src/java/voldemort/client/protocol/RequestFormatType.java
  11. +1 −1 src/java/voldemort/client/protocol/vold/VoldemortNativeClientRequestFormat.java
  12. +2 −14 src/java/voldemort/cluster/Node.java
  13. +2 −2 src/java/voldemort/server/VoldemortConfig.java
  14. +5 −11 src/java/voldemort/server/VoldemortServer.java
  15. +1 −5 src/java/voldemort/server/jmx/JmxService.java
  16. +5 −3 src/java/voldemort/server/protocol/RequestHandlerFactory.java
  17. +17 −2 src/java/voldemort/server/protocol/vold/VoldemortNativeRequestHandler.java
  18. +64 −33 src/java/voldemort/server/socket/SocketServer.java
  19. +80 −10 src/java/voldemort/server/socket/SocketServerSession.java
  20. +13 −6 src/java/voldemort/server/socket/SocketService.java
  21. +10 −18 src/java/voldemort/server/storage/StorageService.java
  22. +63 −24 src/java/voldemort/store/bdb/BdbStorageConfiguration.java
  23. +44 −70 src/java/voldemort/store/bdb/BdbStorageEngine.java
  24. +10 −2 src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java
  25. +5 −1 src/java/voldemort/store/routed/RoutedStore.java
  26. +12 −3 src/java/voldemort/store/socket/SocketAndStreams.java
  27. +13 −5 src/java/voldemort/store/socket/SocketDestination.java
  28. +5 −0 src/java/voldemort/store/socket/SocketPool.java
  29. +34 −5 src/java/voldemort/store/socket/SocketPoolableObjectFactory.java
  30. +12 −18 src/java/voldemort/store/socket/SocketStore.java
  31. +20 −0 src/java/voldemort/utils/JmxUtils.java
  32. +1 −7 src/java/voldemort/xml/ClusterMapper.java
  33. +16 −18 test/common/voldemort/ServerTestUtils.java
  34. +1 −1 test/common/voldemort/TestUtils.java
  35. +67 −0 test/integration/voldemort/CommonsPoolTest.java
  36. +7 −11 test/integration/voldemort/performance/RemoteStoreComparisonTest.java
  37. +31 −0 test/integration/voldemort/store/pausable/PausableStorageConfiguration.java
  38. +105 −0 test/integration/voldemort/store/pausable/PausableStorageEngine.java
  39. +25 −51 test/unit/voldemort/client/AdminServiceTest.java
  40. +2 −2 test/unit/voldemort/client/HttpStoreClientFactoryTest.java
  41. +1 −3 test/unit/voldemort/client/SocketStoreClientFactoryTest.java
  42. +0 −4 test/unit/voldemort/cluster/TestCluster.java
  43. +1 −1 test/unit/voldemort/protocol/vold/VoldemortNativeRequestFormatTest.java
  44. +3 −3 test/unit/voldemort/routing/ConsistentRoutingStrategyTest.java
  45. +16 −8 test/unit/voldemort/server/socket/SocketPoolTest.java
  46. +0 −13 test/unit/voldemort/store/bdb/BdbStorageEngineTest.java
  47. +3 −3 test/unit/voldemort/store/http/HttpStoreTest.java
  48. +4 −6 test/unit/voldemort/store/readonly/ReadOnlyStorageEngineTestInstance.java
  49. +16 −33 test/unit/voldemort/store/rebalancing/RebalancingStoreTest.java
  50. +1 −2 test/unit/voldemort/store/socket/AbstractSocketStoreTest.java
  51. +1 −1 test/unit/voldemort/store/socket/VoldemortNativeSocketStoreTest.java
View
@@ -15,7 +15,6 @@
<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/commons-pool-1.4.jar"/>
<classpathentry kind="lib" path="lib/colt-1.2.0.jar"/>
<classpathentry kind="lib" path="lib/libthrift-20080411p1.jar"/>
<classpathentry kind="lib" path="lib/google-collect-snapshot-20090211.jar"/>
@@ -39,5 +38,6 @@
<classpathentry kind="lib" path="lib/servlet-api-2.5.jar"/>
<classpathentry kind="lib" path="lib/xercesImpl-2.9.1.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-pool-1.5.1.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
@@ -103,6 +103,19 @@ def __init__(self, store_name, bootstrap_urls, reconnect_interval = 500, conflic
self.reconnect_interval = reconnect_interval
self.open = True
+ def _make_connection(self, host, port):
+ protocol = 'pb0'
+ logging.debug('Attempting to connect to ' + host + ':' + str(port))
+ connection = socket.socket()
+ connection.connect((host, port))
+ logging.debug('Connection succeeded, negotiating protocol')
+ connection.send(protocol)
+ resp = connection.recv(2)
+ if resp != 'ok':
+ raise VoldemortException('Server does not understand the protocol ' + protocol)
+ logging.debug('Protocol negotiation suceeded')
+ return connection
+
## Connect to a the next available node in the cluster
## returns a tuple of (node_id, connection)
@@ -115,10 +128,7 @@ def _reconnect(self):
new_node = self.nodes[new_node_id]
connection = None
try:
- logging.debug('Attempting to connect to node ' + str(new_node_id))
- connection = socket.socket()
- connection.connect((new_node.host, new_node.socket_port))
- logging.debug('Connection succeeded')
+ connection = self._make_connection(new_node.host, new_node.socket_port)
self.request_count = 0
return new_node_id, connection
except socket.error, (err_num, message):
@@ -160,7 +170,6 @@ def _receive_response(self, connection):
size_bytes = connection.recv(4)
size = struct.unpack('>i', size_bytes)
return connection.recv(size[0])
-
## Bootstrap cluster metadata from a list of urls of nodes in the cluster.
## The urls are tuples in the form (host, port).
@@ -169,9 +178,9 @@ def _bootstrap_metadata(self, bootstrap_urls):
random.shuffle(bootstrap_urls)
for host, port in bootstrap_urls:
logging.debug('Attempting to bootstrap metadata from ' + host + ':' + str(port))
+ connection = None
try:
- connection = socket.socket()
- connection.connect((host, port))
+ connection = self._make_connection(host, port)
cluster_xmls = self._get_with_connection(connection, 'metadata', 'cluster.xml', should_route = False)
if len(cluster_xmls) != 1:
raise VoldemortException('Expected exactly one version of the metadata but found ' + str(cluster_xmls))
Binary file not shown.
@@ -11,4 +11,4 @@ log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c)%n
#log4j.logger=DEBUG
#log4j.logger.httpclient.wire=DEBUG
log4j.logger.org.mortbay.log=WARN
-log4j.logger.voldemort.store.routed=WARN
+log4j.logger.voldemort.store.routed=INFO
@@ -32,7 +32,6 @@
import voldemort.client.DefaultStoreClient;
import voldemort.client.SocketStoreClientFactory;
import voldemort.client.StoreClientFactory;
-import voldemort.client.protocol.RequestFormatType;
import voldemort.cluster.Node;
import voldemort.serialization.SerializationException;
import voldemort.serialization.json.EndOfFileException;
@@ -27,6 +27,7 @@
import org.apache.log4j.Logger;
import voldemort.VoldemortException;
+import voldemort.client.protocol.RequestFormatType;
import voldemort.cluster.Cluster;
import voldemort.cluster.Node;
import voldemort.serialization.VoldemortOpCode;
@@ -94,7 +95,9 @@ public VoldemortMetadata getMetadata() {
public void updateClusterMetadata(int nodeId, Cluster cluster, String cluster_key)
throws VoldemortException {
Node node = metadata.getCurrentCluster().getNodeById(nodeId);
- SocketDestination destination = new SocketDestination(node.getHost(), node.getAdminPort());
+ SocketDestination destination = new SocketDestination(node.getHost(),
+ node.getSocketPort(),
+ RequestFormatType.ADMIN);
SocketAndStreams sands = pool.checkout(destination);
try {
DataOutputStream outputStream = sands.getOutputStream();
@@ -125,7 +128,9 @@ public void updateStoresMetadata(int nodeId, List<StoreDefinition> storesList)
throws VoldemortException {
Node node = metadata.getCurrentCluster().getNodeById(nodeId);
- SocketDestination destination = new SocketDestination(node.getHost(), node.getAdminPort());
+ SocketDestination destination = new SocketDestination(node.getHost(),
+ node.getSocketPort(),
+ RequestFormatType.ADMIN);
SocketAndStreams sands = pool.checkout(destination);
try {
DataOutputStream outputStream = sands.getOutputStream();
@@ -161,7 +166,8 @@ public void updateStoresMetadata(int nodeId, List<StoreDefinition> storesList)
throws VoldemortException {
Node node = metadata.getCurrentCluster().getNodeById(nodeId);
final SocketDestination destination = new SocketDestination(node.getHost(),
- node.getAdminPort());
+ node.getSocketPort(),
+ RequestFormatType.ADMIN);
final SocketAndStreams sands = pool.checkout(destination);
try {
// get these partitions from the node for store
@@ -236,7 +242,9 @@ public void updatePartitionEntries(int nodeId,
throws VoldemortException, IOException {
Node node = metadata.getCurrentCluster().getNodeById(nodeId);
- SocketDestination destination = new SocketDestination(node.getHost(), node.getAdminPort());
+ SocketDestination destination = new SocketDestination(node.getHost(),
+ node.getSocketPort(),
+ RequestFormatType.ADMIN);
SocketAndStreams sands = pool.checkout(destination);
DataOutputStream outputStream = sands.getOutputStream();
DataInputStream inputStream = sands.getInputStream();
@@ -284,7 +292,9 @@ public void updatePartitionEntries(int nodeId,
public void changeServerState(int nodeId, VoldemortMetadata.ServerState state) {
Cluster currentCluster = metadata.getCurrentCluster();
Node node = currentCluster.getNodeById(nodeId);
- SocketDestination destination = new SocketDestination(node.getHost(), node.getAdminPort());
+ SocketDestination destination = new SocketDestination(node.getHost(),
+ node.getSocketPort(),
+ RequestFormatType.ADMIN);
SocketAndStreams sands = pool.checkout(destination);
try {
DataOutputStream outputStream = sands.getOutputStream();
@@ -315,7 +325,8 @@ public void changeServerState(int nodeId, VoldemortMetadata.ServerState state) {
public List<Versioned<byte[]>> redirectGet(int redirectedNodeId, String storeName, ByteArray key) {
Node redirectedNode = metadata.getCurrentCluster().getNodeById(redirectedNodeId);
SocketDestination destination = new SocketDestination(redirectedNode.getHost(),
- redirectedNode.getAdminPort());
+ redirectedNode.getSocketPort(),
+ RequestFormatType.ADMIN);
SocketAndStreams sands = pool.checkout(destination);
try {
DataOutputStream outputStream = sands.getOutputStream();
@@ -45,7 +45,7 @@
private volatile int socketBufferSize = 64 * 1024;
private volatile SerializerFactory serializerFactory = new DefaultSerializerFactory();
private volatile List<String> bootstrapUrls = null;
- private volatile RequestFormatType requestFormatType = RequestFormatType.VOLDEMORT;
+ private volatile RequestFormatType requestFormatType = RequestFormatType.VOLDEMORT_V1;
private volatile RoutingTier routingTier = RoutingTier.CLIENT;
private volatile boolean enableJmx = true;
@@ -253,7 +253,8 @@ public RoutingTier getRoutingTier() {
/**
* Set the tier at which routing occurs. Client-side routing occurs on the
- * client, and server-side routing on the server.
+ * client, and server-side routing on the server. This is not yet used, as
+ * the java client only supports client-side routing.
*
* @param routingTier The routing tier to use for routing requests
*/
@@ -22,6 +22,7 @@
import voldemort.client.protocol.RequestFormatType;
import voldemort.cluster.Node;
import voldemort.store.Store;
+import voldemort.store.socket.SocketDestination;
import voldemort.store.socket.SocketPool;
import voldemort.store.socket.SocketStore;
import voldemort.utils.ByteArray;
@@ -61,10 +62,8 @@ public SocketStoreClientFactory(ClientConfig config) {
int port,
RequestFormatType type) {
return new SocketStore(Utils.notNull(storeName),
- Utils.notNull(host),
- port,
+ new SocketDestination(Utils.notNull(host), port, type),
socketPool,
- type,
RoutingTier.SERVER.equals(routingTier));
}
@@ -16,6 +16,8 @@
package voldemort.client.protocol;
+import java.util.EnumMap;
+
import voldemort.VoldemortException;
import voldemort.client.protocol.pb.ProtoBuffClientRequestFormat;
import voldemort.client.protocol.vold.VoldemortNativeClientRequestFormat;
@@ -29,15 +31,21 @@
*/
public class RequestFormatFactory {
+ private EnumMap<RequestFormatType, RequestFormat> typeToInstance;
+
+ public RequestFormatFactory() {
+ this.typeToInstance = new EnumMap<RequestFormatType, RequestFormat>(RequestFormatType.class);
+ this.typeToInstance.put(RequestFormatType.VOLDEMORT_V1,
+ new VoldemortNativeClientRequestFormat());
+ this.typeToInstance.put(RequestFormatType.PROTOCOL_BUFFERS,
+ new ProtoBuffClientRequestFormat());
+ }
+
public RequestFormat getRequestFormat(RequestFormatType type) {
- switch(type) {
- case VOLDEMORT:
- return new VoldemortNativeClientRequestFormat();
- case PROTOCOL_BUFFERS:
- return new ProtoBuffClientRequestFormat();
- default:
- throw new VoldemortException("Unknown wire format " + type);
- }
+ RequestFormat format = this.typeToInstance.get(type);
+ if(type == null)
+ throw new VoldemortException("Unknown wire format " + type);
+ return format;
}
}
@@ -23,25 +23,32 @@
*
*/
public enum RequestFormatType {
- VOLDEMORT("vold"),
- PROTOCOL_BUFFERS("pb"),
- ADMIN_HANDLER("admin");
+ VOLDEMORT_V0("vp0", "voldemort-native-v0"),
+ VOLDEMORT_V1("vp1", "voldemort-native-v1"),
+ PROTOCOL_BUFFERS("pb0", "protocol-buffers-v0"),
+ ADMIN("ad0", "admin-v0");
- private final String name;
+ private final String code;
+ private final String displayName;
- private RequestFormatType(String name) {
- this.name = name;
+ private RequestFormatType(String code, String display) {
+ this.code = code;
+ this.displayName = display;
}
- public String getName() {
- return name;
+ public String getCode() {
+ return code;
}
- public static RequestFormatType fromName(String name) {
+ public String getDisplayName() {
+ return this.displayName;
+ }
+
+ public static RequestFormatType fromCode(String code) {
for(RequestFormatType type: RequestFormatType.values())
- if(type.getName().equals(name))
+ if(type.getCode().equals(code))
return type;
- throw new IllegalArgumentException("No wire format '" + name + "' was found");
+ throw new IllegalArgumentException("No request format '" + code + "' was found");
}
}
@@ -42,7 +42,7 @@
*/
public class VoldemortNativeClientRequestFormat implements RequestFormat {
- public final ErrorCodeMapper mapper;
+ private final ErrorCodeMapper mapper;
public VoldemortNativeClientRequestFormat() {
this.mapper = new ErrorCodeMapper();
@@ -41,30 +41,22 @@
private final int httpPort;
private final int socketPort;
private final List<Integer> partitions;
- private final int adminSocketPort;
private final NodeStatus status;
- public Node(int id,
- String host,
- int httpPort,
- int socketPort,
- int adminPort,
- List<Integer> partitions) {
- this(id, host, httpPort, socketPort, adminPort, partitions, new NodeStatus());
+ public Node(int id, String host, int httpPort, int socketPort, List<Integer> partitions) {
+ this(id, host, httpPort, socketPort, partitions, new NodeStatus());
}
public Node(int id,
String host,
int httpPort,
int socketPort,
- int adminSocketPort,
List<Integer> partitions,
NodeStatus status) {
this.id = id;
this.host = Utils.notNull(host);
this.httpPort = httpPort;
this.socketPort = socketPort;
- this.adminSocketPort = adminSocketPort;
this.status = status;
this.partitions = ImmutableList.copyOf(partitions);
}
@@ -81,10 +73,6 @@ public int getSocketPort() {
return socketPort;
}
- public int getAdminPort() {
- return adminSocketPort;
- }
-
public int getId() {
return id;
}
@@ -219,8 +219,8 @@ public VoldemortConfig(Props props) {
this.allProps = props;
String requestFormatName = props.getString("request.format",
- RequestFormatType.VOLDEMORT.getName());
- this.requestFormatType = RequestFormatType.fromName(requestFormatName);
+ RequestFormatType.VOLDEMORT_V1.getCode());
+ this.requestFormatType = RequestFormatType.fromCode(requestFormatName);
validateParams();
}
@@ -105,23 +105,17 @@ public VoldemortServer(VoldemortConfig config, Cluster cluster) {
if(voldemortConfig.isHttpServerEnabled())
services.add(new HttpService(this,
storeRepository,
- RequestFormatType.VOLDEMORT,
+ RequestFormatType.VOLDEMORT_V1,
voldemortConfig.getMaxThreads(),
identityNode.getHttpPort()));
if(voldemortConfig.isSocketServerEnabled())
- services.add(new SocketService(requestHandlerFactory.getRequestHandler(voldemortConfig.getRequestFormatType()),
+ services.add(new SocketService(requestHandlerFactory,
identityNode.getSocketPort(),
voldemortConfig.getCoreThreads(),
voldemortConfig.getMaxThreads(),
voldemortConfig.getSocketBufferSize(),
- "client-request-service"));
- if(voldemortConfig.isAdminServerEnabled())
- services.add(new SocketService(requestHandlerFactory.getRequestHandler(RequestFormatType.ADMIN_HANDLER),
- identityNode.getAdminPort(),
- voldemortConfig.getAdminCoreThreads(),
- voldemortConfig.getAdminMaxThreads(),
- voldemortConfig.getAdminSocketBufferSize(),
- "admin-service"));
+ "socket-server",
+ voldemortConfig.isJmxEnabled()));
if(voldemortConfig.isJmxEnabled())
services.add(new JmxService(this,
@@ -134,7 +128,7 @@ public VoldemortServer(VoldemortConfig config, Cluster cluster) {
@Override
protected void startInner() throws VoldemortException {
- logger.info("Starting all services: " + services.size());
+ logger.info("Starting " + services.size() + " services.");
long start = System.currentTimeMillis();
for(VoldemortService service: services)
service.start();
@@ -74,13 +74,9 @@ public JmxService(VoldemortServer server,
protected void startInner() {
registerBean(server, JmxUtils.createObjectName(VoldemortServer.class));
registerBean(cluster, JmxUtils.createObjectName(Cluster.class));
- for(VoldemortService service: services) {
- logger.debug("Registering mbean for service '" + service.getType().getDisplayName()
- + "'.");
+ for(VoldemortService service: services)
registerBean(service, JmxUtils.createObjectName(service.getClass()));
- }
for(Store<ByteArray, byte[]> store: this.storeRepository.getAllStorageEngines()) {
- logger.info("Registering mbean for store '" + store.getName() + "'.");
registerBean(store,
JmxUtils.createObjectName(JmxUtils.getPackageName(store.getClass()),
store.getName()));
Oops, something went wrong.

0 comments on commit 71c29d0

Please sign in to comment.