Revision: c10d2f6316ad
Author: [email protected] <[email protected]>
Date: Fri Jan 4 03:48:23 2013
Log: Issue 218: M3UA shouldn't limit the SLS
http://code.google.com/p/jss7/source/detail?r=c10d2f6316ad
Modified:
/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/AsImpl.java
/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/M3UAManagementImpl.java
/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/M3UARouteManagement.java
=======================================
---
/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/AsImpl.java
Wed Dec 12 08:26:20 2012
+++
/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/AsImpl.java
Fri Jan 4 03:48:23 2013
@@ -111,8 +111,7 @@
private IPSPType ipspType = null;
private NetworkAppearance networkAppearance = null;
- private int[] slsVsAspTable = null;
- private int maxAsps = 0;
+ private final int[] slsVsAspTable = new int[256];
private int aspSlsMask = 0x07;
private int aspSlsShiftPlaces = 0x00;
@@ -360,45 +359,65 @@
RoutingLabelFormat routingLabelFormat =
this.m3UAManagementImpl.getRoutingLabelFormat();
- // TODO : Its assumed that 1 bit of SLS is always used for AS
- // loadsharing. But what if there is no loadsharing among AS
and all
- // bits are to be used for ASP loadsharing?
- this.maxAsps = (routingLabelFormat.getMaxSls() >> 1);
-
- this.slsVsAspTable = new int[this.maxAsps];
-
- if (this.m3UAManagementImpl.isUseLsbForLinksetSelection()) {
- this.aspSlsShiftPlaces = 0x01;
- switch (routingLabelFormat.getMaxSls()) {
- case 256:
+ switch (this.m3UAManagementImpl.getMaxAsForRoute()) {
+ case 1:
+ case 2:
+ if
(this.m3UAManagementImpl.isUseLsbForLinksetSelection()) {
this.aspSlsMask = 0xfe;
- break;
- case 32:
- this.aspSlsMask = 0x1e;
- break;
- case 16:
- this.aspSlsMask = 0x0e;
- break;
- default:
- this.aspSlsMask = 0x0e;
- break;
+ this.aspSlsShiftPlaces = 0x01;
+ } else {
+ this.aspSlsMask = 0x7f;
+ this.aspSlsShiftPlaces = 0x00;
+ }
+ break;
+ case 3:
+ case 4:
+ if
(this.m3UAManagementImpl.isUseLsbForLinksetSelection()) {
+ this.aspSlsMask = 0xfc;
+ this.aspSlsShiftPlaces = 0x02;
+ } else {
+ this.aspSlsMask = 0x3f;
+ this.aspSlsShiftPlaces = 0x00;
}
- } else {
- this.aspSlsShiftPlaces = 0x0;
- switch (routingLabelFormat.getMaxSls()) {
- case 256:
- this.aspSlsMask = 0x7f;
- break;
- case 32:
+ break;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ if
(this.m3UAManagementImpl.isUseLsbForLinksetSelection()) {
+ this.aspSlsMask = 0xf8;
+ this.aspSlsShiftPlaces = 0x04;
+ } else {
+ this.aspSlsMask = 0x1f;
+ this.aspSlsShiftPlaces = 0x00;
+ }
+ break;
+ case 9:
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ if
(this.m3UAManagementImpl.isUseLsbForLinksetSelection()) {
+ this.aspSlsMask = 0xf0;
+ this.aspSlsShiftPlaces = 0x04;
+ } else {
this.aspSlsMask = 0x0f;
- break;
- case 16:
- this.aspSlsMask = 0x07;
- break;
- default:
- this.aspSlsMask = 0x07;
- break;
+ this.aspSlsShiftPlaces = 0x00;
+ }
+ break;
+ default:
+ if
(this.m3UAManagementImpl.isUseLsbForLinksetSelection()) {
+ this.aspSlsMask = 0xfe;
+ this.aspSlsShiftPlaces = 0x01;
+ } else {
+ this.aspSlsMask = 0x7f;
+ this.aspSlsShiftPlaces = 0x00;
}
+ break;
+
}
}
@@ -530,8 +549,8 @@
protected void addAppServerProcess(AspImpl aspImpl) throws Exception {
aspImpl.setAs(this);
appServerProcs.add(aspImpl);
-
- this.resetSlsVsAspTable();
+
+ this.resetSlsVsAspTable();
}
protected AspImpl removeAppServerProcess(String aspName) throws Exception
{
@@ -580,7 +599,7 @@
if (aspPeerFSM != null) {
aspPeerFSM.cancel();
}
-
+
this.resetSlsVsAspTable();
return aspImpl;
@@ -619,14 +638,9 @@
int aspIndex = (sls & this.aspSlsMask);
aspIndex = (aspIndex >> this.aspSlsShiftPlaces);
- int aspNumber = this.slsVsAspTable[aspIndex];
-
for (int i = 0; i < this.appServerProcs.size(); i++) {
- if (aspNumber >= this.appServerProcs.size()) {
- aspNumber = 0;
- }
-
- AspImpl aspTemp = (AspImpl)
this.appServerProcs.get(aspNumber++);
+
+ AspImpl aspTemp = (AspImpl)
this.appServerProcs.get(this.slsVsAspTable[aspIndex++]);
FSM aspFsm = null;
@@ -785,7 +799,7 @@
private void resetSlsVsAspTable() {
int aspNumber = 0;
- for (int count = 0; count < this.maxAsps; count++) {
+ for (int count = 0; count < 256; count++) {
if (aspNumber >= this.appServerProcs.size()) {
aspNumber = 0;
}
=======================================
---
/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/M3UAManagementImpl.java
Wed Dec 12 08:26:20 2012
+++
/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/M3UAManagementImpl.java
Fri Jan 4 03:48:23 2013
@@ -122,8 +122,6 @@
*/
private int maxSequenceNumber = MAX_SEQUENCE_NUMBER;
- private int[] seqContrlVsSlsTable = null;
-
public M3UAManagementImpl(String name) {
this.name = name;
binding.setClassAttribute(CLASS_ATTRIBUTE);
@@ -223,21 +221,17 @@
fsmTicker = Executors.newSingleThreadScheduledExecutor();
fsmTicker.scheduleAtFixedRate(m3uaScheduler, 500, 500,
TimeUnit.MILLISECONDS);
- // Reset the Sequence Control Vs SLS Table
- this.seqContrlVsSlsTable = new int[this.maxSequenceNumber];
- this.resetSeqControlVsSlsTable();
-
- logger.info("Started M3UAManagement");
-
for (FastList.Node<M3UAManagementEventListener> n =
this.managementEventListeners.head(), end = this.managementEventListeners
.tail(); (n = n.getNext()) != end;) {
M3UAManagementEventListener m3uaManagementEventListener
= n.getValue();
try {
m3uaManagementEventListener.onServiceStarted();
} catch (Throwable ee) {
- logger.error("Exception while invoking
onServiceStarted", ee);
+ logger.error("Exception while invoking
M3UAManagementEventListener.onServiceStarted", ee);
}
}
+
+ logger.info("Started M3UAManagement");
}
public void stop() throws Exception {
@@ -996,7 +990,7 @@
public void sendMessage(Mtp3TransferPrimitive mtp3TransferPrimitive)
throws IOException {
ProtocolData data =
this.parameterFactory.createProtocolData(mtp3TransferPrimitive.getOpc(),
mtp3TransferPrimitive.getDpc(), mtp3TransferPrimitive.getSi(),
mtp3TransferPrimitive.getNi(),
- mtp3TransferPrimitive.getMp(),
this.seqContrlVsSlsTable[mtp3TransferPrimitive.getSls()],
+ mtp3TransferPrimitive.getMp(),
mtp3TransferPrimitive.getSls(),
mtp3TransferPrimitive.getData());
PayloadData payload = (PayloadData)
messageFactory.createMessage(MessageClass.TRANSFER_MESSAGES,
@@ -1012,18 +1006,4 @@
payload.setRoutingContext(asImpl.getRoutingContext());
asImpl.write(payload);
}
-
- /**
- * regenerate the SLS table
- */
- private void resetSeqControlVsSlsTable() {
- int sls = 0;
- for (int count = 0; count < this.maxSequenceNumber; count++) {
- if (sls >= this.getRoutingLabelFormat().getMaxSls()) {
- sls = 0;
- }
- this.seqContrlVsSlsTable[count] = sls++;
- }
- }
-
}
=======================================
---
/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/M3UARouteManagement.java
Fri Oct 26 11:24:11 2012
+++
/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/M3UARouteManagement.java
Fri Jan 4 03:48:23 2013
@@ -75,8 +75,7 @@
private M3UAManagementImpl m3uaManagement = null;
- private final int msbMask;
- private final int lsbMask;
+ private final int asSelectionMask;
private int asSlsShiftPlaces = 0x00;
/**
@@ -98,26 +97,66 @@
this.m3uaManagement = m3uaManagement;
RoutingLabelFormat routingLabelFormat =
this.m3uaManagement.getRoutingLabelFormat();
- this.msbMask = routingLabelFormat.getSlsMsbMask();
- this.lsbMask = routingLabelFormat.getSlsLsbMask();
-
- if (this.m3uaManagement.isUseLsbForLinksetSelection()) {
- this.asSlsShiftPlaces = 0x00;
- } else {
- switch (routingLabelFormat.getMaxSls()) {
- case 256:
+
+ switch (this.m3uaManagement.getMaxAsForRoute()) {
+ case 1:
+ case 2:
+ if (this.m3uaManagement.isUseLsbForLinksetSelection()) {
+ this.asSelectionMask = 0x01;
+ this.asSlsShiftPlaces = 0x00;
+ } else {
+ this.asSelectionMask = 0x80;
this.asSlsShiftPlaces = 0x07;
- break;
- case 32:
+ }
+ break;
+ case 3:
+ case 4:
+ if (this.m3uaManagement.isUseLsbForLinksetSelection()) {
+ this.asSelectionMask = 0x03;
+ this.asSlsShiftPlaces = 0x00;
+ } else {
+ this.asSelectionMask = 0xc0;
+ this.asSlsShiftPlaces = 0x06;
+ }
+ break;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ if (this.m3uaManagement.isUseLsbForLinksetSelection()) {
+ this.asSelectionMask = 0x07;
+ this.asSlsShiftPlaces = 0x00;
+ } else {
+ this.asSelectionMask = 0xe0;
+ this.asSlsShiftPlaces = 0x05;
+ }
+ break;
+ case 9:
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ if (this.m3uaManagement.isUseLsbForLinksetSelection()) {
+ this.asSelectionMask = 0x0f;
+ this.asSlsShiftPlaces = 0x00;
+ } else {
+ this.asSelectionMask = 0xf0;
this.asSlsShiftPlaces = 0x04;
- break;
- case 16:
- this.asSlsShiftPlaces = 0x03;
- break;
- default:
- this.asSlsShiftPlaces = 0x03;
- break;
+ }
+ break;
+ default:
+ if (this.m3uaManagement.isUseLsbForLinksetSelection()) {
+ this.asSelectionMask = 0x01;
+ this.asSlsShiftPlaces = 0x00;
+ } else {
+ this.asSelectionMask = 0x80;
+ this.asSlsShiftPlaces = 0x07;
}
+ break;
+
}
}
@@ -298,34 +337,29 @@
return null;
}
- int count = 0;
-
- if (this.m3uaManagement.isUseLsbForLinksetSelection()) {
- count = (sls & this.lsbMask);
- } else {
- count = (sls & this.msbMask);
- }
-
+ int count = (sls & this.asSelectionMask);
count = (count >> this.asSlsShiftPlaces);
-
+
// First attempt
AsImpl asImpl = asArray[count];
if (this.isAsActive(asImpl)) {
return asImpl;
}
- // Second Attempt
- if (count == BIT_ONE) {
- count = 0;
- } else {
- count = BIT_ONE;
- }
-
- asImpl = asArray[count];
- if (this.isAsActive(asImpl)) {
- return asImpl;
+ // Second recursive Attempt
+ for (int i = 0; i < this.m3uaManagement.getMaxAsForRoute();
i++) {
+ count = count + 1;
+ if (count == this.m3uaManagement.getMaxAsForRoute()) {
+ // If count reaches same value as total As
available for route,
+ // restart from 0
+ count = 0;
+ }
+ asImpl = asArray[count];
+ if (this.isAsActive(asImpl)) {
+ return asImpl;
+ }
+
}
-
return null;
}