Back date data of object on disconnect, and only remove object if is is expired

This commit is contained in:
Manfred Karrer 2016-06-13 19:44:51 +02:00
parent 500fa2826e
commit bf86f0a7e4

View File

@ -165,9 +165,18 @@ public class P2PDataStorage implements MessageListener, ConnectionListener {
" / isIntended=" + closeConnectionReason.isIntended +
" / peer=" + (connection.getPeersNodeAddressOptional().isPresent() ? connection.getPeersNodeAddressOptional().get() : "PeersNode unknown"));
// TODO We get closeConnectionReason TERMINATED which removes offers which should not be removed
// TODO investigate why EOFException happens
doRemoveProtectedExpirableData(protectedData, hashOfPayload);
// We only set the data back by half of the TTL and remove the data only if is has
// expired after tha back dating.
// We might get connection drops which are not caused by the node going offline, so
// we give more tolerance with that approach, giving the node the change to
// refresh the TTL with a refresh message.
// We observed those issues during stress tests, but it might have been caused by the
// test set up (many nodes/connections over 1 router)
// TODO investigate what causes the disconnections.
// Usually the are: SOCKET_TIMEOUT ,TERMINATED (EOFException)
protectedData.backDate();
if (protectedData.isExpired())
doRemoveProtectedExpirableData(protectedData, hashOfPayload);
} else {
log.debug("Remove data ignored as we don't have an entry for that data.");
}