diff --git a/core/src/main/java/org/elasticsearch/ElasticsearchException.java b/core/src/main/java/org/elasticsearch/ElasticsearchException.java index 7c20ed7d2c4..f4e807b9ffc 100644 --- a/core/src/main/java/org/elasticsearch/ElasticsearchException.java +++ b/core/src/main/java/org/elasticsearch/ElasticsearchException.java @@ -28,7 +28,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.logging.LoggerMessageFormat; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.Index; @@ -57,7 +57,7 @@ import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureFieldN /** * A base class for all elasticsearch exceptions. */ -public class ElasticsearchException extends RuntimeException implements ToXContent, Writeable { +public class ElasticsearchException extends RuntimeException implements ToXContentFragment, Writeable { private static final Version UNKNOWN_VERSION_ADDED = Version.fromId(0); diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplanation.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplanation.java index e2911c227a8..095184a5a73 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplanation.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplanation.java @@ -30,7 +30,7 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.shard.ShardId; @@ -44,7 +44,7 @@ import static org.elasticsearch.cluster.routing.allocation.AbstractAllocationDec * or if it is not unassigned, then which nodes it could possibly be relocated to. * It is an immutable class. */ -public final class ClusterAllocationExplanation implements ToXContent, Writeable { +public final class ClusterAllocationExplanation implements ToXContentObject, Writeable { private final ShardRouting shardRouting; private final DiscoveryNode currentNode; diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsGroup.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsGroup.java index 79a014ebda7..2a906a7b93e 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsGroup.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsGroup.java @@ -23,13 +23,13 @@ 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.xcontent.ToXContent; +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, ToXContent { +public class ClusterSearchShardsGroup implements Streamable, ToXContentObject { private ShardId shardId; private ShardRouting[] shards; diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIndices.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIndices.java index 9a7bb5c8f3d..dbc01efe1ff 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIndices.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIndices.java @@ -21,8 +21,10 @@ package org.elasticsearch.action.admin.cluster.stats; import com.carrotsearch.hppc.ObjectObjectHashMap; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; + import org.elasticsearch.action.admin.indices.stats.CommonStats; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.cache.query.QueryCacheStats; import org.elasticsearch.index.engine.SegmentsStats; @@ -34,7 +36,7 @@ import org.elasticsearch.search.suggest.completion.CompletionStats; import java.io.IOException; import java.util.List; -public class ClusterStatsIndices implements ToXContent { +public class ClusterStatsIndices implements ToXContentFragment { private int indexCount; private ShardStats shards; diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsNodes.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsNodes.java index 41cacf2a851..6813267c14c 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsNodes.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsNodes.java @@ -21,6 +21,7 @@ package org.elasticsearch.action.admin.cluster.stats; import com.carrotsearch.hppc.ObjectIntHashMap; import com.carrotsearch.hppc.cursors.ObjectIntCursor; + import org.elasticsearch.Version; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; @@ -32,6 +33,7 @@ import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.monitor.fs.FsInfo; import org.elasticsearch.monitor.jvm.JvmInfo; @@ -48,7 +50,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; -public class ClusterStatsNodes implements ToXContent { +public class ClusterStatsNodes implements ToXContentFragment { private final Counts counts; private final Set versions; @@ -169,7 +171,7 @@ public class ClusterStatsNodes implements ToXContent { return builder; } - public static class Counts implements ToXContent { + public static class Counts implements ToXContentFragment { static final String COORDINATING_ONLY = "coordinating_only"; private final int total; @@ -394,7 +396,7 @@ public class ClusterStatsNodes implements ToXContent { } } - public static class JvmStats implements ToXContent { + public static class JvmStats implements ToXContentFragment { private final ObjectIntHashMap versions; private final long threads; diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsResponse.java index 4ce9c7e6ff5..b8806daaec6 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsResponse.java @@ -25,7 +25,7 @@ import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -33,7 +33,7 @@ import java.io.IOException; import java.util.List; import java.util.Locale; -public class ClusterStatsResponse extends BaseNodesResponse implements ToXContent { +public class ClusterStatsResponse extends BaseNodesResponse implements ToXContentFragment { ClusterStatsNodes nodesStats; ClusterStatsIndices indicesStats; diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java index d543ac67e1d..a394fe17f21 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java @@ -23,13 +23,13 @@ import org.elasticsearch.Version; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.script.StoredScriptSource; import java.io.IOException; -public class GetStoredScriptResponse extends ActionResponse implements ToXContent { +public class GetStoredScriptResponse extends ActionResponse implements ToXContentObject { private StoredScriptSource source; diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/DetailAnalyzeResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/DetailAnalyzeResponse.java index 2d1ba22b989..c080a01a981 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/DetailAnalyzeResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/DetailAnalyzeResponse.java @@ -24,12 +24,13 @@ import org.elasticsearch.common.Strings; 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.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; -public class DetailAnalyzeResponse implements Streamable, ToXContent { +public class DetailAnalyzeResponse implements Streamable, ToXContentFragment { DetailAnalyzeResponse() { } @@ -190,7 +191,7 @@ public class DetailAnalyzeResponse implements Streamable, ToXContent { } } - public static class AnalyzeTokenList implements Streamable, ToXContent { + public static class AnalyzeTokenList implements Streamable, ToXContentObject { private String name; private AnalyzeResponse.AnalyzeToken[] tokens; @@ -216,7 +217,7 @@ public class DetailAnalyzeResponse implements Streamable, ToXContent { return list; } - public XContentBuilder toXContentWithoutObject(XContentBuilder builder, Params params) throws IOException { + XContentBuilder toXContentWithoutObject(XContentBuilder builder, Params params) throws IOException { builder.field(Fields.NAME, this.name); builder.startArray(AnalyzeResponse.Fields.TOKENS); for (AnalyzeResponse.AnalyzeToken token : tokens) { @@ -229,12 +230,7 @@ public class DetailAnalyzeResponse implements Streamable, ToXContent { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); - builder.field(Fields.NAME, this.name); - builder.startArray(AnalyzeResponse.Fields.TOKENS); - for (AnalyzeResponse.AnalyzeToken token : tokens) { - token.toXContent(builder, params); - } - builder.endArray(); + toXContentWithoutObject(builder, params); builder.endObject(); return builder; } @@ -265,7 +261,7 @@ public class DetailAnalyzeResponse implements Streamable, ToXContent { } } - public static class CharFilteredText implements Streamable, ToXContent { + public static class CharFilteredText implements Streamable, ToXContentObject { private String name; private String[] texts; CharFilteredText() { diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java index 3f4ddaf08db..2dc27317c78 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentType; @@ -38,7 +38,7 @@ import static java.util.Collections.emptyMap; import static java.util.Collections.unmodifiableMap; /** Response object for {@link GetFieldMappingsRequest} API */ -public class GetFieldMappingsResponse extends ActionResponse implements ToXContent { +public class GetFieldMappingsResponse extends ActionResponse implements ToXContentFragment { private Map>> mappings = emptyMap(); @@ -92,7 +92,7 @@ public class GetFieldMappingsResponse extends ActionResponse implements ToXConte return builder; } - public static class FieldMappingMetaData implements ToXContent { + public static class FieldMappingMetaData implements ToXContentFragment { public static final FieldMappingMetaData NULL = new FieldMappingMetaData("", BytesArray.EMPTY); private String fullName; diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentResponse.java index 43b1033044c..19b32d25a06 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentResponse.java @@ -29,7 +29,7 @@ import org.elasticsearch.action.support.broadcast.BroadcastResponse; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.engine.Segment; @@ -39,11 +39,11 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.Locale; -public class IndicesSegmentResponse extends BroadcastResponse implements ToXContent { +public class IndicesSegmentResponse extends BroadcastResponse implements ToXContentFragment { private ShardSegments[] shards; diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java index 8cded12b030..b3494094182 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresResponse.java @@ -34,6 +34,7 @@ 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.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -49,7 +50,7 @@ import static org.elasticsearch.action.admin.indices.shards.IndicesShardStoresRe * Consists of {@link StoreStatus}s for requested indices grouped by * indices and shard ids and a list of encountered node {@link Failure}s */ -public class IndicesShardStoresResponse extends ActionResponse implements ToXContent { +public class IndicesShardStoresResponse extends ActionResponse implements ToXContentFragment { /** * Shard store information from a node diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStats.java b/core/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStats.java index b5e91ddf2a1..71360c359d3 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStats.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStats.java @@ -25,6 +25,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.cache.query.QueryCacheStats; import org.elasticsearch.index.cache.request.RequestCacheStats; @@ -50,7 +51,7 @@ import java.util.Arrays; import java.util.Objects; import java.util.stream.Stream; -public class CommonStats implements Writeable, ToXContent { +public class CommonStats implements Writeable, ToXContentFragment { @Nullable public DocsStats docs; diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponse.java b/core/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponse.java index 5b2c024c6b8..5fcd4e5e62e 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponse.java @@ -24,7 +24,7 @@ import org.elasticsearch.action.support.broadcast.BroadcastResponse; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -38,7 +38,7 @@ import java.util.Set; import static java.util.Collections.unmodifiableMap; -public class IndicesStatsResponse extends BroadcastResponse implements ToXContent { +public class IndicesStatsResponse extends BroadcastResponse implements ToXContentFragment { private ShardStats[] shards; diff --git a/core/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java b/core/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java index daf10521f9e..57e14bcaa2d 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java @@ -34,7 +34,7 @@ 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.StatusToXContentObject; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.seqno.SequenceNumbersService; @@ -160,7 +160,7 @@ public class BulkItemResponse implements Streamable, StatusToXContentObject { /** * Represents a failure. */ - public static class Failure implements Writeable, ToXContent { + public static class Failure implements Writeable, ToXContentFragment { static final String INDEX_FIELD = "index"; static final String TYPE_FIELD = "type"; static final String ID_FIELD = "id"; diff --git a/core/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilities.java b/core/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilities.java index ef7513f38ab..ec6d0902ac9 100644 --- a/core/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilities.java +++ b/core/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilities.java @@ -22,20 +22,20 @@ package org.elasticsearch.action.fieldcaps; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; -import java.util.Collections; -import java.util.Arrays; -import java.util.List; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.Comparator; +import java.util.List; /** * Describes the capabilities of a field optionally merged across multiple indices. */ -public class FieldCapabilities implements Writeable, ToXContent { +public class FieldCapabilities implements Writeable, ToXContentObject { private final String name; private final String type; private final boolean isSearchable; diff --git a/core/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponse.java b/core/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponse.java index ae5db583567..4b1bcf57589 100644 --- a/core/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponse.java +++ b/core/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponse.java @@ -23,7 +23,7 @@ import org.elasticsearch.Version; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -34,7 +34,7 @@ import java.util.Map; /** * Response for {@link FieldCapabilitiesRequest} requests. */ -public class FieldCapabilitiesResponse extends ActionResponse implements ToXContent { +public class FieldCapabilitiesResponse extends ActionResponse implements ToXContentFragment { private Map> responseMap; private List indexResponses; diff --git a/core/src/main/java/org/elasticsearch/action/search/SearchResponseSections.java b/core/src/main/java/org/elasticsearch/action/search/SearchResponseSections.java index 1757acbfd6d..5b44c9a473e 100644 --- a/core/src/main/java/org/elasticsearch/action/search/SearchResponseSections.java +++ b/core/src/main/java/org/elasticsearch/action/search/SearchResponseSections.java @@ -20,7 +20,7 @@ package org.elasticsearch.action.search; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.aggregations.Aggregations; @@ -40,7 +40,7 @@ import java.util.Map; * to parse aggregations into, which are not serializable. This is the common part that can be * shared between core and client. */ -public class SearchResponseSections implements ToXContent { +public class SearchResponseSections implements ToXContentFragment { protected final SearchHits hits; protected final Aggregations aggregations; diff --git a/core/src/main/java/org/elasticsearch/cluster/ClusterInfo.java b/core/src/main/java/org/elasticsearch/cluster/ClusterInfo.java index e6e4cf1bb9f..ad305982013 100644 --- a/core/src/main/java/org/elasticsearch/cluster/ClusterInfo.java +++ b/core/src/main/java/org/elasticsearch/cluster/ClusterInfo.java @@ -20,17 +20,16 @@ package org.elasticsearch.cluster; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; + import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.ToXContent.Params; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; -import java.util.HashMap; import java.util.Map; /** * ClusterInfo is an object representing a map of nodes to {@link DiskUsage} @@ -38,7 +37,7 @@ import java.util.Map; * InternalClusterInfoService.shardIdentifierFromRouting(String) * for the key used in the shardSizes map */ -public class ClusterInfo implements ToXContent, Writeable { +public class ClusterInfo implements ToXContentFragment, Writeable { private final ImmutableOpenMap leastAvailableSpaceUsage; private final ImmutableOpenMap mostAvailableSpaceUsage; final ImmutableOpenMap shardSizes; @@ -117,13 +116,13 @@ public class ClusterInfo implements ToXContent, Writeable { builder.startObject(c.key); { // node builder.field("node_name", c.value.getNodeName()); builder.startObject("least_available"); { - c.value.toShortXContent(builder, params); + c.value.toShortXContent(builder); } builder.endObject(); // end "least_available" builder.startObject("most_available"); { DiskUsage most = this.mostAvailableSpaceUsage.get(c.key); if (most != null) { - most.toShortXContent(builder, params); + most.toShortXContent(builder); } } builder.endObject(); // end "most_available" diff --git a/core/src/main/java/org/elasticsearch/cluster/ClusterState.java b/core/src/main/java/org/elasticsearch/cluster/ClusterState.java index 89b3727c9f4..576fd760a08 100644 --- a/core/src/main/java/org/elasticsearch/cluster/ClusterState.java +++ b/core/src/main/java/org/elasticsearch/cluster/ClusterState.java @@ -22,6 +22,7 @@ package org.elasticsearch.cluster; import com.carrotsearch.hppc.cursors.IntObjectCursor; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; + import org.elasticsearch.cluster.block.ClusterBlock; import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.metadata.IndexMetaData; @@ -50,6 +51,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.discovery.Discovery; @@ -85,7 +87,7 @@ import java.util.Set; * throws the {@link IncompatibleClusterStateVersionException}, which causes the publishing mechanism to send * a full version of the cluster state to the node on which this exception was thrown. */ -public class ClusterState implements ToXContent, Diffable { +public class ClusterState implements ToXContentFragment, Diffable { public static final ClusterState EMPTY_STATE = builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).build(); diff --git a/core/src/main/java/org/elasticsearch/cluster/DiskUsage.java b/core/src/main/java/org/elasticsearch/cluster/DiskUsage.java index 868a3f45feb..ace7be50b66 100644 --- a/core/src/main/java/org/elasticsearch/cluster/DiskUsage.java +++ b/core/src/main/java/org/elasticsearch/cluster/DiskUsage.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -33,7 +33,7 @@ import java.util.Objects; /** * Encapsulation class used to represent the amount of disk used on a node. */ -public class DiskUsage implements ToXContent, Writeable { +public class DiskUsage implements ToXContentFragment, Writeable { final String nodeId; final String nodeName; final String path; @@ -73,7 +73,7 @@ public class DiskUsage implements ToXContent, Writeable { return Math.round(pct * 10.0) / 10.0; } - public XContentBuilder toShortXContent(XContentBuilder builder, Params params) throws IOException { + XContentBuilder toShortXContent(XContentBuilder builder) throws IOException { builder.field("path", this.path); builder.byteSizeField("total_bytes", "total", this.totalBytes); builder.byteSizeField("used_bytes", "used", this.getUsedBytes()); @@ -86,7 +86,7 @@ public class DiskUsage implements ToXContent, Writeable { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.field("node_id", this.nodeId); builder.field("node_name", this.nodeName); - builder = toShortXContent(builder, params); + builder = toShortXContent(builder); return builder; } diff --git a/core/src/main/java/org/elasticsearch/cluster/block/ClusterBlock.java b/core/src/main/java/org/elasticsearch/cluster/block/ClusterBlock.java index 2caaa0bddf3..efbd262b16d 100644 --- a/core/src/main/java/org/elasticsearch/cluster/block/ClusterBlock.java +++ b/core/src/main/java/org/elasticsearch/cluster/block/ClusterBlock.java @@ -23,7 +23,7 @@ import org.elasticsearch.Version; 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.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.rest.RestStatus; @@ -32,7 +32,7 @@ import java.util.ArrayList; import java.util.EnumSet; import java.util.Locale; -public class ClusterBlock implements Streamable, ToXContent { +public class ClusterBlock implements Streamable, ToXContentFragment { private int id; diff --git a/core/src/main/java/org/elasticsearch/cluster/health/ClusterIndexHealth.java b/core/src/main/java/org/elasticsearch/cluster/health/ClusterIndexHealth.java index 9bc483ace68..75c564c2038 100644 --- a/core/src/main/java/org/elasticsearch/cluster/health/ClusterIndexHealth.java +++ b/core/src/main/java/org/elasticsearch/cluster/health/ClusterIndexHealth.java @@ -25,7 +25,7 @@ import org.elasticsearch.cluster.routing.IndexShardRoutingTable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -34,7 +34,7 @@ import java.util.Iterator; import java.util.Locale; import java.util.Map; -public final class ClusterIndexHealth implements Iterable, Writeable, ToXContent { +public final class ClusterIndexHealth implements Iterable, Writeable, ToXContentFragment { private final String index; private final int numberOfShards; diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java b/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java index c11bca5cfc5..56a8c1a4b8b 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java @@ -23,6 +23,7 @@ import com.carrotsearch.hppc.LongArrayList; import com.carrotsearch.hppc.cursors.IntObjectCursor; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; + import org.elasticsearch.Version; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.cluster.Diff; @@ -45,6 +46,7 @@ import org.elasticsearch.common.settings.Setting.Property; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.loader.SettingsLoader; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentHelper; @@ -75,7 +77,7 @@ import static org.elasticsearch.cluster.node.DiscoveryNodeFilters.OpType.OR; import static org.elasticsearch.common.settings.Settings.readSettingsFromStream; import static org.elasticsearch.common.settings.Settings.writeSettingsToStream; -public class IndexMetaData implements Diffable, ToXContent { +public class IndexMetaData implements Diffable, ToXContentFragment { /** * This class will be removed in v7.0 diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java index fcc0fdebdd4..870da642c4a 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java @@ -22,6 +22,7 @@ package org.elasticsearch.cluster.metadata; import com.carrotsearch.hppc.ObjectHashSet; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; + import org.apache.logging.log4j.Logger; import org.apache.lucene.util.CollectionUtil; import org.elasticsearch.cluster.Diff; @@ -45,6 +46,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.loader.SettingsLoader; import org.elasticsearch.common.xcontent.NamedXContentRegistry.UnknownNamedObjectException; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -70,7 +72,7 @@ import java.util.TreeMap; import static org.elasticsearch.common.settings.Settings.readSettingsFromStream; import static org.elasticsearch.common.settings.Settings.writeSettingsToStream; -public class MetaData implements Iterable, Diffable, ToXContent { +public class MetaData implements Iterable, Diffable, ToXContentFragment { private static final Logger logger = Loggers.getLogger(MetaData.class); diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 4b214dd5631..283982446dd 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.node.Node; @@ -42,7 +42,7 @@ import java.util.function.Predicate; /** * A discovery node represents a node that is part of the cluster. */ -public class DiscoveryNode implements Writeable, ToXContent { +public class DiscoveryNode implements Writeable, ToXContentFragment { public static boolean nodeRequiresLocalStorage(Settings settings) { boolean localStorageEnable = Node.NODE_LOCAL_STORAGE_SETTING.get(settings); diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/AllocationId.java b/core/src/main/java/org/elasticsearch/cluster/routing/AllocationId.java index 9ab91f9f8de..ef07ef9b1ea 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/AllocationId.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/AllocationId.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.ObjectParser; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -42,7 +42,7 @@ import java.util.Objects; * relocationId. Once relocation is done, the new allocation id is set to the relocationId. This is similar * behavior to how ShardRouting#currentNodeId is used. */ -public class AllocationId implements ToXContent, Writeable { +public class AllocationId implements ToXContentObject, Writeable { private static final String ID_KEY = "id"; private static final String RELOCATION_ID_KEY = "relocation_id"; diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AbstractAllocationDecision.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AbstractAllocationDecision.java index 7ee17c558f7..850e8c9c142 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AbstractAllocationDecision.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/AbstractAllocationDecision.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -38,7 +38,7 @@ import java.util.stream.Collectors; /** * An abstract class for representing various types of allocation decisions. */ -public abstract class AbstractAllocationDecision implements ToXContent, Writeable { +public abstract class AbstractAllocationDecision implements ToXContentFragment, Writeable { @Nullable protected final DiscoveryNode targetNode; diff --git a/core/src/main/java/org/elasticsearch/common/document/DocumentField.java b/core/src/main/java/org/elasticsearch/common/document/DocumentField.java index e1cbec8b477..b0b869ae8ce 100644 --- a/core/src/main/java/org/elasticsearch/common/document/DocumentField.java +++ b/core/src/main/java/org/elasticsearch/common/document/DocumentField.java @@ -22,7 +22,7 @@ package org.elasticsearch.common.document; 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.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.get.GetResult; @@ -44,7 +44,7 @@ import static org.elasticsearch.common.xcontent.XContentParserUtils.parseStoredF * @see SearchHit * @see GetResult */ -public class DocumentField implements Streamable, ToXContent, Iterable { +public class DocumentField implements Streamable, ToXContentFragment, Iterable { private String name; private List values; diff --git a/core/src/main/java/org/elasticsearch/common/geo/builders/ShapeBuilder.java b/core/src/main/java/org/elasticsearch/common/geo/builders/ShapeBuilder.java index 8f40d265acf..dbac02ecb4c 100644 --- a/core/src/main/java/org/elasticsearch/common/geo/builders/ShapeBuilder.java +++ b/core/src/main/java/org/elasticsearch/common/geo/builders/ShapeBuilder.java @@ -22,6 +22,7 @@ package org.elasticsearch.common.geo.builders; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; + import org.apache.logging.log4j.Logger; import org.elasticsearch.Assertions; import org.elasticsearch.ElasticsearchParseException; @@ -31,7 +32,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.unit.DistanceUnit.Distance; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -260,7 +261,7 @@ public abstract class ShapeBuilder extends ToXContentToBytes implements NamedWri * Can either be a leaf node consisting of a Coordinate, or a parent with * children */ - protected static class CoordinateNode implements ToXContent { + protected static class CoordinateNode implements ToXContentObject { protected final Coordinate coordinate; protected final List children; diff --git a/core/src/main/java/org/elasticsearch/common/unit/Fuzziness.java b/core/src/main/java/org/elasticsearch/common/unit/Fuzziness.java index d9403b52882..100ddefd99d 100644 --- a/core/src/main/java/org/elasticsearch/common/unit/Fuzziness.java +++ b/core/src/main/java/org/elasticsearch/common/unit/Fuzziness.java @@ -22,7 +22,7 @@ import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -35,7 +35,7 @@ import java.util.Objects; * parsing and conversion from similarities to edit distances * etc. */ -public final class Fuzziness implements ToXContent, Writeable { +public final class Fuzziness implements ToXContentFragment, Writeable { public static final String X_FIELD_NAME = "fuzziness"; public static final Fuzziness ZERO = new Fuzziness(0); @@ -124,15 +124,7 @@ public final class Fuzziness implements ToXContent, Writeable { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - return toXContent(builder, params, true); - } - - public XContentBuilder toXContent(XContentBuilder builder, Params params, boolean includeFieldName) throws IOException { - if (includeFieldName) { - builder.field(X_FIELD_NAME, fuzziness); - } else { - builder.value(fuzziness); - } + builder.field(X_FIELD_NAME, fuzziness); return builder; } diff --git a/core/src/main/java/org/elasticsearch/common/xcontent/ToXContentFragment.java b/core/src/main/java/org/elasticsearch/common/xcontent/ToXContentFragment.java new file mode 100644 index 00000000000..6d903ef402e --- /dev/null +++ b/core/src/main/java/org/elasticsearch/common/xcontent/ToXContentFragment.java @@ -0,0 +1,36 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.common.xcontent; + +/** + * An interface allowing to transfer an object to "XContent" using an + * {@link XContentBuilder}. The difference between {@link ToXContentFragment} + * and {@link ToXContentObject} is that the former outputs a fragment that + * requires to start and end a new anonymous object externally, while the latter + * guarantees that what gets printed out is fully valid syntax without any + * external addition. + */ +public interface ToXContentFragment extends ToXContent { + + @Override + default boolean isFragment() { + return true; + } +} diff --git a/core/src/main/java/org/elasticsearch/common/xcontent/ToXContentObject.java b/core/src/main/java/org/elasticsearch/common/xcontent/ToXContentObject.java index ed9aa304719..3f8f0a81a50 100644 --- a/core/src/main/java/org/elasticsearch/common/xcontent/ToXContentObject.java +++ b/core/src/main/java/org/elasticsearch/common/xcontent/ToXContentObject.java @@ -20,10 +20,12 @@ package org.elasticsearch.common.xcontent; /** - * An interface allowing to transfer an object to "XContent" using an {@link XContentBuilder}. - * The difference between {@link ToXContent} and {@link ToXContentObject} is that the former may output a fragment that - * requires to start and end a new anonymous object externally, while the latter guarantees that what gets printed - * out is fully valid syntax without any external addition. + * An interface allowing to transfer an object to "XContent" using an + * {@link XContentBuilder}. The difference between {@link ToXContentFragment} + * and {@link ToXContentObject} is that the former outputs a fragment that + * requires to start and end a new anonymous object externally, while the latter + * guarantees that what gets printed out is fully valid syntax without any + * external addition. */ public interface ToXContentObject extends ToXContent { diff --git a/core/src/main/java/org/elasticsearch/discovery/DiscoveryStats.java b/core/src/main/java/org/elasticsearch/discovery/DiscoveryStats.java index 9542b14e569..37e916d65fb 100644 --- a/core/src/main/java/org/elasticsearch/discovery/DiscoveryStats.java +++ b/core/src/main/java/org/elasticsearch/discovery/DiscoveryStats.java @@ -23,13 +23,13 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.discovery.zen.PendingClusterStateStats; import java.io.IOException; -public class DiscoveryStats implements Writeable, ToXContent { +public class DiscoveryStats implements Writeable, ToXContentFragment { @Nullable private final PendingClusterStateStats queueStats; diff --git a/core/src/main/java/org/elasticsearch/http/HttpInfo.java b/core/src/main/java/org/elasticsearch/http/HttpInfo.java index e8f3985a23a..706211af6e4 100644 --- a/core/src/main/java/org/elasticsearch/http/HttpInfo.java +++ b/core/src/main/java/org/elasticsearch/http/HttpInfo.java @@ -24,12 +24,12 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.transport.BoundTransportAddress; import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; -public class HttpInfo implements Writeable, ToXContent { +public class HttpInfo implements Writeable, ToXContentFragment { private final BoundTransportAddress address; private final long maxContentLength; diff --git a/core/src/main/java/org/elasticsearch/http/HttpStats.java b/core/src/main/java/org/elasticsearch/http/HttpStats.java index d019a65f03b..ac7f0d69485 100644 --- a/core/src/main/java/org/elasticsearch/http/HttpStats.java +++ b/core/src/main/java/org/elasticsearch/http/HttpStats.java @@ -22,12 +22,12 @@ package org.elasticsearch.http; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; -public class HttpStats implements Writeable, ToXContent { +public class HttpStats implements Writeable, ToXContentFragment { private final long serverOpen; private final long totalOpen; diff --git a/core/src/main/java/org/elasticsearch/index/Index.java b/core/src/main/java/org/elasticsearch/index/Index.java index da94ad2ec72..41cb90d5ba8 100644 --- a/core/src/main/java/org/elasticsearch/index/Index.java +++ b/core/src/main/java/org/elasticsearch/index/Index.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.ObjectParser; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -35,7 +35,7 @@ import java.util.Objects; /** * A value class representing the basic required properties of an Elasticsearch index. */ -public class Index implements Writeable, ToXContent { +public class Index implements Writeable, ToXContentObject { public static final Index[] EMPTY_ARRAY = new Index[0]; private static final String INDEX_UUID_KEY = "index_uuid"; diff --git a/core/src/main/java/org/elasticsearch/index/engine/CommitStats.java b/core/src/main/java/org/elasticsearch/index/engine/CommitStats.java index eb2e35a5a23..c97ba8ec543 100644 --- a/core/src/main/java/org/elasticsearch/index/engine/CommitStats.java +++ b/core/src/main/java/org/elasticsearch/index/engine/CommitStats.java @@ -24,7 +24,7 @@ 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.lucene.Lucene; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -32,7 +32,7 @@ import java.util.Base64; import java.util.Map; /** a class the returns dynamic information with respect to the last commit point of this shard */ -public final class CommitStats implements Streamable, ToXContent { +public final class CommitStats implements Streamable, ToXContentFragment { private Map userData; private long generation; diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/FieldDataStats.java b/core/src/main/java/org/elasticsearch/index/fielddata/FieldDataStats.java index 6cd2eda5530..729184c221d 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/FieldDataStats.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/FieldDataStats.java @@ -25,13 +25,13 @@ 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.unit.ByteSizeValue; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; import java.util.Objects; -public class FieldDataStats implements Streamable, ToXContent { +public class FieldDataStats implements Streamable, ToXContentFragment { private static final String FIELDDATA = "fielddata"; private static final String MEMORY_SIZE = "memory_size"; diff --git a/core/src/main/java/org/elasticsearch/index/flush/FlushStats.java b/core/src/main/java/org/elasticsearch/index/flush/FlushStats.java index ac9a4a5c9a1..d15a62b0a73 100644 --- a/core/src/main/java/org/elasticsearch/index/flush/FlushStats.java +++ b/core/src/main/java/org/elasticsearch/index/flush/FlushStats.java @@ -23,12 +23,12 @@ 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.unit.TimeValue; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; -public class FlushStats implements Streamable, ToXContent { +public class FlushStats implements Streamable, ToXContentFragment { private long total; diff --git a/core/src/main/java/org/elasticsearch/index/get/GetStats.java b/core/src/main/java/org/elasticsearch/index/get/GetStats.java index 5a386b85330..e89f22ea851 100644 --- a/core/src/main/java/org/elasticsearch/index/get/GetStats.java +++ b/core/src/main/java/org/elasticsearch/index/get/GetStats.java @@ -23,12 +23,12 @@ 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.unit.TimeValue; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; -public class GetStats implements Streamable, ToXContent { +public class GetStats implements Streamable, ToXContentFragment { private long existsCount; private long existsTimeInMillis; diff --git a/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java index a8d172a5112..3654103c189 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.text.Text; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.IndexSettings; @@ -47,7 +48,7 @@ import java.util.Objects; import static java.util.Collections.emptyMap; -public class DocumentMapper implements ToXContent { +public class DocumentMapper implements ToXContentFragment { public static class Builder { diff --git a/core/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java b/core/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java index 0570cd73252..8f3634e0132 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java @@ -23,7 +23,7 @@ import org.elasticsearch.Version; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.regex.Regex; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -34,7 +34,7 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; -public class DynamicTemplate implements ToXContent { +public class DynamicTemplate implements ToXContentObject { private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(DynamicTemplate.class)); diff --git a/core/src/main/java/org/elasticsearch/index/mapper/Mapper.java b/core/src/main/java/org/elasticsearch/index/mapper/Mapper.java index db1060d3be6..4f78ec0ad95 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/Mapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/Mapper.java @@ -21,7 +21,7 @@ package org.elasticsearch.index.mapper; import org.elasticsearch.Version; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.index.analysis.IndexAnalyzers; import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.index.similarity.SimilarityProvider; @@ -31,7 +31,7 @@ import java.util.Objects; import java.util.function.Function; import java.util.function.Supplier; -public abstract class Mapper implements ToXContent, Iterable { +public abstract class Mapper implements ToXContentFragment, Iterable { public static class BuilderContext { private final Settings indexSettings; diff --git a/core/src/main/java/org/elasticsearch/index/mapper/Mapping.java b/core/src/main/java/org/elasticsearch/index/mapper/Mapping.java index 9cb3ea7a57e..6b58c35a66b 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/Mapping.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/Mapping.java @@ -21,6 +21,7 @@ package org.elasticsearch.index.mapper; import org.elasticsearch.Version; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -38,7 +39,7 @@ import static java.util.Collections.unmodifiableMap; * Wrapper around everything that defines a mapping, without references to * utility classes like MapperService, ... */ -public final class Mapping implements ToXContent { +public final class Mapping implements ToXContentFragment { final Version indexCreated; final RootObjectMapper root; diff --git a/core/src/main/java/org/elasticsearch/index/merge/MergeStats.java b/core/src/main/java/org/elasticsearch/index/merge/MergeStats.java index b129d8e8db9..94e5b31a1cd 100644 --- a/core/src/main/java/org/elasticsearch/index/merge/MergeStats.java +++ b/core/src/main/java/org/elasticsearch/index/merge/MergeStats.java @@ -24,12 +24,12 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; -public class MergeStats implements Streamable, ToXContent { +public class MergeStats implements Streamable, ToXContentFragment { private long total; private long totalTimeInMillis; diff --git a/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java index b0147492c1a..172e96cb34d 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java @@ -45,7 +45,7 @@ import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.lucene.search.MoreLikeThisQuery; import org.elasticsearch.common.lucene.search.XMoreLikeThis; import org.elasticsearch.common.lucene.uid.Versions; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -142,7 +142,7 @@ public class MoreLikeThisQueryBuilder extends AbstractQueryBuilder scoreFunction; diff --git a/core/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java b/core/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java index 400baf7b9e2..764a19e8a0d 100644 --- a/core/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java +++ b/core/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -40,7 +40,7 @@ import static org.elasticsearch.common.unit.TimeValue.timeValueNanos; /** * Response used for actions that index many documents using a scroll request. */ -public class BulkByScrollResponse extends ActionResponse implements ToXContent { +public class BulkByScrollResponse extends ActionResponse implements ToXContentFragment { private TimeValue took; private BulkByScrollTask.Status status; private List bulkFailures; diff --git a/core/src/main/java/org/elasticsearch/index/shard/DocsStats.java b/core/src/main/java/org/elasticsearch/index/shard/DocsStats.java index 5ee5ac66083..6d4f5ee7815 100644 --- a/core/src/main/java/org/elasticsearch/index/shard/DocsStats.java +++ b/core/src/main/java/org/elasticsearch/index/shard/DocsStats.java @@ -22,12 +22,12 @@ package org.elasticsearch.index.shard; 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.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; -public class DocsStats implements Streamable, ToXContent { +public class DocsStats implements Streamable, ToXContentFragment { long count = 0; long deleted = 0; diff --git a/core/src/main/java/org/elasticsearch/index/shard/IndexingStats.java b/core/src/main/java/org/elasticsearch/index/shard/IndexingStats.java index c94062e0657..8f900fc9d0b 100644 --- a/core/src/main/java/org/elasticsearch/index/shard/IndexingStats.java +++ b/core/src/main/java/org/elasticsearch/index/shard/IndexingStats.java @@ -19,20 +19,20 @@ package org.elasticsearch.index.shard; -import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; 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.unit.TimeValue; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; import java.util.HashMap; import java.util.Map; -public class IndexingStats implements Streamable, ToXContent { +public class IndexingStats implements Streamable, ToXContentFragment { public static class Stats implements Streamable, ToXContent { diff --git a/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java b/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java index f3597d7e5c9..0abc0724c3a 100644 --- a/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java +++ b/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshot.java @@ -27,6 +27,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.store.StoreFileMetaData; @@ -39,7 +40,7 @@ import java.util.List; /** * Shard snapshot metadata */ -public class BlobStoreIndexShardSnapshot implements ToXContent { +public class BlobStoreIndexShardSnapshot implements ToXContentFragment { /** * Information about snapshotted file diff --git a/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java b/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java index 56c343a5ae9..7ecf92d3bf1 100644 --- a/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java +++ b/core/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardSnapshots.java @@ -21,7 +21,7 @@ package org.elasticsearch.index.snapshots.blobstore; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.ParseField; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.FileInfo; @@ -42,7 +42,7 @@ import static java.util.Collections.unmodifiableMap; * This class is used to find files that were already snapshotted and clear out files that no longer referenced by any * snapshots */ -public class BlobStoreIndexShardSnapshots implements Iterable, ToXContent { +public class BlobStoreIndexShardSnapshots implements Iterable, ToXContentFragment { private final List shardSnapshots; private final Map files; diff --git a/core/src/main/java/org/elasticsearch/indices/breaker/AllCircuitBreakerStats.java b/core/src/main/java/org/elasticsearch/indices/breaker/AllCircuitBreakerStats.java index 3022d885e1a..7ab81182eac 100644 --- a/core/src/main/java/org/elasticsearch/indices/breaker/AllCircuitBreakerStats.java +++ b/core/src/main/java/org/elasticsearch/indices/breaker/AllCircuitBreakerStats.java @@ -22,7 +22,7 @@ package org.elasticsearch.indices.breaker; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -30,7 +30,7 @@ import java.io.IOException; /** * Stats class encapsulating all of the different circuit breaker stats */ -public class AllCircuitBreakerStats implements Writeable, ToXContent { +public class AllCircuitBreakerStats implements Writeable, ToXContentFragment { private final CircuitBreakerStats[] allStats; diff --git a/core/src/main/java/org/elasticsearch/indices/breaker/CircuitBreakerStats.java b/core/src/main/java/org/elasticsearch/indices/breaker/CircuitBreakerStats.java index a079e29edf8..eb5b965f048 100644 --- a/core/src/main/java/org/elasticsearch/indices/breaker/CircuitBreakerStats.java +++ b/core/src/main/java/org/elasticsearch/indices/breaker/CircuitBreakerStats.java @@ -23,7 +23,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -32,7 +32,7 @@ import java.util.Locale; /** * Class encapsulating stats about the circuit breaker */ -public class CircuitBreakerStats implements Writeable, ToXContent { +public class CircuitBreakerStats implements Writeable, ToXContentObject { private final String name; private final long limit; diff --git a/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java b/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java index 459b811552b..f2139f8e251 100644 --- a/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java +++ b/core/src/main/java/org/elasticsearch/indices/recovery/RecoveryState.java @@ -28,6 +28,8 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.shard.ShardId; @@ -552,7 +554,7 @@ public class RecoveryState implements ToXContent, Streamable { } } - public static class File implements ToXContent, Streamable { + public static class File implements ToXContentObject, Streamable { private String name; private long length; private long recovered; @@ -663,7 +665,7 @@ public class RecoveryState implements ToXContent, Streamable { } } - public static class Index extends Timer implements ToXContent, Streamable { + public static class Index extends Timer implements ToXContentFragment, Streamable { private Map fileDetails = new HashMap<>(); diff --git a/core/src/main/java/org/elasticsearch/ingest/IngestInfo.java b/core/src/main/java/org/elasticsearch/ingest/IngestInfo.java index 7dbce888bba..ad7b59368e9 100644 --- a/core/src/main/java/org/elasticsearch/ingest/IngestInfo.java +++ b/core/src/main/java/org/elasticsearch/ingest/IngestInfo.java @@ -22,7 +22,7 @@ package org.elasticsearch.ingest; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -31,7 +31,7 @@ import java.util.Objects; import java.util.Set; import java.util.TreeSet; -public class IngestInfo implements Writeable, ToXContent { +public class IngestInfo implements Writeable, ToXContentFragment { private final Set processors; diff --git a/core/src/main/java/org/elasticsearch/ingest/IngestStats.java b/core/src/main/java/org/elasticsearch/ingest/IngestStats.java index add02a5da90..91e1014e96f 100644 --- a/core/src/main/java/org/elasticsearch/ingest/IngestStats.java +++ b/core/src/main/java/org/elasticsearch/ingest/IngestStats.java @@ -23,6 +23,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -30,7 +31,7 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; -public class IngestStats implements Writeable, ToXContent { +public class IngestStats implements Writeable, ToXContentFragment { private final Stats totalStats; private final Map statsPerPipeline; diff --git a/core/src/main/java/org/elasticsearch/monitor/fs/FsInfo.java b/core/src/main/java/org/elasticsearch/monitor/fs/FsInfo.java index f2538365a71..4f25c4f4dab 100644 --- a/core/src/main/java/org/elasticsearch/monitor/fs/FsInfo.java +++ b/core/src/main/java/org/elasticsearch/monitor/fs/FsInfo.java @@ -27,6 +27,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -35,7 +36,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; -public class FsInfo implements Iterable, Writeable, ToXContent { +public class FsInfo implements Iterable, Writeable, ToXContentFragment { public static class Path implements Writeable, ToXContent { @@ -178,7 +179,7 @@ public class FsInfo implements Iterable, Writeable, ToXContent { } } - public static class DeviceStats implements Writeable, ToXContent { + public static class DeviceStats implements Writeable, ToXContentFragment { final int majorDeviceNumber; final int minorDeviceNumber; @@ -313,7 +314,7 @@ public class FsInfo implements Iterable, Writeable, ToXContent { } - public static class IoStats implements Writeable, ToXContent { + public static class IoStats implements Writeable, ToXContentFragment { private static final String OPERATIONS = "operations"; private static final String READ_OPERATIONS = "read_operations"; diff --git a/core/src/main/java/org/elasticsearch/monitor/jvm/JvmInfo.java b/core/src/main/java/org/elasticsearch/monitor/jvm/JvmInfo.java index 1674ba33c01..c52cce07808 100644 --- a/core/src/main/java/org/elasticsearch/monitor/jvm/JvmInfo.java +++ b/core/src/main/java/org/elasticsearch/monitor/jvm/JvmInfo.java @@ -23,7 +23,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -39,7 +39,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; -public class JvmInfo implements Writeable, ToXContent { +public class JvmInfo implements Writeable, ToXContentFragment { private static JvmInfo INSTANCE; diff --git a/core/src/main/java/org/elasticsearch/monitor/jvm/JvmStats.java b/core/src/main/java/org/elasticsearch/monitor/jvm/JvmStats.java index 5de18ddeec2..712b594b47d 100644 --- a/core/src/main/java/org/elasticsearch/monitor/jvm/JvmStats.java +++ b/core/src/main/java/org/elasticsearch/monitor/jvm/JvmStats.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -44,7 +44,7 @@ import java.util.Iterator; import java.util.List; import java.util.concurrent.TimeUnit; -public class JvmStats implements Writeable, ToXContent { +public class JvmStats implements Writeable, ToXContentFragment { private static final RuntimeMXBean runtimeMXBean; private static final MemoryMXBean memoryMXBean; diff --git a/core/src/main/java/org/elasticsearch/monitor/os/OsStats.java b/core/src/main/java/org/elasticsearch/monitor/os/OsStats.java index c3783c600ea..5c62008cbe8 100644 --- a/core/src/main/java/org/elasticsearch/monitor/os/OsStats.java +++ b/core/src/main/java/org/elasticsearch/monitor/os/OsStats.java @@ -25,6 +25,8 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; @@ -125,7 +127,7 @@ public class OsStats implements Writeable, ToXContent { return builder; } - public static class Cpu implements Writeable, ToXContent { + public static class Cpu implements Writeable, ToXContentFragment { private final short percent; private final double[] loadAverage; @@ -229,7 +231,7 @@ public class OsStats implements Writeable, ToXContent { } } - public static class Mem implements Writeable, ToXContent { + public static class Mem implements Writeable, ToXContentFragment { private final long total; private final long free; @@ -286,7 +288,7 @@ public class OsStats implements Writeable, ToXContent { /** * Encapsulates basic cgroup statistics. */ - public static class Cgroup implements Writeable, ToXContent { + public static class Cgroup implements Writeable, ToXContentObject { private final String cpuAcctControlGroup; private final long cpuAcctUsageNanos; @@ -415,7 +417,7 @@ public class OsStats implements Writeable, ToXContent { /** * Encapsulates CPU time statistics. */ - public static class CpuStat implements Writeable, ToXContent { + public static class CpuStat implements Writeable, ToXContentFragment { private final long numberOfElapsedPeriods; private final long numberOfTimesThrottled; diff --git a/core/src/main/java/org/elasticsearch/repositories/IndexId.java b/core/src/main/java/org/elasticsearch/repositories/IndexId.java index e86d0939b2e..469caa26b64 100644 --- a/core/src/main/java/org/elasticsearch/repositories/IndexId.java +++ b/core/src/main/java/org/elasticsearch/repositories/IndexId.java @@ -23,6 +23,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.Index; @@ -32,7 +33,7 @@ import java.util.Objects; /** * Represents a single snapshotted index in the repository. */ -public final class IndexId implements Writeable, ToXContent { +public final class IndexId implements Writeable, ToXContentObject { protected static final String NAME = "name"; protected static final String ID = "id"; diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilder.java index f0bbe13c05f..99bf9be683e 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilder.java @@ -19,10 +19,10 @@ package org.elasticsearch.search.aggregations; -import org.elasticsearch.action.support.ToXContentToBytes; import org.elasticsearch.common.ParseField; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.NamedWriteable; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.query.QueryRewriteContext; import org.elasticsearch.search.internal.SearchContext; @@ -35,8 +35,7 @@ import java.util.Map; * A factory that knows how to create an {@link Aggregator} of a specific type. */ public abstract class AggregationBuilder - extends ToXContentToBytes - implements NamedWriteable, ToXContent, BaseAggregationBuilder { + implements NamedWriteable, ToXContentFragment, BaseAggregationBuilder { protected final String name; protected AggregatorFactories.Builder factoriesBuilder = AggregatorFactories.builder(); @@ -139,4 +138,9 @@ public abstract class AggregationBuilder public static final class CommonFields extends ParseField.CommonFields { public static final ParseField VALUE_TYPE = new ParseField("value_type"); } + + @Override + public String toString() { + return Strings.toString(this); + } } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/Aggregations.java b/core/src/main/java/org/elasticsearch/search/aggregations/Aggregations.java index ba51fc419fb..af9ea84ec9d 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/Aggregations.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/Aggregations.java @@ -20,7 +20,7 @@ package org.elasticsearch.search.aggregations; import org.apache.lucene.util.SetOnce; import org.elasticsearch.common.ParsingException; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -40,7 +40,7 @@ import static org.elasticsearch.common.xcontent.XContentParserUtils.parseTypedKe /** * Represents a set of {@link Aggregation}s */ -public class Aggregations implements Iterable, ToXContent { +public class Aggregations implements Iterable, ToXContentFragment { public static final String AGGREGATIONS_FIELD = "aggregations"; diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java b/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java index b1652d60365..8f43aa37a21 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java @@ -23,7 +23,6 @@ import org.elasticsearch.common.io.stream.NamedWriteable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.util.BigArrays; -import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.rest.action.search.RestSearchAction; import org.elasticsearch.script.ScriptService; @@ -38,7 +37,7 @@ import java.util.Objects; /** * An internal implementation of {@link Aggregation}. Serves as a base class for all aggregation implementations. */ -public abstract class InternalAggregation implements Aggregation, ToXContent, NamedWriteable { +public abstract class InternalAggregation implements Aggregation, NamedWriteable { public static class ReduceContext { diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregations.java b/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregations.java index 846dc1bb3b0..57170e2f8ab 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregations.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/InternalAggregations.java @@ -21,7 +21,6 @@ package org.elasticsearch.search.aggregations; 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.xcontent.ToXContent; import org.elasticsearch.search.aggregations.InternalAggregation.ReduceContext; import java.io.IOException; @@ -35,7 +34,7 @@ import static java.util.Collections.emptyMap; /** * An internal implementation of {@link Aggregations}. */ -public final class InternalAggregations extends Aggregations implements ToXContent, Streamable { +public final class InternalAggregations extends Aggregations implements Streamable { public static final InternalAggregations EMPTY = new InternalAggregations(); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/adjacency/AdjacencyMatrixAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/adjacency/AdjacencyMatrixAggregator.java index 35d4fe86175..dd1e89897af 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/adjacency/AdjacencyMatrixAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/adjacency/AdjacencyMatrixAggregator.java @@ -28,7 +28,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.xcontent.ObjectParser.NamedObjectParser; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.query.QueryBuilder; @@ -63,7 +63,7 @@ public class AdjacencyMatrixAggregator extends BucketsAggregator { public static final ParseField FILTERS_FIELD = new ParseField("filters"); - protected static class KeyedFilter implements Writeable, ToXContent { + protected static class KeyedFilter implements Writeable, ToXContentFragment { private final String key; private final QueryBuilder filter; diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FiltersAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FiltersAggregator.java index 75ba8ba4c12..d488d092360 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FiltersAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FiltersAggregator.java @@ -27,7 +27,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.lucene.Lucene; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.search.aggregations.Aggregator; @@ -52,7 +52,7 @@ public class FiltersAggregator extends BucketsAggregator { public static final ParseField OTHER_BUCKET_FIELD = new ParseField("other_bucket"); public static final ParseField OTHER_BUCKET_KEY_FIELD = new ParseField("other_bucket_key"); - public static class KeyedFilter implements Writeable, ToXContent { + public static class KeyedFilter implements Writeable, ToXContentFragment { private final String key; private final QueryBuilder filter; diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ExtendedBounds.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ExtendedBounds.java index eeba2994c82..4cecfeff833 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ExtendedBounds.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ExtendedBounds.java @@ -27,7 +27,7 @@ import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.rounding.Rounding; import org.elasticsearch.common.xcontent.ConstructingObjectParser; import org.elasticsearch.common.xcontent.ObjectParser.ValueType; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser.Token; @@ -40,7 +40,7 @@ import java.util.Objects; import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg; -public class ExtendedBounds implements ToXContent, Writeable { +public class ExtendedBounds implements ToXContentFragment, Writeable { static final ParseField EXTENDED_BOUNDS_FIELD = Histogram.EXTENDED_BOUNDS_FIELD; static final ParseField MIN_FIELD = new ParseField("min"); static final ParseField MAX_FIELD = new ParseField("max"); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/InternalSignificantTerms.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/InternalSignificantTerms.java index ac60829c4ca..fe072eb009a 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/InternalSignificantTerms.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/InternalSignificantTerms.java @@ -20,7 +20,6 @@ package org.elasticsearch.search.aggregations.bucket.significant; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.aggregations.Aggregations; @@ -42,7 +41,7 @@ import java.util.Objects; * Result of the significant terms aggregation. */ public abstract class InternalSignificantTerms, B extends InternalSignificantTerms.Bucket> - extends InternalMultiBucketAggregation implements SignificantTerms, ToXContent { + extends InternalMultiBucketAggregation implements SignificantTerms { public static final String SCORE = "score"; public static final String BG_COUNT = "bg_count"; diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/IncludeExclude.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/IncludeExclude.java index fb87048644d..d111c7ee801 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/IncludeExclude.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/IncludeExclude.java @@ -41,7 +41,7 @@ import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.search.DocValueFormat; @@ -57,7 +57,7 @@ import java.util.TreeSet; * Defines the include/exclude regular expression filtering for string terms aggregation. In this filtering logic, * exclusion has precedence, where the {@code include} is evaluated first and then the {@code exclude}. */ -public class IncludeExclude implements Writeable, ToXContent { +public class IncludeExclude implements Writeable, ToXContentFragment { public static final ParseField INCLUDE_FIELD = new ParseField("include"); public static final ParseField EXCLUDE_FIELD = new ParseField("exclude"); public static final ParseField PARTITION_FIELD = new ParseField("partition"); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalTerms.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalTerms.java index d6bfb9edcc8..529191ac311 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalTerms.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalTerms.java @@ -21,18 +21,17 @@ package org.elasticsearch.search.aggregations.bucket.terms; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.aggregations.AggregationExecutionException; import org.elasticsearch.search.aggregations.Aggregations; +import org.elasticsearch.search.aggregations.BucketOrder; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation; -import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; -import org.elasticsearch.search.aggregations.BucketOrder; import org.elasticsearch.search.aggregations.InternalOrder; import org.elasticsearch.search.aggregations.KeyComparable; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.ArrayList; @@ -43,7 +42,7 @@ import java.util.Map; import java.util.Objects; public abstract class InternalTerms, B extends InternalTerms.Bucket> - extends InternalMultiBucketAggregation implements Terms, ToXContent { + extends InternalMultiBucketAggregation implements Terms { protected static final ParseField DOC_COUNT_ERROR_UPPER_BOUND_FIELD_NAME = new ParseField("doc_count_error_upper_bound"); protected static final ParseField SUM_OF_OTHER_DOC_COUNTS = new ParseField("sum_other_doc_count"); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregator.java index 4cada8f70bf..ee8ed9ef6f4 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregator.java @@ -25,21 +25,21 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.util.Comparators; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; +import org.elasticsearch.search.aggregations.BucketOrder; +import org.elasticsearch.search.aggregations.InternalOrder; +import org.elasticsearch.search.aggregations.InternalOrder.Aggregation; +import org.elasticsearch.search.aggregations.InternalOrder.CompoundOrder; import org.elasticsearch.search.aggregations.bucket.BucketsAggregator; import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket; import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregator; import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregator; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationPath; -import org.elasticsearch.search.aggregations.BucketOrder; -import org.elasticsearch.search.aggregations.InternalOrder; -import org.elasticsearch.search.aggregations.InternalOrder.Aggregation; -import org.elasticsearch.search.aggregations.InternalOrder.CompoundOrder; import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; @@ -52,7 +52,7 @@ import java.util.Set; public abstract class TermsAggregator extends BucketsAggregator { - public static class BucketCountThresholds implements Writeable, ToXContent { + public static class BucketCountThresholds implements Writeable, ToXContentFragment { private long minDocCount; private long shardMinDocCount; private int requiredSize; diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModel.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModel.java index f64117236d6..354434b6520 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModel.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModel.java @@ -22,7 +22,7 @@ package org.elasticsearch.search.aggregations.pipeline.movavg.models; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.NamedWriteable; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import java.io.IOException; import java.text.ParseException; @@ -30,7 +30,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Map; -public abstract class MovAvgModel implements NamedWriteable, ToXContent { +public abstract class MovAvgModel implements NamedWriteable, ToXContentFragment { /** * Should this model be fit to the data via a cost minimizing algorithm by default? diff --git a/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index e91957642ed..d1f5dcf5487 100644 --- a/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -1245,7 +1245,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ return builder; } - public static class IndexBoost implements Writeable, ToXContent { + public static class IndexBoost implements Writeable, ToXContentObject { private final String index; private final float boost; diff --git a/core/src/main/java/org/elasticsearch/search/fetch/subphase/FetchSourceContext.java b/core/src/main/java/org/elasticsearch/search/fetch/subphase/FetchSourceContext.java index c86342f690f..4ffc290f1ee 100644 --- a/core/src/main/java/org/elasticsearch/search/fetch/subphase/FetchSourceContext.java +++ b/core/src/main/java/org/elasticsearch/search/fetch/subphase/FetchSourceContext.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.support.XContentMapValues; @@ -42,7 +42,7 @@ import java.util.function.Function; /** * Context used to fetch the {@code _source}. */ -public class FetchSourceContext implements Writeable, ToXContent { +public class FetchSourceContext implements Writeable, ToXContentObject { public static final ParseField INCLUDES_FIELD = new ParseField("includes", "include"); public static final ParseField EXCLUDES_FIELD = new ParseField("excludes", "exclude"); diff --git a/core/src/main/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightField.java b/core/src/main/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightField.java index 7ff2147868a..6030d3863d8 100644 --- a/core/src/main/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightField.java +++ b/core/src/main/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightField.java @@ -24,7 +24,7 @@ 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.text.Text; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -39,7 +39,7 @@ import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpect /** * A field highlighted with its highlighted fragments. */ -public class HighlightField implements ToXContent, Streamable { +public class HighlightField implements ToXContentFragment, Streamable { private String name; diff --git a/core/src/main/java/org/elasticsearch/search/internal/InternalSearchResponse.java b/core/src/main/java/org/elasticsearch/search/internal/InternalSearchResponse.java index baa153e3470..65962e7d2c0 100644 --- a/core/src/main/java/org/elasticsearch/search/internal/InternalSearchResponse.java +++ b/core/src/main/java/org/elasticsearch/search/internal/InternalSearchResponse.java @@ -23,7 +23,7 @@ import org.elasticsearch.action.search.SearchResponseSections; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.profile.SearchProfileShardResults; @@ -34,7 +34,7 @@ import java.io.IOException; /** * {@link SearchResponseSections} subclass that can be serialized over the wire. */ -public class InternalSearchResponse extends SearchResponseSections implements Writeable, ToXContent { +public class InternalSearchResponse extends SearchResponseSections implements Writeable, ToXContentFragment { public static InternalSearchResponse empty() { return new InternalSearchResponse(SearchHits.empty(), null, null, null, false, null, 1); diff --git a/core/src/main/java/org/elasticsearch/search/profile/aggregation/AggregationProfileShardResult.java b/core/src/main/java/org/elasticsearch/search/profile/aggregation/AggregationProfileShardResult.java index 95a41401d11..dd8d8226720 100644 --- a/core/src/main/java/org/elasticsearch/search/profile/aggregation/AggregationProfileShardResult.java +++ b/core/src/main/java/org/elasticsearch/search/profile/aggregation/AggregationProfileShardResult.java @@ -22,7 +22,7 @@ package org.elasticsearch.search.profile.aggregation; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.search.profile.ProfileResult; @@ -38,7 +38,7 @@ import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpect * A container class to hold the profile results for a single shard in the request. * Contains a list of query profiles, a collector tree and a total rewrite tree. */ -public final class AggregationProfileShardResult implements Writeable, ToXContent { +public final class AggregationProfileShardResult implements Writeable, ToXContentFragment { public static final String AGGREGATIONS = "aggregations"; private final List aggProfileResults; diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionStats.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionStats.java index c123d46fe45..ae71c0826ec 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionStats.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionStats.java @@ -24,12 +24,12 @@ 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.unit.ByteSizeValue; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import java.io.IOException; -public class CompletionStats implements Streamable, ToXContent { +public class CompletionStats implements Streamable, ToXContentFragment { private static final String COMPLETION = "completion"; private static final String SIZE_IN_BYTES = "size_in_bytes"; diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/FuzzyOptions.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/FuzzyOptions.java index 8d121b24f12..5d7f4159d18 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/FuzzyOptions.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/FuzzyOptions.java @@ -27,7 +27,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.unit.Fuzziness; import org.elasticsearch.common.xcontent.ObjectParser; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -37,7 +37,7 @@ import java.util.Objects; /** * Fuzzy options for completion suggester */ -public class FuzzyOptions implements ToXContent, Writeable { +public class FuzzyOptions implements ToXContentFragment, Writeable { static final ParseField FUZZY_OPTIONS = new ParseField("fuzzy"); private static final ParseField TRANSPOSITION_FIELD = new ParseField("transpositions"); private static final ParseField MIN_LENGTH_FIELD = new ParseField("min_length"); diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryQueryContext.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryQueryContext.java index 10cf2009a42..e639fb07844 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryQueryContext.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryQueryContext.java @@ -23,7 +23,7 @@ import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.xcontent.ObjectParser; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -37,7 +37,7 @@ import static org.elasticsearch.search.suggest.completion.context.CategoryContex /** * Defines the query context for {@link CategoryContextMapping} */ -public final class CategoryQueryContext implements ToXContent { +public final class CategoryQueryContext implements ToXContentObject { public static final String NAME = "category"; private final String category; diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java index 697394f3ef2..adc269c49b5 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java @@ -21,6 +21,7 @@ package org.elasticsearch.search.suggest.completion.context; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser.Token; @@ -40,7 +41,7 @@ import java.util.Set; * * Implementations have to define how contexts are parsed at query/index time */ -public abstract class ContextMapping implements ToXContent { +public abstract class ContextMapping implements ToXContentFragment { public static final String FIELD_TYPE = "type"; public static final String FIELD_NAME = "name"; diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMappings.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMappings.java index bbefbf41b89..a0a6ce59f0d 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMappings.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMappings.java @@ -30,6 +30,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.mapper.CompletionFieldMapper; import org.elasticsearch.index.mapper.DocumentMapperParser; import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.search.suggest.completion.context.ContextMapping.Type; import java.io.IOException; import java.util.ArrayList; @@ -43,7 +44,6 @@ import java.util.Set; import static org.elasticsearch.search.suggest.completion.context.ContextMapping.FIELD_NAME; import static org.elasticsearch.search.suggest.completion.context.ContextMapping.FIELD_TYPE; -import static org.elasticsearch.search.suggest.completion.context.ContextMapping.Type; /** * ContextMappings indexes context-enabled suggestion fields diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoQueryContext.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoQueryContext.java index 304bc854d2c..151dcc9173f 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoQueryContext.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoQueryContext.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.ParseField; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.geo.GeoUtils; import org.elasticsearch.common.xcontent.ObjectParser; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -41,7 +41,7 @@ import static org.elasticsearch.search.suggest.completion.context.GeoContextMapp /** * Defines the query context for {@link GeoContextMapping} */ -public final class GeoQueryContext implements ToXContent { +public final class GeoQueryContext implements ToXContentObject { public static final String NAME = "geo"; private final GeoPoint geoPoint; diff --git a/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java b/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java index e7efe3ba3be..a05ffd117ab 100644 --- a/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java +++ b/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java @@ -40,7 +40,7 @@ import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.util.concurrent.XRejectedExecutionHandler; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.node.Node; @@ -582,7 +582,7 @@ public class ThreadPool extends AbstractComponent implements Closeable { } } - public static class Info implements Writeable, ToXContent { + public static class Info implements Writeable, ToXContentFragment { private final String name; private final ThreadPoolType type; diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java index 3f3e8496b2a..bc0bd430a88 100644 --- a/core/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java +++ b/core/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java @@ -315,7 +315,7 @@ public class ConstructingObjectParserTests extends ESTestCase { assertEquals(-8, parsed.mineral); } - private static class HasCtorArguments implements ToXContent { + private static class HasCtorArguments implements ToXContentObject { @Nullable final String animal; @Nullable diff --git a/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java b/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java index 1b443a33da5..e82c5fafbf3 100644 --- a/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java +++ b/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java @@ -37,6 +37,7 @@ import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -368,7 +369,7 @@ public class MetaDataStateFormatTests extends ESTestCase { } } - private static class DummyState implements ToXContent { + private static class DummyState implements ToXContentFragment { String string; int aInt; long aLong; diff --git a/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java b/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java index 9d0e353cd44..5c1fe5d2c2c 100644 --- a/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java +++ b/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java @@ -32,6 +32,7 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; @@ -56,7 +57,7 @@ public class BlobStoreFormatIT extends AbstractSnapshotIntegTestCase { public static final String BLOB_CODEC = "blob"; - private static class BlobObj implements ToXContent { + private static class BlobObj implements ToXContentFragment { private final String text; diff --git a/test/framework/src/main/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java b/test/framework/src/main/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java index 63880f265a6..b951d63917d 100644 --- a/test/framework/src/main/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java @@ -19,6 +19,7 @@ package org.elasticsearch.search.aggregations; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; @@ -124,6 +125,20 @@ public abstract class BaseAggregationTestCase> } } + /** + * Generic test that checks that the Strings.toString() method + * renders the XContent correctly. + */ + public void testValidOutput() throws IOException { + for (int runs = 0; runs < NUMBER_OF_TESTQUERIES; runs++) { + QB testQuery = createTestQueryBuilder(); + XContentType xContentType = XContentType.JSON; + String toString = Strings.toString(testQuery); + assertParsedQuery(createParser(xContentType.xContent(), toString), testQuery); + BytesReference bytes = XContentHelper.toXContent(testQuery, xContentType, false); + assertParsedQuery(createParser(xContentType.xContent(), bytes), testQuery); + } + } + private QB changeNameOrBoost(QB original) throws IOException { QB secondQuery = copyQuery(original); if (randomBoolean()) {