imdg http://git.mfd.msk/mfd/clearing/-/issues/22 debug reload
This commit is contained in:
parent
91cc82f154
commit
be311962cb
1 changed files with 25 additions and 19 deletions
|
|
@ -69,38 +69,44 @@ public class ImdgController implements InitializingBean, DisposableBean {
|
||||||
public void handle(HttpExchange t) throws IOException {
|
public void handle(HttpExchange t) throws IOException {
|
||||||
log.info("Reload request by user \"{}\"", t.getRemoteAddress().getAddress());
|
log.info("Reload request by user \"{}\"", t.getRemoteAddress().getAddress());
|
||||||
t.sendResponseHeaders(200, 0);
|
t.sendResponseHeaders(200, 0);
|
||||||
t.setAttribute("Content-Type", "text/plain; charset=utf-8"); // or "text/html; charset=utf-8"
|
t.setAttribute("Content-Type", "text/html; charset=windows-1251"); // or "text/plain или text/html; charset=windows-1251"
|
||||||
try (OutputStream os = t.getResponseBody()) {
|
try (OutputStream os = t.getResponseBody()) {
|
||||||
// writeHead(os);
|
writeHead(os);
|
||||||
writeLine(os, "Wait, reload all maps from DB... " + LocalDateTime.now());
|
writeLine(os, "Wait, reload all maps from DB... </br>");
|
||||||
os.flush();
|
synchronized (ImdgController.this) {
|
||||||
try {
|
os.flush();
|
||||||
long clock = System.currentTimeMillis();
|
try {
|
||||||
int count = imdgService.reloadMapFromDB();
|
long clock = System.currentTimeMillis();
|
||||||
clock = System.currentTimeMillis() - clock;
|
int count = imdgService.reloadMapFromDB();
|
||||||
writeLine(os, count + " map per " + clock + " ms");
|
clock = System.currentTimeMillis() - clock;
|
||||||
} catch (Throwable e) {
|
writeLine(os, count + " map per " + clock + " ms</br>");
|
||||||
String msg = "Error reload: " + ExceptionUtils.getStackTrace(e);
|
} catch (Throwable e) {
|
||||||
log.error(msg);
|
String msg = "Error reload: " + ExceptionUtils.getStackTrace(e);
|
||||||
writeLine(os, msg);
|
log.error(msg);
|
||||||
|
writeLine(os, msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
writeLine(os, "Done. " + LocalDateTime.now());
|
writeLine(os, "<b title=\":)\">Done.</b> " + LocalDateTime.now() + "</br>");
|
||||||
// writeEnd(os)
|
writeLine(os, " <a href=\"\">Reload again.</a> ");
|
||||||
|
writeEnd(os);
|
||||||
} //os.close();
|
} //os.close();
|
||||||
|
log.trace("HTTP Request done.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeHead(OutputStream os) throws IOException {
|
void writeHead(OutputStream os) throws IOException {
|
||||||
//writeLine(os, "<doctype html><html><body>");
|
writeLine(os, "<!DOCTYPE html>\n<html><head></head>\n<body style=\"background-color:lightgray; font-size:14pt;color:black;\">");
|
||||||
|
writeLine(os, "<div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeLine(OutputStream os, String text) throws IOException {
|
void writeLine(OutputStream os, String text) throws IOException {
|
||||||
if (text != null)
|
if (text != null)
|
||||||
os.write(text.getBytes(StandardCharsets.UTF_8));
|
os.write(text.getBytes("windows-1251"));
|
||||||
os.write("\n".getBytes(StandardCharsets.UTF_8));
|
os.write("\n".getBytes("windows-1251"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeEnd(OutputStream os) throws IOException {
|
void writeEnd(OutputStream os) throws IOException {
|
||||||
//writeLine(os, "</body></html>");
|
writeLine(os, "</div>");
|
||||||
|
writeLine(os, "</body></html>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue