mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 23:18:17 +01:00
add roundtrip time
This commit is contained in:
parent
aecbf7ced9
commit
586d9cdcfd
4 changed files with 23 additions and 6 deletions
|
@ -89,6 +89,11 @@
|
||||||
<PropertyValueFactory property="lastActivity"/>
|
<PropertyValueFactory property="lastActivity"/>
|
||||||
</cellValueFactory>
|
</cellValueFactory>
|
||||||
</TableColumn>
|
</TableColumn>
|
||||||
|
<TableColumn text="RTT" fx:id="roundTripTimeColumn" minWidth="80" maxWidth="80">
|
||||||
|
<cellValueFactory>
|
||||||
|
<PropertyValueFactory property="roundTripTime"/>
|
||||||
|
</cellValueFactory>
|
||||||
|
</TableColumn>
|
||||||
<TableColumn text="Sent" fx:id="sentBytesColumn" minWidth="100" maxWidth="120">
|
<TableColumn text="Sent" fx:id="sentBytesColumn" minWidth="100" maxWidth="120">
|
||||||
<cellValueFactory>
|
<cellValueFactory>
|
||||||
<PropertyValueFactory property="sentBytes"/>
|
<PropertyValueFactory property="sentBytes"/>
|
||||||
|
|
|
@ -71,10 +71,7 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
|
||||||
TableView<P2pNetworkListItem> p2PPeerTable;
|
TableView<P2pNetworkListItem> p2PPeerTable;
|
||||||
@FXML
|
@FXML
|
||||||
TableColumn<P2pNetworkListItem, String> onionAddressColumn, connectionTypeColumn, creationDateColumn,
|
TableColumn<P2pNetworkListItem, String> onionAddressColumn, connectionTypeColumn, creationDateColumn,
|
||||||
lastActivityColumn, sentBytesColumn, receivedBytesColumn, peerTypeColumn;
|
lastActivityColumn, roundTripTimeColumn, sentBytesColumn, receivedBytesColumn, peerTypeColumn;
|
||||||
/* TableColumn<NetworkStatisticListItem, NetworkStatisticListItem> onionAddressColumn, connectionTypeColumn, creationDateColumn,
|
|
||||||
lastActivityColumn, sentBytesColumn, receivedBytesColumn, peerTypeColumn;
|
|
||||||
*/
|
|
||||||
private Subscription numP2PPeersSubscription;
|
private Subscription numP2PPeersSubscription;
|
||||||
private Subscription bitcoinPeersSubscription;
|
private Subscription bitcoinPeersSubscription;
|
||||||
private Subscription nodeAddressSubscription;
|
private Subscription nodeAddressSubscription;
|
||||||
|
|
|
@ -3,7 +3,9 @@ package io.bitsquare.p2p.network;
|
||||||
import io.bitsquare.common.UserThread;
|
import io.bitsquare.common.UserThread;
|
||||||
import io.bitsquare.p2p.Message;
|
import io.bitsquare.p2p.Message;
|
||||||
import javafx.beans.property.IntegerProperty;
|
import javafx.beans.property.IntegerProperty;
|
||||||
|
import javafx.beans.property.LongProperty;
|
||||||
import javafx.beans.property.SimpleIntegerProperty;
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
|
import javafx.beans.property.SimpleLongProperty;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -49,6 +51,7 @@ public class Statistic {
|
||||||
private final IntegerProperty receivedBytes = new SimpleIntegerProperty(0);
|
private final IntegerProperty receivedBytes = new SimpleIntegerProperty(0);
|
||||||
private final Map<String, Integer> receivedMessages = new ConcurrentHashMap<>();
|
private final Map<String, Integer> receivedMessages = new ConcurrentHashMap<>();
|
||||||
private final Map<String, Integer> sentMessages = new ConcurrentHashMap<>();
|
private final Map<String, Integer> sentMessages = new ConcurrentHashMap<>();
|
||||||
|
private final LongProperty roundTripTime = new SimpleLongProperty(0);
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -100,6 +103,10 @@ public class Statistic {
|
||||||
sentMessages.put(messageClassName, counter);
|
sentMessages.put(messageClassName, counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRoundTripTime(long roundTripTime) {
|
||||||
|
this.roundTripTime.set(roundTripTime);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Getters
|
// Getters
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -132,6 +139,9 @@ public class Statistic {
|
||||||
return creationDate;
|
return creationDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LongProperty roundTripTimeProperty() {
|
||||||
|
return roundTripTime;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -50,6 +50,7 @@ class KeepAliveHandler implements MessageListener {
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
private boolean stopped;
|
private boolean stopped;
|
||||||
private Timer delayTimer;
|
private Timer delayTimer;
|
||||||
|
private long sendTs;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -79,6 +80,7 @@ class KeepAliveHandler implements MessageListener {
|
||||||
Log.traceCall("connection=" + connection + " / this=" + this);
|
Log.traceCall("connection=" + connection + " / this=" + this);
|
||||||
if (!stopped) {
|
if (!stopped) {
|
||||||
Ping ping = new Ping(nonce);
|
Ping ping = new Ping(nonce);
|
||||||
|
sendTs = System.currentTimeMillis();
|
||||||
SettableFuture<Connection> future = networkNode.sendMessage(connection, ping);
|
SettableFuture<Connection> future = networkNode.sendMessage(connection, ping);
|
||||||
Futures.addCallback(future, new FutureCallback<Connection>() {
|
Futures.addCallback(future, new FutureCallback<Connection>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -125,6 +127,9 @@ class KeepAliveHandler implements MessageListener {
|
||||||
if (!stopped) {
|
if (!stopped) {
|
||||||
Pong pong = (Pong) message;
|
Pong pong = (Pong) message;
|
||||||
if (pong.requestNonce == nonce) {
|
if (pong.requestNonce == nonce) {
|
||||||
|
long roundTripTime = System.currentTimeMillis() - sendTs;
|
||||||
|
log.trace("roundTripTime=" + roundTripTime + "\n\tconnection=" + connection);
|
||||||
|
connection.getStatistic().setRoundTripTime(roundTripTime);
|
||||||
cleanup();
|
cleanup();
|
||||||
listener.onComplete();
|
listener.onComplete();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue