Revision: 15535
Author: baranowb
Date: Mon Nov 29 01:23:40 2010
Log: Update Issue 2148
http://code.google.com/p/mobicents/source/detail?r=15535
Modified:
/trunk/protocols/ss7/mtp/mtp-impl/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp2.java
/trunk/protocols/ss7/mtp/mtp-impl/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp3.java
/trunk/protocols/ss7/mtp/mtp-impl/src/main/java/org/mobicents/protocols/ss7/mtp/Utils.java
=======================================
---
/trunk/protocols/ss7/mtp/mtp-impl/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp2.java
Thu Oct 7 06:31:02 2010
+++
/trunk/protocols/ss7/mtp/mtp-impl/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp2.java
Mon Nov 29 01:23:40 2010
@@ -139,8 +139,14 @@
static {
- FRAME_NAMES = new String[]{"SIO", "SIN", "SIE", "SIOS", "SIPO",
- "SIPB", "FISU"
+ FRAME_NAMES = new String[]{
+ "SIO",
+ "SIN",
+ "SIE",
+ "SIOS",
+ "SIPO",
+ "SIPB",
+ "FISU"
};
}
@@ -153,8 +159,13 @@
static {
- STATE_NAMES = new String[]{"OUT_OF_SERVICE", "NOT_ALIGNED",
- "ALIGNED", "PROVING", "ALIGNED_READY", "IN_SERVICE"
+ STATE_NAMES = new String[]{
+ "OUT_OF_SERVICE",
+ "NOT_ALIGNED",
+ "ALIGNED",
+ "PROVING",
+ "ALIGNED_READY",
+ "IN_SERVICE"
};
}
@@ -242,11 +253,11 @@
/**
* Subservice field of mtp msg. See Q.704.14.2.2
*/
- private int subservice = -1;
- private static final Logger logger = Logger.getLogger(Mtp2.class);
-
+ private static final Logger ROOT_LOGGER = Logger.getLogger(Mtp2.class);
+ private final Logger logger; //actual logger.
public Mtp2(String name, Mtp1 channel) {
this.name = name;
+ this.logger = ROOT_LOGGER.getLogger(name);
this.channel = channel;
channel.setLink(this);
this.sls = channel.getCode();
@@ -338,20 +349,12 @@
this.reset();
- if (this.enabledL2Debug) {
- trace("Is out fo service now");
- }
- // perform initial read, to make buffer empty.
- //this.layer1.read(rxBuffer);
- // mimics power on.
-
- // queueLSSU(Mtp2.FRAME_STATUS_INDICATION_OS);
-
- // poll = mtpThread.submit(this);
- // t = this.threadFactory.newThread(this);
- // t.start();
- state = Mtp2.MTP2_OUT_OF_SERVICE;
-
+ if(logger.isInfoEnabled()){
+ logger.info("Is out of service now. Starting.");
+ }
+
+ //state = Mtp2.MTP2_OUT_OF_SERVICE;
+ setState(MTP2_OUT_OF_SERVICE);
//send Out of service indicator when link starts.
queueLSSU(Mtp2.FRAME_STATUS_INDICATION_OS);
processTx(16);
@@ -359,6 +362,9 @@
}
public void stop() {
+ if(logger.isInfoEnabled()){
+ logger.info("Stopping link.");
+ }
mtp3.unregisterLink(this);
started = false;
reset();
@@ -372,7 +378,10 @@
// should not be used
protected void startInitialAlignment(boolean resetTxOffset) {
- logger.info(String.format("(%s) Starting initial alignment",
name));
+ if(logger.isDebugEnabled())
+ {
+ logger.debug(String.format("(%s) Starting initial alignment",
name));
+ }
// Comment from Oleg: this is done initialy to setup correct spot
in tx
// buffer: dunno, I just believe, for now.
@@ -381,17 +390,25 @@
}
this.reset();
- if (this.enabledL2Debug) {
- trace(" Starting IAM procedure");
- }
-
+
// switch state
- // state = Mtp2.MTP2_NOT_ALIGNED;
- this.state = MTP2_NOT_ALIGNED;
+
+ //this.state = MTP2_NOT_ALIGNED;
+ this.setState(MTP2_NOT_ALIGNED);
// starting T2 timer
start_T2();
}
+
+ private void setState(int newState)
+ {
+ if(logger.isInfoEnabled())
+ {
+ //iirc it should be info
+ logger.info("State changed in link. "+STATE_NAMES[this.state]+"
--> "+STATE_NAMES[this.state]);
+ }
+ this.state = newState;
+ }
private void reset() {
// reset.
@@ -410,28 +427,32 @@
public void fail() {
cleanupTimers();
- this.state = MTP2_OUT_OF_SERVICE;
-
- logger.info(String.format("(%s) Link Out of service", name));
+ //this.state = MTP2_OUT_OF_SERVICE;
+
+ if(logger.isDebugEnabled())
+ {
+ logger.debug(String.format("(%s) Link Out of service", name));
+ }
+ this.setState(MTP2_OUT_OF_SERVICE);
start_T17();
}
public boolean send(byte[] msg, int len) {
- if (this.state != MTP2_INSERVICE) {
- if (enableSuTrace && enabledL2Debug) {
-
- trace("MTP3 scheduled MSU when not in service,
discarding.");
- }
- return false;
- }
+ if (this.state != MTP2_INSERVICE) {
+ if (this.logger.isEnabledFor(Level.TRACE)) {
+ logger.trace("MTP3 scheduled MSU when not in
service, discarding.");
+ }
+ return false;
+ }
// Here we will queue MSU if there is place in transmission buffer
int possibleFSN = NEXT_FSN(this.retransmissionFSN_LastSent);
// check if transmission buffer is full
if (possibleFSN == this.retransmissionFSN_LastAcked) {
// This means buffer is full;
- if (this.enableSuTrace && enabledL2Debug) {
- trace("Failed to queue msg, transmission buffer is full.");
- }
+
+ if(this.logger.isEnabledFor(Level.TRACE)){
+ logger.trace("Failed to queue msg, transmission buffer is
full.");
+ }
return false;
}
// FSN and all that will be set before puting this into txFrame
buffer.
@@ -446,9 +467,11 @@
//3 == FSN(1) + BSN(1) + LI(1)
this.transmissionBuffer[possibleFSN].len = 3 + len;
// FIXME: add check for short frame?
- if (this.enableSuTrace && enabledL2Debug) {
- trace("Queue MSU");
- }
+
+ if(this.logger.isEnabledFor(Level.TRACE)){
+ logger.trace("Queued MSU");
+ }
+
this.retransmissionFSN_LastSent = possibleFSN;
if (this.retransmissionFSN == _OFF_RTR) {
this.retransmissionFSN = possibleFSN;
@@ -476,8 +499,8 @@
}
- if (this.enableSuTrace && enabledL2Debug) {
- trace("Queue LSSU[" + FRAME_NAMES[indicator] + "]");
+ if(this.logger.isEnabledFor(Level.TRACE)){
+ logger.trace("Queue LSSU[" + FRAME_NAMES[indicator] + "]");
}
}
@@ -488,8 +511,9 @@
this.txFrame[2] = 0;
// txQueue.offer(frame);
- if (this.enableSuTrace && enabledL2Debug) {
- trace("Queue FISU");
+
+ if(this.logger.isEnabledFor(Level.TRACE)){
+ logger.trace("Queue FISU");
}
}
@@ -498,7 +522,10 @@
byte[] b = txQueue.peak();
System.arraycopy(b, 0, txFrame, 0, b.length);
this.txLen = b.length;
-
+ if(logger.isTraceEnabled())
+ {
+ logger.trace("Scheduling frame from
queue: "+Utils.dump(txFrame, txLen, true));
+ }
} else {
switch (state) {
case MTP2_OUT_OF_SERVICE:
@@ -548,6 +575,10 @@
// trace("Scheduled next frame in tx buffer: "
// + dump(this.txFrame, this.txLen, false));
// }
+ if(logger.isTraceEnabled())
+ {
+ logger.trace("Retransmiting
frame: "+Utils.dump(txFrame, txLen, true));
+ }
return;
}
// else queue FISU
@@ -580,11 +611,12 @@
queueLSSU(FRAME_STATUS_INDICATION_N);
}
start_T3();
- this.state = MTP2_ALIGNED;
+ //this.state = MTP2_ALIGNED;
if (logger.isDebugEnabled()) {
logger.debug(String.format("(%s) Aligned",
name));
}
+ this.setState(MTP2_ALIGNED);
break;
case FRAME_STATUS_INDICATION_E:
// 1. stop t2
@@ -601,11 +633,12 @@
// 4. start T3
start_T3();
// 5. set state
- this.state = MTP2_ALIGNED;
+ //this.state = MTP2_ALIGNED;
if (logger.isDebugEnabled()) {
logger.debug(String.format("(%s) Aligned",
name));
}
+ this.setState(MTP2_ALIGNED);
break;
default:
// logger.warn("Ingoring LSSU[" + _FRAME_NAMES[type]
@@ -638,11 +671,12 @@
// 6. cancel further proving.
this.futureProving = false;
// 7. set state
- this.state = MTP2_PROVING;
+ //this.state = MTP2_PROVING;
if (logger.isDebugEnabled()) {
logger.debug(String.format("(%s) Proving",
name));
}
+ this.setState(MTP2_PROVING);
break;
case FRAME_STATUS_INDICATION_OS:
// we should invoke ALI first, but we cancel timer
@@ -672,11 +706,12 @@
// 3. start T3
start_T3();
// 4. swithc state
- this.state = MTP2_ALIGNED;
+ //this.state = MTP2_ALIGNED;
if (logger.isDebugEnabled()) {
logger.debug(String.format("(%s) Aligned",
name));
}
+ this.setState(MTP2_ALIGNED);
break;
case FRAME_STATUS_INDICATION_E:
// NOTE: this one is not covered in Olegs src.
@@ -790,8 +825,8 @@
// FIXME: switch to this
// System.arraycopy(rxFrame, 4, sif, 0, realLength);
- if (logger.isDebugEnabled()) {
- logger.debug(String.format("(%s) Delivering MSU to layer
3 ", name));
+ if (logger.isEnabledFor(Level.TRACE)) {
+ logger.trace(String.format("(%s) Delivering MSU to layer
3 ", name));
}
mtp3.onMessage(sio, sif, this);
}
@@ -815,16 +850,17 @@
} else {
type = "MSU";
}
- logger.trace(String.format("(%s) Receive frame, type=%s,
fsn=%d, fib=%d, bsn=%d, bib=%d", name, type, fsn, fib, bsn, bib));
-
+ if(this.logger.isEnabledFor(Level.TRACE)){
+ logger.trace(String.format("(%s) Receive frame, type=%s,
fsn=%d, fib=%d, bsn=%d, bib=%d", name, type, fsn, fib, bsn, bib));
+ }
}
//Why it was 5?
if (li + 3 > rxLen) {
- if (this.enableSuTrace && enabledL2Debug) {
- trace("Discarding frame on wrong RX Len: " + rxLen + " > "
+ li);
- }
+ if(this.logger.isEnabledFor(Level.TRACE)){
+ logger.trace("Discarding frame on wrong RX Len: " + rxLen
+ " > " + li);
+ }
return;
}
@@ -859,10 +895,7 @@
// FIXME: return here?
break;
case MTP2_ALIGNED_READY:
-
- if (enabledL2Debug) {
- trace("Received proper SU in ALIGNED_READY state,
switching to IN_SERVICE.");
- }
+
this.eCount = 0;
this.dCount = 0;
this.stop_T7();
@@ -872,12 +905,12 @@
this.sendBIB = fib;
this.retransmissionFSN_LastAcked = bsn;
- this.state = MTP2_INSERVICE;
+ //this.state = MTP2_INSERVICE;
if (logger.isDebugEnabled()) {
logger.debug(String.format("(%s) MTP now
IN_SERVICE, Notifing layer 3", name));
}
-
+ this.setState(MTP2_INSERVICE);
mtp3.linkInService(this);
break;
}
@@ -1006,12 +1039,7 @@
// private void processRx(ByteBuffer bb, int len) {
int i = 0;
- // byte[] buff = bb.array();
- if (this.enableDataTrace && enabledL2Debug) {
- //dataHolder.add(new BufferHolder(System.currentTimeMillis(),
buff,len));
- // FIXME:
-// Utils.getInstance().addBuffer(this.sls, this.name,
this.linkSet.getName(), this.linkSet.getId(), System.currentTimeMillis(),
buff, len);
- }
+
// start HDLC alg
while (i < len) {
while (rxState.bits <= 24 && i < len) {
@@ -1132,8 +1160,12 @@
processRx(rxBuffer, bytesRead);
}
} catch (Exception e) {
- state = MTP2_OUT_OF_SERVICE;
- logger.error(String.format("(%s) Can not read data from
channel", name), e);
+ //state = MTP2_OUT_OF_SERVICE;
+ if(logger.isEnabledFor(Level.ERROR))
+ {
+ logger.error(String.format("(%s) Can not read data from
channel", name), e);
+ }
+ this.setState(MTP2_OUT_OF_SERVICE);
mtp3.linkFailed(this);
}
}
@@ -1150,8 +1182,12 @@
logger.trace("Sending frame");
}
} catch (Exception e) {
- state = MTP2_OUT_OF_SERVICE;
- logger.error(String.format("(%s) Can not write data to
channel", name), e);
+ //state = MTP2_OUT_OF_SERVICE;
+ if(logger.isEnabledFor(Level.ERROR))
+ {
+ logger.error(String.format("(%s) Can not write data to channel",
name), e);
+ }
+ this.setState(MTP2_OUT_OF_SERVICE);
mtp3.linkFailed(this);
}
}
@@ -1183,8 +1219,10 @@
this.state = MTP2_OUT_OF_SERVICE;
// NOTE: buffer is flushed on start alignment.
start_T17();
-
- logger.info(String.format("(%s) Alignment not possible, initiating
T17 for restart. Cause: %s", name, cause));
+ if(logger.isDebugEnabled())
+ {
+ logger.debug(String.format("(%s) Alignment not possible,
initiating T17 for restart. Cause: %s", name, cause));
+ }
}
private void alignmentBroken(String cause) {
@@ -1198,7 +1236,8 @@
}
}
- this.state = MTP2_OUT_OF_SERVICE;
+ //this.state = MTP2_OUT_OF_SERVICE;
+ this.setState(MTP2_OUT_OF_SERVICE);
// NOTE: buffer is flushed on start alignment.
start_T17();
@@ -1221,11 +1260,12 @@
stop_T2();
stop_T3();
stop_T4();
- this.state = MTP2_ALIGNED_READY;
+ //this.state = MTP2_ALIGNED_READY;
if (logger.isDebugEnabled()) {
logger.debug(String.format("(%s) Aligned ready", name));
}
+ this.setState(MTP2_ALIGNED_READY);
// now we wait for proper data
}
@@ -1241,7 +1281,8 @@
if (this.mtp3 != null) {
mtp3.linkFailed(this);
}
- state = MTP2_OUT_OF_SERVICE;
+ //state = MTP2_OUT_OF_SERVICE;
+ this.setState(MTP2_OUT_OF_SERVICE);
}
break;
case MTP2_PROVING:
@@ -1253,8 +1294,9 @@
if (this.provingAttempts < 5) {
this.futureProving = true;
- if (enabledL2Debug) {
- trace("Exceeded AERM threshold[ " +
aermThreshold + " ] errors[ " + eCount + " ], proving attempts[ " +
provingAttempts + " ]");
+ if(this.logger.isEnabledFor(Level.WARN)){
+ //FIXME: should this remain warn ?
+ logger.warn("Exceeded AERM threshold[ " +
aermThreshold + " ] errors[ " + eCount + " ], proving attempts[ " +
provingAttempts + " ], continue...");
}
return;
}
@@ -1313,12 +1355,13 @@
alignmentNotPossible("T2 Expired.");
// 2. cancel E
emergency = false;
- if (logger.isEnabledFor(Level.WARN) && enabledL2Debug) {
- trace("Timer T2 has expired, Alignment not
possible. ");
+ if(logger.isEnabledFor(Level.WARN)){
+ //FIXME: should this be debug ?
+ logger.warn("Timer T2 has expired, Alignment not
possible. ");
}
} else {
- if (logger.isEnabledFor(Level.WARN) && enabledL2Debug) {
- trace("T2 fired in state[ " + STATE_NAMES[tmpState]
+ " ]");
+ if(logger.isEnabledFor(Level.WARN)){
+ logger.warn("T2 fired in state[ " +
STATE_NAMES[tmpState] + " ]");
}
}
}
@@ -1337,12 +1380,12 @@
alignmentNotPossible("T3 Expired.");
// 2.cancel E
emergency = false;
- if (logger.isEnabledFor(Level.WARN) && enabledL2Debug) {
- trace("Timer T3 has expired, Alignment not
possible. ");
+ if(logger.isEnabledFor(Level.WARN)){
+ logger.warn("Timer T3 has expired, Alignment not
possible. ");
}
} else {
- if (logger.isEnabledFor(Level.WARN) && enabledL2Debug) {
- trace("T3 fired in state[ " + STATE_NAMES[tmpState]
+ " ]");
+ if(logger.isEnabledFor(Level.WARN)){
+ logger.warn("T3 fired in state[ " +
STATE_NAMES[tmpState] + " ]");
}
}
}
@@ -1373,8 +1416,8 @@
}
} else {
- if (logger.isEnabledFor(Level.WARN) && enabledL2Debug) {
- trace("T4 fired in state[ " + STATE_NAMES[tmpState]
+ " ]");
+ if(logger.isEnabledFor(Level.WARN)){
+ logger.warn("T4 fired in state[ " +
STATE_NAMES[tmpState] + " ]");
}
}
}
@@ -1457,49 +1500,9 @@
public boolean isT17() {
return !t17Action.isCanceled();
}
- /**
- * Determines if mtp should dump hex data received.
- */
- private boolean enableDataTrace = false;
- /**
- * Determines if mtp should put trace of sent/received SUs
- */
- private boolean enableSuTrace = false;
- private boolean enabledL2Debug = false;
-
- public boolean isL2Debug() {
- return enabledL2Debug;
- }
-
- public void setL2Debug(boolean l2Debug) {
- this.enabledL2Debug = l2Debug;
- }
-
- public boolean isEnableDataTrace() {
- return enableDataTrace;
- }
-
- public void setEnableDataTrace(boolean enableDataTrace) {
- this.enableDataTrace = enableDataTrace;
- }
-
- public boolean isEnableSuTrace() {
- return enableSuTrace;
- }
-
- public void setEnableSuTrace(boolean enableSuTrace) {
- this.enableSuTrace = enableSuTrace;
- }
-
- public void trace(String msg) {
- // FIXME: add sls
- StringBuilder sb = new StringBuilder();
- sb.append("\n").append(System.currentTimeMillis()).append(" Link
[").append(name).append("] [").append(" state = ").append(
- STATE_NAMES[state]).append(" ]").append(" fsn
= ").append(retransmissionFSN_LastSent).append(", fsn_acked
= ").append(this.retransmissionFSN_LastAcked).append(", rtrFSN
= ").append(this.retransmissionFSN).append(", fib = ").append(
- this.sendFIB).append(", bsn
= ").append(this.sendBSN).append(", bib
= ").append(this.sendBIB).append(") ").append(
- msg);
- Utils.getInstance().append(sb.toString());
- }
+
+
+
// ////////////////////
// Some mtp classes //
@@ -1514,22 +1517,17 @@
* length of actual data fram to be transmited.
*/
int len = 0; // public boolean isFree()
- // {
- // return this.len ==0;
- // }
- // public void free()
- // {
- // this.len =0;
- // }
- // public byte[] getData()
- // {
- // return this.frame;
- // }
- // public int getLen()
- // {
- // return this.len;
- // }
- }
+ }
+
+// private void log(String msg, Level level) {
+// // FIXME: yeah, I know, but in case of more links, logs will be
a pain
+// StringBuilder sb = new StringBuilder();
+//
+// //
+// sb.append(" Link [").append(name).append("] [").append(" state
= ").append( STATE_NAMES[state]).append(" ] ").append(msg);
+// logger.log(level, sb.toString());
+//
+// }
private static final int NEXT_FSN(int x) {
// kill FIB if present
=======================================
---
/trunk/protocols/ss7/mtp/mtp-impl/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp3.java
Fri Nov 26 07:02:24 2010
+++
/trunk/protocols/ss7/mtp/mtp-impl/src/main/java/org/mobicents/protocols/ss7/mtp/Mtp3.java
Mon Nov 29 01:23:40 2010
@@ -241,7 +241,7 @@
{
if (logger.isTraceEnabled()) {
logger.trace(
- String.format("(%s) Received MSSU with bad
SSI, [si=" + serviceIndicator + ",ssi=" + subserviceIndicator + ", dpc=" +
dpc + ", opc=" + opc + ", sls=" + sls + "] data: ", mtp2.getName()) +
Arrays.toString(sif));
+ String.format("(%s) Received MSSU with bad
SSI, discarding! [si=" + serviceIndicator + ",ssi=" + subserviceIndicator
+ ", dpc=" + dpc + ", opc=" + opc + ", sls=" + sls + "] data: ",
mtp2.getName()) + Arrays.toString(sif));
}
return;
}else if (logger.isTraceEnabled()) {
@@ -249,7 +249,7 @@
String.format("(%s) Received MSSU [si=" +
serviceIndicator + ",ssi=" + subserviceIndicator + ", dpc=" + dpc + ",
opc=" + opc + ", sls=" + sls + "] data: ", mtp2.getName()) +
Arrays.toString(sif));
}
-
+
switch (serviceIndicator) {
case LINK_MANAGEMENT:
int h0 = sif[5] & 0x0f;
@@ -277,8 +277,8 @@
int len = (sif[6] & 0xf0) >>> 4;
if (h0 == 1 && h1 == 1) {
- if (logger.isTraceEnabled()) {
- logger.trace(String.format("(%s) Received
SLTM", mtp2.getName()));
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("(%s) Received
SLTM", mtp2.getName()));
}
// receive SLTM from remote end
// create response
@@ -292,14 +292,14 @@
// +1 cause we copy LEN byte also.
System.arraycopy(sif, 6, slta, 6, len + 1);
- if (logger.isTraceEnabled()) {
- logger.trace(String.format("(%s) Responding
with SLTA", mtp2.getName()));
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("(%s) Responding
with SLTA", mtp2.getName()));
}
mtp2.send(slta, slta.length);
} else if (h0 == 1 && h1 == 2) {
// receive SLTA from remote end
- if (logger.isTraceEnabled()) {
- logger.trace(String.format("(%s) Received
SLTA", mtp2.getName()));
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("(%s) Received
SLTA", mtp2.getName()));
}
//checking pattern
@@ -316,12 +316,15 @@
//logger.info("SLTA pattern does not match:
\n"+Arrays.toString(sif)+"\n"+Arrays.toString(SLTM_PATTERN));
}
} else {
- logger.warn(String.format("(%s) Unexpected message
type", mtp2.getName()));
+ if(logger.isEnabledFor(Level.WARN))
+ {
+ logger.warn(String.format("(%s) Unexpected message
type", mtp2.getName()));
+ }
}
break;
case _SI_SERVICE_SCCP:
- if (logger.isEnabledFor(Level.TRACE) && isL3Debug()) {
- mtp2.trace("XXX MSU Indicates SCCP");
+ if (logger.isDebugEnabled()) {
+ logger.debug("Received SCCP MSU");
}
@@ -338,8 +341,8 @@
}
break;
case _SI_SERVICE_ISUP:
- if (logger.isEnabledFor(Level.TRACE) && isL3Debug()) {
- mtp2.trace("XXX MSU Indicates ISUP");
+ if (logger.isDebugEnabled()) {
+ logger.debug("Received ISUP MSU");
}
if (mtp3Listener != null) {
@@ -356,8 +359,8 @@
}
break;
default:
- if (logger.isEnabledFor(Level.WARN) && isL3Debug()) {
- mtp2.trace("XXX MSU Indicates UNKNOWN
SERVICE!!!!!!!!!!!: " + Utils.dump(sif, sif.length, false));
+ if (logger.isEnabledFor(Level.WARN) ) {
+ logger.warn("Received MSU for UNKNOWN
SERVICE!!!!!!!!!!!: " + Utils.dump(sif, sif.length, false));
}
break;
}
@@ -385,8 +388,8 @@
byte sls = (byte) sls(msg, 1);
Mtp2 link = this.selectLink(sls);
- if (logger.isDebugEnabled()) {
- logger.debug(String.format("MTP3 passes MSU to layer 2,
(%s) ", link != null ? link.getName() : "NO LINK"));
+ if (logger.isEnabledFor(Level.TRACE)) {
+ logger.trace(String.format("MTP3 passes MSU to layer 2,
(%s) ", link != null ? link.getName() : "NO LINK"));
}
if (link == null) {
return false;
@@ -436,6 +439,7 @@
}
public void linkFailed(Mtp2 link) {
+ //FIXME: add debug or trace?
//remove this link from list of active links
linkset.remove(link);
@@ -634,16 +638,5 @@
data[4] = (byte) (((opc >> 10) & 0x0F) | ((sls & 0x0F) << 4));
}
- ////////////////
- // Debug Part //
- ////////////////
- private boolean l3Debug;
-
- public boolean isL3Debug() {
- return l3Debug;
- }
-
- public void setL3Debug(boolean l3Debug) {
- this.l3Debug = l3Debug;
- }
-}
+
+}
=======================================
---
/trunk/protocols/ss7/mtp/mtp-impl/src/main/java/org/mobicents/protocols/ss7/mtp/Utils.java
Wed Aug 25 23:23:02 2010
+++
/trunk/protocols/ss7/mtp/mtp-impl/src/main/java/org/mobicents/protocols/ss7/mtp/Utils.java
Mon Nov 29 01:23:40 2010
@@ -88,11 +88,7 @@
createTrace(t, sb, true);
return sb.toString();
}
-
- public static Utils getInstance() {
- return _INSTANCE_;
- }
-
+
/**
* Construct a String containing a hex-dump of a byte array
* @param label the label of the hexdump or null
@@ -185,141 +181,5 @@
return sb.toString();
}
- /**
- * General logger.
- */
- private static final Logger logger = Logger.getLogger(Utils.class);
- private static final Utils _INSTANCE_ = new Utils();
- private StringBuilder loggBuilder = new StringBuilder();
- private LinkedList<BufferHolder> dataHolder = new
LinkedList<BufferHolder>();
- private Future debugFuture; //this is doubling of vars, but....
- private boolean enabledL2Debug = false;
- private boolean enableDataTrace = false;
- //private boolean enableSuTrace = false;
- private boolean enabledL3Debug = false;
-
- /**
- * @return the enabledL2Debug
- */
- public boolean isEnabledL2Debug() {
- return enabledL2Debug;
- }
-
- /**
- * @param enabledL2Debug the enabledL2Debug to set
- */
- public void setEnabledL2Debug(boolean enabledL2Debug) {
- this.enabledL2Debug = enabledL2Debug;
- }
-
- /**
- * @return the enableDataTrace
- */
- public boolean isEnableDataTrace() {
- return enableDataTrace;
- }
-
- /**
- * @param enableDataTrace the enableDataTrace to set
- */
- public void setEnableDataTrace(boolean enableDataTrace) {
- this.enableDataTrace = enableDataTrace;
- }
-// /**
-// * @return the enableSuTrace
-// */
-// public boolean isEnableSuTrace() {
-// return enableSuTrace;
-// }
-// /**
-// * @param enableSuTrace the enableSuTrace to set
-// */
-// public void setEnableSuTrace(boolean enableSuTrace) {
-// this.enableSuTrace = enableSuTrace;
-// }
- /**
- * @return the enabledL3Debug
- */
- public boolean isEnabledL3Debug() {
- return enabledL3Debug;
- }
-
- /**
- * @param enabledL3Debug the enabledL3Debug to set
- */
- public void setEnabledL3Debug(boolean enabledL3Debug) {
- this.enabledL3Debug = enabledL3Debug;
- }
-
- public void append(String s) {
- this.loggBuilder.append("\n" + s);
- }
-
- public void stopDebug() {
- if (this.debugFuture != null) {
- this.debugFuture.cancel(false);
- this.debugFuture = null;
- }
- }
-
- private final class LogginAction implements Runnable {
-
- public void run() {
-
- // TODO Auto-generated method stub
- if ((enabledL2Debug || enabledL3Debug) && loggBuilder.length()
0) {
- logger.info(loggBuilder);
- loggBuilder = new StringBuilder();
- }
- if (enableDataTrace && enabledL2Debug && dataHolder.size() >
0) {
- StringBuilder sb = new StringBuilder();
- while (dataHolder.size() > 0) {
- sb.append(dataHolder.remove(0)).append("\n");
- }
- logger.info("\n" + sb);
- }
- }
- }
- //FIXME: this will be moved once everything is coded and we have
proper framework
- // //////////////////////////////////////
- // LOGGERS Section. Note that MTP acts //
- // on 2ms basis, logging proves to be //
- // killer, we use async loggin, one //
- // event per second //
- // //////////////////////////////////////
- private class BufferHolder {
-
- private long stamp;
- private byte[] buffer;
- private int len;
- private String linkName;
- private int linkSls = -1;
- private String linkSetName;
- private int linkSetId = -1;
-
- private BufferHolder(long stamp, byte[] buffer, int len,
- String linkName, int linkSls, String linkSetName, int
linkSetId) {
- super();
- this.stamp = stamp;
- this.buffer = buffer;
- this.len = len;
- System.arraycopy(buffer, 0, this.buffer, 0, len);
- this.linkName = linkName;
- this.linkSls = linkSls;
- this.linkSetName = linkSetName;
- this.linkSetId = linkSetId;
- }
-
- @Override
- public String toString() {
- return "T:" + this.stamp + ":" + linkName + ":" + linkSls
+ ":" + linkSetName + ":" + linkSetId + ":" + Utils.dump(this.buffer, len,
false);
- }
- }
-
- public void addBuffer(int sls, String name, String linkSetName, int
linkSetId,
- long currentTimeMillis, byte[] buff, int len) {
- //hmm works better if method is implemented :)
- BufferHolder bh = new BufferHolder(currentTimeMillis, buff, len,
name, sls, linkSetName, linkSetId);
- dataHolder.add(bh);
- }
-}
+
+}