Permalink
Browse files

Merge remote branch 'origin/master' into bdb40

* origin/master:
  Fix Issue 208: Check usage Object.wait() in AbstractFailureDetector.
  Add @SuppressWarnings("unchecked").
  Make static field final.
  Remove unnecessary @SuppressWarnings("unchecked") and add it where necessary.
  Remove unnecessary allocation, cast and @SuppressWarnings annotation.
  Remove unused `node` parameter in createNodeStatus.
  Avoid unnecessary allocations (String and Integer).
  Add final to static fields.
  Organise imports.
  Add volatile to routingStrategy.
  Updated released notes, bumped version up to 0.70.1
  Fixed unit test for gossip.
  Fixed issue 205. No longer trying to do proxyGetAll if there are *no* redirecting keys at all.
  Reduced synchronization when lazily initializing failureDetector.
  Avoid String concatenation if not logging.
  Fixed issue 205. No longer trying to do proxyGetAll if there are *no* redirecting keys at all.
  Fix issue #199: SERVER_CONFIG_KEY used in many places where SERVER_KEY should be used
  Reduced synchronization when lazily initializing failureDetector.
  Avoid String concatenation if not logging.
  Removed the @Override annotations from methods to avoid compilation errors.
  • Loading branch information...
2 parents 807f833 + 3ad9a5a commit 0f9eda70fe40563c524931e852b1589a3b6e23a8 @ijuma ijuma committed Feb 3, 2010
Showing with 86 additions and 83 deletions.
  1. +1 −1 build.properties
  2. +0 −2 ...rib/hadoop-store-builder/src/java/voldemort/store/readonly/fetcher/ConfigurableSocketFactory.java
  3. +8 −0 release_notes.txt
  4. +12 −5 src/java/voldemort/client/AbstractStoreClientFactory.java
  5. +0 −2 src/java/voldemort/client/HttpStoreClientFactory.java
  6. +0 −2 src/java/voldemort/client/SocketStoreClientFactory.java
  7. +3 −3 src/java/voldemort/client/rebalance/RebalanceClientConfig.java
  8. +1 −1 src/java/voldemort/cluster/Node.java
  9. +5 −5 src/java/voldemort/cluster/failuredetector/AbstractFailureDetector.java
  10. +0 −1 src/java/voldemort/server/gossip/Gossiper.java
  11. +1 −1 src/java/voldemort/server/http/HttpService.java
  12. +1 −1 src/java/voldemort/server/http/StoreServlet.java
  13. +1 −1 src/java/voldemort/server/http/gui/AdminServlet.java
  14. +1 −1 src/java/voldemort/server/http/gui/ReadOnlyStoreManagementServlet.java
  15. +1 −1 src/java/voldemort/server/http/gui/StatusServlet.java
  16. +11 −8 src/java/voldemort/server/protocol/admin/AdminServiceRequestHandler.java
  17. +1 −2 src/java/voldemort/server/rebalance/Rebalancer.java
  18. +1 −1 src/java/voldemort/store/readonly/JsonStoreBuilder.java
  19. +8 −10 src/java/voldemort/store/rebalancing/RedirectingStore.java
  20. +1 −1 src/java/voldemort/store/routed/RoutedStore.java
  21. +2 −2 test/common/voldemort/TestUtils.java
  22. +2 −2 test/integration/voldemort/performance/ResourcePoolPerfTest.java
  23. +1 −1 test/integration/voldemort/socketpool/ResourcePoolTestUtils.java
  24. +1 −1 test/integration/voldemort/store/pausable/PausableStorageConfiguration.java
  25. +22 −28 test/unit/voldemort/server/gossip/GossiperTest.java
  26. +1 −0 test/unit/voldemort/store/readonly/ReadOnlyStorageEngineTestInstance.java
