Remove XContentBuilderString

This is the xplugins side of elastic/elasticsearchelastic/elasticsearch#17833

Original commit: elastic/x-pack-elasticsearch@2400192775
This commit is contained in:
Ryan Ernst 2016-04-18 14:37:17 -07:00
parent 74c9358bdf
commit 7275d48bbd
23 changed files with 168 additions and 202 deletions

View File

@ -13,7 +13,6 @@ 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.common.xcontent.XContentBuilderString;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
@ -315,23 +314,23 @@ public class License implements ToXContent {
version = this.version;
}
if (restViewMode) {
builder.field(XFields.STATUS, status().label());
builder.field(Fields.STATUS, status().label());
}
builder.field(XFields.UID, uid);
builder.field(XFields.TYPE, type);
builder.field(Fields.UID, uid);
builder.field(Fields.TYPE, type);
if (version == VERSION_START) {
builder.field(XFields.SUBSCRIPTION_TYPE, subscriptionType);
builder.field(Fields.SUBSCRIPTION_TYPE, subscriptionType);
}
builder.dateValueField(XFields.ISSUE_DATE_IN_MILLIS, XFields.ISSUE_DATE, issueDate);
builder.dateValueField(Fields.ISSUE_DATE_IN_MILLIS, Fields.ISSUE_DATE, issueDate);
if (version == VERSION_START) {
builder.field(XFields.FEATURE, feature);
builder.field(Fields.FEATURE, feature);
}
builder.dateValueField(XFields.EXPIRY_DATE_IN_MILLIS, XFields.EXPIRY_DATE, expiryDate);
builder.field(XFields.MAX_NODES, maxNodes);
builder.field(XFields.ISSUED_TO, issuedTo);
builder.field(XFields.ISSUER, issuer);
builder.dateValueField(Fields.EXPIRY_DATE_IN_MILLIS, Fields.EXPIRY_DATE, expiryDate);
builder.field(Fields.MAX_NODES, maxNodes);
builder.field(Fields.ISSUED_TO, issuedTo);
builder.field(Fields.ISSUER, issuer);
if (!licenseSpecMode && !restViewMode && signature != null) {
builder.field(XFields.SIGNATURE, signature);
builder.field(Fields.SIGNATURE, signature);
}
if (restViewMode) {
builder.humanReadable(previouslyHumanReadable);
@ -504,43 +503,27 @@ public class License implements ToXContent {
return result;
}
final static class Fields {
static final String STATUS = "status";
static final String UID = "uid";
static final String TYPE = "type";
static final String SUBSCRIPTION_TYPE = "subscription_type";
static final String ISSUE_DATE_IN_MILLIS = "issue_date_in_millis";
static final String ISSUE_DATE = "issue_date";
static final String FEATURE = "feature";
static final String EXPIRY_DATE_IN_MILLIS = "expiry_date_in_millis";
static final String EXPIRY_DATE = "expiry_date";
static final String MAX_NODES = "max_nodes";
static final String ISSUED_TO = "issued_to";
static final String ISSUER = "issuer";
static final String VERSION = "version";
static final String SIGNATURE = "signature";
public final static class Fields {
public static final String STATUS = "status";
public static final String UID = "uid";
public static final String TYPE = "type";
public static final String SUBSCRIPTION_TYPE = "subscription_type";
public static final String ISSUE_DATE_IN_MILLIS = "issue_date_in_millis";
public static final String ISSUE_DATE = "issue_date";
public static final String FEATURE = "feature";
public static final String EXPIRY_DATE_IN_MILLIS = "expiry_date_in_millis";
public static final String EXPIRY_DATE = "expiry_date";
public static final String MAX_NODES = "max_nodes";
public static final String ISSUED_TO = "issued_to";
public static final String ISSUER = "issuer";
public static final String VERSION = "version";
public static final String SIGNATURE = "signature";
static final String LICENSES = "licenses";
static final String LICENSE = "license";
public static final String LICENSES = "licenses";
public static final String LICENSE = "license";
}
public interface XFields {
XContentBuilderString STATUS = new XContentBuilderString(Fields.STATUS);
XContentBuilderString UID = new XContentBuilderString(Fields.UID);
XContentBuilderString TYPE = new XContentBuilderString(Fields.TYPE);
XContentBuilderString SUBSCRIPTION_TYPE = new XContentBuilderString(Fields.SUBSCRIPTION_TYPE);
XContentBuilderString ISSUE_DATE_IN_MILLIS = new XContentBuilderString(Fields.ISSUE_DATE_IN_MILLIS);
XContentBuilderString ISSUE_DATE = new XContentBuilderString(Fields.ISSUE_DATE);
XContentBuilderString FEATURE = new XContentBuilderString(Fields.FEATURE);
XContentBuilderString EXPIRY_DATE_IN_MILLIS = new XContentBuilderString(Fields.EXPIRY_DATE_IN_MILLIS);
XContentBuilderString EXPIRY_DATE = new XContentBuilderString(Fields.EXPIRY_DATE);
XContentBuilderString MAX_NODES = new XContentBuilderString(Fields.MAX_NODES);
XContentBuilderString ISSUED_TO = new XContentBuilderString(Fields.ISSUED_TO);
XContentBuilderString ISSUER = new XContentBuilderString(Fields.ISSUER);
XContentBuilderString SIGNATURE = new XContentBuilderString(Fields.SIGNATURE);
}
private static long parseDate(XContentParser parser, String description, boolean endOfTheDay) throws IOException {
if (parser.currentToken() == XContentParser.Token.VALUE_NUMBER) {
return parser.longValue();

View File

@ -15,7 +15,6 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.graph.action.Connection.ConnectionId;
import org.elasticsearch.graph.action.Vertex.VertexId;
@ -149,12 +148,12 @@ public class GraphExploreResponse extends ActionResponse implements ToXContent {
}
static final class Fields {
static final XContentBuilderString TOOK = new XContentBuilderString("took");
static final XContentBuilderString TIMED_OUT = new XContentBuilderString("timed_out");
static final XContentBuilderString INDICES = new XContentBuilderString("_indices");
static final XContentBuilderString FAILURES = new XContentBuilderString("failures");
static final XContentBuilderString VERTICES = new XContentBuilderString("vertices");
static final XContentBuilderString CONNECTIONS = new XContentBuilderString("connections");
static final String TOOK = "took";
static final String TIMED_OUT = "timed_out";
static final String INDICES = "_indices";
static final String FAILURES = "failures";
static final String VERTICES = "vertices";
static final String CONNECTIONS = "connections";
}

View File

@ -11,7 +11,6 @@ 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.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import java.io.IOException;
import java.util.Collections;
@ -229,12 +228,12 @@ public class MonitoringDoc implements Writeable<MonitoringDoc> {
}
static final class Fields {
static final XContentBuilderString UUID = new XContentBuilderString("uuid");
static final XContentBuilderString HOST = new XContentBuilderString("host");
static final XContentBuilderString TRANSPORT_ADDRESS = new XContentBuilderString("transport_address");
static final XContentBuilderString IP = new XContentBuilderString("ip");
static final XContentBuilderString NAME = new XContentBuilderString("name");
static final XContentBuilderString ATTRIBUTES = new XContentBuilderString("attributes");
static final String UUID = "uuid";
static final String HOST = "host";
static final String TRANSPORT_ADDRESS = "transport_address";
static final String IP = "ip";
static final String NAME = "name";
static final String ATTRIBUTES = "attributes";
}
}
}

View File

@ -13,7 +13,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsException;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.marvel.MonitoredSystem;
import org.elasticsearch.marvel.agent.exporter.MarvelTemplateUtils;
@ -128,9 +127,9 @@ public abstract class MonitoringIndexNameResolver<T extends MonitoringDoc> {
protected abstract void buildXContent(T document, XContentBuilder builder, ToXContent.Params params) throws IOException;
public static final class Fields {
public static final XContentBuilderString CLUSTER_UUID = new XContentBuilderString("cluster_uuid");
public static final XContentBuilderString TIMESTAMP = new XContentBuilderString("timestamp");
public static final XContentBuilderString SOURCE_NODE = new XContentBuilderString("source_node");
public static final String CLUSTER_UUID = "cluster_uuid";
public static final String TIMESTAMP = "timestamp";
public static final String SOURCE_NODE = "source_node";
}
/**

View File

@ -10,7 +10,6 @@ import org.elasticsearch.common.collect.MapBuilder;
import org.elasticsearch.common.hash.MessageDigests;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.license.core.License;
import org.elasticsearch.marvel.agent.collector.cluster.ClusterInfoMonitoringDoc;
import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolver;
@ -72,14 +71,14 @@ public class ClusterInfoResolver extends MonitoringIndexNameResolver.Data<Cluste
}
static final class Fields {
static final XContentBuilderString CLUSTER_NAME = new XContentBuilderString("cluster_name");
static final XContentBuilderString LICENSE = new XContentBuilderString("license");
static final XContentBuilderString VERSION = new XContentBuilderString("version");
static final XContentBuilderString CLUSTER_STATS = new XContentBuilderString("cluster_stats");
static final String CLUSTER_NAME = "cluster_name";
static final String LICENSE = "license";
static final String VERSION = "version";
static final String CLUSTER_STATS = "cluster_stats";
static final XContentBuilderString HKEY = new XContentBuilderString("hkey");
static final String HKEY = "hkey";
static final XContentBuilderString UID = new XContentBuilderString("uid");
static final XContentBuilderString TYPE = new XContentBuilderString("type");
static final String UID = "uid";
static final String TYPE = "type";
}
}

View File

@ -8,7 +8,6 @@ package org.elasticsearch.marvel.agent.resolver.cluster;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.marvel.MonitoredSystem;
import org.elasticsearch.marvel.agent.collector.cluster.ClusterStateNodeMonitoringDoc;
import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolver;
@ -38,8 +37,8 @@ public class ClusterStateNodeResolver extends MonitoringIndexNameResolver.Timest
}
static final class Fields {
static final XContentBuilderString STATE_UUID = new XContentBuilderString("state_uuid");
static final XContentBuilderString NODE = new XContentBuilderString("node");
static final XContentBuilderString ID = new XContentBuilderString("id");
static final String STATE_UUID = "state_uuid";
static final String NODE = "node";
static final String ID = "id";
}
}

View File

@ -9,7 +9,6 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.marvel.MonitoredSystem;
import org.elasticsearch.marvel.agent.collector.cluster.ClusterStateMonitoringDoc;
import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolver;
@ -58,7 +57,7 @@ public class ClusterStateResolver extends MonitoringIndexNameResolver.Timestampe
}
static final class Fields {
static final XContentBuilderString CLUSTER_STATE = new XContentBuilderString(TYPE);
static final XContentBuilderString STATUS = new XContentBuilderString("status");
static final String CLUSTER_STATE = new String(TYPE);
static final String STATUS = "status";
}
}

View File

@ -9,7 +9,6 @@ import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.marvel.MonitoredSystem;
import org.elasticsearch.marvel.agent.collector.cluster.ClusterStatsMonitoringDoc;
import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolver;
@ -64,6 +63,6 @@ public class ClusterStatsResolver extends MonitoringIndexNameResolver.Timestampe
}
static final class Fields {
static final XContentBuilderString CLUSTER_STATS = new XContentBuilderString(TYPE);
static final String CLUSTER_STATS = new String(TYPE);
}
}

View File

@ -8,7 +8,6 @@ package org.elasticsearch.marvel.agent.resolver.cluster;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.marvel.agent.collector.cluster.DiscoveryNodeMonitoringDoc;
import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolver;
@ -55,10 +54,10 @@ public class DiscoveryNodeResolver extends MonitoringIndexNameResolver.Data<Disc
}
static final class Fields {
static final XContentBuilderString NODE = new XContentBuilderString(TYPE);
static final XContentBuilderString NAME = new XContentBuilderString("name");
static final XContentBuilderString TRANSPORT_ADDRESS = new XContentBuilderString("transport_address");
static final XContentBuilderString ATTRIBUTES = new XContentBuilderString("attributes");
static final XContentBuilderString ID = new XContentBuilderString("id");
static final String NODE = new String(TYPE);
static final String NAME = "name";
static final String TRANSPORT_ADDRESS = "transport_address";
static final String ATTRIBUTES = "attributes";
static final String ID = "id";
}
}

View File

@ -9,7 +9,6 @@ import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.indices.recovery.RecoveryState;
import org.elasticsearch.marvel.MonitoredSystem;
import org.elasticsearch.marvel.agent.collector.indices.IndexRecoveryMonitoringDoc;
@ -62,8 +61,8 @@ public class IndexRecoveryResolver extends MonitoringIndexNameResolver.Timestamp
}
static final class Fields {
static final XContentBuilderString INDEX_RECOVERY = new XContentBuilderString(TYPE);
static final XContentBuilderString SHARDS = new XContentBuilderString("shards");
static final XContentBuilderString INDEX_NAME = new XContentBuilderString("index_name");
static final String INDEX_RECOVERY = new String(TYPE);
static final String SHARDS = "shards";
static final String INDEX_NAME = "index_name";
}
}

View File

@ -9,7 +9,6 @@ import org.elasticsearch.action.admin.indices.stats.IndexStats;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.marvel.MonitoredSystem;
import org.elasticsearch.marvel.agent.collector.indices.IndexStatsMonitoringDoc;
import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolver;
@ -106,9 +105,9 @@ public class IndexStatsResolver extends MonitoringIndexNameResolver.Timestamped<
}
static final class Fields {
static final XContentBuilderString INDEX_STATS = new XContentBuilderString(TYPE);
static final XContentBuilderString INDEX = new XContentBuilderString("index");
static final XContentBuilderString TOTAL = new XContentBuilderString("total");
static final XContentBuilderString PRIMARIES = new XContentBuilderString("primaries");
static final String INDEX_STATS = new String(TYPE);
static final String INDEX = "index";
static final String TOTAL = "total";
static final String PRIMARIES = "primaries";
}
}

View File

@ -9,7 +9,6 @@ import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.marvel.MonitoredSystem;
import org.elasticsearch.marvel.agent.collector.indices.IndicesStatsMonitoringDoc;
import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolver;
@ -67,6 +66,6 @@ public class IndicesStatsResolver extends MonitoringIndexNameResolver.Timestampe
}
static final class Fields {
static final XContentBuilderString INDICES_STATS = new XContentBuilderString(TYPE);
static final String INDICES_STATS = new String(TYPE);
}
}

View File

@ -9,7 +9,6 @@ import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.marvel.MonitoredSystem;
import org.elasticsearch.marvel.agent.collector.node.NodeStatsMonitoringDoc;
import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolver;
@ -121,11 +120,11 @@ public class NodeStatsResolver extends MonitoringIndexNameResolver.Timestamped<N
}
static final class Fields {
static final XContentBuilderString NODE_STATS = new XContentBuilderString(TYPE);
static final XContentBuilderString NODE_ID = new XContentBuilderString("node_id");
static final XContentBuilderString NODE_MASTER = new XContentBuilderString("node_master");
static final XContentBuilderString MLOCKALL = new XContentBuilderString("mlockall");
static final XContentBuilderString DISK_THRESHOLD_ENABLED = new XContentBuilderString("disk_threshold_enabled");
static final XContentBuilderString DISK_THRESHOLD_WATERMARK_HIGH = new XContentBuilderString("disk_threshold_watermark_high");
static final String NODE_STATS = new String(TYPE);
static final String NODE_ID = "node_id";
static final String NODE_MASTER = "node_master";
static final String MLOCKALL = "mlockall";
static final String DISK_THRESHOLD_ENABLED = "disk_threshold_enabled";
static final String DISK_THRESHOLD_WATERMARK_HIGH = "disk_threshold_watermark_high";
}
}

View File

@ -9,7 +9,6 @@ import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.marvel.MonitoredSystem;
import org.elasticsearch.marvel.agent.collector.shards.ShardMonitoringDoc;
import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolver;
@ -60,13 +59,13 @@ public class ShardsResolver extends MonitoringIndexNameResolver.Timestamped<Shar
if (shardRouting != null) {
// ShardRouting is rendered inside a startObject() / endObject() but without a name,
// so we must use XContentBuilder.field(String, ToXContent, ToXContent.Params) here
builder.field(Fields.SHARD.value(), shardRouting, params);
builder.field(Fields.SHARD, shardRouting, params);
}
}
static final class Fields {
static final XContentBuilderString SHARD = new XContentBuilderString("shard");
static final XContentBuilderString STATE_UUID = new XContentBuilderString("state_uuid");
static final String SHARD = "shard";
static final String STATE_UUID = "state_uuid";
}
/**

View File

@ -11,7 +11,6 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.marvel.action.MonitoringBulkRequestBuilder;
import org.elasticsearch.marvel.action.MonitoringBulkResponse;
import org.elasticsearch.marvel.client.MonitoringClient;
@ -79,8 +78,8 @@ public class RestMonitoringBulkAction extends MonitoringRestHandler {
}
static final class Fields {
static final XContentBuilderString TOOK = new XContentBuilderString("took");
static final XContentBuilderString ERRORS = new XContentBuilderString("errors");
static final XContentBuilderString ERROR = new XContentBuilderString("error");
static final String TOOK = "took";
static final String ERRORS = "errors";
static final String ERROR = "error";
}
}

View File

@ -58,9 +58,9 @@ public class MonitoringBulkTests extends MarvelIntegTestCase {
for (SearchHit searchHit : searchResponse.getHits()) {
Map<String, Object> source = searchHit.sourceAsMap();
assertNotNull(source.get(MonitoringBulkResolver.Fields.CLUSTER_UUID.value()));
assertNotNull(source.get(MonitoringBulkResolver.Fields.TIMESTAMP.value()));
assertNotNull(source.get(MonitoringBulkResolver.Fields.SOURCE_NODE.value()));
assertNotNull(source.get(MonitoringBulkResolver.Fields.CLUSTER_UUID));
assertNotNull(source.get(MonitoringBulkResolver.Fields.TIMESTAMP));
assertNotNull(source.get(MonitoringBulkResolver.Fields.SOURCE_NODE));
}
}

View File

@ -148,9 +148,9 @@ public abstract class MonitoringIndexNameResolverTestCase<M extends MonitoringDo
assertNotNull(sourceFields);
String[] commons = new String[]{
CLUSTER_UUID.value(),
TIMESTAMP.value(),
SOURCE_NODE.value(),
CLUSTER_UUID,
TIMESTAMP,
SOURCE_NODE,
};
assertThat("source must contains default fields", sourceFields.keySet(), hasItems(commons));

View File

@ -77,42 +77,42 @@ public class ClusterInfoTests extends MarvelIntegTestCase {
assertThat(response.getId(), equalTo(clusterUUID));
Map<String, Object> source = response.getSource();
assertThat(source.get(MonitoringIndexNameResolver.Fields.CLUSTER_UUID.value()), notNullValue());
assertThat(source.get(MonitoringIndexNameResolver.Fields.TIMESTAMP.value()), notNullValue());
assertThat(source.get(MonitoringIndexNameResolver.Fields.SOURCE_NODE.value()), notNullValue());
assertThat(source.get(ClusterInfoResolver.Fields.CLUSTER_NAME.value()), equalTo(cluster().getClusterName()));
assertThat(source.get(ClusterInfoResolver.Fields.VERSION.value()), equalTo(Version.CURRENT.toString()));
assertThat(source.get(MonitoringIndexNameResolver.Fields.CLUSTER_UUID), notNullValue());
assertThat(source.get(MonitoringIndexNameResolver.Fields.TIMESTAMP), notNullValue());
assertThat(source.get(MonitoringIndexNameResolver.Fields.SOURCE_NODE), notNullValue());
assertThat(source.get(ClusterInfoResolver.Fields.CLUSTER_NAME), equalTo(cluster().getClusterName()));
assertThat(source.get(ClusterInfoResolver.Fields.VERSION), equalTo(Version.CURRENT.toString()));
logger.debug("--> checking that the document contains license information");
Object licenseObj = source.get(ClusterInfoResolver.Fields.LICENSE.value());
Object licenseObj = source.get(ClusterInfoResolver.Fields.LICENSE);
assertThat(licenseObj, instanceOf(Map.class));
Map license = (Map) licenseObj;
assertThat(license, instanceOf(Map.class));
String uid = (String) license.get(ClusterInfoResolver.Fields.UID.value());
String uid = (String) license.get(ClusterInfoResolver.Fields.UID);
assertThat(uid, not(isEmptyOrNullString()));
String type = (String) license.get(ClusterInfoResolver.Fields.TYPE.value());
String type = (String) license.get(ClusterInfoResolver.Fields.TYPE);
assertThat(type, not(isEmptyOrNullString()));
String status = (String) license.get(License.XFields.STATUS.value());
String status = (String) license.get(License.Fields.STATUS);
assertThat(status, not(isEmptyOrNullString()));
Long expiryDate = (Long) license.get(License.XFields.EXPIRY_DATE_IN_MILLIS.value());
Long expiryDate = (Long) license.get(License.Fields.EXPIRY_DATE_IN_MILLIS);
assertThat(expiryDate, greaterThan(0L));
// We basically recompute the hash here
String hkey = (String) license.get(ClusterInfoResolver.Fields.HKEY.value());
String hkey = (String) license.get(ClusterInfoResolver.Fields.HKEY);
String recalculated = ClusterInfoResolver.hash(status, uid, type, String.valueOf(expiryDate), clusterUUID);
assertThat(hkey, equalTo(recalculated));
assertThat((String) license.get(License.XFields.ISSUER.value()), not(isEmptyOrNullString()));
assertThat((String) license.get(License.XFields.ISSUED_TO.value()), not(isEmptyOrNullString()));
assertThat((Long) license.get(License.XFields.ISSUE_DATE_IN_MILLIS.value()), greaterThan(0L));
assertThat((Integer) license.get(License.XFields.MAX_NODES.value()), greaterThan(0));
assertThat((String) license.get(License.Fields.ISSUER), not(isEmptyOrNullString()));
assertThat((String) license.get(License.Fields.ISSUED_TO), not(isEmptyOrNullString()));
assertThat((Long) license.get(License.Fields.ISSUE_DATE_IN_MILLIS), greaterThan(0L));
assertThat((Integer) license.get(License.Fields.MAX_NODES), greaterThan(0));
Object clusterStats = source.get(ClusterInfoResolver.Fields.CLUSTER_STATS.value());
Object clusterStats = source.get(ClusterInfoResolver.Fields.CLUSTER_STATS);
assertNotNull(clusterStats);
assertThat(clusterStats, instanceOf(Map.class));
assertThat(((Map) clusterStats).size(), greaterThan(0));
@ -128,10 +128,10 @@ public class ClusterInfoTests extends MarvelIntegTestCase {
.setTypes(ClusterInfoResolver.TYPE)
.setQuery(
QueryBuilders.boolQuery()
.should(QueryBuilders.matchQuery(License.XFields.STATUS.value(), License.Status.ACTIVE.label()))
.should(QueryBuilders.matchQuery(License.XFields.STATUS.value(), License.Status.INVALID.label()))
.should(QueryBuilders.matchQuery(License.XFields.STATUS.value(), License.Status.EXPIRED.label()))
.should(QueryBuilders.matchQuery(ClusterInfoResolver.Fields.CLUSTER_NAME.value(),
.should(QueryBuilders.matchQuery(License.Fields.STATUS, License.Status.ACTIVE.label()))
.should(QueryBuilders.matchQuery(License.Fields.STATUS, License.Status.INVALID.label()))
.should(QueryBuilders.matchQuery(License.Fields.STATUS, License.Status.EXPIRED.label()))
.should(QueryBuilders.matchQuery(ClusterInfoResolver.Fields.CLUSTER_NAME,
cluster().getClusterName()))
.minimumNumberShouldMatch(1)
).get(), 0L);

View File

@ -122,13 +122,13 @@ public class ClusterStateTests extends MarvelIntegTestCase {
logger.debug("--> checking that every document contains the expected fields");
String[] filters = {
MonitoringIndexNameResolver.Fields.CLUSTER_UUID.value(),
MonitoringIndexNameResolver.Fields.TIMESTAMP.value(),
SOURCE_NODE.value(),
ClusterStateNodeResolver.Fields.STATE_UUID.value(),
ClusterStateNodeResolver.Fields.NODE.value(),
ClusterStateNodeResolver.Fields.NODE.value() + "."
+ ClusterStateNodeResolver.Fields.ID.value(),
MonitoringIndexNameResolver.Fields.CLUSTER_UUID,
MonitoringIndexNameResolver.Fields.TIMESTAMP,
SOURCE_NODE,
ClusterStateNodeResolver.Fields.STATE_UUID,
ClusterStateNodeResolver.Fields.NODE,
ClusterStateNodeResolver.Fields.NODE + "."
+ ClusterStateNodeResolver.Fields.ID,
};
for (SearchHit searchHit : response.getHits().getHits()) {
@ -143,7 +143,7 @@ public class ClusterStateTests extends MarvelIntegTestCase {
assertThat(client().prepareSearch().setSize(0)
.setIndices(timestampedIndex)
.setTypes(ClusterStateNodeResolver.TYPE)
.setQuery(QueryBuilders.matchQuery(SOURCE_NODE.value() + ".attributes.custom", randomInt))
.setQuery(QueryBuilders.matchQuery(SOURCE_NODE + ".attributes.custom", randomInt))
.get().getHits().getTotalHits(), greaterThan(0L));
logger.debug("--> cluster state nodes successfully collected");
@ -167,18 +167,18 @@ public class ClusterStateTests extends MarvelIntegTestCase {
logger.debug("--> checking that every document contains the expected fields");
String[] filters = {
MonitoringIndexNameResolver.Fields.CLUSTER_UUID.value(),
MonitoringIndexNameResolver.Fields.TIMESTAMP.value(),
MonitoringIndexNameResolver.Fields.SOURCE_NODE.value(),
DiscoveryNodeResolver.Fields.NODE.value(),
DiscoveryNodeResolver.Fields.NODE.value() + "."
+ DiscoveryNodeResolver.Fields.ID.value(),
DiscoveryNodeResolver.Fields.NODE.value() + "."
+ DiscoveryNodeResolver.Fields.NAME.value(),
DiscoveryNodeResolver.Fields.NODE.value() + "."
+ DiscoveryNodeResolver.Fields.ATTRIBUTES.value(),
DiscoveryNodeResolver.Fields.NODE.value() + "."
+ DiscoveryNodeResolver.Fields.TRANSPORT_ADDRESS.value(),
MonitoringIndexNameResolver.Fields.CLUSTER_UUID,
MonitoringIndexNameResolver.Fields.TIMESTAMP,
MonitoringIndexNameResolver.Fields.SOURCE_NODE,
DiscoveryNodeResolver.Fields.NODE,
DiscoveryNodeResolver.Fields.NODE + "."
+ DiscoveryNodeResolver.Fields.ID,
DiscoveryNodeResolver.Fields.NODE + "."
+ DiscoveryNodeResolver.Fields.NAME,
DiscoveryNodeResolver.Fields.NODE + "."
+ DiscoveryNodeResolver.Fields.ATTRIBUTES,
DiscoveryNodeResolver.Fields.NODE + "."
+ DiscoveryNodeResolver.Fields.TRANSPORT_ADDRESS,
};
for (SearchHit searchHit : response.getHits().getHits()) {

View File

@ -80,12 +80,12 @@ public class IndexRecoveryTests extends MarvelIntegTestCase {
logger.debug("--> checking that every document contains the expected fields");
String[] filters = {
MonitoringIndexNameResolver.Fields.CLUSTER_UUID.value(),
MonitoringIndexNameResolver.Fields.TIMESTAMP.value(),
MonitoringIndexNameResolver.Fields.SOURCE_NODE.value(),
IndexRecoveryResolver.Fields.INDEX_RECOVERY.value(),
IndexRecoveryResolver.Fields.INDEX_RECOVERY.value() + "."
+ IndexRecoveryResolver.Fields.SHARDS.value(),
MonitoringIndexNameResolver.Fields.CLUSTER_UUID,
MonitoringIndexNameResolver.Fields.TIMESTAMP,
MonitoringIndexNameResolver.Fields.SOURCE_NODE,
IndexRecoveryResolver.Fields.INDEX_RECOVERY,
IndexRecoveryResolver.Fields.INDEX_RECOVERY + "."
+ IndexRecoveryResolver.Fields.SHARDS,
};
for (SearchHit searchHit : response.getHits().getHits()) {

View File

@ -41,7 +41,6 @@ import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.node.Node;
@ -937,25 +936,25 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail, Cl
}
interface Field {
XContentBuilderString TIMESTAMP = new XContentBuilderString("@timestamp");
XContentBuilderString NODE_NAME = new XContentBuilderString("node_name");
XContentBuilderString NODE_HOST_NAME = new XContentBuilderString("node_host_name");
XContentBuilderString NODE_HOST_ADDRESS = new XContentBuilderString("node_host_address");
XContentBuilderString LAYER = new XContentBuilderString("layer");
XContentBuilderString TYPE = new XContentBuilderString("event_type");
XContentBuilderString ORIGIN_ADDRESS = new XContentBuilderString("origin_address");
XContentBuilderString ORIGIN_TYPE = new XContentBuilderString("origin_type");
XContentBuilderString PRINCIPAL = new XContentBuilderString("principal");
XContentBuilderString RUN_AS_PRINCIPAL = new XContentBuilderString("run_as_principal");
XContentBuilderString RUN_BY_PRINCIPAL = new XContentBuilderString("run_by_principal");
XContentBuilderString ACTION = new XContentBuilderString("action");
XContentBuilderString INDICES = new XContentBuilderString("indices");
XContentBuilderString REQUEST = new XContentBuilderString("request");
XContentBuilderString REQUEST_BODY = new XContentBuilderString("request_body");
XContentBuilderString URI = new XContentBuilderString("uri");
XContentBuilderString REALM = new XContentBuilderString("realm");
XContentBuilderString TRANSPORT_PROFILE = new XContentBuilderString("transport_profile");
XContentBuilderString RULE = new XContentBuilderString("rule");
String TIMESTAMP = new String("@timestamp");
String NODE_NAME = new String("node_name");
String NODE_HOST_NAME = new String("node_host_name");
String NODE_HOST_ADDRESS = new String("node_host_address");
String LAYER = new String("layer");
String TYPE = new String("event_type");
String ORIGIN_ADDRESS = new String("origin_address");
String ORIGIN_TYPE = new String("origin_type");
String PRINCIPAL = new String("principal");
String RUN_AS_PRINCIPAL = new String("run_as_principal");
String RUN_BY_PRINCIPAL = new String("run_by_principal");
String ACTION = new String("action");
String INDICES = new String("indices");
String REQUEST = new String("request");
String REQUEST_BODY = new String("request_body");
String URI = new String("uri");
String REALM = new String("realm");
String TRANSPORT_PROFILE = new String("transport_profile");
String RULE = new String("rule");
}
public enum State {

View File

@ -8,7 +8,6 @@ package org.elasticsearch.watcher.actions.hipchat.service;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.watcher.support.http.HttpRequest;
import org.elasticsearch.watcher.support.http.HttpResponse;
@ -65,7 +64,7 @@ public class SentMessages implements ToXContent, Iterable<SentMessages.SentMessa
public enum TargetType {
ROOM, USER;
final XContentBuilderString fieldName = new XContentBuilderString(name().toLowerCase(Locale.ROOT));
final String fieldName = new String(name().toLowerCase(Locale.ROOT));
}
final String targetName;
@ -155,12 +154,12 @@ public class SentMessages implements ToXContent, Iterable<SentMessages.SentMessa
}
interface Field {
XContentBuilderString ACCOUNT = new XContentBuilderString("account");
XContentBuilderString SENT_MESSAGES = new XContentBuilderString("sent_messages");
XContentBuilderString STATUS = new XContentBuilderString("status");
XContentBuilderString REASON = new XContentBuilderString("reason");
XContentBuilderString REQUEST = new XContentBuilderString("request");
XContentBuilderString RESPONSE = new XContentBuilderString("response");
XContentBuilderString MESSAGE = new XContentBuilderString("message");
String ACCOUNT = new String("account");
String SENT_MESSAGES = new String("sent_messages");
String STATUS = new String("status");
String REASON = new String("reason");
String REQUEST = new String("request");
String RESPONSE = new String("response");
String MESSAGE = new String("message");
}
}

View File

@ -8,7 +8,6 @@ package org.elasticsearch.watcher.actions.slack.service;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.watcher.actions.slack.service.message.SlackMessage;
import org.elasticsearch.watcher.support.http.HttpRequest;
import org.elasticsearch.watcher.support.http.HttpResponse;
@ -138,13 +137,13 @@ public class SentMessages implements ToXContent, Iterable<SentMessages.SentMessa
}
interface Field {
XContentBuilderString ACCOUNT = new XContentBuilderString("account");
XContentBuilderString SENT_MESSAGES = new XContentBuilderString("sent_messages");
XContentBuilderString STATUS = new XContentBuilderString("status");
XContentBuilderString REASON = new XContentBuilderString("reason");
XContentBuilderString REQUEST = new XContentBuilderString("request");
XContentBuilderString RESPONSE = new XContentBuilderString("response");
XContentBuilderString MESSAGE = new XContentBuilderString("message");
XContentBuilderString TO = new XContentBuilderString("to");
String ACCOUNT = new String("account");
String SENT_MESSAGES = new String("sent_messages");
String STATUS = new String("status");
String REASON = new String("reason");
String REQUEST = new String("request");
String RESPONSE = new String("response");
String MESSAGE = new String("message");
String TO = new String("to");
}
}