Commit c9b36019 authored by Benoit Lavenier's avatar Benoit Lavenier

[fix] Revert: store peer stats in second, no more in millis

parent 886b7342
Pipeline #4624 passed with stage
in 25 seconds
......@@ -160,7 +160,8 @@ public class MemoryPeerDaoImpl implements PeerDao {
@Override
public void updatePeersAsDown(String currencyId, long minUpTimeInMs, Collection<String> endpointApis) {
long firstDownTimeInMs = System.currentTimeMillis();
long minUpTimeInS = Math.round(minUpTimeInMs / 1000);
long firstDownTimeInMs = Math.round(System.currentTimeMillis() / 1000);
getPeersByCurrencyId(currencyId).stream()
.filter(peer ->
......@@ -168,7 +169,7 @@ public class MemoryPeerDaoImpl implements PeerDao {
&& peer.getStats().isReacheable()
&& (
peer.getStats().getLastUpTime() == null
|| peer.getStats().getLastUpTime() < minUpTimeInMs
|| peer.getStats().getLastUpTime() < minUpTimeInS
)
&& (endpointApis == null || endpointApis.contains(peer.getApi()))
)
......
......@@ -197,8 +197,7 @@ public class Peer implements LocalEntity<String>, Serializable {
stats.setStatus(Peer.PeerStatus.UP);
// FIXME: Duniter 1.7 return lastUpTime in ms. Check if this a bug or not
stats.setLastUpTime(System.currentTimeMillis());
//stats.setLastUpTime((long)Math.round(System.currentTimeMillis() / 1000));
stats.setLastUpTime((long)Math.round(System.currentTimeMillis() / 1000));
}
else {
stats.setStatus(Peer.PeerStatus.DOWN);
......@@ -683,7 +682,7 @@ public class Peer implements LocalEntity<String>, Serializable {
}
/**
* Last time the peer was UP (in millisecond)
* Last time the peer was UP (in second)
* @return
*/
public Long getLastUpTime() {
......@@ -695,7 +694,7 @@ public class Peer implements LocalEntity<String>, Serializable {
}
/**
* First time the peer was DOWN (in millisecond)
* First time the peer was DOWN (in second)
* @return
*/
public Long getFirstDownTime() {
......
......@@ -262,8 +262,7 @@ public final class Peers {
stats.setStatus(Peer.PeerStatus.UP);
// FIXME: Duniter 1.7 return lastUpTime in ms. Check if this a bug or not
stats.setLastUpTime(System.currentTimeMillis());
//stats.setLastUpTime((long)Math.round(System.currentTimeMillis() / 1000));
stats.setLastUpTime((long)Math.round(System.currentTimeMillis() / 1000));
}
else {
stats.setStatus(Peer.PeerStatus.DOWN);
......
......@@ -192,8 +192,7 @@ public class PeerServiceImpl implements PeerService, InitializingBean {
}
// FIXME: Duniter 1.7 return lastUpTime in ms. Check if this a bug or not
final long upTime = System.currentTimeMillis();
//final long upTime = System.currentTimeMillis() / 1000;
final long upTime = System.currentTimeMillis() / 1000;
peers.forEach(peer -> {
// On each UP peers: set last UP time
......@@ -217,8 +216,8 @@ public class PeerServiceImpl implements PeerService, InitializingBean {
int peerDownTimeoutMs = config.getPeerUpMaxAge();
// Mark old peers as DOWN
if (peerDownTimeoutMs >0) {
long maxUpTimeInSec = Math.round((System.currentTimeMillis() - peerDownTimeoutMs*1000));
updatePeersAsDown(currencyId, maxUpTimeInSec, filterApis);
long maxUpTimeInMs = System.currentTimeMillis() - peerDownTimeoutMs;
updatePeersAsDown(currencyId, maxUpTimeInMs, filterApis);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment