use of io.crate.metadata.SystemTable 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();
}
Aggregations