Revision: b5dfb18f5ef0
Author: [email protected] <[email protected]>
Date: Thu Jul 12 06:18:52 2012
Log: changed the logic to get SmppServerSession from systemId if
present
http://code.google.com/p/smscgateway/source/detail?r=b5dfb18f5ef0
Modified:
/core/slee/services/mtsbb/src/main/java/org/mobicents/smsc/slee/services/mt/MtSbb.java
/core/slee/services/rxsmppserversbb/src/main/java/org/mobicents/smsc/slee/services/smpp/server/rx/RxSmppServerSbb.java
/core/slee/services/txsmppserversbb/src/main/java/org/mobicents/smsc/slee/services/smpp/server/tx/TxSmppServerSbb.java
/core/slee/smpp-server-ra/ra/src/main/java/org/mobicents/smsc/slee/resources/smpp/server/SmppServerSessionsImpl.java
=======================================
---
/core/slee/services/mtsbb/src/main/java/org/mobicents/smsc/slee/services/mt/MtSbb.java
Wed Jul 11 08:55:35 2012
+++
/core/slee/services/mtsbb/src/main/java/org/mobicents/smsc/slee/services/mt/MtSbb.java
Thu Jul 12 06:18:52 2012
@@ -279,7 +279,10 @@
deliveryReport.setDestAddrNpi(original.getSourceAddrNpi());
deliveryReport.setDestAddrTon(original.getSourceAddrTon());
- deliveryReport.setSystemId(original.getSystemId());
+ // Setting SystemId as null, so RxSmppServerSbb
actually tries to
+ // find real SmppServerSession from Destination TON,
NPI and address
+ // range
+ deliveryReport.setSystemId(null);
deliveryReport.setSubmitDate(original.getSubmitDate());
=======================================
---
/core/slee/services/rxsmppserversbb/src/main/java/org/mobicents/smsc/slee/services/smpp/server/rx/RxSmppServerSbb.java
Wed Jul 11 08:55:35 2012
+++
/core/slee/services/rxsmppserversbb/src/main/java/org/mobicents/smsc/slee/services/smpp/server/rx/RxSmppServerSbb.java
Thu Jul 12 06:18:52 2012
@@ -39,19 +39,26 @@
public void onDeliverSm(SmsEvent event, ActivityContextInterface aci,
EventContext eventContext) {
try {
- SmppServerSession smppSession =
smppServerSessions.getSmppSession(event.getDestAddrTon(),
- event.getDestAddrNpi(),
event.getDestAddr());
-
- if (smppSession == null) {
- this.logger.severe(String.format(
- "Received Delivery Report SmsEvent=%s but no SmppSession found for
SystemId", event));
+ String systemId = event.getSystemId();
+ SmppServerSession smppServerSession = null;
+ if (systemId == null) {
+ //Try to find SmppServerSession from dest TON,
NPI and Range
+ smppServerSession =
smppServerSessions.getSmppSession(event.getDestAddrTon(),
event.getDestAddrNpi(),
+ event.getDestAddr());
+ } else {
+ smppServerSession =
smppServerSessions.getSmppSession(systemId);
+ }
+
+ if (smppServerSession == null) {
+ this.logger.severe(String.format("Received DELIVER_SM SmsEvent=%s but
no SmppServerSession found",
+ event));
return;
}
- if (!smppSession.isBound()) {
+ if (!smppServerSession.isBound()) {
this.logger.severe(String.format(
- "Received Delivery Report SmsEvent=%s but no SmppSession=%s is not
BOUND", event,
- event.getSystemId()));
+ "Received DELIVER_SM SmsEvent=%s but SmppServerSession=%s is not
BOUND", event,
+
smppServerSession.getSystemId()));
// TODO : Add to SnF module
return;
}
@@ -65,7 +72,7 @@
// TODO : waiting for 2 secs for window to accept our
request, is it
// good? Should time be more here?
- SmppServerTransaction smppServerTransaction =
smppSession.sendRequestPdu(deliverSm, 2000);
+ SmppServerTransaction smppServerTransaction =
smppServerSession.sendRequestPdu(deliverSm, 2000);
ActivityContextInterface smppTxaci =
this.smppServerTransactionACIFactory
.getActivityContextInterface(smppServerTransaction);
smppTxaci.attach(this.sbbContext.getSbbLocalObject());
=======================================
---
/core/slee/services/txsmppserversbb/src/main/java/org/mobicents/smsc/slee/services/smpp/server/tx/TxSmppServerSbb.java
Tue May 15 06:25:33 2012
+++
/core/slee/services/txsmppserversbb/src/main/java/org/mobicents/smsc/slee/services/smpp/server/tx/TxSmppServerSbb.java
Thu Jul 12 06:18:52 2012
@@ -52,7 +52,7 @@
if (this.logger.isInfoEnabled()) {
this.logger.info("Received SUBMIT_SM = " + event + " from SystemId=" +
systemId);
}
-
+
String messageId = this.smppServerSessions.getNextMessageId();
SmsEvent smsEvent = new SmsEvent();
@@ -116,16 +116,17 @@
this.logger.severe("Error while trying to send DataSmResponse=" +
response, e);
}
}
-
+
public void onPduRequestTimeout(PduRequestTimeout event,
ActivityContextInterface aci, EventContext eventContext) {
logger.severe(String.format("onPduRequestTimeout :
PduRequestTimeout=%s", event));
- //TODO : Handle this
- }
-
- public void onRecoverablePduException(RecoverablePduException event,
ActivityContextInterface aci, EventContext eventContext) {
+ // TODO : Handle this
+ }
+
+ public void onRecoverablePduException(RecoverablePduException event,
ActivityContextInterface aci,
+ EventContext eventContext) {
logger.severe(String.format("onRecoverablePduException :
RecoverablePduException=%s", event));
- //TODO : Handle this
- }
+ // TODO : Handle this
+ }
public abstract void fireSms(SmsEvent event, ActivityContextInterface
aci, javax.slee.Address address);
@@ -236,9 +237,10 @@
// If null means there are no SMS handled by Mt for
this destination
// address. Lets create new NullActivity and bind it to
// naming-facility
-
- this.logger.info(String
- .format("lookup of NullActivityContextInterface returned null, create
new NullActivity"));
+ if (this.logger.isInfoEnabled()) {
+ this.logger.info(String
+ .format("lookup of NullActivityContextInterface returned null,
create new NullActivity"));
+ }
nullActivity =
this.sbbContext.getNullActivityFactory().createNullActivity();
nullActivityContextInterface =
this.sbbContext.getNullActivityContextInterfaceFactory()
@@ -283,7 +285,9 @@
int pendingEventsOnNullActivity =
txSmppServerSbbActivityContextInterface.getPendingEventsOnNullActivity();
pendingEventsOnNullActivity = pendingEventsOnNullActivity + 1;
- this.logger.info(String.format("pendingEventsOnNullActivity = %d",
pendingEventsOnNullActivity));
+ if (this.logger.isInfoEnabled()) {
+ this.logger.info(String.format("pendingEventsOnNullActivity = %d",
pendingEventsOnNullActivity));
+ }
txSmppServerSbbActivityContextInterface.setPendingEventsOnNullActivity(pendingEventsOnNullActivity);
// We have NullActivityContextInterface, lets fire SmsEvent on
this
=======================================
---
/core/slee/smpp-server-ra/ra/src/main/java/org/mobicents/smsc/slee/resources/smpp/server/SmppServerSessionsImpl.java
Sat Jul 7 10:32:42 2012
+++
/core/slee/smpp-server-ra/ra/src/main/java/org/mobicents/smsc/slee/resources/smpp/server/SmppServerSessionsImpl.java
Thu Jul 12 06:18:52 2012
@@ -1,13 +1,12 @@
package org.mobicents.smsc.slee.resources.smpp.server;
-import java.util.Collection;
import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.slee.facilities.Tracer;
-import javolution.util.FastList;
+import javolution.util.FastMap;
import org.mobicents.smsc.slee.resources.smpp.server.events.EventsType;
import
org.mobicents.smsc.slee.resources.smpp.server.events.PduRequestTimeout;
@@ -35,7 +34,8 @@
private SmppServerResourceAdaptor smppServerResourceAdaptor = null;
- private Collection<SmppServerSessionImpl> smppServerSessions = new
FastList<SmppServerSessionImpl>().shared();
+ private FastMap<String, SmppServerSessionImpl> smppServerSessions = new
FastMap<String, SmppServerSessionImpl>()
+ .shared();
protected SmppSessionHandlerInterfaceImpl smppSessionHandlerInterfaceImpl
= null;
@@ -52,7 +52,9 @@
}
public SmppServerSession getSmppSession(byte ton, byte npi, String
address) {
- for (SmppServerSessionImpl smppServerSessionImpl :
smppServerSessions) {
+ for (FastMap.Entry<String, SmppServerSessionImpl> e =
smppServerSessions.head(), end = smppServerSessions
+ .tail(); (e = e.getNext()) != end;) {
+ SmppServerSessionImpl smppServerSessionImpl =
e.getValue();
SmppBindType sessionBindType =
smppServerSessionImpl.getBindType();
if (sessionBindType == SmppBindType.TRANSCEIVER || sessionBindType ==
SmppBindType.RECEIVER) {
@@ -62,10 +64,14 @@
return smppServerSessionImpl;
}
}
- }// for
+ }
tracer.warning(String.format("No SmppServerSession found for address
range=%s", address));
return null;
}
+
+ public SmppServerSession getSmppSession(String systemId) {
+ return this.smppServerSessions.get(systemId);
+ }
protected SmppSessionHandlerInterface getSmppSessionHandlerInterface() {
return this.smppSessionHandlerInterfaceImpl;
@@ -75,10 +81,14 @@
tracer.info(String.format("smppServerSessions.size()=%d",
smppServerSessions.size()));
- for (SmppServerSessionImpl session : smppServerSessions) {
+ for (FastMap.Entry<String, SmppServerSessionImpl> e =
smppServerSessions.head(), end = smppServerSessions
+ .tail(); (e = e.getNext()) != end;) {
+
+ String key = e.getKey();
+ SmppServerSessionImpl session = e.getValue();
session.getWrappedSmppServerSession().close();
if (tracer.isInfoEnabled()) {
- tracer.info(String.format("Closed Session=%s",
session.getSystemId()));
+ tracer.info(String.format("Closed Session=%s",
key));
}
}
@@ -95,7 +105,7 @@
public SmppSessionHandler sessionCreated(Long sessionId,
com.cloudhopper.smpp.SmppServerSession session,
BaseBindResp preparedBindResponse) throws
SmppProcessingException {
SmppServerSessionImpl smppServerSessionImpl = new
SmppServerSessionImpl(session, smppServerResourceAdaptor);
- smppServerSessions.add(smppServerSessionImpl);
+ smppServerSessions.put(session.getConfiguration().getSystemId(),
smppServerSessionImpl);
if (tracer.isInfoEnabled()) {
tracer.info(String.format("Added Session=%s to list of maintained
sessions", session.getConfiguration()
.getSystemId()));
@@ -105,24 +115,18 @@
@Override
public void sessionDestroyed(Long sessionId,
com.cloudhopper.smpp.SmppServerSession session) {
- boolean destroyed = false;
- for (SmppServerSessionImpl smppServerSessionImpl :
smppServerSessions) {
- if
(smppServerSessionImpl.getSystemId().equals(session.getConfiguration().getSystemId()))
{
-
smppServerSessions.remove(smppServerSessionImpl);
- if (tracer.isInfoEnabled()) {
- tracer.info(String.format("Removed Session=%s from list of
maintained sessions", session
-
.getConfiguration().getSystemId()));
- }
- destroyed = true;
- break;
- }
- }
-
- if (!destroyed) {
+ SmppServerSessionImpl smppSession =
smppServerSessions.remove(session.getConfiguration().getSystemId());
+ if (smppSession != null) {
+ if (tracer.isInfoEnabled()) {
+ tracer.info(String.format("Removed Session=%s from list of maintained
sessions", session
+
.getConfiguration().getSystemId()));
+ }
+ } else {
tracer.warning(String.format("Session destroyed for=%, but was not
maintained in list of sessions",
session.getConfiguration().getSystemId()));
}
}
+
}
protected class SmppSessionHandlerImpl implements SmppSessionHandler {