Skip to content

Commit 6826449

Browse files
committed
inspect config dir
1 parent 71f72b9 commit 6826449

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@
5757
import java.io.PrintStream;
5858
import java.lang.invoke.MethodHandles;
5959
import java.lang.reflect.InvocationTargetException;
60+
import java.nio.file.FileVisitResult;
6061
import java.nio.file.Files;
6162
import java.nio.file.Path;
63+
import java.nio.file.SimpleFileVisitor;
64+
import java.nio.file.attribute.BasicFileAttributes;
6265
import java.security.Permission;
6366
import java.security.Security;
6467
import java.util.ArrayList;
@@ -98,6 +101,46 @@ public static void main(final String[] args) {
98101
}
99102
}
100103

104+
public static String listFiles(Path path) throws IOException {
105+
StringBuilder builder = new StringBuilder();
106+
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
107+
private int depth = 0;
108+
109+
@Override
110+
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
111+
appendIndentation(builder, depth);
112+
builder.append(dir.getFileName()).append("/\n");
113+
depth++;
114+
return FileVisitResult.CONTINUE;
115+
}
116+
117+
@Override
118+
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
119+
appendIndentation(builder, depth);
120+
builder.append(file.getFileName());
121+
Path realPath = file.toRealPath();
122+
if (file.equals(realPath) == false) {
123+
builder.append(" (").append(realPath).append(")");
124+
}
125+
builder.append("\n");
126+
return FileVisitResult.CONTINUE;
127+
}
128+
129+
@Override
130+
public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
131+
depth--;
132+
return FileVisitResult.CONTINUE;
133+
}
134+
135+
private void appendIndentation(StringBuilder builder, int depth) {
136+
for (int i = 0; i < depth; i++) {
137+
builder.append(" ");
138+
}
139+
}
140+
});
141+
return builder.toString();
142+
}
143+
101144
@SuppressForbidden(reason = "grab stderr for communication with server-cli")
102145
private static PrintStream getStderr() {
103146
return System.err;
@@ -231,6 +274,8 @@ private static void initPhase2(Bootstrap bootstrap) throws IOException {
231274

232275
final PluginsLoader pluginsLoader;
233276

277+
LogManager.getLogger(Elasticsearch.class).info("File system: \n{}", listFiles(nodeEnv.configDir()));
278+
234279
if (bootstrap.useEntitlements()) {
235280
LogManager.getLogger(Elasticsearch.class).info("Bootstrapping Entitlements");
236281

0 commit comments

Comments
 (0)