View
@@ -33,4 +33,4 @@ tomcat.manager.password=tomcat
tomcat.context=/voldemort
## Release
-curr.release=0.70
+curr.release=0.70.1
@@ -71,12 +71,10 @@ public Socket createSocket(String host, int port) throws IOException, UnknownHos
return socket;
}
- @Override
public Configuration getConf() {
return this.configuration;
}
- @Override
public void setConf(Configuration conf) {
this.configuration = conf;
this.socketReceiveBufferSize = conf.getInt("io.socket.receive.buffer", 100 * 1024 * 1024);
View
@@ -1,3 +1,11 @@
+Release 0.70.1 on 2/1/2010
+
+Changes made since 0.70:
+
+* Fixed issue 205: if no keys passed to getAll() were in partitions
+ undergoing rebalancing, proxyGetAll() would be called with an
+ empty list even if rebalancing wasn't happening
+
Release 0.70 on 1/27/2010
Changes made since 0.60.1:
@@ -86,7 +86,7 @@
private final boolean isJmxEnabled;
private final RequestFormatType requestFormatType;
private final int jmxId;
- protected FailureDetector failureDetector;
+ protected volatile FailureDetector failureDetector;
private final int maxBootstrapRetries;
private final StoreStats stats;
private final ClientConfig config;
@@ -194,14 +194,21 @@ public AbstractStoreClientFactory(ClientConfig config) {
protected abstract FailureDetector initFailureDetector(final ClientConfig config,
final Collection<Node> nodes);
- public synchronized FailureDetector getFailureDetector() {
- if (failureDetector == null) {
+ public FailureDetector getFailureDetector() {
+ // first check: avoids locking as the field is volatile
+ FailureDetector result = failureDetector;
+ if (result == null) {
String clusterXml = bootstrapMetadataWithRetries(MetadataStore.CLUSTER_KEY, bootstrapUrls);
Cluster cluster = clusterMapper.readCluster(new StringReader(clusterXml));
- failureDetector = initFailureDetector(config, cluster.getNodes());
+ synchronized(this) {
+ // second check: avoids double initialization
+ result = failureDetector;
+ if (result == null)
+ failureDetector = result = initFailureDetector(config, cluster.getNodes());
+ }
}
- return failureDetector;
+ return result;
}
private CompressionStrategy getCompressionStrategy(SerializerDefinition serializerDef) {
@@ -18,7 +18,6 @@
import static voldemort.cluster.failuredetector.FailureDetectorUtils.create;
-import java.io.StringReader;
import java.net.URI;
import java.util.Collection;
import java.util.concurrent.TimeUnit;
@@ -35,7 +34,6 @@
import voldemort.client.protocol.RequestFormatFactory;
import voldemort.client.protocol.RequestFormatType;
-import voldemort.cluster.Cluster;
import voldemort.cluster.Node;
import voldemort.cluster.failuredetector.ClientStoreVerifier;
import voldemort.cluster.failuredetector.FailureDetector;
@@ -18,13 +18,11 @@
import static voldemort.cluster.failuredetector.FailureDetectorUtils.create;
-import java.io.StringReader;
import java.net.URI;
import java.util.Collection;
import java.util.concurrent.TimeUnit;
import voldemort.client.protocol.RequestFormatType;
-import voldemort.cluster.Cluster;
import voldemort.cluster.Node;
import voldemort.cluster.failuredetector.ClientStoreVerifier;
import voldemort.cluster.failuredetector.FailureDetector;
@@ -11,9 +11,9 @@
private int rebalancingClientTimeoutSeconds = 7 * 24 * 60 * 60;
private boolean deleteAfterRebalancingEnabled;
- public static String MaxParallelRebalancingString = "max.parallel.rebalancing";
- public static String RebalancingClientTimeoutSeconds = "rebalancing.client.timeout.seconds";
- public static String EnableDeleteAfterRebalancing = "enable.delete.after.rebalancing";
+ public static final String MaxParallelRebalancingString = "max.parallel.rebalancing";
+ public static final String RebalancingClientTimeoutSeconds = "rebalancing.client.timeout.seconds";
+ public static final String EnableDeleteAfterRebalancing = "enable.delete.after.rebalancing";
public RebalanceClientConfig(Properties properties) {
super(properties);
@@ -135,6 +135,6 @@ public int hashCode() {
}
public int compareTo(Node other) {
- return new Integer(this.id).compareTo(other.getId());
+ return Integer.valueOf(this.id).compareTo(other.getId());
}
}
@@ -57,12 +57,12 @@ protected AbstractFailureDetector(FailureDetectorConfig failureDetectorConfig) {
nodeStatusMap = new ConcurrentHashMap<Node, NodeStatus>();
for(Node node: failureDetectorConfig.getNodes()) {
- nodeStatusMap.put(node, createNodeStatus(node, failureDetectorConfig.getTime()
- .getMilliseconds()));
+ nodeStatusMap.put(node, createNodeStatus(failureDetectorConfig.getTime()
+ .getMilliseconds()));
}
}
- private NodeStatus createNodeStatus(Node node, long currTime) {
+ private NodeStatus createNodeStatus(long currTime) {
NodeStatus nodeStatus = new NodeStatus();
nodeStatus.setLastChecked(currTime);
nodeStatus.setStartMillis(currTime);
@@ -131,7 +131,7 @@ public void waitForAvailability(Node node) throws InterruptedException {
NodeStatus nodeStatus = getNodeStatus(node);
synchronized(nodeStatus) {
- if(!isAvailable(node))
+ while(!isAvailable(node))
nodeStatus.wait();
}
}
@@ -216,7 +216,7 @@ protected NodeStatus getNodeStatus(Node node) {
if(nodeStatus == null) {
logger.warn("creating new node status for node " + node + " for failure detector.");
- nodeStatus = createNodeStatus(node, failureDetectorConfig.getTime().getMilliseconds());
+ nodeStatus = createNodeStatus(failureDetectorConfig.getTime().getMilliseconds());
nodeStatusMap.put(node, nodeStatus);
}
@@ -10,7 +10,6 @@
import voldemort.cluster.Cluster;
import voldemort.cluster.Node;
import voldemort.store.metadata.MetadataStore;
-import voldemort.versioning.Occured;
import voldemort.versioning.Version;
import voldemort.versioning.Versioned;
@@ -91,7 +91,7 @@ public void startInner() {
httpServer.setSendServerVersion(false);
httpServer.setSendDateHeader(false);
Context context = new Context(httpServer, "/", Context.NO_SESSIONS);
- context.setAttribute(VoldemortServletContextListener.SERVER_CONFIG_KEY, server);
+ context.setAttribute(VoldemortServletContextListener.SERVER_KEY, server);
context.setAttribute(VoldemortServletContextListener.VELOCITY_ENGINE_KEY,
velocityEngine);
context.addServlet(new ServletHolder(new AdminServlet(server, velocityEngine)),
@@ -62,7 +62,7 @@ public void init() throws ServletException {
// servlet context
if(this.requestHandler == null) {
ServletContext context = this.getServletContext();
- VoldemortServer server = (VoldemortServer) Utils.notNull(context.getAttribute(VoldemortServletContextListener.SERVER_CONFIG_KEY));
+ VoldemortServer server = (VoldemortServer) Utils.notNull(context.getAttribute(VoldemortServletContextListener.SERVER_KEY));
HttpService httpService = (HttpService) server.getService(ServiceType.HTTP);
this.requestHandler = httpService.getRequestHandler();
}
@@ -54,7 +54,7 @@ public AdminServlet(VoldemortServer server, VelocityEngine engine) {
@Override
public void init() throws ServletException {
super.init();
- this.server = (VoldemortServer) Utils.notNull(getServletContext().getAttribute(VoldemortServletContextListener.SERVER_CONFIG_KEY));
+ this.server = (VoldemortServer) Utils.notNull(getServletContext().getAttribute(VoldemortServletContextListener.SERVER_KEY));
this.velocityEngine = (VelocityEngine) Utils.notNull(getServletContext().getAttribute(VoldemortServletContextListener.VELOCITY_ENGINE_KEY));
}
@@ -77,7 +77,7 @@ public ReadOnlyStoreManagementServlet(VoldemortServer server, VelocityEngine eng
@Override
public void init() throws ServletException {
super.init();
- VoldemortServer server = (VoldemortServer) getServletContext().getAttribute(VoldemortServletContextListener.SERVER_CONFIG_KEY);
+ VoldemortServer server = (VoldemortServer) getServletContext().getAttribute(VoldemortServletContextListener.SERVER_KEY);
this.stores = getReadOnlyStores(server);
this.velocityEngine = (VelocityEngine) Utils.notNull(getServletContext().getAttribute(VoldemortServletContextListener.VELOCITY_ENGINE_KEY));
@@ -64,7 +64,7 @@ public StatusServlet(VoldemortServer server, VelocityEngine engine) {
@Override
public void init() throws ServletException {
super.init();
- this.server = (VoldemortServer) Utils.notNull(getServletContext().getAttribute(VoldemortServletContextListener.SERVER_CONFIG_KEY));
+ this.server = (VoldemortServer) Utils.notNull(getServletContext().getAttribute(VoldemortServletContextListener.SERVER_KEY));
this.velocityEngine = (VelocityEngine) Utils.notNull(getServletContext().getAttribute(VoldemortServletContextListener.VELOCITY_ENGINE_KEY));
}
@@ -244,9 +244,10 @@ private void fetchEntries(StorageEngine<ByteArray, byte[]> storageEngine,
counter++;
if(0 == counter % 100000) {
long totalTime = (System.currentTimeMillis() - startTime) / 1000;
- logger.debug("fetchEntries() scanned " + counter + " entries, fetched "
- + fetched + " entries for store:" + storageEngine.getName()
- + " partition:" + partitionList + " in " + totalTime + " s");
+ if(logger.isDebugEnabled())
+ logger.debug("fetchEntries() scanned " + counter + " entries, fetched "
+ + fetched + " entries for store:" + storageEngine.getName()
+ + " partition:" + partitionList + " in " + totalTime + " s");
}
}
} finally {
@@ -287,9 +288,10 @@ private void fetchKeys(StorageEngine<ByteArray, byte[]> storageEngine,
counter++;
if(0 == counter % 100000) {
long totalTime = (System.currentTimeMillis() - startTime) / 1000;
- logger.debug("fetchKeys() scanned " + counter + " keys, fetched " + fetched
- + " keys for store:" + storageEngine.getName() + " partition:"
- + partitionList + " in " + totalTime + " s");
+ if(logger.isDebugEnabled())
+ logger.debug("fetchKeys() scanned " + counter + " keys, fetched " + fetched
+ + " keys for store:" + storageEngine.getName() + " partition:"
+ + partitionList + " in " + totalTime + " s");
}
}
} finally {
@@ -336,8 +338,9 @@ public void handleUpdatePartitionEntries(VAdminProto.UpdatePartitionEntriesReque
counter++;
if(0 == counter % 100000) {
long totalTime = (System.currentTimeMillis() - startTime) / 1000;
- logger.debug("updateEntries() updated " + counter + " entries for store:"
- + storageEngine.getName() + " in " + totalTime + " s");
+ if(logger.isDebugEnabled())
+ logger.debug("updateEntries() updated " + counter + " entries for store:"
+ + storageEngine.getName() + " in " + totalTime + " s");
}
int size = inputStream.readInt();
@@ -230,7 +230,6 @@ public void stop() {
executors.shutdownNow();
}
- @SuppressWarnings("cast")
private void rebalanceStore(String storeName,
AdminClient adminClient,
RebalancePartitionsInfo stealInfo)
@@ -249,7 +248,7 @@ private void rebalanceStore(String storeName,
voldemortConfig.getAdminSocketTimeout(),
TimeUnit.SECONDS);
- rebalanceStatusList.remove((Object) new Integer(asyncId));
+ rebalanceStatusList.remove((Object) asyncId);
if(stealInfo.getDeletePartitionsList().size() > 0) {
adminClient.deletePartitions(stealInfo.getDonorId(),
@@ -210,7 +210,6 @@ public static void main(String[] args) throws IOException {
}
}
- @SuppressWarnings("unchecked")
public void build() throws IOException {
logger.info("Building store " + storeDefinition.getName() + " for "
+ cluster.getNumberOfNodes() + " with " + numChunks + " chunks per node.");
@@ -321,6 +320,7 @@ public KeyValuePair toObject(byte[] bytes) {
private CompressionStrategy valueCompressor;
private CompressionStrategy keyCompressor;
+ @SuppressWarnings("unchecked")
public JsonObjectIterator(JsonReader reader, StoreDefinition storeDefinition) {
SerializerFactory factory = new DefaultSerializerFactory();
@@ -16,6 +16,7 @@
package voldemort.store.rebalancing;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -41,9 +42,6 @@
import voldemort.versioning.Version;
import voldemort.versioning.Versioned;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
/**
* The RedirectingStore extends {@link DelegatingStore}
* <p>
@@ -120,13 +118,13 @@ private boolean redirectingKey(ByteArray key) {
@Override
public Map<ByteArray, List<Versioned<byte[]>>> getAll(Iterable<ByteArray> keys)
throws VoldemortException {
-
- proxyGetAllAndLocalPut(Iterables.filter(keys, new Predicate<ByteArray>() {
-
- public boolean apply(ByteArray key) {
- return redirectingKey(key);
- }
- }));
+ List<ByteArray> redirectingKeys = new ArrayList<ByteArray>();
+ for (ByteArray key: keys) {
+ if (redirectingKey(key))
+ redirectingKeys.add(key);
+ }
+ if (!redirectingKeys.isEmpty())
+ proxyGetAllAndLocalPut(redirectingKeys);
return getInnerStore().getAll(keys);
}
@@ -98,7 +98,7 @@
private final StoreDefinition storeDef;
private final FailureDetector failureDetector;
- private RoutingStrategy routingStrategy;
+ private volatile RoutingStrategy routingStrategy;
/**
* Create a RoutedStoreClient
@@ -307,7 +307,7 @@ public static String createReadOnlyIndex(Cluster cluster,
// make a temp dir
File dataDir = new File(baseDir + File.separatorChar + "read-only-temp-index-"
- + new Integer((int) (Math.random() * 1000)));
+ + ((int) (Math.random() * 1000)));
// build and open store
JsonStoreBuilder storeBuilder = new JsonStoreBuilder(jsonReader,
cluster,
@@ -356,7 +356,7 @@ public static int getMissingPartitionsSize(Cluster orig, Cluster updated) {
SortedSet<Integer> bPartitonSet = new TreeSet<Integer>(nodeB.getPartitionIds());
for(int p: nodeA.getPartitionIds()) {
- if(!bPartitonSet.contains(new Integer(p))) {
+ if(!bPartitonSet.contains(p)) {
diffPartition++;
}
}
@@ -72,7 +72,7 @@ public void doOperation(int id) throws Exception {
private static class StringResourceFactory implements ResourceFactory<Integer, String> {
public String create(Integer key) {
- return new String(key + "-val");
+ return key + "-val";
}
public void destroy(Integer key, String obj) {}
@@ -91,7 +91,7 @@ public void passivateObject(Object k, Object v) {}
public void destroyObject(Object k, Object v) {}
public Object makeObject(Object k) {
- return new String(k + "-val");
+ return k + "-val";
}
public boolean validateObject(Object k, Object v) {
@@ -11,7 +11,7 @@
return new ResourceFactory<String, String>() {
public String create(String key) throws Exception {
- return new String("resource");
+ return "resource";
}
public void destroy(String key, String obj) throws Exception {}
@@ -14,7 +14,7 @@
*/
public class PausableStorageConfiguration implements StorageConfiguration {
- private final String TYPE_NAME = "pausable";
+ private static final String TYPE_NAME = "pausable";
public PausableStorageConfiguration(@SuppressWarnings("unused") VoldemortConfig config) {}
Oops, something went wrong.

0 comments on commit 0f9eda7

Please sign in to comment.