Merge branch '808-introduction-client-logs-contact-names' into 'master'

Remove verbose logging from introduction client

Closes #808

See merge request !449
This commit is contained in:
akwizgran
2016-12-07 15:49:14 +00:00
4 changed files with 38 additions and 100 deletions

View File

@@ -266,14 +266,6 @@ class IntroduceeEngine
m.put(SESSION_ID, localState.getRaw(SESSION_ID)); m.put(SESSION_ID, localState.getRaw(SESSION_ID));
m.put(MAC, localState.getRaw(OUR_MAC)); m.put(MAC, localState.getRaw(OUR_MAC));
m.put(SIGNATURE, localState.getRaw(OUR_SIGNATURE)); m.put(SIGNATURE, localState.getRaw(OUR_SIGNATURE));
if (LOG.isLoggable(INFO)) {
LOG.info("Sending ACK " + " to " +
localState.getString(INTRODUCER) + " for " +
localState.getString(NAME) + " with session ID " +
Arrays.hashCode(m.getRaw(SESSION_ID)) + " in group " +
Arrays.hashCode(m.getRaw(GROUP_ID)));
}
return m; return m;
} }
@@ -285,14 +277,9 @@ class IntroduceeEngine
try { try {
LOG.info("Sending " + LOG.info("Sending " +
(localState.getBoolean(ACCEPT) ? "accept " : "decline ") + (localState.getBoolean(ACCEPT) ? "accept " : "decline ") +
"response in state " + state.name() + "response in state " + state.name());
" to " + localState.getString(INTRODUCER) + LOG.info("Moving on to state " +
" for " + localState.getString(NAME) + " with session ID " + getState(localState.getLong(STATE)).name());
Arrays.hashCode(msg.getRaw(SESSION_ID)) + " in group " +
Arrays.hashCode(msg.getRaw(GROUP_ID)) + ". " +
"Moving on to state " +
getState(localState.getLong(STATE)).name()
);
} catch (FormatException e) { } catch (FormatException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }
@@ -304,25 +291,14 @@ class IntroduceeEngine
if (!LOG.isLoggable(INFO)) return; if (!LOG.isLoggable(INFO)) return;
try { String t = "unknown";
String t = "unknown"; if (type == TYPE_REQUEST) t = "Introduction";
if (type == TYPE_REQUEST) t = "Introduction"; else if (type == TYPE_RESPONSE) t = "Response";
else if (type == TYPE_RESPONSE) t = "Response"; else if (type == TYPE_ACK) t = "ACK";
else if (type == TYPE_ACK) t = "ACK"; else if (type == TYPE_ABORT) t = "Abort";
else if (type == TYPE_ABORT) t = "Abort";
LOG.info("Received " + t + " in state " + currentState.name() + LOG.info("Received " + t + " in state " + currentState.name());
" from " + localState.getString(INTRODUCER) + LOG.info("Moving on to state " + nextState.name());
(localState.containsKey(NAME) ?
" related to " + localState.getString(NAME) : "") +
" with session ID " +
Arrays.hashCode(msg.getRaw(SESSION_ID)) + " in group " +
Arrays.hashCode(msg.getRaw(GROUP_ID)) + ". " +
"Moving on to state " + nextState.name()
);
} catch (FormatException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
} }
@Override @Override
@@ -368,11 +344,9 @@ class IntroduceeEngine
IntroduceeProtocolState currentState, BdfDictionary localState) IntroduceeProtocolState currentState, BdfDictionary localState)
throws FormatException { throws FormatException {
if (LOG.isLoggable(WARNING)) { if (LOG.isLoggable(WARNING))
LOG.warning("Aborting protocol session " + LOG.warning("Aborting protocol session in state " +
Arrays.hashCode(localState.getRaw(SESSION_ID)) + currentState.name());
" in state " + currentState.name());
}
localState.put(STATE, ERROR.getValue()); localState.put(STATE, ERROR.getValue());
localState.put(TASK, TASK_ABORT); localState.put(TASK, TASK_ABORT);

View File

@@ -114,7 +114,7 @@ class IntroducerEngine
} }
msg1.put(MESSAGE_TIME, localAction.getLong(MESSAGE_TIME)); msg1.put(MESSAGE_TIME, localAction.getLong(MESSAGE_TIME));
messages.add(msg1); messages.add(msg1);
logLocalAction(currentState, localState, msg1); logLocalAction(currentState, localState);
BdfDictionary msg2 = new BdfDictionary(); BdfDictionary msg2 = new BdfDictionary();
msg2.put(TYPE, TYPE_REQUEST); msg2.put(TYPE, TYPE_REQUEST);
msg2.put(SESSION_ID, localState.getRaw(SESSION_ID)); msg2.put(SESSION_ID, localState.getRaw(SESSION_ID));
@@ -126,7 +126,7 @@ class IntroducerEngine
} }
msg2.put(MESSAGE_TIME, localAction.getLong(MESSAGE_TIME)); msg2.put(MESSAGE_TIME, localAction.getLong(MESSAGE_TIME));
messages.add(msg2); messages.add(msg2);
logLocalAction(currentState, localState, msg2); logLocalAction(currentState, localState);
List<Event> events = Collections.emptyList(); List<Event> events = Collections.emptyList();
return new StateUpdate<BdfDictionary, BdfDictionary>(false, return new StateUpdate<BdfDictionary, BdfDictionary>(false,
@@ -214,19 +214,13 @@ class IntroducerEngine
} }
private void logLocalAction(IntroducerProtocolState state, private void logLocalAction(IntroducerProtocolState state,
BdfDictionary localState, BdfDictionary msg) { BdfDictionary localState) {
if (!LOG.isLoggable(INFO)) return; if (!LOG.isLoggable(INFO)) return;
try { try {
String to = getMessagePartner(localState, msg); LOG.info("Sending introduction request in state " + state.name());
LOG.info("Sending introduction request in state " + state.name() + LOG.info("Moving on to state " +
" to " + to + " with session ID " + getState(localState.getLong(STATE)).name());
Arrays.hashCode(msg.getRaw(SESSION_ID)) + " in group " +
Arrays.hashCode(msg.getRaw(GROUP_ID)) + ". " +
"Moving on to state " +
getState(localState.getLong(STATE)).name()
);
} catch (FormatException e) { } catch (FormatException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }
@@ -235,28 +229,17 @@ class IntroducerEngine
private void logMessageReceived(IntroducerProtocolState currentState, private void logMessageReceived(IntroducerProtocolState currentState,
IntroducerProtocolState nextState, IntroducerProtocolState nextState,
BdfDictionary localState, int type, BdfDictionary msg) { BdfDictionary localState, int type, BdfDictionary msg) {
if (!LOG.isLoggable(INFO)) return; if (!LOG.isLoggable(INFO)) return;
try { String t = "unknown";
String t = "unknown"; if (type == TYPE_REQUEST) t = "Introduction";
if (type == TYPE_REQUEST) t = "Introduction"; else if (type == TYPE_RESPONSE) t = "Response";
else if (type == TYPE_RESPONSE) t = "Response"; else if (type == TYPE_ACK) t = "ACK";
else if (type == TYPE_ACK) t = "ACK"; else if (type == TYPE_ABORT) t = "Abort";
else if (type == TYPE_ABORT) t = "Abort";
String from = getMessagePartner(localState, msg); LOG.info("Received " + t + " in state " + currentState.name());
String to = getOtherContact(localState, msg); LOG.info("Moving on to state " + nextState.name());
LOG.info("Received " + t + " in state " + currentState.name() +
" from " +
from + " to " + to + " with session ID " +
Arrays.hashCode(msg.getRaw(SESSION_ID)) + " in group " +
Arrays.hashCode(msg.getRaw(GROUP_ID)) + ". " +
"Moving on to state " + nextState.name()
);
} catch (FormatException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
} }
private List<BdfDictionary> forwardMessage(BdfDictionary localState, private List<BdfDictionary> forwardMessage(BdfDictionary localState,
@@ -270,11 +253,6 @@ class IntroducerEngine
msg.put(GROUP_ID, localState.getRaw(GROUP_ID_1)); msg.put(GROUP_ID, localState.getRaw(GROUP_ID_1));
} }
if (LOG.isLoggable(INFO)) {
LOG.info("Forwarding message to group " +
Arrays.hashCode(msg.getRaw(GROUP_ID)));
}
return Collections.singletonList(msg); return Collections.singletonList(msg);
} }
@@ -336,17 +314,6 @@ class IntroducerEngine
} }
} }
private String getMessagePartner(BdfDictionary localState,
BdfDictionary msg) throws FormatException {
String from = localState.getString(CONTACT_1);
if (Arrays
.equals(msg.getRaw(GROUP_ID), localState.getRaw(GROUP_ID_2))) {
from = localState.getString(CONTACT_2);
}
return from;
}
private String getOtherContact(BdfDictionary localState, BdfDictionary msg) private String getOtherContact(BdfDictionary localState, BdfDictionary msg)
throws FormatException { throws FormatException {
@@ -362,11 +329,9 @@ class IntroducerEngine
IntroducerProtocolState currentState, BdfDictionary localState) IntroducerProtocolState currentState, BdfDictionary localState)
throws FormatException { throws FormatException {
if (LOG.isLoggable(WARNING)) { if (LOG.isLoggable(WARNING))
LOG.warning("Aborting protocol session " + LOG.warning("Aborting protocol session in state " +
Arrays.hashCode(localState.getRaw(SESSION_ID)) + currentState.name());
" in state " + currentState.name());
}
localState.put(STATE, ERROR.getValue()); localState.put(STATE, ERROR.getValue());
List<BdfDictionary> messages = new ArrayList<BdfDictionary>(2); List<BdfDictionary> messages = new ArrayList<BdfDictionary>(2);

View File

@@ -167,7 +167,6 @@ class IntroducerManager {
} }
public void abort(Transaction txn, BdfDictionary state) { public void abort(Transaction txn, BdfDictionary state) {
IntroducerEngine engine = new IntroducerEngine(); IntroducerEngine engine = new IntroducerEngine();
BdfDictionary localAction = new BdfDictionary(); BdfDictionary localAction = new BdfDictionary();
localAction.put(TYPE, TYPE_ABORT); localAction.put(TYPE, TYPE_ABORT);

View File

@@ -436,7 +436,8 @@ class IntroductionManagerImpl extends ConversationClientImpl
list.add(ir); list.add(ir);
} }
} catch (FormatException e) { } catch (FormatException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if (LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e);
} }
} }
db.commitTransaction(txn); db.commitTransaction(txn);
@@ -455,7 +456,8 @@ class IntroductionManagerImpl extends ConversationClientImpl
return state.getString(CONTACT_2); return state.getString(CONTACT_2);
if (contactId.getInt() == state.getLong(CONTACT_ID_2).intValue()) if (contactId.getInt() == state.getLong(CONTACT_ID_2).intValue())
return state.getString(CONTACT_1); return state.getString(CONTACT_1);
throw new RuntimeException("Contact not part of this introduction session"); throw new RuntimeException(
"Contact not part of this introduction session");
} }
private AuthorId getAuthorIdForIntroducer(ContactId contactId, private AuthorId getAuthorIdForIntroducer(ContactId contactId,
@@ -465,7 +467,8 @@ class IntroductionManagerImpl extends ConversationClientImpl
return new AuthorId(state.getRaw(AUTHOR_ID_2)); return new AuthorId(state.getRaw(AUTHOR_ID_2));
if (contactId.getInt() == state.getLong(CONTACT_ID_2).intValue()) if (contactId.getInt() == state.getLong(CONTACT_ID_2).intValue())
return new AuthorId(state.getRaw(AUTHOR_ID_1)); return new AuthorId(state.getRaw(AUTHOR_ID_1));
throw new RuntimeException("Contact not part of this introduction session"); throw new RuntimeException(
"Contact not part of this introduction session");
} }
private boolean concernsThisContact(ContactId contactId, MessageId messageId, private boolean concernsThisContact(ContactId contactId, MessageId messageId,
@@ -508,11 +511,8 @@ class IntroductionManagerImpl extends ConversationClientImpl
if (g.equals(groupId)) return state; if (g.equals(groupId)) return state;
} }
} }
if (warn && LOG.isLoggable(WARNING)) { if (warn && LOG.isLoggable(WARNING))
LOG.warning( LOG.warning("No session state found");
"No session state found for message with session ID " +
Arrays.hashCode(sessionId));
}
throw new FormatException(); throw new FormatException();
} }
} }