|
21 | 21 |
|
22 | 22 | import com.carrotsearch.hppc.cursors.ObjectCursor;
|
23 | 23 | import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
24 |
| - |
25 | 24 | import org.elasticsearch.cluster.DiffableUtils.KeyedReader;
|
26 | 25 | import org.elasticsearch.cluster.block.ClusterBlock;
|
27 | 26 | import org.elasticsearch.cluster.block.ClusterBlocks;
|
|
31 | 30 | import org.elasticsearch.cluster.metadata.MetaData;
|
32 | 31 | import org.elasticsearch.cluster.node.DiscoveryNode;
|
33 | 32 | import org.elasticsearch.cluster.node.DiscoveryNodes;
|
34 |
| -import org.elasticsearch.cluster.routing.IndexRoutingTable; |
35 |
| -import org.elasticsearch.cluster.routing.IndexShardRoutingTable; |
36 |
| -import org.elasticsearch.cluster.routing.RoutingNode; |
37 |
| -import org.elasticsearch.cluster.routing.RoutingNodes; |
38 |
| -import org.elasticsearch.cluster.routing.RoutingTable; |
39 |
| -import org.elasticsearch.cluster.routing.ShardRouting; |
| 33 | +import org.elasticsearch.cluster.routing.*; |
40 | 34 | import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
41 | 35 | import org.elasticsearch.cluster.service.InternalClusterService;
|
42 | 36 | import org.elasticsearch.common.Nullable;
|
|
57 | 51 | import org.elasticsearch.discovery.zen.publish.PublishClusterStateAction;
|
58 | 52 |
|
59 | 53 | import java.io.IOException;
|
60 |
| -import java.util.EnumSet; |
61 |
| -import java.util.HashMap; |
62 |
| -import java.util.Locale; |
63 |
| -import java.util.Map; |
64 |
| -import java.util.Set; |
| 54 | +import java.util.*; |
65 | 55 |
|
66 | 56 | /**
|
67 | 57 | * Represents the current state of the cluster.
|
@@ -137,7 +127,7 @@ public static <T extends Custom> T lookupPrototype(String type) {
|
137 | 127 |
|
138 | 128 | public static <T extends Custom> T lookupPrototypeSafe(String type) {
|
139 | 129 | @SuppressWarnings("unchecked")
|
140 |
| - T proto = (T)customPrototypes.get(type); |
| 130 | + T proto = (T) customPrototypes.get(type); |
141 | 131 | if (proto == null) {
|
142 | 132 | throw new IllegalArgumentException("No custom state prototype registered for type [" + type + "]");
|
143 | 133 | }
|
@@ -478,6 +468,12 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
|
478 | 468 | }
|
479 | 469 | builder.endArray();
|
480 | 470 |
|
| 471 | + builder.startObject("primary_terms"); |
| 472 | + for (int shard = 0; shard < indexMetaData.getNumberOfShards(); shard++) { |
| 473 | + builder.field(Integer.toString(shard), indexMetaData.primaryTerm(shard)); |
| 474 | + } |
| 475 | + builder.endObject(); |
| 476 | + |
481 | 477 | builder.endObject();
|
482 | 478 | }
|
483 | 479 | builder.endObject();
|
@@ -593,6 +589,7 @@ public Builder nodes(DiscoveryNodes nodes) {
|
593 | 589 |
|
594 | 590 | public Builder routingResult(RoutingAllocation.Result routingResult) {
|
595 | 591 | this.routingTable = routingResult.routingTable();
|
| 592 | + this.metaData = routingResult.metaData(); |
596 | 593 | return this;
|
597 | 594 | }
|
598 | 595 |
|
@@ -673,16 +670,16 @@ public static byte[] toBytes(ClusterState state) throws IOException {
|
673 | 670 | }
|
674 | 671 |
|
675 | 672 | /**
|
676 |
| - * @param data input bytes |
677 |
| - * @param localNode used to set the local node in the cluster state. |
| 673 | + * @param data input bytes |
| 674 | + * @param localNode used to set the local node in the cluster state. |
678 | 675 | */
|
679 | 676 | public static ClusterState fromBytes(byte[] data, DiscoveryNode localNode) throws IOException {
|
680 | 677 | return readFrom(StreamInput.wrap(data), localNode);
|
681 | 678 | }
|
682 | 679 |
|
683 | 680 | /**
|
684 |
| - * @param in input stream |
685 |
| - * @param localNode used to set the local node in the cluster state. can be null. |
| 681 | + * @param in input stream |
| 682 | + * @param localNode used to set the local node in the cluster state. can be null. |
686 | 683 | */
|
687 | 684 | public static ClusterState readFrom(StreamInput in, @Nullable DiscoveryNode localNode) throws IOException {
|
688 | 685 | return PROTO.readFrom(in, localNode);
|
|
0 commit comments