use of com.netflix.exhibitor.core.analyze.UsageListing in project exhibitor by soabase.
the class ExplorerResource method usageListing.
@POST
@Path("usage-listing")
@Consumes("application/json")
@Produces("text/plain")
public Response usageListing(UsageListingRequest usageListingRequest) throws Exception {
context.getExhibitor().getLog().add(ActivityLog.Type.INFO, "Starting usage listing");
final UsageListing usageListing = new UsageListing(context.getExhibitor(), usageListingRequest.getStartPath(), usageListingRequest.getMaxChildrenForTraversal());
usageListing.generate();
final PipedInputStream in = new PipedInputStream();
final PipedOutputStream pipedOutputStream = new PipedOutputStream(in);
executorService.submit(new Runnable() {
@Override
public void run() {
PrintStream out = null;
try {
out = new PrintStream(pipedOutputStream);
out.println("Path\tCreateDate\tChildQty\tDeepChildQty");
Iterator<String> iterator = usageListing.getPaths();
while (iterator.hasNext()) {
String path = iterator.next();
UsageListing.NodeEntry details = usageListing.getNodeDetails(path);
out.println(path + "\t" + details.getCreationDate() + "\t" + details.getDirectChildQty() + "\t" + details.getDeepChildQty());
}
} catch (Exception e) {
context.getExhibitor().getLog().add(ActivityLog.Type.ERROR, "Generating usage listing", e);
} finally {
CloseableUtils.closeQuietly(out);
}
}
});
return Response.ok(in).header("content-disposition", "attachment; filename=listing_tab_delimited.txt").build();
}
Aggregations