Marvel: Use UUIDs in Marvel Docs

Related to elastic/elasticsearch#460

Original commit: elastic/x-pack-elasticsearch@ecf360eff5
This commit is contained in:
Tanguy Leroux 2015-08-19 13:51:22 +02:00
parent 804cf68031
commit 1f41d42f39
28 changed files with 105 additions and 110 deletions

View File

@ -7,7 +7,6 @@ package org.elasticsearch.marvel.agent.collector;
import org.elasticsearch.ElasticsearchTimeoutException;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.common.component.AbstractLifecycleComponent;
import org.elasticsearch.common.inject.Inject;
@ -22,16 +21,13 @@ public abstract class AbstractCollector<T> extends AbstractLifecycleComponent<T>
private final String name;
protected final ClusterService clusterService;
protected final ClusterName clusterName;
protected final MarvelSettings marvelSettings;
@Inject
public AbstractCollector(Settings settings, String name, ClusterService clusterService,
ClusterName clusterName, MarvelSettings marvelSettings) {
public AbstractCollector(Settings settings, String name, ClusterService clusterService, MarvelSettings marvelSettings) {
super(settings);
this.name = name;
this.clusterService = clusterService;
this.clusterName = clusterName;
this.marvelSettings = marvelSettings;
}
@ -96,4 +92,8 @@ public abstract class AbstractCollector<T> extends AbstractLifecycleComponent<T>
@Override
protected void doClose() {
}
protected String clusterUUID() {
return clusterService.state().metaData().clusterUUID();
}
}

View File

@ -9,7 +9,6 @@ import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.common.inject.Inject;
@ -34,9 +33,8 @@ public class ClusterStateCollector extends AbstractCollector<ClusterStateCollect
private final Client client;
@Inject
public ClusterStateCollector(Settings settings, ClusterService clusterService,
ClusterName clusterName, MarvelSettings marvelSettings, Client client) {
super(settings, NAME, clusterService, clusterName, marvelSettings);
public ClusterStateCollector(Settings settings, ClusterService clusterService, MarvelSettings marvelSettings, Client client) {
super(settings, NAME, clusterService, marvelSettings);
this.client = client;
}
@ -52,11 +50,11 @@ public class ClusterStateCollector extends AbstractCollector<ClusterStateCollect
ClusterState clusterState = clusterService.state();
ClusterHealthResponse clusterHealth = client.admin().cluster().prepareHealth().get(marvelSettings.clusterStateTimeout());
results.add(buildMarvelDoc(clusterName.value(), TYPE, System.currentTimeMillis(), clusterState, clusterHealth.getStatus()));
results.add(buildMarvelDoc(clusterUUID(), TYPE, System.currentTimeMillis(), clusterState, clusterHealth.getStatus()));
return results.build();
}
protected MarvelDoc buildMarvelDoc(String clusterName, String type, long timestamp, ClusterState clusterState, ClusterHealthStatus status) {
return ClusterStateMarvelDoc.createMarvelDoc(clusterName, type, timestamp, clusterState, status);
protected MarvelDoc buildMarvelDoc(String clusterUUID, String type, long timestamp, ClusterState clusterState, ClusterHealthStatus status) {
return ClusterStateMarvelDoc.createMarvelDoc(clusterUUID, type, timestamp, clusterState, status);
}
}

View File

