Revision: 2ee2b8a3395e
Author:   Oifa Yulian <[email protected]>
Date:     Thu Jun 21 07:25:06 2012
Log:      Optimized ISUP Stack and SGW Internetworking

http://code.google.com/p/jss7/source/detail?r=2ee2b8a3395e

Modified:
/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLinkset.java /isup/isup-api/src/main/java/org/mobicents/protocols/ss7/isup/ISUPProvider.java /isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/ISUPProviderImpl.java /isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/ISUPStackImpl.java /sgw/gateway/src/main/java/org/mobicents/ss7/sgw/NodalInterworkingFunction.java

=======================================
--- /hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLinkset.java Thu May 17 05:52:04 2012 +++ /hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLinkset.java Thu Jun 21 07:25:06 2012
@@ -337,7 +337,7 @@
System.arraycopy(data, 0, paramArrayOfByte, 0, data.length);
             }

-            return paramArrayOfByte == null ? 0 : paramArrayOfByte.length;
+            return paramArrayOfByte == null ? 0 : data.length;
         }

public SelectorKey register(StreamSelector selector) throws IOException {
=======================================
--- /isup/isup-api/src/main/java/org/mobicents/protocols/ss7/isup/ISUPProvider.java Sun Jun 17 08:45:31 2012 +++ /isup/isup-api/src/main/java/org/mobicents/protocols/ss7/isup/ISUPProvider.java Thu Jun 21 07:25:06 2012
@@ -98,4 +98,13 @@
         */
        public boolean cancelTimer(int cic, int dcp, int timerId);

-}
+       /**
+        * cancel all timers. Useable when circuit usage is ended
+        *
+        * @param cic
+        *            - circuit identification code
+        * @param dpc
+        *            - destination point code
+        */
+       public void cancelAllTimers(int cic, int dpc);
+}
=======================================
--- /isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/ISUPProviderImpl.java Sun Jun 17 08:45:31 2012 +++ /isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/ISUPProviderImpl.java Thu Jun 21 07:25:06 2012
@@ -168,6 +168,15 @@
                return false;
        }

+       public void cancelAllTimers(int cic, int dpc)
+       {
+               long 
channelID=this.stack.getCircuitManager().getChannelID(cic,dpc);
+               if (this.cic2Circuit.containsKey(channelID)) {
+                       Circuit c = this.cic2Circuit.get(channelID);
+                       c.onStop();
+               }
+       }
+
        // ---------------------- non interface methods ----------------

        public void start() {
@@ -213,8 +222,12 @@
                        if (this.cic2Circuit.containsKey(channelID)) {
                                this.cic2Circuit.remove(channelID);
                        }
- throw new IllegalArgumentException("Curcuit not defined, no route definition present!");
-
+
+ //what for do we need to throw this error , lets simply add a circuit and return it , we have all parameters anyway + //throw new IllegalArgumentException("Curcuit not defined, no route definition present!");
+                       this.stack.getCircuitManager().addCircuit(cic,dpc);
+                       c = new Circuit(cic, dpc,this, scheduler);
+                       cic2Circuit.put(channelID, c);
                } else {
                        c = this.cic2Circuit.get(channelID);
                }
