proxy progress - I am getting tired :(

This commit is contained in:
rusefi 2020-07-22 21:06:58 -04:00
parent 2fdbf01a5d
commit badac39e87
3 changed files with 12 additions and 3 deletions

View File

@ -110,6 +110,7 @@ public class Backend implements Closeable {
new Thread(() -> {
while (true) {
logger.info(getApplicationsCount() + " applications, " + getControllersCount() + " controllers");
runApplicationConnectionsCleanup();
BinaryProtocol.sleep(applicationTimeout);
}
@ -129,7 +130,7 @@ public class Backend implements Closeable {
if (System.currentTimeMillis() - controller.getStream().getStreamStats().getPreviousPacketArrivalTime() > 20 * SECOND) {
if (controller.getTwoKindSemaphore().acquireForShortTermUsage()) {
try {
controller.grabOutputs();
controller.grabOutputs(this);
} finally {
controller.getTwoKindSemaphore().releaseFromShortTermUsage();
}
@ -348,4 +349,9 @@ public class Backend implements Closeable {
}
}
public int getApplicationsCount() {
synchronized (lock) {
return applications.size();
}
}
}

View File

@ -111,11 +111,12 @@ public class ControllerConnectionState {
return sensorsHolder;
}
public void grabOutputs() {
public void grabOutputs(Backend backend) {
try {
getOutputs();
} catch (IOException e) {
close();
// todo: this is currently not covered by a unit test
backend.close(this);
}
}
}

View File

@ -37,6 +37,8 @@ public class Monitoring {
builder.add("sessions", Backend.totalSessions.get());
builder.add("serverPortForApplications", backend.serverPortForApplications);
builder.add("serverPortForControllers", backend.serverPortForControllers);
builder.add("applicationsCount", backend.getApplicationsCount());
builder.add("controllersCount", backend.getControllersCount());
return new RsJson(builder.build());
}