Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions core/src/main/java/org/elasticsearch/env/ESFileStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.nio.file.attribute.FileAttributeView;
import java.nio.file.attribute.FileStoreAttributeView;
import java.util.Arrays;
import java.util.List;

/**
* Implementation of FileStore that supports
Expand All @@ -44,6 +45,8 @@ class ESFileStore extends FileStore {
final FileStore in;
/** Cached result of Lucene's {@code IOUtils.spins} on path. */
final Boolean spins;
int majorDeviceNumber;
int minorDeviceNumber;

@SuppressForbidden(reason = "tries to determine if disk is spinning")
// TODO: move PathUtils to be package-private here instead of
Expand All @@ -58,6 +61,21 @@ class ESFileStore extends FileStore {
} catch (Exception e) {
spins = null;
}
try {
final List<String> lines = Files.readAllLines(PathUtils.get("/proc/self/mountinfo"));
for (final String line : lines) {
final String[] fields = line.trim().split("\\s+");
final String mountPoint = fields[4];
if (mountPoint.equals(getMountPointLinux(in))) {
final String[] deviceNumbers = fields[2].split(":");
majorDeviceNumber = Integer.parseInt(deviceNumbers[0]);
minorDeviceNumber = Integer.parseInt(deviceNumbers[1]);
}
}
} catch (Exception e) {
majorDeviceNumber = -1;
minorDeviceNumber = -1;
}
} else {
spins = null;
}
Expand Down Expand Up @@ -229,10 +247,13 @@ public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> t

@Override
public Object getAttribute(String attribute) throws IOException {
if ("lucene:spins".equals(attribute)) {
return spins;
} else {
return in.getAttribute(attribute);
switch(attribute) {
// for the device
case "lucene:spins": return spins;
// for the partition
case "lucene:major_device_number": return majorDeviceNumber;
case "lucene:minor_device_number": return minorDeviceNumber;
default: return in.getAttribute(attribute);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Semaphore;
Expand All @@ -88,14 +87,21 @@ public static class NodePath {
* not running on Linux, or we hit an exception trying), True means the device possibly spins and False means it does not. */
public final Boolean spins;

public final int majorDeviceNumber;
public final int minorDeviceNumber;

public NodePath(Path path) throws IOException {
this.path = path;
this.indicesPath = path.resolve(INDICES_FOLDER);
this.fileStore = Environment.getFileStore(path);
if (fileStore.supportsFileAttributeView("lucene")) {
this.spins = (Boolean) fileStore.getAttribute("lucene:spins");
this.majorDeviceNumber = (int) fileStore.getAttribute("lucene:major_device_number");
this.minorDeviceNumber = (int) fileStore.getAttribute("lucene:minor_device_number");
} else {
this.spins = null;
this.majorDeviceNumber = -1;
this.minorDeviceNumber = -1;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,12 @@

import java.io.IOException;

/**
*
*/
public class MonitorService extends AbstractLifecycleComponent<MonitorService> {

private final JvmGcMonitorService jvmGcMonitorService;

private final OsService osService;

private final ProcessService processService;

private final JvmService jvmService;

private final FsService fsService;

public MonitorService(Settings settings, NodeEnvironment nodeEnvironment, ThreadPool threadPool) throws IOException {
Expand Down Expand Up @@ -85,4 +78,5 @@ protected void doStop() {
protected void doClose() {
jvmGcMonitorService.close();
}

}
Loading