Renaming FsStats to FsInfo
This commit is contained in:
parent
fbcf4dbbf7
commit
44efbf2770
|
@ -29,7 +29,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.http.HttpStats;
|
||||
import org.elasticsearch.indices.NodeIndicesStats;
|
||||
import org.elasticsearch.indices.breaker.AllCircuitBreakerStats;
|
||||
import org.elasticsearch.monitor.fs.FsStats;
|
||||
import org.elasticsearch.monitor.fs.FsInfo;
|
||||
import org.elasticsearch.monitor.jvm.JvmStats;
|
||||
import org.elasticsearch.monitor.os.OsStats;
|
||||
import org.elasticsearch.monitor.process.ProcessStats;
|
||||
|
@ -62,7 +62,7 @@ public class NodeStats extends BaseNodeResponse implements ToXContent {
|
|||
private ThreadPoolStats threadPool;
|
||||
|
||||
@Nullable
|
||||
private FsStats fs;
|
||||
private FsInfo fs;
|
||||
|
||||
@Nullable
|
||||
private TransportStats transport;
|
||||
|
@ -78,7 +78,7 @@ public class NodeStats extends BaseNodeResponse implements ToXContent {
|
|||
|
||||
public NodeStats(DiscoveryNode node, long timestamp, @Nullable NodeIndicesStats indices,
|
||||
@Nullable OsStats os, @Nullable ProcessStats process, @Nullable JvmStats jvm, @Nullable ThreadPoolStats threadPool,
|
||||
@Nullable FsStats fs, @Nullable TransportStats transport, @Nullable HttpStats http,
|
||||
@Nullable FsInfo fs, @Nullable TransportStats transport, @Nullable HttpStats http,
|
||||
@Nullable AllCircuitBreakerStats breaker) {
|
||||
super(node);
|
||||
this.timestamp = timestamp;
|
||||
|
@ -146,7 +146,7 @@ public class NodeStats extends BaseNodeResponse implements ToXContent {
|
|||
* File system level stats.
|
||||
*/
|
||||
@Nullable
|
||||
public FsStats getFs() {
|
||||
public FsInfo getFs() {
|
||||
return fs;
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ public class NodeStats extends BaseNodeResponse implements ToXContent {
|
|||
threadPool = ThreadPoolStats.readThreadPoolStats(in);
|
||||
}
|
||||
if (in.readBoolean()) {
|
||||
fs = FsStats.readFsStats(in);
|
||||
fs = FsInfo.readFsInfo(in);
|
||||
}
|
||||
if (in.readBoolean()) {
|
||||
transport = TransportStats.readTransportStats(in);
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||
import org.elasticsearch.monitor.fs.FsStats;
|
||||
import org.elasticsearch.monitor.fs.FsInfo;
|
||||
import org.elasticsearch.monitor.jvm.JvmInfo;
|
||||
import org.elasticsearch.monitor.os.OsInfo;
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class ClusterStatsNodes implements ToXContent, Streamable {
|
|||
private OsStats os;
|
||||
private ProcessStats process;
|
||||
private JvmStats jvm;
|
||||
private FsStats.Path fs;
|
||||
private FsInfo.Path fs;
|
||||
private Set<PluginInfo> plugins;
|
||||
|
||||
private ClusterStatsNodes() {
|
||||
|
@ -63,7 +63,7 @@ public class ClusterStatsNodes implements ToXContent, Streamable {
|
|||
this.versions = new HashSet<>();
|
||||
this.os = new OsStats();
|
||||
this.jvm = new JvmStats();
|
||||
this.fs = new FsStats.Path();
|
||||
this.fs = new FsInfo.Path();
|
||||
this.plugins = new HashSet<>();
|
||||
this.process = new ProcessStats();
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class ClusterStatsNodes implements ToXContent, Streamable {
|
|||
return jvm;
|
||||
}
|
||||
|
||||
public FsStats.Path getFs() {
|
||||
public FsInfo.Path getFs() {
|
||||
return fs;
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ public class ClusterStatsNodes implements ToXContent, Streamable {
|
|||
os = OsStats.readOsStats(in);
|
||||
process = ProcessStats.readStats(in);
|
||||
jvm = JvmStats.readJvmStats(in);
|
||||
fs = FsStats.Path.readInfoFrom(in);
|
||||
fs = FsInfo.Path.readInfoFrom(in);
|
||||
|
||||
size = in.readVInt();
|
||||
plugins = new HashSet<>(size);
|
||||
|
|
|
@ -39,7 +39,7 @@ import org.elasticsearch.common.inject.Inject;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
|
||||
import org.elasticsearch.monitor.fs.FsStats;
|
||||
import org.elasticsearch.monitor.fs.FsInfo;
|
||||
import org.elasticsearch.node.settings.NodeSettingsService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.ReceiveTimeoutTransportException;
|
||||
|
@ -320,7 +320,7 @@ public class InternalClusterInfoService extends AbstractComponent implements Clu
|
|||
long available = 0;
|
||||
long total = 0;
|
||||
|
||||
for (FsStats.Path info : nodeStats.getFs()) {
|
||||
for (FsInfo.Path info : nodeStats.getFs()) {
|
||||
available += info.getAvailable().bytes();
|
||||
total += info.getTotal().bytes();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.elasticsearch.index.Index;
|
|||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.index.store.FsDirectoryService;
|
||||
import org.elasticsearch.monitor.fs.FsStats;
|
||||
import org.elasticsearch.monitor.fs.FsInfo;
|
||||
import org.elasticsearch.monitor.fs.FsProbe;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
@ -225,7 +225,7 @@ public class NodeEnvironment extends AbstractComponent implements Closeable {
|
|||
spinsDesc = "no";
|
||||
}
|
||||
|
||||
FsStats.Path fsPath = FsProbe.getFSInfo(nodePath);
|
||||
FsInfo.Path fsPath = FsProbe.getFSInfo(nodePath);
|
||||
sb.append(", free_space [")
|
||||
.append(fsPath.getFree())
|
||||
.append("], usable_space [")
|
||||
|
@ -242,13 +242,12 @@ public class NodeEnvironment extends AbstractComponent implements Closeable {
|
|||
}
|
||||
logger.debug(sb.toString());
|
||||
} else if (logger.isInfoEnabled()) {
|
||||
FsStats.Path totFSPath = new FsStats.Path();
|
||||
FsInfo.Path totFSPath = new FsInfo.Path();
|
||||
Set<String> allTypes = new HashSet<>();
|
||||
Set<String> allSpins = new HashSet<>();
|
||||
Set<String> allMounts = new HashSet<>();
|
||||
for (NodePath nodePath : nodePaths) {
|
||||
// TODO: can/should I use the chosen FsProbe instead (i.e. sigar if it's available)?
|
||||
FsStats.Path fsPath = FsProbe.getFSInfo(nodePath);
|
||||
FsInfo.Path fsPath = FsProbe.getFSInfo(nodePath);
|
||||
String mount = fsPath.getMount();
|
||||
if (allMounts.contains(mount) == false) {
|
||||
allMounts.add(mount);
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.util.HashSet;
|
|||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
public class FsStats implements Iterable<FsStats.Path>, Streamable, ToXContent {
|
||||
public class FsInfo implements Iterable<FsInfo.Path>, Streamable, ToXContent {
|
||||
|
||||
public static class Path implements Streamable, ToXContent {
|
||||
|
||||
|
@ -197,11 +197,11 @@ public class FsStats implements Iterable<FsStats.Path>, Streamable, ToXContent {
|
|||
Path total;
|
||||
Path[] paths;
|
||||
|
||||
FsStats() {
|
||||
FsInfo() {
|
||||
|
||||
}
|
||||
|
||||
public FsStats(long timestamp, Path[] paths) {
|
||||
public FsInfo(long timestamp, Path[] paths) {
|
||||
this.timestamp = timestamp;
|
||||
this.paths = paths;
|
||||
this.total = null;
|
||||
|
@ -238,8 +238,8 @@ public class FsStats implements Iterable<FsStats.Path>, Streamable, ToXContent {
|
|||
return Iterators.forArray(paths);
|
||||
}
|
||||
|
||||
public static FsStats readFsStats(StreamInput in) throws IOException {
|
||||
FsStats stats = new FsStats();
|
||||
public static FsInfo readFsInfo(StreamInput in) throws IOException {
|
||||
FsInfo stats = new FsInfo();
|
||||
stats.readFrom(in);
|
||||
return stats;
|
||||
}
|
|
@ -37,20 +37,20 @@ public class FsProbe extends AbstractComponent {
|
|||
this.nodeEnv = nodeEnv;
|
||||
}
|
||||
|
||||
public FsStats stats() throws IOException {
|
||||
public FsInfo stats() throws IOException {
|
||||
if (!nodeEnv.hasNodeFile()) {
|
||||
return new FsStats(System.currentTimeMillis(), new FsStats.Path[0]);
|
||||
return new FsInfo(System.currentTimeMillis(), new FsInfo.Path[0]);
|
||||
}
|
||||
NodePath[] dataLocations = nodeEnv.nodePaths();
|
||||
FsStats.Path[] paths = new FsStats.Path[dataLocations.length];
|
||||
FsInfo.Path[] paths = new FsInfo.Path[dataLocations.length];
|
||||
for (int i = 0; i < dataLocations.length; i++) {
|
||||
paths[i] = getFSInfo(dataLocations[i]);
|
||||
}
|
||||
return new FsStats(System.currentTimeMillis(), paths);
|
||||
return new FsInfo(System.currentTimeMillis(), paths);
|
||||
}
|
||||
|
||||
public static FsStats.Path getFSInfo(NodePath nodePath) throws IOException {
|
||||
FsStats.Path fsPath = new FsStats.Path();
|
||||
public static FsInfo.Path getFSInfo(NodePath nodePath) throws IOException {
|
||||
FsInfo.Path fsPath = new FsInfo.Path();
|
||||
fsPath.path = nodePath.path.toAbsolutePath().toString();
|
||||
|
||||
// NOTE: we use already cached (on node startup) FileStore and spins
|
||||
|
|
|
@ -33,33 +33,33 @@ public class FsService extends AbstractComponent {
|
|||
|
||||
private final FsProbe probe;
|
||||
|
||||
private final SingleObjectCache<FsStats> fsStatsCache;
|
||||
private final SingleObjectCache<FsInfo> fsStatsCache;
|
||||
|
||||
@Inject
|
||||
public FsService(Settings settings, FsProbe probe) throws IOException {
|
||||
super(settings);
|
||||
this.probe = probe;
|
||||
TimeValue refreshInterval = settings.getAsTime("monitor.fs.refresh_interval", TimeValue.timeValueSeconds(1));
|
||||
fsStatsCache = new FsStatsCache(refreshInterval, probe.stats());
|
||||
fsStatsCache = new FsInfoCache(refreshInterval, probe.stats());
|
||||
logger.debug("Using probe [{}] with refresh_interval [{}]", probe, refreshInterval);
|
||||
}
|
||||
|
||||
public FsStats stats() {
|
||||
public FsInfo stats() {
|
||||
return fsStatsCache.getOrRefresh();
|
||||
}
|
||||
|
||||
private class FsStatsCache extends SingleObjectCache<FsStats> {
|
||||
public FsStatsCache(TimeValue interval, FsStats initValue) {
|
||||
private class FsInfoCache extends SingleObjectCache<FsInfo> {
|
||||
public FsInfoCache(TimeValue interval, FsInfo initValue) {
|
||||
super(interval, initValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FsStats refresh() {
|
||||
protected FsInfo refresh() {
|
||||
try {
|
||||
return probe.stats();
|
||||
} catch (IOException ex) {
|
||||
logger.warn("Failed to fetch fs stats - returning empty instance");
|
||||
return new FsStats();
|
||||
return new FsInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ import org.elasticsearch.index.refresh.RefreshStats;
|
|||
import org.elasticsearch.index.search.stats.SearchStats;
|
||||
import org.elasticsearch.index.suggest.stats.SuggestStats;
|
||||
import org.elasticsearch.indices.NodeIndicesStats;
|
||||
import org.elasticsearch.monitor.fs.FsStats;
|
||||
import org.elasticsearch.monitor.fs.FsInfo;
|
||||
import org.elasticsearch.monitor.jvm.JvmInfo;
|
||||
import org.elasticsearch.monitor.jvm.JvmStats;
|
||||
import org.elasticsearch.monitor.os.OsInfo;
|
||||
|
@ -224,7 +224,7 @@ public class RestNodesAction extends AbstractCatAction {
|
|||
ProcessInfo processInfo = info == null ? null : info.getProcess();
|
||||
|
||||
JvmStats jvmStats = stats == null ? null : stats.getJvm();
|
||||
FsStats fsStats = stats == null ? null : stats.getFs();
|
||||
FsInfo fsInfo = stats == null ? null : stats.getFs();
|
||||
OsStats osStats = stats == null ? null : stats.getOs();
|
||||
ProcessStats processStats = stats == null ? null : stats.getProcess();
|
||||
NodeIndicesStats indicesStats = stats == null ? null : stats.getIndices();
|
||||
|
@ -244,7 +244,7 @@ public class RestNodesAction extends AbstractCatAction {
|
|||
table.addCell(node.getVersion().number());
|
||||
table.addCell(info == null ? null : info.getBuild().hashShort());
|
||||
table.addCell(jvmInfo == null ? null : jvmInfo.version());
|
||||
table.addCell(fsStats == null ? null : fsStats.getTotal().getAvailable());
|
||||
table.addCell(fsInfo == null ? null : fsInfo.getTotal().getAvailable());
|
||||
table.addCell(jvmStats == null ? null : jvmStats.getMem().getHeapUsed());
|
||||
table.addCell(jvmStats == null ? null : jvmStats.getMem().getHeapUsedPercent());
|
||||
table.addCell(jvmInfo == null ? null : jvmInfo.getMem().getHeapMax());
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
|
|||
import org.elasticsearch.cluster.routing.RoutingNode;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.monitor.fs.FsStats;
|
||||
import org.elasticsearch.monitor.fs.FsInfo;
|
||||
import org.elasticsearch.node.settings.NodeSettingsService;
|
||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
@ -141,15 +141,15 @@ public class MockDiskUsagesTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
/** Create a fake NodeStats for the given node and usage */
|
||||
public static NodeStats makeStats(String nodeName, DiskUsage usage) {
|
||||
FsStats.Path[] paths = new FsStats.Path[1];
|
||||
FsStats.Path path = new FsStats.Path("/path.data", null,
|
||||
FsInfo.Path[] paths = new FsInfo.Path[1];
|
||||
FsInfo.Path path = new FsInfo.Path("/path.data", null,
|
||||
usage.getTotalBytes(), usage.getFreeBytes(), usage.getFreeBytes());
|
||||
paths[0] = path;
|
||||
FsStats fsStats = new FsStats(System.currentTimeMillis(), paths);
|
||||
FsInfo fsInfo = new FsInfo(System.currentTimeMillis(), paths);
|
||||
return new NodeStats(new DiscoveryNode(nodeName, null, Version.V_2_0_0),
|
||||
System.currentTimeMillis(),
|
||||
null, null, null, null, null,
|
||||
fsStats,
|
||||
fsInfo,
|
||||
null, null, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ import org.elasticsearch.indices.IndicesService;
|
|||
import org.elasticsearch.indices.recovery.RecoveryFileChunkRequest;
|
||||
import org.elasticsearch.indices.recovery.RecoverySettings;
|
||||
import org.elasticsearch.indices.recovery.RecoveryTarget;
|
||||
import org.elasticsearch.monitor.fs.FsStats;
|
||||
import org.elasticsearch.monitor.fs.FsInfo;
|
||||
import org.elasticsearch.snapshots.SnapshotState;
|
||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||
import org.elasticsearch.test.InternalTestCluster;
|
||||
|
@ -570,7 +570,7 @@ public class CorruptedFileTest extends ElasticsearchIntegrationTest {
|
|||
NodeStats nodeStats = nodeStatses.getNodes()[0];
|
||||
List<Path> files = new ArrayList<>();
|
||||
filesToNodes.put(nodeStats.getNode().getName(), files);
|
||||
for (FsStats.Path info : nodeStats.getFs()) {
|
||||
for (FsInfo.Path info : nodeStats.getFs()) {
|
||||
String path = info.getPath();
|
||||
final String relativeDataLocationPath = "indices/test/" + Integer.toString(shardRouting.getId()) + "/index";
|
||||
Path file = PathUtils.get(path).resolve(relativeDataLocationPath);
|
||||
|
@ -604,7 +604,7 @@ public class CorruptedFileTest extends ElasticsearchIntegrationTest {
|
|||
String nodeId = shardRouting.currentNodeId();
|
||||
NodesStatsResponse nodeStatses = client().admin().cluster().prepareNodesStats(nodeId).setFs(true).get();
|
||||
Set<Path> files = new TreeSet<>(); // treeset makes sure iteration order is deterministic
|
||||
for (FsStats.Path info : nodeStatses.getNodes()[0].getFs()) {
|
||||
for (FsInfo.Path info : nodeStatses.getNodes()[0].getFs()) {
|
||||
String path = info.getPath();
|
||||
final String relativeDataLocationPath = "indices/test/" + Integer.toString(shardRouting.getId()) + "/index";
|
||||
Path file = PathUtils.get(path).resolve(relativeDataLocationPath);
|
||||
|
@ -716,7 +716,7 @@ public class CorruptedFileTest extends ElasticsearchIntegrationTest {
|
|||
|
||||
assertThat(routing.toString(), nodeStatses.getNodes().length, equalTo(1));
|
||||
List<Path> files = new ArrayList<>();
|
||||
for (FsStats.Path info : nodeStatses.getNodes()[0].getFs()) {
|
||||
for (FsInfo.Path info : nodeStatses.getNodes()[0].getFs()) {
|
||||
String path = info.getPath();
|
||||
Path file = PathUtils.get(path).resolve("indices/test/" + Integer.toString(routing.getId()) + "/index");
|
||||
if (Files.exists(file)) { // multi data path might only have one path in use
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.elasticsearch.common.io.PathUtils;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.shard.IndexShard;
|
||||
import org.elasticsearch.index.translog.TranslogConfig;
|
||||
import org.elasticsearch.monitor.fs.FsStats;
|
||||
import org.elasticsearch.monitor.fs.FsInfo;
|
||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||
import org.elasticsearch.test.engine.MockEngineSupport;
|
||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||
|
@ -124,7 +124,7 @@ public class CorruptedTranslogTests extends ElasticsearchIntegrationTest {
|
|||
String nodeId = shardRouting.currentNodeId();
|
||||
NodesStatsResponse nodeStatses = client().admin().cluster().prepareNodesStats(nodeId).setFs(true).get();
|
||||
Set<Path> files = new TreeSet<>(); // treeset makes sure iteration order is deterministic
|
||||
for (FsStats.Path fsPath : nodeStatses.getNodes()[0].getFs()) {
|
||||
for (FsInfo.Path fsPath : nodeStatses.getNodes()[0].getFs()) {
|
||||
String path = fsPath.getPath();
|
||||
final String relativeDataLocationPath = "indices/test/" + Integer.toString(shardRouting.getId()) + "/translog";
|
||||
Path file = PathUtils.get(path).resolve(relativeDataLocationPath);
|
||||
|
|
|
@ -31,21 +31,21 @@ import static org.hamcrest.Matchers.*;
|
|||
public class FsProbeTests extends ElasticsearchTestCase {
|
||||
|
||||
@Test
|
||||
public void testFsStats() throws IOException {
|
||||
public void testFsInfo() throws IOException {
|
||||
try (NodeEnvironment env = newNodeEnvironment()) {
|
||||
FsProbe probe = new FsProbe(Settings.EMPTY, env);
|
||||
|
||||
FsStats stats = probe.stats();
|
||||
FsInfo stats = probe.stats();
|
||||
assertNotNull(stats);
|
||||
assertThat(stats.getTimestamp(), greaterThan(0L));
|
||||
|
||||
FsStats.Path total = stats.getTotal();
|
||||
FsInfo.Path total = stats.getTotal();
|
||||
assertNotNull(total);
|
||||
assertThat(total.total, greaterThan(0L));
|
||||
assertThat(total.free, greaterThan(0L));
|
||||
assertThat(total.available, greaterThan(0L));
|
||||
|
||||
for (FsStats.Path path : stats) {
|
||||
for (FsInfo.Path path : stats) {
|
||||
assertNotNull(path);
|
||||
assertThat(path.getPath(), not(isEmptyOrNullString()));
|
||||
assertThat(path.getMount(), not(isEmptyOrNullString()));
|
||||
|
|
Loading…
Reference in New Issue