Revision: 88cbbd4609f7
Author: Alexandre Mendonça <ammendonca>
Date: Tue Jan 8 18:07:56 2013
Log: Better and more logging.
Update Issue 21
Status: Fixed
Committed remaining changes.
http://code.google.com/p/jdiameter/source/detail?r=88cbbd4609f7
Modified:
/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/fsm/PeerFSMImpl.java
/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/PeerImpl.java
/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/io/tcp/NetworkGuard.java
=======================================
---
/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/fsm/PeerFSMImpl.java
Thu Nov 22 19:54:28 2012
+++
/core/jdiameter/impl/src/main/java/org/jdiameter/client/impl/fsm/PeerFSMImpl.java
Tue Jan 8 18:07:56 2013
@@ -181,6 +181,9 @@
StateEvent event;
try {
event = eventQueue.poll(100, TimeUnit.MILLISECONDS);
+ if(logger.isDebugEnabled() && event != null) {
+ logger.debug("Got Event [{}] from Queue", event);
+ }
}
catch (InterruptedException e) {
logger.debug("Peer FSM stopped", e);
@@ -188,7 +191,7 @@
}
//FIXME: baranowb: why this lock is here?
// PCB removed lock
- // lock.lock();
+ lock.lock();
try {
if (event != null) {
if (event instanceof FsmEvent && queueStat != null &&
queueStat.isEnabled()) {
@@ -211,7 +214,7 @@
}
finally {
// PCB removed lock
- // lock.unlock();
+ lock.unlock();
}
}
//PCB added logging
@@ -298,7 +301,7 @@
boolean rc;
try {
if(logger.isDebugEnabled()) {
- logger.debug("Placing message into linked blocking queue with
remaining capacity: [{}].", eventQueue.remainingCapacity());
+ logger.debug("Placing event [{}] into linked blocking queue with
remaining capacity: [{}].", event, eventQueue.remainingCapacity());
//PCB added logging
//int queueSize = eventQueue.size();
//if (System.currentTimeMillis() - lastLogged > 1000) {
@@ -320,7 +323,7 @@
}
//PCB added logging
- private static long lastLogged;
+ //private static long lastLogged;
protected void setInActiveTimer() {
timer = IAC_TIMEOUT - 2 * 1000 + random.nextInt(5) * 1000 +
System.currentTimeMillis();
=======================================
---
/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/PeerImpl.java
Mon Nov 5 18:46:19 2012
+++
/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/PeerImpl.java
Tue Jan 8 18:07:56 2013
@@ -148,6 +148,8 @@
PeerState state = fsm.getState(PeerState.class);
if (DOWN == state || INITIAL == state) {
conn.addConnectionListener(connListener);
+ // ammendonca: if we are receiving a new connection in such state,
we may want to make it primary, right?
+ this.connection = conn;
logger.debug("Append external connection [{}]", conn.getKey());
}
else {
@@ -174,10 +176,11 @@
}
public String toString() {
- if(fsm!=null)
- return "SPeer{" + "Uri=" + uri + "; State=" +
fsm.getState(PeerState.class) + "; con="+ connection +";
incCon"+incConnections+" }";
- return "SPeer{" + "Uri=" + uri + "; State=" + fsm + "; con="+
connection +"; incCon"+incConnections+" }";
- }
+ if (fsm != null) {
+ return "SPeer{" + "Uri=" + uri + "; State=" +
fsm.getState(PeerState.class) + "; con="+ connection +";
incCon"+incConnections+" }";
+ }
+ return "SPeer{" + "Uri=" + uri + "; State=" + fsm + "; con="+
connection +"; incCon"+incConnections+" }";
+ }
protected class LocalActionConext extends ActionContext {
@@ -240,7 +243,7 @@
break;
case INITIAL:
boolean isLocalWin = false;
- if (isElection)
+ if (isElection) {
try {
// ammendonca: can't understand why it checks for <=
0 ... using equals
//isLocalWin =
metaData.getLocalPeer().getUri().getFQDN().compareTo(
@@ -248,8 +251,9 @@
isLocalWin =
metaData.getLocalPeer().getUri().getFQDN().equals(
message.getAvps().getAvp(Avp.ORIGIN_HOST).getOctetString());
}
- catch(Exception exc) {
- isLocalWin = true;
+ catch (Exception exc) {
+ isLocalWin = true;
+ }
}
logger.debug("local peer is win - [{}]", isLocalWin);
@@ -319,7 +323,7 @@
try{
destRealm = destRealmAvp.getDiameterIdentity();
}
- catch(AvpDataException ade) {
+ catch (AvpDataException ade) {
sendErrorAnswer(message, "Failed to parse Destination-Realm
AVP", ResultCode.INVALID_AVP_VALUE, destRealmAvp);
return true;
}
@@ -412,7 +416,7 @@
}
}
}
- catch(AvpDataException ade) {
+ catch (AvpDataException ade) {
logger.warn("Received message with present but unparsable
Destination-Host. Answering with 5004 (INVALID_AVP_VALUE) Result-Code.");
sendErrorAnswer(message, "Failed to parse Destination-Host
AVP", ResultCode.INVALID_AVP_VALUE, destHostAvp);
return true;
@@ -427,7 +431,7 @@
if(matched != null) {
action = matched.getLocalAction();
}
- else{
+ else {
// We don't support it locally, its not defined as remote, so
send no such realm answer.
sendErrorAnswer(message, null,
ResultCode.APPLICATION_UNSUPPORTED);
// or REALM_NOT_SERVED ?
@@ -552,7 +556,7 @@
statistic.getRecordByName(IStatisticRecord.Counters.SysGenResponse.name()).inc();
}
}
- catch(Exception e) {
+ catch (Exception e) {
// TODO: check this!!
logger.warn("Error during processing message by duplicate
protection", e);
sendErrorAnswer(message, "Unable to process",
ResultCode.UNABLE_TO_COMPLY);
=======================================
---
/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/io/tcp/NetworkGuard.java
Mon Mar 19 19:16:58 2012
+++
/core/jdiameter/impl/src/main/java/org/jdiameter/server/impl/io/tcp/NetworkGuard.java
Tue Jan 8 18:07:56 2013
@@ -109,6 +109,8 @@
Socket s = serverSocket.accept();
logger.info("Open incomming connection {}", s);
TCPClientConnection client = new TCPClientConnection(null,
concurrentFactory, s, parser, null);
+ //PCB added logging
+ logger.debug("Finished initialising TCPClientConnection
for {}", s);
for (INetworkConnectionListener listener : listeners) {
listener.newNetworkConnection(client);
}