|
57 | 57 | import java.io.PrintStream; |
58 | 58 | import java.lang.invoke.MethodHandles; |
59 | 59 | import java.lang.reflect.InvocationTargetException; |
| 60 | +import java.nio.file.FileVisitResult; |
60 | 61 | import java.nio.file.Files; |
61 | 62 | import java.nio.file.Path; |
| 63 | +import java.nio.file.SimpleFileVisitor; |
| 64 | +import java.nio.file.attribute.BasicFileAttributes; |
62 | 65 | import java.security.Permission; |
63 | 66 | import java.security.Security; |
64 | 67 | import java.util.ArrayList; |
@@ -98,6 +101,46 @@ public static void main(final String[] args) { |
98 | 101 | } |
99 | 102 | } |
100 | 103 |
|
| 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 | + |
101 | 144 | @SuppressForbidden(reason = "grab stderr for communication with server-cli") |
102 | 145 | private static PrintStream getStderr() { |
103 | 146 | return System.err; |
@@ -231,6 +274,8 @@ private static void initPhase2(Bootstrap bootstrap) throws IOException { |
231 | 274 |
|
232 | 275 | final PluginsLoader pluginsLoader; |
233 | 276 |
|
| 277 | + LogManager.getLogger(Elasticsearch.class).info("File system: \n{}", listFiles(nodeEnv.configDir())); |
| 278 | + |
234 | 279 | if (bootstrap.useEntitlements()) { |
235 | 280 | LogManager.getLogger(Elasticsearch.class).info("Bootstrapping Entitlements"); |
236 | 281 |
|
|
0 commit comments