当前位置: 首页>>代码示例>>Java>>正文


Java Settings.toXContent方法代码示例

本文整理汇总了Java中org.elasticsearch.common.settings.Settings.toXContent方法的典型用法代码示例。如果您正苦于以下问题:Java Settings.toXContent方法的具体用法?Java Settings.toXContent怎么用?Java Settings.toXContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.common.settings.Settings的用法示例。


在下文中一共展示了Settings.toXContent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toXContent

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject("nodes");
    for (NodeInfo nodeInfo : getNodes()) {
        builder.startObject(nodeInfo.getNode().getId());

        builder.field("name", nodeInfo.getNode().getName());
        builder.field("transport_address", nodeInfo.getNode().getAddress().toString());
        builder.field("host", nodeInfo.getNode().getHostName());
        builder.field("ip", nodeInfo.getNode().getHostAddress());

        builder.field("version", nodeInfo.getVersion());
        builder.field("build_hash", nodeInfo.getBuild().shortHash());
        if (nodeInfo.getTotalIndexingBuffer() != null) {
            builder.byteSizeField("total_indexing_buffer", "total_indexing_buffer_in_bytes", nodeInfo.getTotalIndexingBuffer());
        }

        builder.startArray("roles");
        for (DiscoveryNode.Role role : nodeInfo.getNode().getRoles()) {
            builder.value(role.getRoleName());
        }
        builder.endArray();

        if (!nodeInfo.getNode().getAttributes().isEmpty()) {
            builder.startObject("attributes");
            for (Map.Entry<String, String> entry : nodeInfo.getNode().getAttributes().entrySet()) {
                builder.field(entry.getKey(), entry.getValue());
            }
            builder.endObject();
        }

        if (nodeInfo.getSettings() != null) {
            builder.startObject("settings");
            Settings settings = nodeInfo.getSettings();
            settings.toXContent(builder, params);
            builder.endObject();
        }

        if (nodeInfo.getOs() != null) {
            nodeInfo.getOs().toXContent(builder, params);
        }
        if (nodeInfo.getProcess() != null) {
            nodeInfo.getProcess().toXContent(builder, params);
        }
        if (nodeInfo.getJvm() != null) {
            nodeInfo.getJvm().toXContent(builder, params);
        }
        if (nodeInfo.getThreadPool() != null) {
            nodeInfo.getThreadPool().toXContent(builder, params);
        }
        if (nodeInfo.getTransport() != null) {
            nodeInfo.getTransport().toXContent(builder, params);
        }
        if (nodeInfo.getHttp() != null) {
            nodeInfo.getHttp().toXContent(builder, params);
        }
        if (nodeInfo.getPlugins() != null) {
            nodeInfo.getPlugins().toXContent(builder, params);
        }
        if (nodeInfo.getIngest() != null) {
            nodeInfo.getIngest().toXContent(builder, params);
        }

        builder.endObject();
    }
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:69,代码来源:NodesInfoResponse.java

示例2: toXContent

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.field("cluster_name", getClusterName().value(), XContentBuilder.FieldCaseConversion.NONE);

    builder.startObject("nodes");
    for (NodeInfo nodeInfo : this) {
        builder.startObject(nodeInfo.getNode().id(), XContentBuilder.FieldCaseConversion.NONE);

        builder.field("name", nodeInfo.getNode().name(), XContentBuilder.FieldCaseConversion.NONE);
        builder.field("transport_address", nodeInfo.getNode().address().toString());
        builder.field("host", nodeInfo.getNode().getHostName(), XContentBuilder.FieldCaseConversion.NONE);
        builder.field("ip", nodeInfo.getNode().getHostAddress(), XContentBuilder.FieldCaseConversion.NONE);

        builder.field("version", nodeInfo.getVersion());
        builder.field("build", nodeInfo.getBuild().hashShort());

        if (nodeInfo.getServiceAttributes() != null) {
            for (Map.Entry<String, String> nodeAttribute : nodeInfo.getServiceAttributes().entrySet()) {
                builder.field(nodeAttribute.getKey(), nodeAttribute.getValue(), XContentBuilder.FieldCaseConversion.NONE);
            }
        }

        if (!nodeInfo.getNode().attributes().isEmpty()) {
            builder.startObject("attributes");
            for (Map.Entry<String, String> attr : nodeInfo.getNode().attributes().entrySet()) {
                builder.field(attr.getKey(), attr.getValue(), XContentBuilder.FieldCaseConversion.NONE);
            }
            builder.endObject();
        }


        if (nodeInfo.getSettings() != null) {
            builder.startObject("settings");
            Settings settings = nodeInfo.getSettings();
            settings.toXContent(builder, params);
            builder.endObject();
        }

        if (nodeInfo.getOs() != null) {
            nodeInfo.getOs().toXContent(builder, params);
        }
        if (nodeInfo.getProcess() != null) {
            nodeInfo.getProcess().toXContent(builder, params);
        }
        if (nodeInfo.getJvm() != null) {
            nodeInfo.getJvm().toXContent(builder, params);
        }
        if (nodeInfo.getThreadPool() != null) {
            nodeInfo.getThreadPool().toXContent(builder, params);
        }
        if (nodeInfo.getTransport() != null) {
            nodeInfo.getTransport().toXContent(builder, params);
        }
        if (nodeInfo.getHttp() != null) {
            nodeInfo.getHttp().toXContent(builder, params);
        }
        if (nodeInfo.getPlugins() != null) {
            nodeInfo.getPlugins().toXContent(builder, params);
        }

        builder.endObject();
    }
    builder.endObject();
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:66,代码来源:NodesInfoResponse.java

示例3: writeSettings

import org.elasticsearch.common.settings.Settings; //导入方法依赖的package包/类
private void writeSettings(Settings settings, XContentBuilder builder, ToXContent.Params params) throws IOException {
    builder.startObject(Fields.SETTINGS);
    settings.toXContent(builder, params);
    builder.endObject();
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:6,代码来源:GetIndexRequestRestListener.java


注:本文中的org.elasticsearch.common.settings.Settings.toXContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。