Skip to content
Browse files

Added better logging if config/.temp config/.version are copied.

  • Loading branch information...
1 parent f1e5ec7 commit 35520c33a00de692b635e82fa3ceab9d7d1b1cfb @bbansal bbansal committed
View
8 src/java/voldemort/store/StoreUtils.java
@@ -128,15 +128,17 @@ public static void close(InputStream stream) {
*/
public static void assertValidMetadata(ByteArray key,
RoutingStrategy routingStrategy,
- int currentNodeId) {
+ Node currentNode) {
List<Node> nodes = routingStrategy.routeRequest(key.get());
for(Node node: nodes) {
- if(node.getId() == currentNodeId) {
+ if(node.getId() == currentNode.getId()) {
return;
}
}
- throw new InvalidMetadataException("client routing strategy not in sync with store routing strategy!");
+ throw new InvalidMetadataException("client attempt accessing key belonging to partition:"
+ + routingStrategy.getPartitionList(key.get())
+ + " at Node:" + currentNode);
}
public static <V> List<Version> getVersions(List<Versioned<V>> versioneds) {
View
13 src/java/voldemort/store/invalidmetadata/InvalidMetadataCheckingStore.java
@@ -19,6 +19,7 @@
import java.util.List;
import voldemort.VoldemortException;
+import voldemort.cluster.Node;
import voldemort.store.DelegatingStore;
import voldemort.store.InvalidMetadataException;
import voldemort.store.Store;
@@ -38,7 +39,7 @@
*/
public class InvalidMetadataCheckingStore extends DelegatingStore<ByteArray, byte[]> {
- private final int nodeId;
+ private final Node node;
private final MetadataStore metadata;
/**
@@ -51,18 +52,18 @@
* @param routingStrategy the routing stratgey for this cluster
* configuration.
*/
- public InvalidMetadataCheckingStore(int node,
+ public InvalidMetadataCheckingStore(int nodeId,
Store<ByteArray, byte[]> innerStore,
MetadataStore metadata) {
super(innerStore);
this.metadata = metadata;
- this.nodeId = node;
+ this.node = metadata.getCluster().getNodeById(nodeId);
}
@Override
public boolean delete(ByteArray key, Version version) throws VoldemortException {
StoreUtils.assertValidKey(key);
- StoreUtils.assertValidMetadata(key, metadata.getRoutingStrategy(getName()), nodeId);
+ StoreUtils.assertValidMetadata(key, metadata.getRoutingStrategy(getName()), node);
return getInnerStore().delete(key, version);
}
@@ -70,7 +71,7 @@ public boolean delete(ByteArray key, Version version) throws VoldemortException
@Override
public void put(ByteArray key, Versioned<byte[]> value) throws VoldemortException {
StoreUtils.assertValidKey(key);
- StoreUtils.assertValidMetadata(key, metadata.getRoutingStrategy(getName()), nodeId);
+ StoreUtils.assertValidMetadata(key, metadata.getRoutingStrategy(getName()), node);
getInnerStore().put(key, value);
}
@@ -78,7 +79,7 @@ public void put(ByteArray key, Versioned<byte[]> value) throws VoldemortExceptio
@Override
public List<Versioned<byte[]>> get(ByteArray key) throws VoldemortException {
StoreUtils.assertValidKey(key);
- StoreUtils.assertValidMetadata(key, metadata.getRoutingStrategy(getName()), nodeId);
+ StoreUtils.assertValidMetadata(key, metadata.getRoutingStrategy(getName()), node);
return getInnerStore().get(key);
}
View
9 src/java/voldemort/store/metadata/MetadataStore.java
@@ -317,8 +317,15 @@ private void init(int nodeId) {
initCache(CLUSTER_KEY);
initCache(STORES_KEY);
- // Initialize with default if not present
initCache(NODE_ID_KEY, nodeId);
+ if(getNodeId() != nodeId)
+ throw new RuntimeException("Attempt to start previous node:"
+ + getNodeId()
+ + " as node:"
+ + nodeId
+ + " (Did you copy config directory ? try deleting .temp .version in config dir to force clean) aborting ...");
+
+ // Initialize with default if not present
initCache(REBALANCING_SLAVES_LIST_KEY, new ArrayList<Integer>(0));
initCache(REBALANCING_PARTITIONS_LIST_KEY, new ArrayList<Integer>(0));
initCache(SERVER_STATE_KEY, VoldemortState.NORMAL_SERVER.toString());

0 comments on commit 35520c3

Please sign in to comment.
Something went wrong with that request. Please try again.