@RequestMapping(value = "/projects/{projectName}/logs/more", method = RequestMethod.GET)
public void console(final HttpServletResponse response, ModelMap map, @PathVariable String projectName, LogQuery logQuery) throws IOException, ParseException {
Project project = projectService.findProject(projectName);
map.put("project", project);
final MongoConverter converter = project.fetchMongoTemplate().getConverter();
final DBCursor cursor = logsService.findLogs(projectName, logQuery);
final StringBuffer buf = new StringBuffer();
@SuppressWarnings("unchecked")
FutureTask<String> task = new FutureTask(new Callable<String>() {
@Override
public String call() throws Exception {
long startTime = System.currentTimeMillis();
//遍历游标,最长不能超过20秒
logger.debug("游标遍历结果:");
while (cursor.hasNext()) {
Log log = converter.read(Log.class, cursor.next());
buf.insert(0, log.toString() + "\n");
long current = System.currentTimeMillis();
if ((current - startTime) / 1000 >= mongWaitSeconds) break;
}