From a1299a3d4fef7b6cb5539adf3fa0d9366dc2c9b5 Mon Sep 17 00:00:00 2001 From: kimchy Date: Tue, 21 Sep 2010 11:39:22 +0200 Subject: [PATCH] refactoring in routing logic to allow adding allocation explanation that later can be shown --- .../routing/allocation/AllocationExplanation.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationExplanation.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationExplanation.java index d178177551a..c297f16e949 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationExplanation.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationExplanation.java @@ -86,8 +86,13 @@ public class AllocationExplanation implements Streamable { int size2 = in.readVInt(); List ne = Lists.newArrayListWithCapacity(size2); for (int j = 0; j < size2; j++) { - ne.add(new NodeExplanation(DiscoveryNode.readNode(in), in.readUTF())); + DiscoveryNode node = null; + if (in.readBoolean()) { + node = DiscoveryNode.readNode(in); + } + ne.add(new NodeExplanation(node, in.readUTF())); } + explanations.put(shardId, ne); } } @@ -97,7 +102,12 @@ public class AllocationExplanation implements Streamable { entry.getKey().writeTo(out); out.writeVInt(entry.getValue().size()); for (NodeExplanation nodeExplanation : entry.getValue()) { - nodeExplanation.node().writeTo(out); + if (nodeExplanation.node() == null) { + out.writeBoolean(false); + } else { + out.writeBoolean(true); + nodeExplanation.node().writeTo(out); + } out.writeUTF(nodeExplanation.description()); } }