=======================================
--- /isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/ISUPStackImpl.java Sun Jun 17 08:45:31 2012 +++ /isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/ISUPStackImpl.java Thu Jun 21 07:25:06 2012
@@ -79,7 +79,7 @@
        public ISUPStackImpl(Scheduler scheduler,int localSpc,int ni) {
                super();
                this.scheduler=scheduler;
-               this.provider = new ISUPProviderImpl(this, scheduler , 
localSpc, ni);
+               this.provider = new ISUPProviderImpl(this, scheduler , ni, 
localSpc);
                this.parameterFactory = this.provider.getParameterFactory();
                this.messageFactory = this.provider.getMessageFactory();

=======================================
--- /sgw/gateway/src/main/java/org/mobicents/ss7/sgw/NodalInterworkingFunction.java Thu May 17 05:52:04 2012 +++ /sgw/gateway/src/main/java/org/mobicents/ss7/sgw/NodalInterworkingFunction.java Thu Jun 21 07:25:06 2012
@@ -47,6 +47,7 @@

 import org.mobicents.protocols.ss7.scheduler.Scheduler;
 import org.mobicents.protocols.ss7.scheduler.Task;
+import org.mobicents.protocols.ss7.scheduler.IntConcurrentHashMap;

 /** */
public class NodalInterworkingFunction extends Task implements Layer4,Mtp3UserPartListener {
@@ -64,11 +65,14 @@

        private int OP_READ_WRITE = 3;

-       private byte[] rxBuffer;
-
+       //max data size is 2176;
+       private byte[] rxBuffer=new byte[2176];
+       private byte[] tempBuffer;
+
private ConcurrentLinkedQueue<byte[]> mtpqueue = new ConcurrentLinkedQueue<byte[]>(); private ConcurrentLinkedQueue<Mtp3TransferPrimitive> m3uaqueue = new ConcurrentLinkedQueue<Mtp3TransferPrimitive>();

+ private IntConcurrentHashMap<Linkset> linksets=new IntConcurrentHashMap<Linkset>();
        public NodalInterworkingFunction(Scheduler scheduler) {
                super(scheduler);
        }
@@ -98,6 +102,8 @@
        // Layer4 methods
        public void add(Linkset linkset) {
                try {
+                       linksets.add(linkset,linkset.getApc());
+
                        linksetStream = linkset.getLinksetStream();
                        linksetStream.register(this.linkSetSelector);
                } catch (IOException ex) {
@@ -105,8 +111,8 @@
                }
        }

-       public void remove(Linkset arg0) {
-               // TODO Auto-generated method stub
+       public void remove(Linkset linkset) {
+               linksets.remove(linkset.getApc());

        }

@@ -144,38 +150,34 @@
FastList<SelectorKey> selected = linkSetSelector.selectNow(OP_READ_WRITE, 1); for (FastList.Node<SelectorKey> n = selected.head(), end = selected.tail(); (n = n.getNext()) != end;) {
                                SelectorKey key = n.getValue();
-                               ((LinksetStream) 
key.getStream()).read(rxBuffer);
-
-                               // Read data
-                               if (rxBuffer != null) {
+                               int size=((LinksetStream) 
key.getStream()).read(rxBuffer);
+                               if(size>0)
+                               {
+                                       tempBuffer=new byte[size];
+                                       System.arraycopy(rxBuffer, 0, 
tempBuffer, 0, size);
+
                                        currPrimitive=new 
Mtp3TransferPrimitive();
-                                       currPrimitive.decodeMtp3(rxBuffer);
-                                       
this.m3UAManagement.sendMessage(currPrimitive);
-                               }
+                                       currPrimitive.decodeMtp3(tempBuffer);
+                                       
this.m3UAManagement.sendMessage(currPrimitive);
+                               }
                        }
                }
                catch(IOException e)
-               {
-
+               {
                }

                try
                {
-                       // TODO
-                       currPrimitive = null;
-                       FastMap<String, Linkset> map = 
this.linksetManager.getLinksets();
+                       currPrimitive = null;
                        while ((currPrimitive = m3uaqueue.poll()) != null)
-                       {
- for (FastMap.Entry<String, Linkset> e = map.head(), end = map.tail(); (e = e.getNext()) != end;) {
-                                       Linkset value = e.getValue();
-                                       
if(value.getApc()==currPrimitive.getDpc())
-                                               
value.getLinksetStream().write(currPrimitive.encodeMtp3());
-                               }
-                       }
+                       {
+                               Linkset value = 
linksets.get(currPrimitive.getDpc());
+                               if(value!=null)
+                                       
value.getLinksetStream().write(currPrimitive.encodeMtp3());
+                       }
                }
                catch(IOException e)
-               {
-
+               {
                }

                scheduler.submit(this,scheduler.INTERNETWORKING_QUEUE);

Reply via email to