Skip to content

Commit

Permalink
Cut over ClusterSearchShardsGroup to Writeable (#41788)
Browse files Browse the repository at this point in the history
  • Loading branch information
javanna authored May 3, 2019
1 parent 24d9d84 commit 482bd98
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,24 @@
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Streamable;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.shard.ShardId;

import java.io.IOException;

public class ClusterSearchShardsGroup implements Streamable, ToXContentObject {
public class ClusterSearchShardsGroup implements Writeable, ToXContentObject {

private ShardId shardId;
private ShardRouting[] shards;

private ClusterSearchShardsGroup() {

}
private final ShardId shardId;
private final ShardRouting[] shards;

public ClusterSearchShardsGroup(ShardId shardId, ShardRouting[] shards) {
this.shardId = shardId;
this.shards = shards;
}

static ClusterSearchShardsGroup readSearchShardsGroupResponse(StreamInput in) throws IOException {
ClusterSearchShardsGroup response = new ClusterSearchShardsGroup();
response.readFrom(in);
return response;
}

public ShardId getShardId() {
return shardId;
}

public ShardRouting[] getShards() {
return shards;
}

@Override
public void readFrom(StreamInput in) throws IOException {
ClusterSearchShardsGroup(StreamInput in) throws IOException {
shardId = ShardId.readShardId(in);
shards = new ShardRouting[in.readVInt()];
for (int i = 0; i < shards.length; i++) {
Expand All @@ -75,6 +56,14 @@ public void writeTo(StreamOutput out) throws IOException {
}
}

public ShardId getShardId() {
return shardId;
}

public ShardRouting[] getShards() {
return shards;
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ClusterSearchShardsResponse(StreamInput in) throws IOException {
super(in);
groups = new ClusterSearchShardsGroup[in.readVInt()];
for (int i = 0; i < groups.length; i++) {
groups[i] = ClusterSearchShardsGroup.readSearchShardsGroupResponse(in);
groups[i] = new ClusterSearchShardsGroup(in);
}
nodes = new DiscoveryNode[in.readVInt()];
for (int i = 0; i < nodes.length; i++) {
Expand Down

0 comments on commit 482bd98

Please sign in to comment.