Setting human_readable to false while exporting node stats.

Original commit: elastic/x-pack-elasticsearch@c0c3f0bab5
This commit is contained in:
Boaz Leskes 2013-05-22 13:47:24 +02:00
parent 6c56fe1110
commit e6c3646d9a
1 changed files with 10 additions and 2 deletions

View File

@ -5,6 +5,7 @@
*/
package com.elasticsearch.dash.exporters;
import com.elasticsearch.dash.Exporter;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.ElasticSearchException;
import org.elasticsearch.ElasticSearchIllegalArgumentException;
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
@ -25,7 +26,7 @@ import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Date;
import java.util.*;
public class ESExporter extends AbstractLifecycleComponent<ESExporter> implements Exporter<ESExporter> {
@ -37,6 +38,9 @@ public class ESExporter extends AbstractLifecycleComponent<ESExporter> implement
final ESLogger logger = ESLoggerFactory.getLogger(ESExporter.class.getName());
final ToXContent.Params xContentParams;
public ESExporter(Settings settings, ClusterName clusterName) {
super(settings);
@ -57,6 +61,9 @@ public class ESExporter extends AbstractLifecycleComponent<ESExporter> implement
}
xContentParams = new ToXContent.MapParams(ImmutableMap.of("human_readable","false"));
logger.info("ESExporter initialized. Target: {}:{} Index prefix set to {}", targetHost, targetPort, targetIndexPrefix );
// explode early on broken settings
getTargetURL("test");
@ -77,6 +84,7 @@ public class ESExporter extends AbstractLifecycleComponent<ESExporter> implement
return "ESExporter";
}
@Override
public void exportNodeStats(NodeStats nodeStats) {
URL url = getTargetURL("nodestats");
@ -91,7 +99,7 @@ public class ESExporter extends AbstractLifecycleComponent<ESExporter> implement
XContentBuilder builder = XContentFactory.smileBuilder(os);
builder.startObject();
nodeStats.toXContent(builder, ToXContent.EMPTY_PARAMS);
nodeStats.toXContent(builder, xContentParams);
builder.endObject();
builder.close();