Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'bug_zone_id'

  • Loading branch information...
commit ba1eaa96f9dae30bdd14ae99fc5468d3d6dfb877 2 parents de2f94d + ed45d3d
Chinmay Soman authored
View
44 src/java/voldemort/VoldemortUnsupportedOperationalException.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2008-2009 LinkedIn, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package voldemort;
+
+/**
+ * Base exception that all other Voldemort exceptions extend.
+ *
+ *
+ */
+public class VoldemortUnsupportedOperationalException extends VoldemortException {
+
+ private static final long serialVersionUID = 1L;
+
+ public VoldemortUnsupportedOperationalException() {
+ super();
+ }
+
+ public VoldemortUnsupportedOperationalException(String s, Throwable t) {
+ super(s, t);
+ }
+
+ public VoldemortUnsupportedOperationalException(String s) {
+ super(s);
+ }
+
+ public VoldemortUnsupportedOperationalException(Throwable t) {
+ super(t);
+ }
+
+}
View
23 src/java/voldemort/cluster/Cluster.java
@@ -105,11 +105,30 @@ public String getName() {
public Zone getZoneById(int id) {
Zone zone = zonesById.get(id);
- if(zone == null)
- throw new VoldemortException("No such zone in cluster: " + id);
+ if(zone == null) {
+ if(id == Zone.DEFAULT_ZONE_ID)
+ throw new VoldemortException("Incorrect configuration. Default zone ID:" + id
+ + " required but not specified.");
+ else {
+ throw new VoldemortException("No such zone in cluster: " + id
+ + " Available zones : " + displayZones());
+ }
+
+ }
return zone;
}
+ private String displayZones() {
+ String zoneIDS = "{";
+ for(Zone z: this.getZones()) {
+ if(zoneIDS.length() != 1)
+ zoneIDS += ",";
+ zoneIDS += z.getId();
+ }
+ zoneIDS += "}";
+ return zoneIDS;
+ }
+
public int getNumberOfZones() {
return zonesById.size();
}
View
2  src/java/voldemort/store/ErrorCodeMapper.java
@@ -21,6 +21,7 @@
import voldemort.VoldemortApplicationException;
import voldemort.VoldemortException;
+import voldemort.VoldemortUnsupportedOperationalException;
import voldemort.server.rebalance.AlreadyRebalancingException;
import voldemort.server.rebalance.VoldemortRebalancingException;
import voldemort.store.rebalancing.ProxyUnreachableException;
@@ -56,6 +57,7 @@ public ErrorCodeMapper() {
codeToException.put((short) 13, AlreadyRebalancingException.class);
codeToException.put((short) 14, VoldemortRebalancingException.class);
codeToException.put((short) 15, ProxyUnreachableException.class);
+ codeToException.put((short) 16, VoldemortUnsupportedOperationalException.class);
exceptionToCode = new HashMap<Class<? extends VoldemortException>, Short>();
for(Map.Entry<Short, Class<? extends VoldemortException>> entry: codeToException.entrySet())
View
33 src/java/voldemort/store/StoreTimeoutException.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2008-2009 LinkedIn, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package voldemort.store;
+
+/**
+ * Indicates that the given request for the store timed out.
+ */
+public class StoreTimeoutException extends UnreachableStoreException {
+
+ private static final long serialVersionUID = 1L;
+
+ public StoreTimeoutException(String s) {
+ super(s);
+ }
+
+ public StoreTimeoutException(String s, Throwable t) {
+ super(s, t);
+ }
+}
View
3  src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java
@@ -30,6 +30,7 @@
import org.apache.log4j.Logger;
import voldemort.VoldemortException;
+import voldemort.VoldemortUnsupportedOperationalException;
import voldemort.annotations.jmx.JmxGetter;
import voldemort.annotations.jmx.JmxOperation;
import voldemort.routing.RoutingStrategy;
@@ -543,7 +544,7 @@ public boolean delete(ByteArray key, Version version) throws VoldemortException
*/
public void put(ByteArray key, Versioned<byte[]> value, byte[] transforms)
throws VoldemortException {
- throw new UnsupportedOperationException("Put is not supported on this store, it is read-only.");
+ throw new VoldemortUnsupportedOperationalException("Put is not supported on this store, it is read-only.");
}
@JmxGetter(name = "name", description = "The name of the store.")
View
16 src/java/voldemort/store/routed/action/AbstractAction.java
@@ -22,11 +22,12 @@
import voldemort.VoldemortApplicationException;
import voldemort.cluster.Node;
import voldemort.cluster.failuredetector.FailureDetector;
+import voldemort.store.StoreTimeoutException;
import voldemort.store.UnreachableStoreException;
import voldemort.store.routed.Pipeline;
+import voldemort.store.routed.Pipeline.Event;
import voldemort.store.routed.PipelineData;
import voldemort.store.routed.Response;
-import voldemort.store.routed.Pipeline.Event;
import voldemort.utils.Utils;
public abstract class AbstractAction<K, V, PD extends PipelineData<K, V>> implements Action {
@@ -57,10 +58,15 @@ protected boolean handleResponseError(Exception e,
long requestTime,
Pipeline pipeline,
FailureDetector failureDetector) {
- if(logger.isEnabledFor(Level.WARN))
- logger.warn("Error in " + pipeline.getOperation().getSimpleName() + " on node "
- + node.getId() + "(" + node.getHost() + ")", e);
-
+ if(logger.isEnabledFor(Level.WARN)) {
+ if(e instanceof StoreTimeoutException)
+ logger.warn("Error in " + pipeline.getOperation().getSimpleName() + " on node "
+ + node.getId() + "(" + node.getHost() + ") : " + e.getMessage());
+ else
+ logger.warn("Error in " + pipeline.getOperation().getSimpleName() + " on node "
+ + node.getId() + "(" + node.getHost() + ")", e);
+ }
+
if(e instanceof UnreachableStoreException) {
pipelineData.addFailedNode(node);
pipelineData.recordFailure(e);
View
3  src/java/voldemort/store/routed/action/PerformParallelPutRequests.java
@@ -296,7 +296,8 @@ public void requestComplete(Object result, long requestTime) {
.getSimpleName()
+ "s required zone, but only "
+ zonesSatisfied
- + " succeeded"));
+ + " succeeded. Failing nodes : "
+ + pipelineData.getFailedNodes()));
pipeline.abort();
}
}
View
5 src/java/voldemort/store/routed/action/PerformSerialGetAllRequests.java
@@ -30,8 +30,8 @@
import voldemort.store.Store;
import voldemort.store.routed.GetAllPipelineData;
import voldemort.store.routed.Pipeline;
-import voldemort.store.routed.Response;
import voldemort.store.routed.Pipeline.Event;
+import voldemort.store.routed.Response;
import voldemort.utils.ByteArray;
import voldemort.utils.Time;
import voldemort.versioning.Versioned;
@@ -162,7 +162,8 @@ public void execute(Pipeline pipeline) {
.getSimpleName()
+ "s required, but "
+ successCount.intValue()
- + " succeeded",
+ + " succeeded. Failing nodes : "
+ + pipelineData.getFailedNodes(),
pipelineData.getFailures()));
pipeline.addEvent(Event.ERROR);
return;
View
3  src/java/voldemort/store/socket/SocketStore.java
@@ -33,6 +33,7 @@
import voldemort.store.NoSuchCapabilityException;
import voldemort.store.Store;
import voldemort.store.StoreCapabilityType;
+import voldemort.store.StoreTimeoutException;
import voldemort.store.StoreUtils;
import voldemort.store.UnreachableStoreException;
import voldemort.store.nonblockingstore.NonblockingStore;
@@ -375,7 +376,7 @@ public void parseResponse(DataInputStream inputStream) {
public void timeOut() {
clientRequest.timeOut();
- invokeCallback(new UnreachableStoreException("ClientRequestExecutor timed out. Cannot complete request."),
+ invokeCallback(new StoreTimeoutException("ClientRequestExecutor timed out. Cannot complete request."),
(System.nanoTime() - startNs) / Time.NS_PER_MS);
pool.checkin(destination, clientRequestExecutor);
}
View
4 src/java/voldemort/store/socket/clientrequest/AbstractClientRequest.java
@@ -21,6 +21,7 @@
import java.io.IOException;
import voldemort.VoldemortException;
+import voldemort.store.StoreTimeoutException;
import voldemort.store.UnreachableStoreException;
/**
@@ -73,6 +74,9 @@ public void parseResponse(DataInputStream inputStream) {
}
public T getResult() throws VoldemortException, IOException {
+ if(isTimedOut)
+ throw new StoreTimeoutException("Request timed out");
+
if(!isComplete)
throw new IllegalStateException("Client response not complete, cannot determine result");
View
35 test/unit/voldemort/client/SocketStoreClientFactoryTest.java
@@ -30,6 +30,7 @@
import org.junit.runners.Parameterized.Parameters;
import voldemort.ServerTestUtils;
+import voldemort.VoldemortException;
import voldemort.serialization.SerializerFactory;
import voldemort.server.AbstractSocketService;
@@ -52,10 +53,8 @@ public SocketStoreClientFactoryTest(boolean useNio, boolean useLazy) {
@Parameters
public static Collection<Object[]> configs() {
- return Arrays.asList(new Object[][] { { true, true },
- { true, false },
- { false, true },
- { false, false } });
+ return Arrays.asList(new Object[][] { { true, true }, { true, false }, { false, true },
+ { false, false } });
}
@Override
@@ -113,9 +112,8 @@ public void testTwoFactories() throws Exception {
@Override
public void testBootstrapServerDown() throws Exception {
try {
- getFactory(getValidScheme() + "://localhost:58558")
- .getStoreClient(getValidStoreName())
- .get("test");
+ getFactory(getValidScheme() + "://localhost:58558").getStoreClient(getValidStoreName())
+ .get("test");
fail("Should throw exception.");
} catch(BootstrapFailureException e) {
// this is good
@@ -139,8 +137,25 @@ public void testUnknownStoreName() throws Exception {
@Test
@Override
public void testBootstrapFailoverSucceeds() throws Exception {
- getFactory(getValidScheme() + "://localhost:58558", getValidBootstrapUrl())
- .getStoreClient(getValidStoreName())
- .get("test");
+ getFactory(getValidScheme() + "://localhost:58558", getValidBootstrapUrl()).getStoreClient(getValidStoreName())
+ .get("test");
+ }
+
+ protected StoreClientFactory getFactoryForZoneID(int zoneID, String... bootstrapUrls) {
+ return new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrls)
+ .setEnableLazy(useLazy)
+ .setClientZoneId(zoneID));
+ }
+
+ @Test
+ public void testInvalidZoneID() throws Exception {
+ try {
+ getFactoryForZoneID(345334, getValidBootstrapUrl()).getStoreClient(getValidStoreName())
+ .get("test");
+ fail("Should throw exception.");
+ } catch(VoldemortException e) {
+ e.printStackTrace();
+ // this is good
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.