more debug stats
(cherry picked from commit 7f06a41dc081f45683218aaaa0c3621040b5d0a0)
This commit is contained in:
parent
af38886f97
commit
4dbcbaa707
|
@ -62,4 +62,8 @@ public interface RecordingProcess extends Callable<RecordingProcess> {
|
|||
void awaitEnd();
|
||||
|
||||
AtomicLong getDownloadedBytes();
|
||||
|
||||
default String getStats() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,14 @@ public class MergedFfmpegHlsDownload extends AbstractHlsDownload {
|
|||
protected OutputStream ffmpegStdIn;
|
||||
protected BlockingQueue<Future<SegmentDownload>> queue = new LinkedBlockingQueue<>();
|
||||
protected Lock ffmpegStreamLock = new ReentrantLock();
|
||||
|
||||
public String getStats() {
|
||||
String text = (running ? "RUN" : "stp") + String.format(" %d: ", queue.size());
|
||||
for (var elem : queue) {
|
||||
text += elem.isDone() ? "|" : "-";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public MergedFfmpegHlsDownload(HttpClient client) {
|
||||
super(client);
|
||||
|
|
|
@ -2,6 +2,7 @@ package ctbrec.recorder.server;
|
|||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.io.HttpClient;
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.recorder.SimplifiedLocalRecorder;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -28,8 +29,12 @@ public class DebugServlet extends AbstractCtbrecServlet {
|
|||
private static final Pattern URL_PATTERN_DEBUG_STACK = Pattern.compile(BASE_URL + "/stack(/.*?)");
|
||||
private static final Pattern URL_PATTERN_DEBUG_STATS = Pattern.compile(BASE_URL + "/stats");
|
||||
|
||||
public DebugServlet()
|
||||
{}
|
||||
protected Recorder recorder;
|
||||
|
||||
public DebugServlet(Recorder rec)
|
||||
{
|
||||
this.recorder = rec;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
||||
|
@ -64,7 +69,7 @@ public class DebugServlet extends AbstractCtbrecServlet {
|
|||
resp.setContentType("text/plain");
|
||||
sendResponse(resp, SC_OK, box.text);
|
||||
} else if ((m = URL_PATTERN_DEBUG_STATS.matcher(requestURI)).matches()) {
|
||||
String text = "";
|
||||
String text = "<html><body style=\"body { font-family: Monospace; }\">";
|
||||
text += String.format("GLOBAL_HTTP_CONN_POOL: connectionCount=%d, idleConnectionCount=%d\n",
|
||||
HttpClient.getGLOBAL_HTTP_CONN_POOL().connectionCount(),
|
||||
HttpClient.getGLOBAL_HTTP_CONN_POOL().idleConnectionCount());
|
||||
|
@ -77,8 +82,20 @@ public class DebugServlet extends AbstractCtbrecServlet {
|
|||
rlock.unlock();
|
||||
}
|
||||
|
||||
text += "\nRecording stats:\n<table>";
|
||||
text = text.replace("\n", "<br>");
|
||||
|
||||
for (var rec : recorder.getRecordings()) {
|
||||
var proc = rec.getRecordingProcess();
|
||||
if (proc == null) continue;
|
||||
text += String.format("<tr><td>%s</td><td>%s</td></tr>\n", proc.getModel().getDisplayName(), proc.getStats());
|
||||
}
|
||||
|
||||
text += "</table>";
|
||||
text += "</body></html>";
|
||||
|
||||
log.debug("Stats Request");
|
||||
resp.setContentType("text/plain");
|
||||
resp.setContentType("text/html");
|
||||
sendResponse(resp, SC_OK, text);
|
||||
} else
|
||||
sendResponse(resp, SC_NOT_FOUND, "");
|
||||
|
|
|
@ -259,7 +259,7 @@ public class HttpServer {
|
|||
holder = new ServletHolder(modelServlet);
|
||||
defaultContext.addServlet(holder, ModelServlet.BASE_URL + "/*");
|
||||
|
||||
DebugServlet debugServlet = new DebugServlet();
|
||||
DebugServlet debugServlet = new DebugServlet(recorder);
|
||||
holder = new ServletHolder(debugServlet);
|
||||
defaultContext.addServlet(holder, DebugServlet.BASE_URL + "/*");
|
||||
|
||||
|
|
Loading…
Reference in New Issue