Merge branch 'master' of github.com:elastic/x-plugins

Original commit: elastic/x-pack-elasticsearch@0278f6ced2
This commit is contained in:
Areek Zillur 2015-08-31 15:53:57 -04:00
commit b9ac72efd7
8 changed files with 43 additions and 33 deletions

View File

@ -5,7 +5,6 @@
*/
package org.elasticsearch.marvel;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterModule;
import org.elasticsearch.cluster.settings.Validator;
@ -20,9 +19,9 @@ import org.elasticsearch.marvel.agent.exporter.ExporterModule;
import org.elasticsearch.marvel.agent.exporter.HttpESExporter;
import org.elasticsearch.marvel.agent.renderer.RendererModule;
import org.elasticsearch.marvel.agent.settings.MarvelModule;
import org.elasticsearch.marvel.license.LicenseModule;
import org.elasticsearch.marvel.agent.settings.MarvelSetting;
import org.elasticsearch.marvel.agent.settings.MarvelSettings;
import org.elasticsearch.marvel.license.LicenseModule;
import org.elasticsearch.marvel.license.LicenseService;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.tribe.TribeService;
@ -74,9 +73,9 @@ public class MarvelPlugin extends Plugin {
@Override
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
if (!enabled) {
return ImmutableList.of();
return Collections.emptyList();
}
return ImmutableList.<Class<? extends LifecycleComponent>>of(LicenseService.class, AgentService.class);
return Arrays.<Class<? extends LifecycleComponent>>asList(LicenseService.class, AgentService.class);
}
public static boolean marvelEnabled(Settings settings) {

View File

@ -5,7 +5,6 @@
*/
package org.elasticsearch.marvel.agent.collector.cluster;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterService;
@ -17,7 +16,10 @@ import org.elasticsearch.marvel.agent.exporter.MarvelDoc;
import org.elasticsearch.marvel.agent.settings.MarvelSettings;
import org.elasticsearch.marvel.license.LicenseService;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* Collector for cluster state.
@ -46,12 +48,12 @@ public class ClusterStateCollector extends AbstractCollector<ClusterStateCollect
@Override
protected Collection<MarvelDoc> doCollect() throws Exception {
ImmutableList.Builder<MarvelDoc> results = ImmutableList.builder();
List<MarvelDoc> results = new ArrayList<>(1);
ClusterState clusterState = clusterService.state();
ClusterHealthResponse clusterHealth = client.admin().cluster().prepareHealth().get(marvelSettings.clusterStateTimeout());
results.add(new ClusterStateMarvelDoc(clusterUUID(), TYPE, System.currentTimeMillis(), clusterState, clusterHealth.getStatus()));
return results.build();
return Collections.unmodifiableCollection(results);
}
}

View File

@ -5,7 +5,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.ClusterService;
@ -16,7 +15,10 @@ import org.elasticsearch.marvel.agent.exporter.MarvelDoc;
import org.elasticsearch.marvel.agent.settings.MarvelSettings;
import org.elasticsearch.marvel.license.LicenseService;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* Collector for cluster stats.
@ -45,10 +47,10 @@ public class ClusterStatsCollector extends AbstractCollector<ClusterStatsCollect
@Override
protected Collection<MarvelDoc> doCollect() throws Exception {
ImmutableList.Builder<MarvelDoc> results = ImmutableList.builder();
List<MarvelDoc> results = new ArrayList<>(1);
ClusterStatsResponse clusterStatsResponse = client.admin().cluster().prepareClusterStats().get(marvelSettings.clusterStatsTimeout());
results.add(new ClusterStatsMarvelDoc(clusterUUID(), TYPE, System.currentTimeMillis(), clusterStatsResponse));
return results.build();
return Collections.unmodifiableCollection(results);
}
}

View File

