round trip metric
This commit is contained in:
parent
b99c81f7ac
commit
2c19ff8c48
|
@ -26,12 +26,12 @@ import java.util.concurrent.TimeUnit;
|
||||||
*/
|
*/
|
||||||
public class NetworkConnector {
|
public class NetworkConnector {
|
||||||
public static SessionDetails runNetworkConnector(String authToken, String controllerPort, int serverPortForControllers, TcpIoStream.DisconnectListener disconnectListener) throws InterruptedException, IOException {
|
public static SessionDetails runNetworkConnector(String authToken, String controllerPort, int serverPortForControllers, TcpIoStream.DisconnectListener disconnectListener) throws InterruptedException, IOException {
|
||||||
LinkManager linkManager = new LinkManager()
|
LinkManager controllerConnector = new LinkManager()
|
||||||
.setCompositeLogicEnabled(false)
|
.setCompositeLogicEnabled(false)
|
||||||
.setNeedPullData(false);
|
.setNeedPullData(false);
|
||||||
|
|
||||||
CountDownLatch onConnected = new CountDownLatch(1);
|
CountDownLatch onConnected = new CountDownLatch(1);
|
||||||
linkManager.startAndConnect(controllerPort, new ConnectionStateListener() {
|
controllerConnector.startAndConnect(controllerPort, new ConnectionStateListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onConnectionEstablished() {
|
public void onConnectionEstablished() {
|
||||||
onConnected.countDown();
|
onConnected.countDown();
|
||||||
|
@ -50,7 +50,7 @@ public class NetworkConnector {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return runNetworkConnector(serverPortForControllers, linkManager, Logger.CONSOLE, authToken, disconnectListener);
|
return runNetworkConnector(serverPortForControllers, controllerConnector, Logger.CONSOLE, authToken, disconnectListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|
|
@ -293,6 +293,7 @@ public class Backend implements Closeable {
|
||||||
.add(UserDetails.USER_ID, client.getUserDetails().getUserId())
|
.add(UserDetails.USER_ID, client.getUserDetails().getUserId())
|
||||||
.add(UserDetails.USERNAME, client.getUserDetails().getUserName())
|
.add(UserDetails.USERNAME, client.getUserDetails().getUserName())
|
||||||
.add(AGE, client.getBirthday().getDuration())
|
.add(AGE, client.getBirthday().getDuration())
|
||||||
|
.add("OUTPUT_ROUND_TRIP", client.getOutputRoundAroundDuration())
|
||||||
.add(ProxyClient.IS_USED, client.getTwoKindSemaphore().isUsed())
|
.add(ProxyClient.IS_USED, client.getTwoKindSemaphore().isUsed())
|
||||||
.add(ControllerStateDetails.RPM, rpm)
|
.add(ControllerStateDetails.RPM, rpm)
|
||||||
.add(ControllerStateDetails.CLT, clt)
|
.add(ControllerStateDetails.CLT, clt)
|
||||||
|
|
|
@ -37,6 +37,7 @@ public class ControllerConnectionState {
|
||||||
private final TwoKindSemaphore twoKindSemaphore = new TwoKindSemaphore();
|
private final TwoKindSemaphore twoKindSemaphore = new TwoKindSemaphore();
|
||||||
private final SensorsHolder sensorsHolder = new SensorsHolder();
|
private final SensorsHolder sensorsHolder = new SensorsHolder();
|
||||||
private final Birthday birthday = new Birthday();
|
private final Birthday birthday = new Birthday();
|
||||||
|
private int outputRoundAroundDuration;
|
||||||
|
|
||||||
public ControllerConnectionState(Socket clientSocket, UserDetailsResolver userDetailsResolver) {
|
public ControllerConnectionState(Socket clientSocket, UserDetailsResolver userDetailsResolver) {
|
||||||
this.clientSocket = clientSocket;
|
this.clientSocket = clientSocket;
|
||||||
|
@ -53,6 +54,10 @@ public class ControllerConnectionState {
|
||||||
return birthday;
|
return birthday;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getOutputRoundAroundDuration() {
|
||||||
|
return outputRoundAroundDuration;
|
||||||
|
}
|
||||||
|
|
||||||
public IoStream getStream() {
|
public IoStream getStream() {
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
@ -98,10 +103,11 @@ public class ControllerConnectionState {
|
||||||
|
|
||||||
public void getOutputs() throws IOException {
|
public void getOutputs() throws IOException {
|
||||||
byte[] commandPacket = GetOutputsCommand.createRequest();
|
byte[] commandPacket = GetOutputsCommand.createRequest();
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
stream.sendPacket(commandPacket);
|
stream.sendPacket(commandPacket);
|
||||||
|
|
||||||
byte[] packet = incomingData.getPacket("msg", true);
|
byte[] packet = incomingData.getPacket("msg", true);
|
||||||
|
outputRoundAroundDuration = (int) (System.currentTimeMillis() - start);
|
||||||
if (packet == null)
|
if (packet == null)
|
||||||
throw new IOException("getOutputs: No response");
|
throw new IOException("getOutputs: No response");
|
||||||
sensorsHolder.grabSensorValues(packet);
|
sensorsHolder.grabSensorValues(packet);
|
||||||
|
|
Loading…
Reference in New Issue