2011-08-20 21:37:37 +03:00
|
|
|
/*
|
2011-12-06 02:42:25 +02:00
|
|
|
* Licensed to ElasticSearch and Shay Banon under one
|
2011-08-20 21:37:37 +03:00
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
2011-12-06 02:42:25 +02:00
|
|
|
* regarding copyright ownership. ElasticSearch licenses this
|
2011-08-20 21:37:37 +03:00
|
|
|
* file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.elasticsearch.node.service;
|
|
|
|
|
2011-12-06 02:42:25 +02:00
|
|
|
import com.google.common.collect.ImmutableMap;
|
2012-12-06 15:22:44 +01:00
|
|
|
import org.elasticsearch.Version;
|
2011-08-20 21:37:37 +03:00
|
|
|
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
|
|
|
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
|
2013-04-07 20:22:48 -07:00
|
|
|
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
|
2011-08-20 21:37:37 +03:00
|
|
|
import org.elasticsearch.cluster.ClusterService;
|
|
|
|
import org.elasticsearch.common.Nullable;
|
|
|
|
import org.elasticsearch.common.collect.MapBuilder;
|
|
|
|
import org.elasticsearch.common.component.AbstractComponent;
|
|
|
|
import org.elasticsearch.common.inject.Inject;
|
2011-10-31 14:50:18 +01:00
|
|
|
import org.elasticsearch.common.network.NetworkUtils;
|
2011-08-20 21:37:37 +03:00
|
|
|
import org.elasticsearch.common.settings.Settings;
|
2011-12-12 20:22:19 +02:00
|
|
|
import org.elasticsearch.discovery.Discovery;
|
2011-08-20 21:37:37 +03:00
|
|
|
import org.elasticsearch.http.HttpServer;
|
|
|
|
import org.elasticsearch.indices.IndicesService;
|
|
|
|
import org.elasticsearch.monitor.MonitorService;
|
List of existing plugins with Node Info API
We want to display information about loaded plugins in Node Info API using plugin option:
```sh
curl http://localhost:9200/_nodes?plugin=true
```
For example, on a 4 nodes cluster, it could provide the following output:
```javascript
{
"ok" : true,
"cluster_name" : "test-cluster-MacBook-Air-de-David.local",
"nodes" : {
"lodYfbFTRnmwE6rjWGGyQQ" : {
"name" : "node1",
"transport_address" : "inet[/172.18.58.139:9300]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9200]",
"plugins" : [ ]
},
"hJLXmY_NTrCytiIMbX4_1g" : {
"name" : "node4",
"transport_address" : "inet[/172.18.58.139:9303]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9203]",
"plugins" : [ {
"name" : "test-plugin",
"description" : "test-plugin description",
"site" : true,
"jvm" : false
}, {
"name" : "test-no-version-plugin",
"description" : "test-no-version-plugin description",
"site" : true,
"jvm" : false
}, {
"name" : "dummy",
"description" : "No description found for dummy.",
"url" : "/_plugin/dummy/",
"site" : false,
"jvm" : true
} ]
},
"bnoySsBfTrSzbDRZ0BFHvg" : {
"name" : "node2",
"transport_address" : "inet[/172.18.58.139:9301]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9201]",
"plugins" : [ {
"name" : "dummy",
"description" : "This is a description for a dummy test site plugin.",
"url" : "/_plugin/dummy/",
"site" : false,
"jvm" : true
} ]
},
"0Vwil01LSfK9YgRrMce3Ug" : {
"name" : "node3",
"transport_address" : "inet[/172.18.58.139:9302]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9202]",
"plugins" : [ {
"name" : "test-plugin",
"description" : "test-plugin description",
"site" : true,
"jvm" : false
} ]
}
}
}
```
Information are cached for 10 seconds by default. Modify `plugins.info_refresh_interval` property if needed.
Setting `plugins.info_refresh_interval` to `-1` will cause infinite caching.
Setting `plugins.info_refresh_interval` to `0` will disable caching.
Closes #2668.
2013-03-15 19:28:01 +01:00
|
|
|
import org.elasticsearch.plugins.PluginsService;
|
2012-01-10 17:45:10 +02:00
|
|
|
import org.elasticsearch.threadpool.ThreadPool;
|
2011-08-20 21:37:37 +03:00
|
|
|
import org.elasticsearch.transport.TransportService;
|
|
|
|
|
2012-01-09 15:24:17 +02:00
|
|
|
import java.net.InetAddress;
|
|
|
|
|
2011-08-20 21:37:37 +03:00
|
|
|
/**
|
|
|
|
*/
|
|
|
|
public class NodeService extends AbstractComponent {
|
|
|
|
|
2012-01-10 17:45:10 +02:00
|
|
|
private final ThreadPool threadPool;
|
|
|
|
|
2011-08-20 21:37:37 +03:00
|
|
|
private final MonitorService monitorService;
|
|
|
|
|
|
|
|
private final ClusterService clusterService;
|
|
|
|
|
|
|
|
private final TransportService transportService;
|
|
|
|
|
|
|
|
private final IndicesService indicesService;
|
|
|
|
|
List of existing plugins with Node Info API
We want to display information about loaded plugins in Node Info API using plugin option:
```sh
curl http://localhost:9200/_nodes?plugin=true
```
For example, on a 4 nodes cluster, it could provide the following output:
```javascript
{
"ok" : true,
"cluster_name" : "test-cluster-MacBook-Air-de-David.local",
"nodes" : {
"lodYfbFTRnmwE6rjWGGyQQ" : {
"name" : "node1",
"transport_address" : "inet[/172.18.58.139:9300]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9200]",
"plugins" : [ ]
},
"hJLXmY_NTrCytiIMbX4_1g" : {
"name" : "node4",
"transport_address" : "inet[/172.18.58.139:9303]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9203]",
"plugins" : [ {
"name" : "test-plugin",
"description" : "test-plugin description",
"site" : true,
"jvm" : false
}, {
"name" : "test-no-version-plugin",
"description" : "test-no-version-plugin description",
"site" : true,
"jvm" : false
}, {
"name" : "dummy",
"description" : "No description found for dummy.",
"url" : "/_plugin/dummy/",
"site" : false,
"jvm" : true
} ]
},
"bnoySsBfTrSzbDRZ0BFHvg" : {
"name" : "node2",
"transport_address" : "inet[/172.18.58.139:9301]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9201]",
"plugins" : [ {
"name" : "dummy",
"description" : "This is a description for a dummy test site plugin.",
"url" : "/_plugin/dummy/",
"site" : false,
"jvm" : true
} ]
},
"0Vwil01LSfK9YgRrMce3Ug" : {
"name" : "node3",
"transport_address" : "inet[/172.18.58.139:9302]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9202]",
"plugins" : [ {
"name" : "test-plugin",
"description" : "test-plugin description",
"site" : true,
"jvm" : false
} ]
}
}
}
```
Information are cached for 10 seconds by default. Modify `plugins.info_refresh_interval` property if needed.
Setting `plugins.info_refresh_interval` to `-1` will cause infinite caching.
Setting `plugins.info_refresh_interval` to `0` will disable caching.
Closes #2668.
2013-03-15 19:28:01 +01:00
|
|
|
private final PluginsService pluginService;
|
|
|
|
|
2011-12-06 02:42:25 +02:00
|
|
|
@Nullable
|
|
|
|
private HttpServer httpServer;
|
2011-08-20 21:37:37 +03:00
|
|
|
|
2011-12-11 18:54:07 +02:00
|
|
|
private volatile ImmutableMap<String, String> serviceAttributes = ImmutableMap.of();
|
2011-08-20 21:37:37 +03:00
|
|
|
|
2011-10-31 14:50:18 +01:00
|
|
|
@Nullable
|
|
|
|
private String hostname;
|
|
|
|
|
2012-12-06 15:37:03 +01:00
|
|
|
private final Version version;
|
2012-12-06 15:22:44 +01:00
|
|
|
|
2011-12-06 02:42:25 +02:00
|
|
|
@Inject
|
List of existing plugins with Node Info API
We want to display information about loaded plugins in Node Info API using plugin option:
```sh
curl http://localhost:9200/_nodes?plugin=true
```
For example, on a 4 nodes cluster, it could provide the following output:
```javascript
{
"ok" : true,
"cluster_name" : "test-cluster-MacBook-Air-de-David.local",
"nodes" : {
"lodYfbFTRnmwE6rjWGGyQQ" : {
"name" : "node1",
"transport_address" : "inet[/172.18.58.139:9300]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9200]",
"plugins" : [ ]
},
"hJLXmY_NTrCytiIMbX4_1g" : {
"name" : "node4",
"transport_address" : "inet[/172.18.58.139:9303]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9203]",
"plugins" : [ {
"name" : "test-plugin",
"description" : "test-plugin description",
"site" : true,
"jvm" : false
}, {
"name" : "test-no-version-plugin",
"description" : "test-no-version-plugin description",
"site" : true,
"jvm" : false
}, {
"name" : "dummy",
"description" : "No description found for dummy.",
"url" : "/_plugin/dummy/",
"site" : false,
"jvm" : true
} ]
},
"bnoySsBfTrSzbDRZ0BFHvg" : {
"name" : "node2",
"transport_address" : "inet[/172.18.58.139:9301]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9201]",
"plugins" : [ {
"name" : "dummy",
"description" : "This is a description for a dummy test site plugin.",
"url" : "/_plugin/dummy/",
"site" : false,
"jvm" : true
} ]
},
"0Vwil01LSfK9YgRrMce3Ug" : {
"name" : "node3",
"transport_address" : "inet[/172.18.58.139:9302]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9202]",
"plugins" : [ {
"name" : "test-plugin",
"description" : "test-plugin description",
"site" : true,
"jvm" : false
} ]
}
}
}
```
Information are cached for 10 seconds by default. Modify `plugins.info_refresh_interval` property if needed.
Setting `plugins.info_refresh_interval` to `-1` will cause infinite caching.
Setting `plugins.info_refresh_interval` to `0` will disable caching.
Closes #2668.
2013-03-15 19:28:01 +01:00
|
|
|
public NodeService(Settings settings, ThreadPool threadPool, MonitorService monitorService, Discovery discovery,
|
|
|
|
ClusterService clusterService, TransportService transportService, IndicesService indicesService,
|
|
|
|
PluginsService pluginService) {
|
2011-08-20 21:37:37 +03:00
|
|
|
super(settings);
|
2012-01-10 17:45:10 +02:00
|
|
|
this.threadPool = threadPool;
|
2011-08-20 21:37:37 +03:00
|
|
|
this.monitorService = monitorService;
|
|
|
|
this.clusterService = clusterService;
|
|
|
|
this.transportService = transportService;
|
|
|
|
this.indicesService = indicesService;
|
2011-12-12 20:22:19 +02:00
|
|
|
discovery.setNodeService(this);
|
2011-10-31 14:50:18 +01:00
|
|
|
InetAddress address = NetworkUtils.getLocalAddress();
|
|
|
|
if (address != null) {
|
|
|
|
this.hostname = address.getHostName();
|
|
|
|
}
|
2012-12-06 15:37:03 +01:00
|
|
|
this.version = Version.CURRENT;
|
List of existing plugins with Node Info API
We want to display information about loaded plugins in Node Info API using plugin option:
```sh
curl http://localhost:9200/_nodes?plugin=true
```
For example, on a 4 nodes cluster, it could provide the following output:
```javascript
{
"ok" : true,
"cluster_name" : "test-cluster-MacBook-Air-de-David.local",
"nodes" : {
"lodYfbFTRnmwE6rjWGGyQQ" : {
"name" : "node1",
"transport_address" : "inet[/172.18.58.139:9300]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9200]",
"plugins" : [ ]
},
"hJLXmY_NTrCytiIMbX4_1g" : {
"name" : "node4",
"transport_address" : "inet[/172.18.58.139:9303]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9203]",
"plugins" : [ {
"name" : "test-plugin",
"description" : "test-plugin description",
"site" : true,
"jvm" : false
}, {
"name" : "test-no-version-plugin",
"description" : "test-no-version-plugin description",
"site" : true,
"jvm" : false
}, {
"name" : "dummy",
"description" : "No description found for dummy.",
"url" : "/_plugin/dummy/",
"site" : false,
"jvm" : true
} ]
},
"bnoySsBfTrSzbDRZ0BFHvg" : {
"name" : "node2",
"transport_address" : "inet[/172.18.58.139:9301]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9201]",
"plugins" : [ {
"name" : "dummy",
"description" : "This is a description for a dummy test site plugin.",
"url" : "/_plugin/dummy/",
"site" : false,
"jvm" : true
} ]
},
"0Vwil01LSfK9YgRrMce3Ug" : {
"name" : "node3",
"transport_address" : "inet[/172.18.58.139:9302]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9202]",
"plugins" : [ {
"name" : "test-plugin",
"description" : "test-plugin description",
"site" : true,
"jvm" : false
} ]
}
}
}
```
Information are cached for 10 seconds by default. Modify `plugins.info_refresh_interval` property if needed.
Setting `plugins.info_refresh_interval` to `-1` will cause infinite caching.
Setting `plugins.info_refresh_interval` to `0` will disable caching.
Closes #2668.
2013-03-15 19:28:01 +01:00
|
|
|
this.pluginService = pluginService;
|
2011-08-20 21:37:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setHttpServer(@Nullable HttpServer httpServer) {
|
|
|
|
this.httpServer = httpServer;
|
|
|
|
}
|
|
|
|
|
2011-12-11 18:54:07 +02:00
|
|
|
@Deprecated
|
|
|
|
public void putNodeAttribute(String key, String value) {
|
|
|
|
putAttribute(key, value);
|
2011-08-20 21:37:37 +03:00
|
|
|
}
|
|
|
|
|
2011-12-11 18:54:07 +02:00
|
|
|
@Deprecated
|
|
|
|
public void removeNodeAttribute(String key) {
|
|
|
|
removeAttribute(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void putAttribute(String key, String value) {
|
2012-05-20 19:50:47 +02:00
|
|
|
serviceAttributes = new MapBuilder<String, String>(serviceAttributes).put(key, value).immutableMap();
|
2011-12-11 18:54:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void removeAttribute(String key) {
|
2012-05-20 19:50:47 +02:00
|
|
|
serviceAttributes = new MapBuilder<String, String>(serviceAttributes).remove(key).immutableMap();
|
2011-12-11 18:54:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attributes different services in the node can add to be reported as part of the node info (for example).
|
|
|
|
*/
|
|
|
|
public ImmutableMap<String, String> attributes() {
|
|
|
|
return this.serviceAttributes;
|
2011-08-20 21:37:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public NodeInfo info() {
|
2012-12-06 15:22:44 +01:00
|
|
|
return new NodeInfo(hostname, version, clusterService.state().nodes().localNode(), serviceAttributes,
|
2012-01-10 17:45:10 +02:00
|
|
|
settings,
|
|
|
|
monitorService.osService().info(),
|
|
|
|
monitorService.processService().info(),
|
|
|
|
monitorService.jvmService().info(),
|
|
|
|
threadPool.info(),
|
|
|
|
monitorService.networkService().info(),
|
|
|
|
transportService.info(),
|
List of existing plugins with Node Info API
We want to display information about loaded plugins in Node Info API using plugin option:
```sh
curl http://localhost:9200/_nodes?plugin=true
```
For example, on a 4 nodes cluster, it could provide the following output:
```javascript
{
"ok" : true,
"cluster_name" : "test-cluster-MacBook-Air-de-David.local",
"nodes" : {
"lodYfbFTRnmwE6rjWGGyQQ" : {
"name" : "node1",
"transport_address" : "inet[/172.18.58.139:9300]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9200]",
"plugins" : [ ]
},
"hJLXmY_NTrCytiIMbX4_1g" : {
"name" : "node4",
"transport_address" : "inet[/172.18.58.139:9303]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9203]",
"plugins" : [ {
"name" : "test-plugin",
"description" : "test-plugin description",
"site" : true,
"jvm" : false
}, {
"name" : "test-no-version-plugin",
"description" : "test-no-version-plugin description",
"site" : true,
"jvm" : false
}, {
"name" : "dummy",
"description" : "No description found for dummy.",
"url" : "/_plugin/dummy/",
"site" : false,
"jvm" : true
} ]
},
"bnoySsBfTrSzbDRZ0BFHvg" : {
"name" : "node2",
"transport_address" : "inet[/172.18.58.139:9301]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9201]",
"plugins" : [ {
"name" : "dummy",
"description" : "This is a description for a dummy test site plugin.",
"url" : "/_plugin/dummy/",
"site" : false,
"jvm" : true
} ]
},
"0Vwil01LSfK9YgRrMce3Ug" : {
"name" : "node3",
"transport_address" : "inet[/172.18.58.139:9302]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9202]",
"plugins" : [ {
"name" : "test-plugin",
"description" : "test-plugin description",
"site" : true,
"jvm" : false
} ]
}
}
}
```
Information are cached for 10 seconds by default. Modify `plugins.info_refresh_interval` property if needed.
Setting `plugins.info_refresh_interval` to `-1` will cause infinite caching.
Setting `plugins.info_refresh_interval` to `0` will disable caching.
Closes #2668.
2013-03-15 19:28:01 +01:00
|
|
|
httpServer == null ? null : httpServer.info(),
|
|
|
|
pluginService == null ? null : pluginService.info()
|
2012-01-10 17:45:10 +02:00
|
|
|
);
|
2011-08-20 21:37:37 +03:00
|
|
|
}
|
|
|
|
|
List of existing plugins with Node Info API
We want to display information about loaded plugins in Node Info API using plugin option:
```sh
curl http://localhost:9200/_nodes?plugin=true
```
For example, on a 4 nodes cluster, it could provide the following output:
```javascript
{
"ok" : true,
"cluster_name" : "test-cluster-MacBook-Air-de-David.local",
"nodes" : {
"lodYfbFTRnmwE6rjWGGyQQ" : {
"name" : "node1",
"transport_address" : "inet[/172.18.58.139:9300]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9200]",
"plugins" : [ ]
},
"hJLXmY_NTrCytiIMbX4_1g" : {
"name" : "node4",
"transport_address" : "inet[/172.18.58.139:9303]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9203]",
"plugins" : [ {
"name" : "test-plugin",
"description" : "test-plugin description",
"site" : true,
"jvm" : false
}, {
"name" : "test-no-version-plugin",
"description" : "test-no-version-plugin description",
"site" : true,
"jvm" : false
}, {
"name" : "dummy",
"description" : "No description found for dummy.",
"url" : "/_plugin/dummy/",
"site" : false,
"jvm" : true
} ]
},
"bnoySsBfTrSzbDRZ0BFHvg" : {
"name" : "node2",
"transport_address" : "inet[/172.18.58.139:9301]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9201]",
"plugins" : [ {
"name" : "dummy",
"description" : "This is a description for a dummy test site plugin.",
"url" : "/_plugin/dummy/",
"site" : false,
"jvm" : true
} ]
},
"0Vwil01LSfK9YgRrMce3Ug" : {
"name" : "node3",
"transport_address" : "inet[/172.18.58.139:9302]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9202]",
"plugins" : [ {
"name" : "test-plugin",
"description" : "test-plugin description",
"site" : true,
"jvm" : false
} ]
}
}
}
```
Information are cached for 10 seconds by default. Modify `plugins.info_refresh_interval` property if needed.
Setting `plugins.info_refresh_interval` to `-1` will cause infinite caching.
Setting `plugins.info_refresh_interval` to `0` will disable caching.
Closes #2668.
2013-03-15 19:28:01 +01:00
|
|
|
public NodeInfo info(boolean settings, boolean os, boolean process, boolean jvm, boolean threadPool,
|
|
|
|
boolean network, boolean transport, boolean http, boolean plugin) {
|
2012-12-06 15:22:44 +01:00
|
|
|
return new NodeInfo(hostname, version, clusterService.state().nodes().localNode(), serviceAttributes,
|
2012-01-09 15:24:17 +02:00
|
|
|
settings ? this.settings : null,
|
|
|
|
os ? monitorService.osService().info() : null,
|
|
|
|
process ? monitorService.processService().info() : null,
|
|
|
|
jvm ? monitorService.jvmService().info() : null,
|
2012-01-10 17:45:10 +02:00
|
|
|
threadPool ? this.threadPool.info() : null,
|
2012-01-09 15:24:17 +02:00
|
|
|
network ? monitorService.networkService().info() : null,
|
|
|
|
transport ? transportService.info() : null,
|
List of existing plugins with Node Info API
We want to display information about loaded plugins in Node Info API using plugin option:
```sh
curl http://localhost:9200/_nodes?plugin=true
```
For example, on a 4 nodes cluster, it could provide the following output:
```javascript
{
"ok" : true,
"cluster_name" : "test-cluster-MacBook-Air-de-David.local",
"nodes" : {
"lodYfbFTRnmwE6rjWGGyQQ" : {
"name" : "node1",
"transport_address" : "inet[/172.18.58.139:9300]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9200]",
"plugins" : [ ]
},
"hJLXmY_NTrCytiIMbX4_1g" : {
"name" : "node4",
"transport_address" : "inet[/172.18.58.139:9303]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9203]",
"plugins" : [ {
"name" : "test-plugin",
"description" : "test-plugin description",
"site" : true,
"jvm" : false
}, {
"name" : "test-no-version-plugin",
"description" : "test-no-version-plugin description",
"site" : true,
"jvm" : false
}, {
"name" : "dummy",
"description" : "No description found for dummy.",
"url" : "/_plugin/dummy/",
"site" : false,
"jvm" : true
} ]
},
"bnoySsBfTrSzbDRZ0BFHvg" : {
"name" : "node2",
"transport_address" : "inet[/172.18.58.139:9301]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9201]",
"plugins" : [ {
"name" : "dummy",
"description" : "This is a description for a dummy test site plugin.",
"url" : "/_plugin/dummy/",
"site" : false,
"jvm" : true
} ]
},
"0Vwil01LSfK9YgRrMce3Ug" : {
"name" : "node3",
"transport_address" : "inet[/172.18.58.139:9302]",
"hostname" : "MacBook-Air-de-David.local",
"version" : "0.90.0.Beta2-SNAPSHOT",
"http_address" : "inet[/172.18.58.139:9202]",
"plugins" : [ {
"name" : "test-plugin",
"description" : "test-plugin description",
"site" : true,
"jvm" : false
} ]
}
}
}
```
Information are cached for 10 seconds by default. Modify `plugins.info_refresh_interval` property if needed.
Setting `plugins.info_refresh_interval` to `-1` will cause infinite caching.
Setting `plugins.info_refresh_interval` to `0` will disable caching.
Closes #2668.
2013-03-15 19:28:01 +01:00
|
|
|
http ? (httpServer == null ? null : httpServer.info()) : null,
|
|
|
|
plugin ? (pluginService == null ? null : pluginService.info()) : null
|
2012-01-09 15:24:17 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-08-20 21:37:37 +03:00
|
|
|
public NodeStats stats() {
|
2011-08-25 20:20:14 +03:00
|
|
|
// for indices stats we want to include previous allocated shards stats as well (it will
|
|
|
|
// only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats)
|
2012-04-11 12:20:21 +03:00
|
|
|
return new NodeStats(clusterService.state().nodes().localNode(), System.currentTimeMillis(), hostname,
|
2012-01-10 17:45:10 +02:00
|
|
|
indicesService.stats(true),
|
|
|
|
monitorService.osService().stats(),
|
|
|
|
monitorService.processService().stats(),
|
|
|
|
monitorService.jvmService().stats(),
|
|
|
|
threadPool.stats(),
|
|
|
|
monitorService.networkService().stats(),
|
2012-01-18 21:00:09 +02:00
|
|
|
monitorService.fsService().stats(),
|
2012-01-10 17:45:10 +02:00
|
|
|
transportService.stats(),
|
|
|
|
httpServer == null ? null : httpServer.stats()
|
|
|
|
);
|
2011-08-20 21:37:37 +03:00
|
|
|
}
|
2012-01-09 18:01:41 +02:00
|
|
|
|
2013-04-07 20:22:48 -07:00
|
|
|
public NodeStats stats(CommonStatsFlags indices, boolean os, boolean process, boolean jvm, boolean threadPool, boolean network, boolean fs, boolean transport, boolean http) {
|
2012-01-09 18:01:41 +02:00
|
|
|
// for indices stats we want to include previous allocated shards stats as well (it will
|
|
|
|
// only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats)
|
2012-04-11 12:20:21 +03:00
|
|
|
return new NodeStats(clusterService.state().nodes().localNode(), System.currentTimeMillis(), hostname,
|
2013-04-07 20:22:48 -07:00
|
|
|
indices.anySet() ? indicesService.stats(true, indices) : null,
|
2012-01-09 18:01:41 +02:00
|
|
|
os ? monitorService.osService().stats() : null,
|
|
|
|
process ? monitorService.processService().stats() : null,
|
|
|
|
jvm ? monitorService.jvmService().stats() : null,
|
2012-01-10 17:45:10 +02:00
|
|
|
threadPool ? this.threadPool.stats() : null,
|
2012-01-09 18:01:41 +02:00
|
|
|
network ? monitorService.networkService().stats() : null,
|
2012-01-18 21:00:09 +02:00
|
|
|
fs ? monitorService.fsService().stats() : null,
|
2012-01-09 18:01:41 +02:00
|
|
|
transport ? transportService.stats() : null,
|
2012-01-10 17:45:10 +02:00
|
|
|
http ? (httpServer == null ? null : httpServer.stats()) : null
|
|
|
|
);
|
2012-01-09 18:01:41 +02:00
|
|
|
}
|
2011-08-20 21:37:37 +03:00
|
|
|
}
|