@ -13,8 +13,8 @@ public class ClusterStateMarvelDoc extends MarvelDoc<ClusterStateMarvelDoc.Paylo
private final Payload payload;
public ClusterStateMarvelDoc(String clusterName, String type, long timestamp, Payload payload) {
super(clusterName, type, timestamp);
public ClusterStateMarvelDoc(String clusterUUID, String type, long timestamp, Payload payload) {
super(clusterUUID, type, timestamp);
this.payload = payload;
}
@ -23,8 +23,8 @@ public class ClusterStateMarvelDoc extends MarvelDoc<ClusterStateMarvelDoc.Paylo
return payload;
}
public static ClusterStateMarvelDoc createMarvelDoc(String clusterName, String type, long timestamp, ClusterState clusterState, ClusterHealthStatus status) {
return new ClusterStateMarvelDoc(clusterName, type, timestamp, new Payload(clusterState, status));
public static ClusterStateMarvelDoc createMarvelDoc(String clusterUUID, String type, long timestamp, ClusterState clusterState, ClusterHealthStatus status) {
return new ClusterStateMarvelDoc(clusterUUID, type, timestamp, new Payload(clusterState, status));
}
public static class Payload {

View File

@ -8,7 +8,6 @@ package org.elasticsearch.marvel.agent.collector.cluster;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
@ -32,9 +31,8 @@ public class ClusterStatsCollector extends AbstractCollector<ClusterStatsCollect
private final Client client;
@Inject
public ClusterStatsCollector(Settings settings, ClusterService clusterService,
ClusterName clusterName, MarvelSettings marvelSettings, Client client) {
super(settings, NAME, clusterService, clusterName, marvelSettings);
public ClusterStatsCollector(Settings settings, ClusterService clusterService, MarvelSettings marvelSettings, Client client) {
super(settings, NAME, clusterService, marvelSettings);
this.client = client;
}
@ -48,11 +46,11 @@ public class ClusterStatsCollector extends AbstractCollector<ClusterStatsCollect
ImmutableList.Builder<MarvelDoc> results = ImmutableList.builder();
ClusterStatsResponse clusterStatsResponse = client.admin().cluster().prepareClusterStats().get(marvelSettings.clusterStatsTimeout());
results.add(buildMarvelDoc(clusterName.value(), TYPE, System.currentTimeMillis(), clusterStatsResponse));
results.add(buildMarvelDoc(clusterUUID(), TYPE, System.currentTimeMillis(), clusterStatsResponse));
return results.build();
}
protected MarvelDoc buildMarvelDoc(String clusterName, String type, long timestamp, ClusterStatsResponse clusterStatsResponse) {
return ClusterStatsMarvelDoc.createMarvelDoc(clusterName, type, timestamp, clusterStatsResponse);
protected MarvelDoc buildMarvelDoc(String clusterUUID, String type, long timestamp, ClusterStatsResponse clusterStatsResponse) {
return ClusterStatsMarvelDoc.createMarvelDoc(clusterUUID, type, timestamp, clusterStatsResponse);
}
}

View File

@ -12,8 +12,8 @@ public class ClusterStatsMarvelDoc extends MarvelDoc<ClusterStatsMarvelDoc.Paylo
private final Payload payload;
public ClusterStatsMarvelDoc(String clusterName, String type, long timestamp, Payload payload) {
super(clusterName, type, timestamp);
public ClusterStatsMarvelDoc(String clusterUUID, String type, long timestamp, Payload payload) {
super(clusterUUID, type, timestamp);
this.payload = payload;
}
@ -22,8 +22,8 @@ public class ClusterStatsMarvelDoc extends MarvelDoc<ClusterStatsMarvelDoc.Paylo
return payload;
}
public static ClusterStatsMarvelDoc createMarvelDoc(String clusterName, String type, long timestamp, ClusterStatsResponse clusterStats) {
return new ClusterStatsMarvelDoc(clusterName, type, timestamp, new Payload(clusterStats));
public static ClusterStatsMarvelDoc createMarvelDoc(String clusterUUID, String type, long timestamp, ClusterStatsResponse clusterStats) {
return new ClusterStatsMarvelDoc(clusterUUID, type, timestamp, new Payload(clusterStats));
}
public static class Payload {

View File

@ -9,7 +9,6 @@ import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
@ -33,9 +32,8 @@ public class IndexRecoveryCollector extends AbstractCollector<IndexRecoveryColle
private final Client client;
@Inject
public IndexRecoveryCollector(Settings settings, ClusterService clusterService,
ClusterName clusterName, MarvelSettings marvelSettings, Client client) {
super(settings, NAME, clusterService, clusterName, marvelSettings);
public IndexRecoveryCollector(Settings settings, ClusterService clusterService, MarvelSettings marvelSettings, Client client) {
super(settings, NAME, clusterService, marvelSettings);
this.client = client;
}
@ -55,12 +53,12 @@ public class IndexRecoveryCollector extends AbstractCollector<IndexRecoveryColle
.get(marvelSettings.recoveryTimeout());
if (recoveryResponse.hasRecoveries()) {
results.add(buildMarvelDoc(clusterName.value(), TYPE, System.currentTimeMillis(), recoveryResponse));
results.add(buildMarvelDoc(clusterUUID(), TYPE, System.currentTimeMillis(), recoveryResponse));
}
return results.build();
}
protected MarvelDoc buildMarvelDoc(String clusterName, String type, long timestamp, RecoveryResponse recoveryResponse) {
return IndexRecoveryMarvelDoc.createMarvelDoc(clusterName, type, timestamp, recoveryResponse);
protected MarvelDoc buildMarvelDoc(String clusterUUID, String type, long timestamp, RecoveryResponse recoveryResponse) {
return IndexRecoveryMarvelDoc.createMarvelDoc(clusterUUID, type, timestamp, recoveryResponse);
}
}

View File

@ -12,8 +12,8 @@ public class IndexRecoveryMarvelDoc extends MarvelDoc<IndexRecoveryMarvelDoc.Pay
private final Payload payload;
public IndexRecoveryMarvelDoc(String clusterName, String type, long timestamp, Payload payload) {
super(clusterName, type, timestamp);
public IndexRecoveryMarvelDoc(String clusterUUID, String type, long timestamp, Payload payload) {
super(clusterUUID, type, timestamp);
this.payload = payload;
}
@ -22,9 +22,9 @@ public class IndexRecoveryMarvelDoc extends MarvelDoc<IndexRecoveryMarvelDoc.Pay
return payload;
}
public static IndexRecoveryMarvelDoc createMarvelDoc(String clusterName, String type, long timestamp,
public static IndexRecoveryMarvelDoc createMarvelDoc(String clusterUUID, String type, long timestamp,
RecoveryResponse recoveryResponse) {
return new IndexRecoveryMarvelDoc(clusterName, type, timestamp, new Payload(recoveryResponse));
return new IndexRecoveryMarvelDoc(clusterUUID, type, timestamp, new Payload(recoveryResponse));
}
public static class Payload {

View File

@ -10,7 +10,6 @@ import org.elasticsearch.action.admin.indices.stats.IndexStats;
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
@ -34,9 +33,8 @@ public class IndexStatsCollector extends AbstractCollector<IndexStatsCollector>
private final Client client;
@Inject
public IndexStatsCollector(Settings settings, ClusterService clusterService,
ClusterName clusterName, MarvelSettings marvelSettings, Client client) {
super(settings, NAME, clusterService, clusterName, marvelSettings);
public IndexStatsCollector(Settings settings, ClusterService clusterService, MarvelSettings marvelSettings, Client client) {
super(settings, NAME, clusterService, marvelSettings);
this.client = client;
}
@ -56,13 +54,14 @@ public class IndexStatsCollector extends AbstractCollector<IndexStatsCollector>
.get(marvelSettings.indexStatsTimeout());
long timestamp = System.currentTimeMillis();
String clusterUUID = clusterUUID();
for (IndexStats indexStats : indicesStats.getIndices().values()) {
results.add(buildMarvelDoc(clusterName.value(), TYPE, timestamp, indexStats));
results.add(buildMarvelDoc(clusterUUID, TYPE, timestamp, indexStats));
}
return results.build();
}
protected MarvelDoc buildMarvelDoc(String clusterName, String type, long timestamp, IndexStats indexStats) {
return IndexStatsMarvelDoc.createMarvelDoc(clusterName, type, timestamp, indexStats);
protected MarvelDoc buildMarvelDoc(String clusterUUID, String type, long timestamp, IndexStats indexStats) {
return IndexStatsMarvelDoc.createMarvelDoc(clusterUUID, type, timestamp, indexStats);
}
}

View File

@ -12,8 +12,8 @@ public class IndexStatsMarvelDoc extends MarvelDoc<IndexStatsMarvelDoc.Payload>
private final Payload payload;
public IndexStatsMarvelDoc(String clusterName, String type, long timestamp, Payload payload) {
super(clusterName, type, timestamp);
public IndexStatsMarvelDoc(String clusterUUID, String type, long timestamp, Payload payload) {
super(clusterUUID, type, timestamp);
this.payload = payload;
}
@ -22,8 +22,8 @@ public class IndexStatsMarvelDoc extends MarvelDoc<IndexStatsMarvelDoc.Payload>
return payload;
}
public static IndexStatsMarvelDoc createMarvelDoc(String clusterName, String type, long timestamp, IndexStats indexStats) {
return new IndexStatsMarvelDoc(clusterName, type, timestamp, new Payload(indexStats));
public static IndexStatsMarvelDoc createMarvelDoc(String clusterUUID, String type, long timestamp, IndexStats indexStats) {
return new IndexStatsMarvelDoc(clusterUUID, type, timestamp, new Payload(indexStats));
}
public static class Payload {

View File

@ -32,13 +32,14 @@ public class LicensesCollector extends AbstractCollector<LicensesMarvelDoc> {
public static final String NAME = "licenses-collector";
public static final String TYPE = "cluster_licenses";
private final ClusterName clusterName;
private final LicenseService licenseService;
@Inject
public LicensesCollector(Settings settings, ClusterService clusterService, ClusterName clusterName,
MarvelSettings marvelSettings,
LicenseService licenseService) {
super(settings, NAME, clusterService, clusterName, marvelSettings);
public LicensesCollector(Settings settings, ClusterService clusterService, MarvelSettings marvelSettings,
ClusterName clusterName, LicenseService licenseService) {
super(settings, NAME, clusterService, marvelSettings);
this.clusterName = clusterName;
this.licenseService = licenseService;
}
@ -48,8 +49,9 @@ public class LicensesCollector extends AbstractCollector<LicensesMarvelDoc> {
List<License> licenses = licenseService.licenses();
if (licenses != null) {
results.add(LicensesMarvelDoc.createMarvelDoc(MarvelSettings.MARVEL_DATA_INDEX_NAME, TYPE, clusterName.value(), clusterName.value(),
System.currentTimeMillis(), Version.CURRENT.toString(), licenses));
String clusterUUID = clusterUUID();
results.add(LicensesMarvelDoc.createMarvelDoc(MarvelSettings.MARVEL_DATA_INDEX_NAME, TYPE, clusterUUID, clusterUUID, System.currentTimeMillis(),
clusterName.value(), Version.CURRENT.toString(), licenses));
}
return results.build();
}

View File

@ -14,8 +14,8 @@ public class LicensesMarvelDoc extends MarvelDoc<LicensesMarvelDoc.Payload> {
private final Payload payload;
LicensesMarvelDoc(String index, String type, String id, String clusterName, long timestamp, Payload payload) {
super(index, type, id, clusterName, timestamp);
LicensesMarvelDoc(String index, String type, String id, String clusterUUID, long timestamp, Payload payload) {
super(index, type, id, clusterUUID, timestamp);
this.payload = payload;
}
@ -24,20 +24,26 @@ public class LicensesMarvelDoc extends MarvelDoc<LicensesMarvelDoc.Payload> {
return payload;
}
public static LicensesMarvelDoc createMarvelDoc(String index, String type, String id, String clusterName, long timestamp, String version, List<License> licenses) {
return new LicensesMarvelDoc(index, type, id, clusterName, timestamp, new Payload(version, licenses));
public static LicensesMarvelDoc createMarvelDoc(String index, String type, String id, String clusterUUID, long timestamp, String clusterName, String version, List<License> licenses) {
return new LicensesMarvelDoc(index, type, id, clusterUUID, timestamp, new Payload(clusterName, version, licenses));
}
public static class Payload {
private final String clusterName;
private final String version;
private final List<License> licenses;
public Payload(String version, List<License> licenses) {
public Payload(String clusterName, String version, List<License> licenses) {
this.clusterName = clusterName;
this.version = version;
this.licenses = licenses;
}
public String getClusterName() {
return clusterName;
}
public String getVersion() {
return version;
}

View File

@ -9,7 +9,6 @@ package org.elasticsearch.marvel.agent.collector.node;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
import org.elasticsearch.bootstrap.Bootstrap;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider;
import org.elasticsearch.common.inject.ConfigurationException;
@ -44,11 +43,10 @@ public class NodeStatsCollector extends AbstractCollector<NodeStatsCollector> {
private final Provider<DiskThresholdDecider> diskThresholdDeciderProvider;
@Inject
public NodeStatsCollector(Settings settings, ClusterService clusterService, ClusterName clusterName,
MarvelSettings marvelSettings,
public NodeStatsCollector(Settings settings, ClusterService clusterService, MarvelSettings marvelSettings,
NodeService nodeService, DiscoveryService discoveryService,
Provider<DiskThresholdDecider> diskThresholdDeciderProvider) {
super(settings, NAME, clusterService, clusterName, marvelSettings);
super(settings, NAME, clusterService, marvelSettings);
this.nodeService = nodeService;
this.discoveryService = discoveryService;
this.diskThresholdDeciderProvider = diskThresholdDeciderProvider;
@ -72,16 +70,16 @@ public class NodeStatsCollector extends AbstractCollector<NodeStatsCollector> {
Double diskThresholdWatermarkHigh = (diskThresholdDecider != null) ? 100.0 - diskThresholdDecider.getFreeDiskThresholdHigh() : -1;
boolean diskThresholdDeciderEnabled = (diskThresholdDecider != null) && diskThresholdDecider.isEnabled();
results.add(buildMarvelDoc(clusterName.value(), TYPE, System.currentTimeMillis(),
results.add(buildMarvelDoc(clusterUUID(), TYPE, System.currentTimeMillis(),
discoveryService.localNode().id(), clusterService.state().nodes().localNodeMaster(), nodeStats,
Bootstrap.isMemoryLocked(), diskThresholdWatermarkHigh, diskThresholdDeciderEnabled));
return results.build();
}
protected MarvelDoc buildMarvelDoc(String clusterName, String type, long timestamp,
protected MarvelDoc buildMarvelDoc(String clusterUUID, String type, long timestamp,
String nodeId, boolean nodeMaster, NodeStats nodeStats,
boolean mlockall, Double diskThresholdWaterMarkHigh, boolean diskThresholdDeciderEnabled) {
return NodeStatsMarvelDoc.createMarvelDoc(clusterName, type, timestamp, nodeId, nodeMaster, nodeStats, mlockall, diskThresholdWaterMarkHigh, diskThresholdDeciderEnabled);
return NodeStatsMarvelDoc.createMarvelDoc(clusterUUID, type, timestamp, nodeId, nodeMaster, nodeStats, mlockall, diskThresholdWaterMarkHigh, diskThresholdDeciderEnabled);
}
}

View File

@ -12,8 +12,8 @@ public class NodeStatsMarvelDoc extends MarvelDoc<NodeStatsMarvelDoc.Payload> {
private final Payload payload;
public NodeStatsMarvelDoc(String clusterName, String type, long timestamp, Payload payload) {
super(clusterName, type, timestamp);
public NodeStatsMarvelDoc(String clusterUUID, String type, long timestamp, Payload payload) {
super(clusterUUID, type, timestamp);
this.payload = payload;
}
@ -22,10 +22,10 @@ public class NodeStatsMarvelDoc extends MarvelDoc<NodeStatsMarvelDoc.Payload> {
return payload;
}
public static NodeStatsMarvelDoc createMarvelDoc(String clusterName, String type, long timestamp,
public static NodeStatsMarvelDoc createMarvelDoc(String clusterUUID, String type, long timestamp,
String nodeId, boolean nodeMaster, NodeStats nodeStats,
boolean mlockall, Double diskThresholdWaterMarkHigh, boolean diskThresholdDeciderEnabled) {
return new NodeStatsMarvelDoc(clusterName, type, timestamp, new Payload(nodeId, nodeMaster, nodeStats, mlockall, diskThresholdWaterMarkHigh, diskThresholdDeciderEnabled));
return new NodeStatsMarvelDoc(clusterUUID, type, timestamp, new Payload(nodeId, nodeMaster, nodeStats, mlockall, diskThresholdWaterMarkHigh, diskThresholdDeciderEnabled));
}
public static class Payload {

View File

@ -11,23 +11,23 @@ public abstract class MarvelDoc<T> {
private final String type;
private final String id;
private final String clusterName;
private final String clusterUUID;
private final long timestamp;
public MarvelDoc(String index, String type, String id, String clusterName, long timestamp) {
public MarvelDoc(String index, String type, String id, String clusterUUID, long timestamp) {
this.index = index;
this.type = type;
this.id = id;
this.clusterName = clusterName;
this.clusterUUID = clusterUUID;
this.timestamp = timestamp;
}
public MarvelDoc(String clusterName, String type, long timestamp) {
this(null, type, null, clusterName, timestamp);
public MarvelDoc(String clusterUUID, String type, long timestamp) {
this(null, type, null, clusterUUID, timestamp);
}
public String clusterName() {
return clusterName;
public String clusterUUID() {
return clusterUUID;
}
public String index() {

View File

@ -26,7 +26,7 @@ import java.util.Set;
public abstract class AbstractRenderer<T extends MarvelDoc> implements Renderer<T> {
private static final String[] DEFAULT_FILTERS = {
Fields.CLUSTER_NAME.underscore().toString(),
Fields.CLUSTER_UUID.underscore().toString(),
Fields.TIMESTAMP.underscore().toString(),
};
@ -54,7 +54,7 @@ public abstract class AbstractRenderer<T extends MarvelDoc> implements Renderer<
builder.startObject();
// Add fields common to all Marvel documents
builder.field(Fields.CLUSTER_NAME, marvelDoc.clusterName());
builder.field(Fields.CLUSTER_UUID, marvelDoc.clusterUUID());
DateTime timestampDateTime = new DateTime(marvelDoc.timestamp(), DateTimeZone.UTC);
builder.field(Fields.TIMESTAMP, timestampDateTime.toString());
@ -77,7 +77,7 @@ public abstract class AbstractRenderer<T extends MarvelDoc> implements Renderer<
}
static final class Fields {
static final XContentBuilderString CLUSTER_NAME = new XContentBuilderString("cluster_name");
static final XContentBuilderString CLUSTER_UUID = new XContentBuilderString("cluster_uuid");
static final XContentBuilderString TIMESTAMP = new XContentBuilderString("timestamp");
}
}

View File

@ -29,6 +29,7 @@ public class LicensesRenderer extends AbstractRenderer<LicensesMarvelDoc> {
LicensesMarvelDoc.Payload payload = marvelDoc.payload();
if (payload != null) {
builder.field(Fields.CLUSTER_NAME, payload.getClusterName());
builder.field(Fields.VERSION, payload.getVersion());
builder.startArray(Fields.LICENSES);
@ -45,7 +46,7 @@ public class LicensesRenderer extends AbstractRenderer<LicensesMarvelDoc> {
builder.field(Fields.MAX_NODES, license.maxNodes());
builder.field(Fields.ISSUED_TO, license.issuedTo());
builder.field(Fields.ISSUER, license.issuer());
builder.field(Fields.HKEY, hash(license, marvelDoc.clusterName()));
builder.field(Fields.HKEY, hash(license, payload.getClusterName()));
builder.endObject();
}
}
@ -71,6 +72,7 @@ public class LicensesRenderer extends AbstractRenderer<LicensesMarvelDoc> {
}
static final class Fields {
static final XContentBuilderString CLUSTER_NAME = new XContentBuilderString("cluster_name");
static final XContentBuilderString LICENSES = new XContentBuilderString("licenses");
static final XContentBuilderString VERSION = new XContentBuilderString("version");

View File

@ -15,7 +15,7 @@
},
"date_detection": false,
"properties": {
"cluster_name": {
"cluster_uuid": {
"type": "string",
"index": "not_analyzed"
},

View File

@ -5,7 +5,6 @@
*/
package org.elasticsearch.marvel.agent.collector.cluster;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
@ -32,7 +31,7 @@ public class ClusterStateCollectorTests extends ESSingleNodeTestCase {
assertThat(marvelDoc, instanceOf(ClusterStateMarvelDoc.class));
ClusterStateMarvelDoc clusterStateMarvelDoc = (ClusterStateMarvelDoc) marvelDoc;
assertThat(clusterStateMarvelDoc.clusterName(), equalTo(client().admin().cluster().prepareHealth().get().getClusterName()));
assertThat(clusterStateMarvelDoc.clusterUUID(), equalTo(client().admin().cluster().prepareState().setMetaData(true).get().getState().metaData().clusterUUID()));
assertThat(clusterStateMarvelDoc.timestamp(), greaterThan(0L));
assertThat(clusterStateMarvelDoc.type(), equalTo(ClusterStateCollector.TYPE));
@ -64,7 +63,7 @@ public class ClusterStateCollectorTests extends ESSingleNodeTestCase {
assertThat(marvelDoc, instanceOf(ClusterStateMarvelDoc.class));
ClusterStateMarvelDoc clusterStateMarvelDoc = (ClusterStateMarvelDoc) marvelDoc;
assertThat(clusterStateMarvelDoc.clusterName(), equalTo(client().admin().cluster().prepareHealth().get().getClusterName()));
assertThat(clusterStateMarvelDoc.clusterUUID(), equalTo(client().admin().cluster().prepareState().setMetaData(true).get().getState().metaData().clusterUUID()));
assertThat(clusterStateMarvelDoc.timestamp(), greaterThan(0L));
assertThat(clusterStateMarvelDoc.type(), equalTo(ClusterStateCollector.TYPE));
@ -103,7 +102,7 @@ public class ClusterStateCollectorTests extends ESSingleNodeTestCase {
assertThat(marvelDoc, instanceOf(ClusterStateMarvelDoc.class));
ClusterStateMarvelDoc clusterStateMarvelDoc = (ClusterStateMarvelDoc) marvelDoc;
assertThat(clusterStateMarvelDoc.clusterName(), equalTo(client().admin().cluster().prepareHealth().get().getClusterName()));
assertThat(clusterStateMarvelDoc.clusterUUID(), equalTo(client().admin().cluster().prepareState().setMetaData(true).get().getState().metaData().clusterUUID()));
assertThat(clusterStateMarvelDoc.timestamp(), greaterThan(0L));
assertThat(clusterStateMarvelDoc.type(), equalTo(ClusterStateCollector.TYPE));
@ -120,7 +119,6 @@ public class ClusterStateCollectorTests extends ESSingleNodeTestCase {
private ClusterStateCollector newClusterStateCollector() {
return new ClusterStateCollector(getInstanceFromNode(Settings.class),
getInstanceFromNode(ClusterService.class),
getInstanceFromNode(ClusterName.class),
getInstanceFromNode(MarvelSettings.class),
client());
}

View File

@ -5,7 +5,6 @@
*/
package org.elasticsearch.marvel.agent.collector.cluster;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.marvel.agent.exporter.MarvelDoc;
@ -29,7 +28,7 @@ public class ClusterStatsCollectorTests extends ESIntegTestCase {
assertThat(marvelDoc, instanceOf(ClusterStatsMarvelDoc.class));
ClusterStatsMarvelDoc clusterStatsMarvelDoc = (ClusterStatsMarvelDoc) marvelDoc;
assertThat(clusterStatsMarvelDoc.clusterName(), equalTo(client().admin().cluster().prepareHealth().get().getClusterName()));
assertThat(clusterStatsMarvelDoc.clusterUUID(), equalTo(client().admin().cluster().prepareState().setMetaData(true).get().getState().metaData().clusterUUID()));
assertThat(clusterStatsMarvelDoc.timestamp(), greaterThan(0L));
assertThat(clusterStatsMarvelDoc.type(), equalTo(ClusterStatsCollector.TYPE));
@ -42,7 +41,6 @@ public class ClusterStatsCollectorTests extends ESIntegTestCase {
private ClusterStatsCollector newClusterStatsCollector() {
return new ClusterStatsCollector(internalCluster().getInstance(Settings.class),
internalCluster().getInstance(ClusterService.class),
internalCluster().getInstance(ClusterName.class),
internalCluster().getInstance(MarvelSettings.class),
client());
}

View File

@ -7,7 +7,6 @@ package org.elasticsearch.marvel.agent.collector.indices;
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
import org.elasticsearch.action.admin.indices.recovery.ShardRecoveryResponse;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.block.ClusterBlocks;
import org.elasticsearch.common.settings.Settings;
@ -96,7 +95,7 @@ public class IndexRecoveryCollectorTests extends ESIntegTestCase {
assertThat(marvelDoc, instanceOf(IndexRecoveryMarvelDoc.class));
IndexRecoveryMarvelDoc indexRecoveryMarvelDoc = (IndexRecoveryMarvelDoc) marvelDoc;
assertThat(indexRecoveryMarvelDoc.clusterName(), equalTo(client().admin().cluster().prepareHealth().get().getClusterName()));
assertThat(indexRecoveryMarvelDoc.clusterUUID(), equalTo(client().admin().cluster().prepareState().setMetaData(true).get().getState().metaData().clusterUUID()));
assertThat(indexRecoveryMarvelDoc.timestamp(), greaterThan(0L));
assertThat(indexRecoveryMarvelDoc.type(), equalTo(IndexRecoveryCollector.TYPE));
@ -124,7 +123,6 @@ public class IndexRecoveryCollectorTests extends ESIntegTestCase {
private IndexRecoveryCollector newIndexRecoveryCollector() {
return new IndexRecoveryCollector(internalCluster().getInstance(Settings.class),
internalCluster().getInstance(ClusterService.class),
internalCluster().getInstance(ClusterName.class),
internalCluster().getInstance(MarvelSettings.class),
client());
}

View File

@ -7,7 +7,6 @@ package org.elasticsearch.marvel.agent.collector.indices;
import com.google.common.collect.ImmutableSet;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.block.ClusterBlock;
import org.elasticsearch.common.settings.Settings;
@ -53,7 +52,7 @@ public class IndexStatsCollectorTests extends ESSingleNodeTestCase {
assertThat(marvelDoc, instanceOf(IndexStatsMarvelDoc.class));
IndexStatsMarvelDoc indexStatsMarvelDoc = (IndexStatsMarvelDoc) marvelDoc;
assertThat(indexStatsMarvelDoc.clusterName(), equalTo(client().admin().cluster().prepareHealth().get().getClusterName()));
assertThat(indexStatsMarvelDoc.clusterUUID(), equalTo(client().admin().cluster().prepareState().setMetaData(true).get().getState().metaData().clusterUUID()));
assertThat(indexStatsMarvelDoc.timestamp(), greaterThan(0L));
assertThat(indexStatsMarvelDoc.type(), equalTo(IndexStatsCollector.TYPE));
@ -84,7 +83,7 @@ public class IndexStatsCollectorTests extends ESSingleNodeTestCase {
}
}
String clusterName = client().admin().cluster().prepareHealth().get().getClusterName();
String clusterUUID = client().admin().cluster().prepareState().setMetaData(true).get().getState().metaData().clusterUUID();
client().admin().indices().prepareRefresh().get();
for (int i = 0; i < nbIndices; i++) {
assertHitCount(client().prepareCount("test-" + i).get(), docsPerIndex[i]);
@ -108,7 +107,7 @@ public class IndexStatsCollectorTests extends ESSingleNodeTestCase {
assertNotNull(payload.getIndexStats());
if (payload.getIndexStats().getIndex().equals("test-" + i)) {
assertThat(indexStatsMarvelDoc.clusterName(), equalTo(clusterName));
assertThat(indexStatsMarvelDoc.clusterUUID(), equalTo(clusterUUID));
assertThat(indexStatsMarvelDoc.timestamp(), greaterThan(0L));
assertThat(indexStatsMarvelDoc.type(), equalTo(IndexStatsCollector.TYPE));
@ -129,7 +128,6 @@ public class IndexStatsCollectorTests extends ESSingleNodeTestCase {
private IndexStatsCollector newIndexStatsCollector() {
return new IndexStatsCollector(getInstanceFromNode(Settings.class),
getInstanceFromNode(ClusterService.class),
getInstanceFromNode(ClusterName.class),
getInstanceFromNode(MarvelSettings.class),
client());
}

View File

@ -6,7 +6,6 @@
package org.elasticsearch.marvel.agent.collector.node;
import org.elasticsearch.bootstrap.Bootstrap;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider;
import org.elasticsearch.common.inject.Provider;
@ -37,7 +36,7 @@ public class NodeStatsCollectorTests extends ESIntegTestCase {
assertThat(marvelDoc, instanceOf(NodeStatsMarvelDoc.class));
NodeStatsMarvelDoc nodeStatsMarvelDoc = (NodeStatsMarvelDoc) marvelDoc;
assertThat(nodeStatsMarvelDoc.clusterName(), equalTo(client().admin().cluster().prepareHealth().get().getClusterName()));
assertThat(nodeStatsMarvelDoc.clusterUUID(), equalTo(client().admin().cluster().prepareState().setMetaData(true).get().getState().metaData().clusterUUID()));
assertThat(nodeStatsMarvelDoc.timestamp(), greaterThan(0L));
assertThat(nodeStatsMarvelDoc.type(), equalTo(NodeStatsCollector.TYPE));
@ -56,7 +55,6 @@ public class NodeStatsCollectorTests extends ESIntegTestCase {
private NodeStatsCollector newNodeStatsCollector(final String nodeId) {
return new NodeStatsCollector(internalCluster().getInstance(Settings.class, nodeId),
internalCluster().getInstance(ClusterService.class, nodeId),
internalCluster().getInstance(ClusterName.class, nodeId),
internalCluster().getInstance(MarvelSettings.class, nodeId),
internalCluster().getInstance(NodeService.class, nodeId),
internalCluster().getInstance(DiscoveryService.class, nodeId),

View File

@ -8,13 +8,13 @@ package org.elasticsearch.marvel.agent.renderer.licenses;
import org.elasticsearch.Version;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.license.core.License;
import org.elasticsearch.license.plugin.LicensePlugin;
import org.elasticsearch.marvel.MarvelPlugin;
import org.elasticsearch.marvel.agent.collector.licenses.LicensesCollector;
import org.elasticsearch.marvel.agent.exporter.MarvelDoc;
import org.elasticsearch.marvel.agent.settings.MarvelSettings;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESIntegTestCase;
@ -45,6 +45,9 @@ public class LicensesRendererIT extends ESIntegTestCase {
@Test
public void testLicenses() throws Exception {
final String clusterUUID = client().admin().cluster().prepareState().setMetaData(true).get().getState().metaData().clusterUUID();
assertTrue(Strings.hasText(clusterUUID));
logger.debug("--> waiting for licenses collector to collect data (ie, the trial marvel license)");
GetResponse response = assertBusy(new Callable<GetResponse>() {
@Override
@ -53,7 +56,7 @@ public class LicensesRendererIT extends ESIntegTestCase {
assertTrue(client().admin().indices().prepareExists(MarvelSettings.MARVEL_DATA_INDEX_NAME).get().isExists());
ensureYellow(MarvelSettings.MARVEL_DATA_INDEX_NAME);
GetResponse response = client().prepareGet(MarvelSettings.MARVEL_DATA_INDEX_NAME, LicensesCollector.TYPE, cluster().getClusterName()).get();
GetResponse response = client().prepareGet(MarvelSettings.MARVEL_DATA_INDEX_NAME, LicensesCollector.TYPE, clusterUUID).get();
assertTrue(response.isExists());
return response;
}
@ -62,9 +65,10 @@ public class LicensesRendererIT extends ESIntegTestCase {
logger.debug("--> checking that the document contains license information");
assertThat(response.getIndex(), equalTo(MarvelSettings.MARVEL_DATA_INDEX_NAME));
assertThat(response.getType(), equalTo(LicensesCollector.TYPE));
assertThat(response.getId(), equalTo(cluster().getClusterName()));
assertThat(response.getId(), equalTo(clusterUUID));
Map<String, Object> source = response.getSource();
assertThat((String) source.get(LicensesRenderer.Fields.CLUSTER_NAME.underscore().toString()), equalTo(cluster().getClusterName()));
assertThat((String) source.get(LicensesRenderer.Fields.VERSION.underscore().toString()), equalTo(Version.CURRENT.toString()));
Object licensesList = source.get(LicensesRenderer.Fields.LICENSES.underscore().toString());

View File

@ -1,5 +1,5 @@
{
"cluster_name": "test",
"cluster_uuid": "dsFPzYRyQCe6cq48a0wxkQ",
"timestamp": "2015-07-22T15:54:02.979Z",
"cluster_state": {
"status": "yellow",

View File

@ -1,5 +1,5 @@
{
"cluster_name": "test",
"cluster_uuid": "dsFPzYRyQCe6cq48a0wxkQ",
"timestamp": "2015-07-22T15:54:02.979Z",
"cluster_stats": {
"indices": {

View File

@ -1,5 +1,5 @@
{
"cluster_name": "test",
"cluster_uuid": "dsFPzYRyQCe6cq48a0wxkQ",
"timestamp": "2015-07-22T15:54:02.979Z",
"index_recovery": {
"shards": [

View File

@ -1,5 +1,5 @@
{
"cluster_name": "test",
"cluster_uuid": "dsFPzYRyQCe6cq48a0wxkQ",
"timestamp": "2015-07-22T15:54:02.979Z",
"index_stats": {
"index": "index-0",

View File

@ -1,5 +1,5 @@
{
"cluster_name": "test",
"cluster_uuid": "dsFPzYRyQCe6cq48a0wxkQ",
"timestamp": "2015-07-22T15:54:02.979Z",
"node_stats": {
"node_id": "OB5Mr2NGQe6xYCFvMggReg",