Remove verbose logging from introduction client

This commit is contained in:
Torsten Grote
2016-12-06 15:36:54 -02:00
parent 27c2ee8d89
commit 7f5a5d40dc
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(MAC, localState.getRaw(OUR_MAC));
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;
}
@@ -285,14 +277,9 @@ class IntroduceeEngine
try {
LOG.info("Sending " +
(localState.getBoolean(ACCEPT) ? "accept " : "decline ") +
"response in state " + state.name() +
" to " + localState.getString(INTRODUCER) +
" for " + localState.getString(NAME) + " with session ID " +
Arrays.hashCode(msg.getRaw(SESSION_ID)) + " in group " +
Arrays.hashCode(msg.getRaw(GROUP_ID)) + ". " +
"Moving on to state " +
getState(localState.getLong(STATE)).name()
);
"response in state " + state.name());
LOG.info("Moving on to state " +
getState(localState.getLong(STATE)).name());
} catch (FormatException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
@@ -304,25 +291,14 @@ class IntroduceeEngine
if (!LOG.isLoggable(INFO)) return;
try {
String t = "unknown";
if (type == TYPE_REQUEST) t = "Introduction";
else if (type == TYPE_RESPONSE) t = "Response";
else if (type == TYPE_ACK) t = "ACK";
else if (type == TYPE_ABORT) t = "Abort";
String t = "unknown";
if (type == TYPE_REQUEST) t = "Introduction";
else if (type == TYPE_RESPONSE) t = "Response";
else if (type == TYPE_ACK) t = "ACK";
else if (type == TYPE_ABORT) t = "Abort";
LOG.info("Received " + t + " in state " + currentState.name() +
" from " + localState.getString(INTRODUCER) +
(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);
}
LOG.info("Received " + t + " in state " + currentState.name());
LOG.info("Moving on to state " + nextState.name());
}
@Override
@@ -368,11 +344,9 @@ class IntroduceeEngine
IntroduceeProtocolState currentState, BdfDictionary localState)
throws FormatException {
if (LOG.isLoggable(WARNING)) {
LOG.warning("Aborting protocol session " +
Arrays.hashCode(localState.getRaw(SESSION_ID)) +
" in state " + currentState.name());
}
if (LOG.isLoggable(WARNING))
LOG.warning("Aborting protocol session in state " +
currentState.name());
localState.put(STATE, ERROR.getValue());
localState.put(TASK, TASK_ABORT);

View File

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

View File

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

View File

@@ -436,7 +436,8 @@ class IntroductionManagerImpl extends ConversationClientImpl
list.add(ir);
}
} 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);
@@ -455,7 +456,8 @@ class IntroductionManagerImpl extends ConversationClientImpl
return state.getString(CONTACT_2);
if (contactId.getInt() == state.getLong(CONTACT_ID_2).intValue())
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,
@@ -465,7 +467,8 @@ class IntroductionManagerImpl extends ConversationClientImpl
return new AuthorId(state.getRaw(AUTHOR_ID_2));
if (contactId.getInt() == state.getLong(CONTACT_ID_2).intValue())
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,
@@ -508,11 +511,8 @@ class IntroductionManagerImpl extends ConversationClientImpl
if (g.equals(groupId)) return state;
}
}
if (warn && LOG.isLoggable(WARNING)) {
LOG.warning(
"No session state found for message with session ID " +
Arrays.hashCode(sessionId));
}
if (warn && LOG.isLoggable(WARNING))
LOG.warning("No session state found");
throw new FormatException();
}
}