Improve logging, fix toString

This commit is contained in:
Manfred Karrer 2016-05-22 00:24:38 +02:00
parent 9f45abcf81
commit ea818cf66b
3 changed files with 15 additions and 5 deletions

View File

@ -386,11 +386,11 @@ public class P2PDataStorage implements MessageListener, ConnectionListener {
private boolean isSequenceNrValid(int newSequenceNumber, ByteArray hashOfData) {
if (sequenceNumberMap.containsKey(hashOfData)) {
Integer storedSequenceNumber = sequenceNumberMap.get(hashOfData).sequenceNr;
int storedSequenceNumber = sequenceNumberMap.get(hashOfData).sequenceNr;
if (newSequenceNumber >= storedSequenceNumber) {
return true;
} else {
log.info("Sequence number is invalid. sequenceNumber = "
log.warn("Sequence number is invalid. sequenceNumber = "
+ newSequenceNumber + " / storedSequenceNumber=" + storedSequenceNumber + "\n" +
"That can happen if the data owner gets an old delayed data storage message.");
return false;
@ -402,9 +402,19 @@ public class P2PDataStorage implements MessageListener, ConnectionListener {
private boolean hasSequenceNrIncreased(int newSequenceNumber, ByteArray hashOfData) {
if (sequenceNumberMap.containsKey(hashOfData)) {
Integer storedSequenceNumber = sequenceNumberMap.get(hashOfData).sequenceNr;
int storedSequenceNumber = sequenceNumberMap.get(hashOfData).sequenceNr;
if (newSequenceNumber > storedSequenceNumber) {
return true;
} else if (newSequenceNumber == storedSequenceNumber) {
if (newSequenceNumber == 0) {
log.trace("Sequence number is equal to the stored one and both are 0." +
"That is expected for messages which never got updated (mailbox msg).");
return false;
} else {
log.trace("Sequence number is equal to the stored one. sequenceNumber = "
+ newSequenceNumber + " / storedSequenceNumber=" + storedSequenceNumber);
return false;
}
} else {
log.warn("Sequence number is invalid. sequenceNumber = "
+ newSequenceNumber + " / storedSequenceNumber=" + storedSequenceNumber + "\n" +

View File

@ -101,7 +101,7 @@ public final class MailboxStoragePayload implements StoragePayload {
@Override
public String toString() {
return "ExpirableMailboxPayload{" +
return "MailboxStoragePayload{" +
"prefixedSealedAndSignedMessage=" + prefixedSealedAndSignedMessage +
", senderStoragePublicKey.hashCode()=" + senderPubKeyForAddOperation.hashCode() +
", receiverStoragePublicKey.hashCode()=" + receiverPubKeyForRemoveOperation.hashCode() +

View File

@ -69,7 +69,7 @@ public class ProtectedStorageEntry implements Payload {
@Override
public String toString() {
return "ProtectedData{" +
return "ProtectedStorageEntry{" +
"expirablePayload=" + storagePayload +
", timeStamp=" + timeStamp +
", sequenceNumber=" + sequenceNumber +