use of org.infinispan.commons.util.OS in project infinispan by infinispan.
the class Server method getServerReport.
@Override
public CompletionStage<Path> getServerReport() {
SecurityActions.checkPermission(cacheManager.withSubject(Security.getSubject()), AuthorizationPermission.ADMIN);
OS os = OS.getCurrentOs();
String reportFile = "bin/%s";
switch(os) {
case LINUX:
reportFile = String.format(reportFile, "report.sh");
break;
case MAC_OS:
reportFile = String.format(reportFile, "report-osx.sh");
break;
default:
return CompletableFutures.completedExceptionFuture(log.serverReportUnavailable(os));
}
long pid = ProcessInfo.getInstance().getPid();
Path home = serverHome.toPath();
Path root = serverRoot.toPath();
ProcessBuilder builder = new ProcessBuilder();
builder.command("sh", "-c", home.resolve(reportFile).toString(), Long.toString(pid), root.toString());
return blockingManager.supplyBlocking(() -> {
try {
Process process = builder.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
Path path = Paths.get(reader.readLine());
process.waitFor(1, TimeUnit.MINUTES);
return path;
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}, "report");
}
Aggregations