@ -5,7 +5,6 @@
*/
package org.elasticsearch.marvel.agent.collector.indices;
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;
@ -17,7 +16,10 @@ import org.elasticsearch.marvel.agent.exporter.MarvelDoc;
import org.elasticsearch.marvel.agent.settings.MarvelSettings;
import org.elasticsearch.marvel.license.LicenseService;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* Collector for the Recovery API.
@ -46,7 +48,7 @@ public class IndexRecoveryCollector extends AbstractCollector<IndexRecoveryColle
@Override
protected Collection<MarvelDoc> doCollect() throws Exception {
ImmutableList.Builder<MarvelDoc> results = ImmutableList.builder();
List<MarvelDoc> results = new ArrayList<>(1);
RecoveryResponse recoveryResponse = client.admin().indices().prepareRecoveries()
.setIndices(marvelSettings.indices())
@ -57,6 +59,6 @@ public class IndexRecoveryCollector extends AbstractCollector<IndexRecoveryColle
if (recoveryResponse.hasRecoveries()) {
results.add(new IndexRecoveryMarvelDoc(clusterUUID(), TYPE, System.currentTimeMillis(), recoveryResponse));
}
return results.build();
return Collections.unmodifiableCollection(results);
}
}

View File

@ -5,7 +5,6 @@
*/
package org.elasticsearch.marvel.agent.collector.indices;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.admin.indices.stats.IndexStats;
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
import org.elasticsearch.action.support.IndicesOptions;
@ -18,7 +17,10 @@ import org.elasticsearch.marvel.agent.exporter.MarvelDoc;
import org.elasticsearch.marvel.agent.settings.MarvelSettings;
import org.elasticsearch.marvel.license.LicenseService;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* Collector for indices statistics.
@ -47,7 +49,7 @@ public class IndexStatsCollector extends AbstractCollector<IndexStatsCollector>
@Override
protected Collection<MarvelDoc> doCollect() throws Exception {
ImmutableList.Builder<MarvelDoc> results = ImmutableList.builder();
List<MarvelDoc> results = new ArrayList<>(1);
IndicesStatsResponse indicesStats = client.admin().indices().prepareStats()
.setRefresh(true)
@ -60,6 +62,6 @@ public class IndexStatsCollector extends AbstractCollector<IndexStatsCollector>
for (IndexStats indexStats : indicesStats.getIndices().values()) {
results.add(new IndexStatsMarvelDoc(clusterUUID, TYPE, timestamp, indexStats));
}
return results.build();
return Collections.unmodifiableCollection(results);
}
}

View File

@ -5,7 +5,6 @@
*/
package org.elasticsearch.marvel.agent.collector.licenses;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
@ -17,7 +16,9 @@ import org.elasticsearch.marvel.agent.exporter.MarvelDoc;
import org.elasticsearch.marvel.agent.settings.MarvelSettings;
import org.elasticsearch.marvel.license.LicenseService;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
@ -51,7 +52,7 @@ public class LicensesCollector extends AbstractCollector<LicensesMarvelDoc> {
@Override
protected Collection<MarvelDoc> doCollect() throws Exception {
ImmutableList.Builder<MarvelDoc> results = ImmutableList.builder();
List<MarvelDoc> results = new ArrayList<>(1);
List<License> licenses = licenseService.licenses();
if (licenses != null) {
@ -59,6 +60,6 @@ public class LicensesCollector extends AbstractCollector<LicensesMarvelDoc> {
results.add(new LicensesMarvelDoc(MarvelSettings.MARVEL_DATA_INDEX_NAME, TYPE, clusterUUID, clusterUUID, System.currentTimeMillis(),
clusterName.value(), Version.CURRENT.toString(), licenses));
}
return results.build();
return Collections.unmodifiableCollection(results);
}
}

View File

@ -6,7 +6,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.BootstrapInfo;
import org.elasticsearch.cluster.ClusterService;
@ -23,7 +22,10 @@ import org.elasticsearch.marvel.agent.settings.MarvelSettings;
import org.elasticsearch.marvel.license.LicenseService;
import org.elasticsearch.node.service.NodeService;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* Collector for nodes statistics.
@ -55,7 +57,7 @@ public class NodeStatsCollector extends AbstractCollector<NodeStatsCollector> {
@Override
protected Collection<MarvelDoc> doCollect() throws Exception {
ImmutableList.Builder<MarvelDoc> results = ImmutableList.builder();
List<MarvelDoc> results = new ArrayList<>(1);
NodeStats nodeStats = nodeService.stats();
@ -75,6 +77,6 @@ public class NodeStatsCollector extends AbstractCollector<NodeStatsCollector> {
discoveryService.localNode().id(), isLocalNodeMaster(), nodeStats,
BootstrapInfo.isMemoryLocked(), diskThresholdWatermarkHigh, diskThresholdDeciderEnabled));
return results.build();
return Collections.unmodifiableCollection(results);
}
}

