![JAR search and dependency download from the Maven repository](/logo.png)
querqy.elasticsearch.rewriterstore.NodesClearRewriterCacheResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of querqy-elasticsearch Show documentation
Show all versions of querqy-elasticsearch Show documentation
Querqy library for query rewriting: Querqy for Elasticsearch
package querqy.elasticsearch.rewriterstore;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
import org.elasticsearch.action.support.nodes.BaseNodesResponse;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
public class NodesClearRewriterCacheResponse extends BaseNodesResponse
implements ToXContentObject {
public NodesClearRewriterCacheResponse(final ClusterName clusterName,
final List responses,
final List failures) {
super(clusterName, responses, failures);
}
public NodesClearRewriterCacheResponse(final StreamInput in) throws IOException {
super(in);
}
@Override
protected List readNodesFrom(final StreamInput in) throws IOException {
return in.readList(NodesClearRewriterCacheResponse.NodeResponse::readNodeResponse);
}
@Override
protected void writeNodesTo(final StreamOutput out, final List nodes) throws IOException {
out.writeCollection(nodes);
}
@Override
public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException {
builder.startObject();
builder.startObject("nodes");
for (final NodesClearRewriterCacheResponse.NodeResponse node : getNodes()) {
builder.startObject(node.getNode().getId());
node.toXContent(builder, params);
builder.endObject();
}
builder.endObject();
builder.endObject();
return builder;
}
public static class NodeResponse extends BaseNodeResponse
implements ToXContentObject {
public NodeResponse(final StreamInput in) throws IOException {
super(in);
}
public NodeResponse(final DiscoveryNode node) {
super(node);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
return Objects.equals(getNode(), ((NodesClearRewriterCacheResponse.NodeResponse) o).getNode());
}
static NodesClearRewriterCacheResponse.NodeResponse readNodeResponse(final StreamInput in) throws IOException {
return new NodesClearRewriterCacheResponse.NodeResponse(in);
}
@Override
public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException {
return builder.field("name", getNode().getName());
}
@Override
public boolean isFragment() {
return true;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy