moved to elasticsearch-enterprise - part 2

Original commit: elastic/x-pack-elasticsearch@e7a7b2fa60
This commit is contained in:
Boaz Leskes 2013-09-27 16:55:18 +02:00
parent 72357446aa
commit 318b0e7b88
6 changed files with 28 additions and 30 deletions

View File

@ -25,7 +25,7 @@
</parent> </parent>
<properties> <properties>
<elasticsearch.version>0.90.5</elasticsearch.version> <elasticsearch.version>0.90.6-SNAPSHOT</elasticsearch.version>
</properties> </properties>
<repositories> <repositories>

View File

@ -3,9 +3,9 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package com.elasticsearch.dash; package org.elasticsearch.enterprise.monitor;
import com.google.common.collect.ImmutableList; import org.elasticsearch.common.collect.ImmutableList;
import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.Module;

View File

@ -3,9 +3,9 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package com.elasticsearch.dash;/* package org.elasticsearch.enterprise.monitor;
import com.elasticsearch.dash.exporters.ESExporter; import org.elasticsearch.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet; import org.elasticsearch.enterprise.monitor.exporter.ESExporter;
import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchException;
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
@ -16,6 +16,7 @@ import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.enterprise.monitor.exporter.StatsExporter;
import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.indices.InternalIndicesService; import org.elasticsearch.indices.InternalIndicesService;
import org.elasticsearch.node.service.NodeService; import org.elasticsearch.node.service.NodeService;
@ -91,18 +92,18 @@ public class StatsExportersService extends AbstractLifecycleComponent<StatsExpor
} }
} }
logger.debug("Collecting shard stats"); // logger.warn("Collecting shard stats");
List<ShardStats> shardStatsList = indicesService.shardLevelStats(CommonStatsFlags.ALL); // List<ShardStats> shardStatsList = indicesService.shardLevelStats(CommonStatsFlags.ALL);
//
logger.debug("Exporting shards stats"); // logger.debug("Exporting shards stats");
for (StatsExporter e : exporters) { // for (StatsExporter e : exporters) {
try { // try {
for (ShardStats shardStats : shardStatsList) // for (ShardStats shardStats : shardStatsList)
e.exportShardStats(shardStats); // e.exportShardStats(shardStats);
} catch (Throwable t) { // } catch (Throwable t) {
logger.error("StatsExporter {} has thrown an exception:", t, e.name()); // logger.error("StatsExporter {} has thrown an exception:", t, e.name());
} // }
} // }
} catch (Throwable t) { } catch (Throwable t) {
logger.error("Background thread had an uncaught exception:", t); logger.error("Background thread had an uncaught exception:", t);
} }

View File

@ -3,9 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package com.elasticsearch.dash.exporters; package org.elasticsearch.enterprise.monitor.exporter;
import com.elasticsearch.dash.StatsExporter; import org.elasticsearch.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchException;
import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.ElasticSearchIllegalArgumentException;
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
@ -50,19 +49,18 @@ public class ESExporter extends AbstractLifecycleComponent<ESExporter> implement
// TODO: move to a single settings. // TODO: move to a single settings.
targetHost = settings.get("target.host", "localhost"); targetHost = settings.get("target.host", "localhost");
targetPort = settings.getAsInt("target.post", 9200); targetPort = settings.getAsInt("target.post", 9200);
String targetIndexPrefix = settings.get("target.index.prefix", "dash"); String targetIndexPrefix = settings.get("target.index.prefix", "");
try { try {
targetPathPrefix = String.format("/%s_%s_", if (!targetIndexPrefix.isEmpty()) targetIndexPrefix += targetIndexPrefix + "_";
URLEncoder.encode(targetIndexPrefix,"UTF-8"), targetPathPrefix = "/"+ URLEncoder.encode(targetIndexPrefix,"UTF-8") + URLEncoder.encode(clusterName.value(),"UTF-8");
URLEncoder.encode(clusterName.value(),"UTF-8"));
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
throw new ElasticSearchException("Can't encode target url", e); throw new ElasticSearchException("Can't encode target url", e);
} }
xContentParams = new ToXContent.MapParams(ImmutableMap.of("human_readable","false")); xContentParams = new ToXContent.MapParams(ImmutableMap.of("human_readable", "false"));
logger.info("ESExporter initialized. Target: {}:{} Index prefix set to {}", targetHost, targetPort, targetIndexPrefix ); logger.info("ESExporter initialized. Target: {}:{} Index prefix set to {}", targetHost, targetPort, targetIndexPrefix );
@ -93,7 +91,7 @@ public class ESExporter extends AbstractLifecycleComponent<ESExporter> implement
@Override @Override
public void exportShardStats(ShardStats shardStats) { public void exportShardStats(ShardStats shardStats) {
exportXContent("shardstats", shardStats); //exportXContent("shardstats", shardStats);
} }
private void exportXContent(String type,ToXContent xContent) { private void exportXContent(String type,ToXContent xContent) {

View File

@ -3,10 +3,9 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package com.elasticsearch.dash; package org.elasticsearch.enterprise.monitor.exporter;
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
import org.elasticsearch.action.admin.indices.stats.ShardStats; import org.elasticsearch.action.admin.indices.stats.ShardStats;
import org.elasticsearch.common.component.CloseableComponent;
import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.component.LifecycleComponent;
public interface StatsExporter<T> extends LifecycleComponent<T> { public interface StatsExporter<T> extends LifecycleComponent<T> {

View File

@ -1 +1 @@
plugin=com.elasticsearch.dash.Plugin plugin=org.elasticsearch.enterprise.monitor.Plugin