View File

@ -6,7 +6,6 @@
package org.elasticsearch.marvel.agent.exporter;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import org.elasticsearch.action.admin.indices.stats.IndexStats;
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData;
import org.elasticsearch.common.Strings;
@ -27,6 +26,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicLong;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@ -57,7 +57,7 @@ public class HttpESExporterTests extends ESIntegTestCase {
internalCluster().startNode(builder);
HttpESExporter httpEsExporter = getEsExporter();
logger.info("trying exporting despite of no target");
httpEsExporter.export(ImmutableList.of(newRandomMarvelDoc()));
httpEsExporter.export(Collections.singletonList(newRandomMarvelDoc()));
}
/*
@ -102,13 +102,13 @@ public class HttpESExporterTests extends ESIntegTestCase {
HttpESExporter httpEsExporter = getEsExporter();
logger.info("exporting events while there is no cluster");
httpEsExporter.export(ImmutableList.of(newRandomMarvelDoc()));
httpEsExporter.export(Collections.singletonList(newRandomMarvelDoc()));
logger.info("bringing up a second node");
internalCluster().startNode(builder);
ensureGreen();
logger.info("exporting a second event");
httpEsExporter.export(ImmutableList.of(newRandomMarvelDoc()));
httpEsExporter.export(Collections.singletonList(newRandomMarvelDoc()));
logger.info("verifying template is inserted");
assertMarvelTemplate();
@ -145,7 +145,7 @@ public class HttpESExporterTests extends ESIntegTestCase {
HttpESExporter httpEsExporter = getEsExporter();
logger.info("exporting an event");
httpEsExporter.export(ImmutableList.of(newRandomMarvelDoc()));
httpEsExporter.export(Collections.singletonList(newRandomMarvelDoc()));
logger.info("removing the marvel template");
@ -155,7 +155,7 @@ public class HttpESExporterTests extends ESIntegTestCase {
Settings.builder().putArray(HttpESExporter.SETTINGS_HOSTS, httpEsExporter.getHosts())).get());
logger.info("exporting a second event");
httpEsExporter.export(ImmutableList.of(newRandomMarvelDoc()));
httpEsExporter.export(Collections.singletonList(newRandomMarvelDoc()));
logger.info("verifying template is inserted");
assertMarvelTemplate();
@ -173,8 +173,8 @@ public class HttpESExporterTests extends ESIntegTestCase {
final HttpESExporter httpEsExporter1 = getEsExporter(node1);
logger.info("--> exporting events to force host resolution");
httpEsExporter0.export(ImmutableList.of(newRandomMarvelDoc()));
httpEsExporter1.export(ImmutableList.of(newRandomMarvelDoc()));
httpEsExporter0.export(Collections.singletonList(newRandomMarvelDoc()));
httpEsExporter1.export(Collections.singletonList(newRandomMarvelDoc()));
logger.info("--> setting exporting hosts to {} + {}", httpEsExporter0.getHosts(), httpEsExporter1.getHosts());
ArrayList<String> mergedHosts = new ArrayList<String>();
@ -185,8 +185,8 @@ public class HttpESExporterTests extends ESIntegTestCase {
Settings.builder().putArray(HttpESExporter.SETTINGS_HOSTS, mergedHosts.toArray(Strings.EMPTY_ARRAY))).get());
logger.info("--> exporting events to have new settings take effect");
httpEsExporter0.export(ImmutableList.of(newRandomMarvelDoc()));
httpEsExporter1.export(ImmutableList.of(newRandomMarvelDoc()));
httpEsExporter0.export(Collections.singletonList(newRandomMarvelDoc()));
httpEsExporter1.export(Collections.singletonList(newRandomMarvelDoc()));
assertMarvelTemplate();
@ -206,7 +206,7 @@ public class HttpESExporterTests extends ESIntegTestCase {
assertTrue("failed to find a template named 'marvel'", awaitBusy(new Predicate<Object>() {
@Override
public boolean apply(Object o) {
httpEsExporter1.export(ImmutableList.of(newRandomMarvelDoc()));
httpEsExporter1.export(Collections.singletonList(newRandomMarvelDoc()));
logger.debug("--> checking for template");
return findMarvelTemplate();
}