use of com.netflix.exhibitor.core.entities.Index in project exhibitor by soabase.
the class IndexResource method getIndexedLogs.
@Path("indexed-logs")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getIndexedLogs() {
final DateFormat format = new SimpleDateFormat("MM/dd/yyyy-HH:mm");
final IndexCache indexCache = context.getExhibitor().getIndexCache();
IndexList indexList = new IndexList(new File(context.getExhibitor().getConfigManager().getConfig().getString(StringConfigs.LOG_INDEX_DIRECTORY)));
GenericEntity<List<Index>> entity = new GenericEntity<List<Index>>(Lists.transform(indexList.getIndexes(), new Function<File, Index>() {
@Override
public Index apply(File f) {
IndexMetaData metaData;
try {
metaData = indexCache.getMetaData(f);
} catch (Exception e) {
context.getExhibitor().getLog().add(ActivityLog.Type.ERROR, "Loading index metadata: " + f, e);
metaData = new IndexMetaData(new Date(), new Date(), 0);
}
return new Index(f.getName(), format.format(metaData.getFrom()), format.format(metaData.getTo()), metaData.getEntryCount());
}
})) {
};
return Response.ok(entity).build();
}
Aggregations