mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +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"/>
|
||||
</cellValueFactory>
|
||||
</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">
|
||||
<cellValueFactory>
|
||||
<PropertyValueFactory property="sentBytes"/>
|
||||
|
|
|
@ -71,10 +71,7 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
|
|||
TableView<P2pNetworkListItem> p2PPeerTable;
|
||||
@FXML
|
||||
TableColumn<P2pNetworkListItem, String> onionAddressColumn, connectionTypeColumn, creationDateColumn,
|
||||
lastActivityColumn, sentBytesColumn, receivedBytesColumn, peerTypeColumn;
|
||||
/* TableColumn<NetworkStatisticListItem, NetworkStatisticListItem> onionAddressColumn, connectionTypeColumn, creationDateColumn,
|
||||
lastActivityColumn, sentBytesColumn, receivedBytesColumn, peerTypeColumn;
|
||||
*/
|
||||
lastActivityColumn, roundTripTimeColumn, sentBytesColumn, receivedBytesColumn, peerTypeColumn;
|
||||
private Subscription numP2PPeersSubscription;
|
||||
private Subscription bitcoinPeersSubscription;
|
||||
private Subscription nodeAddressSubscription;
|
||||
|
|
|
@ -3,7 +3,9 @@ package io.bitsquare.p2p.network;
|
|||
import io.bitsquare.common.UserThread;
|
||||
import io.bitsquare.p2p.Message;
|
||||
import javafx.beans.property.IntegerProperty;
|
||||
import javafx.beans.property.LongProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleLongProperty;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -49,6 +51,7 @@ public class Statistic {
|
|||
private final IntegerProperty receivedBytes = new SimpleIntegerProperty(0);
|
||||
private final Map<String, Integer> receivedMessages = 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);
|
||||
}
|
||||
|
||||
public void setRoundTripTime(long roundTripTime) {
|
||||
this.roundTripTime.set(roundTripTime);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -132,6 +139,9 @@ public class Statistic {
|
|||
return creationDate;
|
||||
}
|
||||
|
||||
public LongProperty roundTripTimeProperty() {
|
||||
return roundTripTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
@ -50,6 +50,7 @@ class KeepAliveHandler implements MessageListener {
|
|||
private Connection connection;
|
||||
private boolean stopped;
|
||||
private Timer delayTimer;
|
||||
private long sendTs;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -79,6 +80,7 @@ class KeepAliveHandler implements MessageListener {
|
|||
Log.traceCall("connection=" + connection + " / this=" + this);
|
||||
if (!stopped) {
|
||||
Ping ping = new Ping(nonce);
|
||||
sendTs = System.currentTimeMillis();
|
||||
SettableFuture<Connection> future = networkNode.sendMessage(connection, ping);
|
||||
Futures.addCallback(future, new FutureCallback<Connection>() {
|
||||
@Override
|
||||
|
@ -125,6 +127,9 @@ class KeepAliveHandler implements MessageListener {
|
|||
if (!stopped) {
|
||||
Pong pong = (Pong) message;
|
||||
if (pong.requestNonce == nonce) {
|
||||
long roundTripTime = System.currentTimeMillis() - sendTs;
|
||||
log.trace("roundTripTime=" + roundTripTime + "\n\tconnection=" + connection);
|
||||
connection.getStatistic().setRoundTripTime(roundTripTime);
|
||||
cleanup();
|
||||
listener.onComplete();
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue