Search in sources :

Example 1 with Builder

use of io.crate.metadata.SystemTable.Builder in project crate by crate.

the class SysClusterTableInfo method of.

public static SystemTable<Void> of(ClusterService clusterService, CrateSettings crateSettings) {
    Settings settings = clusterService.getSettings();
    var relBuilder = SystemTable.<Void>builder(IDENT).add("id", DataTypes.STRING, nothing -> clusterService.state().metadata().clusterUUID()).add("name", DataTypes.STRING, nothing -> ClusterName.CLUSTER_NAME_SETTING.get(settings).value()).add("master_node", DataTypes.STRING, nothing -> clusterService.state().nodes().getMasterNodeId()).startObject("license", ignored -> true).add("expiry_date", DataTypes.TIMESTAMPZ, ignored -> null).add("issued_to", DataTypes.STRING, ignored -> null).add("max_nodes", DataTypes.INTEGER, ignored -> null).endObject();
    var settingsBuilder = relBuilder.startObject("settings").startObjectArray("logger", extractLoggers(crateSettings)).add("name", DataTypes.STRING, LoggerEntry::loggerName).add("level", DataTypes.STRING, LoggerEntry::level).endObjectArray();
    // turns the settings:
    // 
    // [
    // [stats, enabled],
    // [stats, jobs_log_size],
    // ...
    // ]
    // 
    // into tree form:
    // 
    // Node
    // name: stats
    // children: [
    // Leaf:
    // name: enabled
    // value: CrateSetting{stats.enabled}
    // Leaf:
    // name: jobs_log_size
    // value: CrateSetting{stats.jobs_log_size}
    // 
    // 
    // To make it easier to build the objects
    var rootNode = toTree(CrateSettings.EXPOSED_SETTINGS);
    for (var child : rootNode.children) {
        addSetting(crateSettings, settingsBuilder, child);
    }
    return settingsBuilder.endObject().build();
}
Also used : CrateSettings(io.crate.metadata.settings.CrateSettings) Setting(org.elasticsearch.common.settings.Setting) RelationName(io.crate.metadata.RelationName) ClusterService(org.elasticsearch.cluster.service.ClusterService) DataType(io.crate.types.DataType) Function(java.util.function.Function) ArrayList(java.util.ArrayList) ObjectBuilder(io.crate.metadata.SystemTable.ObjectBuilder) List(java.util.List) SystemTable(io.crate.metadata.SystemTable) Settings(org.elasticsearch.common.settings.Settings) Locale(java.util.Locale) Builder(io.crate.metadata.SystemTable.Builder) DataTypes(io.crate.types.DataTypes) ClusterName(org.elasticsearch.cluster.ClusterName) CrateSettings(io.crate.metadata.settings.CrateSettings) Settings(org.elasticsearch.common.settings.Settings)

Aggregations

RelationName (io.crate.metadata.RelationName)1 SystemTable (io.crate.metadata.SystemTable)1 Builder (io.crate.metadata.SystemTable.Builder)1 ObjectBuilder (io.crate.metadata.SystemTable.ObjectBuilder)1 CrateSettings (io.crate.metadata.settings.CrateSettings)1 DataType (io.crate.types.DataType)1 DataTypes (io.crate.types.DataTypes)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Locale (java.util.Locale)1 Function (java.util.function.Function)1 ClusterName (org.elasticsearch.cluster.ClusterName)1 ClusterService (org.elasticsearch.cluster.service.ClusterService)1 Setting (org.elasticsearch.common.settings.Setting)1 Settings (org.elasticsearch.common.settings.Settings)1