Revision: 16073
Author: [email protected]
Date: Mon Dec 27 22:52:52 2010
Log: impl activate / deactivate
http://code.google.com/p/mobicents/source/detail?r=16073

Modified:
/trunk/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLink.java /trunk/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLinkset.java /trunk/protocols/ss7/hardware/dialogic/java/src/main/java/org/mobicents/ss7/hardware/dialogic/oam/DialogicLinkset.java /trunk/protocols/ss7/hardware/m3ua/src/main/java/org/mobicents/ss7/m3ua/oam/M3UALinkset.java

=======================================
--- /trunk/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLink.java Mon Dec 27 09:29:37 2010 +++ /trunk/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLink.java Mon Dec 27 22:52:52 2010
@@ -1,14 +1,14 @@
 package org.mobicents.ss7.hardware.dahdi.oam;

-import java.nio.ByteBuffer;
-
 import javolution.xml.XMLFormat;
 import javolution.xml.stream.XMLStreamException;

+import org.apache.log4j.Logger;
 import org.mobicents.protocols.ss7.mtp.Mtp2;
 import org.mobicents.ss7.hardware.dahdi.Channel;
 import org.mobicents.ss7.linkset.oam.Link;
 import org.mobicents.ss7.linkset.oam.LinkMode;
+import org.mobicents.ss7.linkset.oam.LinkOAMMessages;
 import org.mobicents.ss7.linkset.oam.LinkState;

 /**
@@ -17,6 +17,8 @@
  *
  */
 public class DahdiLink extends Link {
+
+    private static final Logger logger = Logger.getLogger(DahdiLink.class);

     private int span = -1;
     private int channelID = -1;
@@ -44,7 +46,7 @@
     }

     @Override
-    protected void init() {
+    protected void init() throws Exception {

         if (this.mode == LinkMode.CONFIGURED) {
             if (this.channel == null) {
@@ -94,30 +96,27 @@
     }

     @Override
-    public boolean noShutdown(ByteBuffer byteBuffer) {
+    public void activate() throws Exception {
         if (this.state == LinkState.AVAILABLE) {
-            byteBuffer.put(LINK_ALREADY_ACTIVE);
-            return FALSE;
+            throw new Exception(LinkOAMMessages.LINK_ALREADY_ACTIVE);
         }

         // Add check that all parameters are set before initializing the
         // Link. Else send error message
         if (this.span == -1 || this.code == -1 || this.channelID == -1) {
-            byteBuffer.put(LINK_NOT_CONFIGURED);
-            return FALSE;
+            throw new Exception(LinkOAMMessages.LINK_NOT_CONFIGURED);
         }

         this.mode = LinkMode.CONFIGURED;

         this.init();
-        return TRUE;
     }

     /**
      * Management Operations
      */
-    public void shutdown(ByteBuffer byteBuffer) {
-
+    public void deactivate() throws Exception {
+        throw new Exception(LinkOAMMessages.NOT_IMPLEMENTED);
     }

protected static final XMLFormat<DahdiLink> DAHDI_LINK_XML = new XMLFormat<DahdiLink>(
@@ -134,7 +133,11 @@
             link.code = xml.getAttribute(LINK_CODE, -1);
             link.ioBufferSize = xml.getAttribute(LINK_IO_BUFFER_SIZE, 32);

-            link.init();
+            try {
+                link.init();
+            } catch (Exception e) {
+                logger.error("Failed to initialize dahdi link", e);
+            }
         }

         @Override
=======================================
--- /trunk/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLinkset.java Mon Dec 27 09:29:37 2010 +++ /trunk/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLinkset.java Mon Dec 27 22:52:52 2010
@@ -1,19 +1,19 @@
 package org.mobicents.ss7.hardware.dahdi.oam;

 import java.io.IOException;
-import java.nio.ByteBuffer;
 import java.util.concurrent.ConcurrentLinkedQueue;

 import javolution.util.FastMap;
 import javolution.xml.XMLFormat;
 import javolution.xml.stream.XMLStreamException;

-import org.mobicents.ss7.linkset.oam.LinkState;
+import org.apache.log4j.Logger;
 import org.mobicents.protocols.ss7.mtp.Mtp3;
 import org.mobicents.protocols.ss7.mtp.Mtp3Listener;
 import org.mobicents.ss7.linkset.oam.Link;
 import org.mobicents.ss7.linkset.oam.LinkMode;
 import org.mobicents.ss7.linkset.oam.LinkOAMMessages;
+import org.mobicents.ss7.linkset.oam.LinkState;
 import org.mobicents.ss7.linkset.oam.Linkset;
 import org.mobicents.ss7.linkset.oam.LinksetMode;
 import org.mobicents.ss7.linkset.oam.LinksetState;
@@ -25,6 +25,8 @@
  */
 public class DahdiLinkset extends Linkset implements Mtp3Listener {

+ private static final Logger logger = Logger.getLogger(DahdiLinkset.class);
+
     private Mtp3 mtp3 = null;
private ConcurrentLinkedQueue<byte[]> queue = new ConcurrentLinkedQueue();

@@ -37,7 +39,7 @@
     }

     @Override
-    protected void init() {
+    protected void init() throws Exception {

         if (this.mode == LinksetMode.CONFIGURED) {

@@ -58,11 +60,7 @@
             }

             if (this.state != LinksetState.SHUTDOWN) {
-                try {
-                    this.mtp3.start();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
+                this.mtp3.start();
             }
         }
     }
@@ -120,22 +118,21 @@
     @Override
     public void deleteLink(String linkName) throws Exception {
         Link link = this.links.get(linkName);
-        if(link == null){
+        if (link == null) {
             throw new Exception(LinkOAMMessages.LINK_DOESNT_EXIST);
         }
-
-        if(link.getState() == LinkState.AVAILABLE){
+
+        if (link.getState() == LinkState.AVAILABLE) {
             throw new Exception(LinkOAMMessages.CANT_DELETE_LINK);
         }
-
+
         this.links.remove(linkName);
     }

     @Override
-    public boolean noShutdown(ByteBuffer byteBuffer) {
+    public void activate() throws Exception {
         if (this.state == LinksetState.AVAILABLE) {
-            //byteBuffer.put(LinkOAMMessages.LINKSET_ALREADY_ACTIVE);
-            return FALSE;
+            throw new Exception(LinkOAMMessages.LINKSET_ALREADY_ACTIVE);
         }

         // Check if atleast one Link is in Configured mode
@@ -144,20 +141,41 @@
             Link value = e.getValue();
             if (value.getMode() == LinkMode.CONFIGURED) {
                 this.mode = LinksetMode.CONFIGURED;
-                break;
+                this.init();
+                return;
             }

         }

-        // If at least 1 Link is configured, lets start Mtp3
-        if (this.mode == LinksetMode.CONFIGURED) {
-            this.init();
-            return TRUE;
+        // If at least 1 Link is not configured
+        throw new Exception(LinkOAMMessages.LINKSET_NO_LINKS_CONFIGURED);
+    }
+
+    @Override
+    public void deactivate() throws Exception {
+        throw new Exception(LinkOAMMessages.NOT_IMPLEMENTED);
+    }
+
+    @Override
+    public void activateLink(String linkName) throws Exception {
+        Link link = this.links.get(linkName);
+
+        if (link == null) {
+            throw new Exception(LinkOAMMessages.LINK_DOESNT_EXIST);
         }

-        //byteBuffer.put(LinkOAMMessages.LINKSET_NO_LINKS_CONFIGURED);
-        return FALSE;
-
+        link.activate();
+    }
+
+    @Override
+    public void deactivateLink(String linkName) throws Exception {
+        Link link = this.links.get(linkName);
+
+        if (link == null) {
+            throw new Exception(LinkOAMMessages.LINK_DOESNT_EXIST);
+        }
+
+        link.deactivate();
     }

     /**
@@ -171,7 +189,11 @@
                 DahdiLinkset linkSet) throws XMLStreamException {
             LINKSET_XML.read(xml, linkSet);

-            linkSet.init();
+            try {
+                linkSet.init();
+            } catch (Exception e) {
+                logger.error("Error while initializing dahdi linkset", e);
+            }
         }

         @Override
@@ -229,5 +251,4 @@
     public void receive(byte[] msgBuff) {
         queue.offer(msgBuff);
     }
-
-}
+}
=======================================
--- /trunk/protocols/ss7/hardware/dialogic/java/src/main/java/org/mobicents/ss7/hardware/dialogic/oam/DialogicLinkset.java Mon Dec 27 09:29:37 2010 +++ /trunk/protocols/ss7/hardware/dialogic/java/src/main/java/org/mobicents/ss7/hardware/dialogic/oam/DialogicLinkset.java Mon Dec 27 22:52:52 2010
@@ -3,6 +3,7 @@
 import java.io.IOException;
 import java.nio.ByteBuffer;

+import org.mobicents.ss7.linkset.oam.Link;
 import org.mobicents.ss7.linkset.oam.LinkOAMMessages;
 import org.mobicents.ss7.linkset.oam.Linkset;
 import org.mobicents.ss7.linkset.oam.LinksetState;
@@ -29,14 +30,27 @@
     }

     @Override
-    public boolean noShutdown(ByteBuffer byteBuffer) {
+    public void activate() throws Exception {
         if (this.state == LinksetState.AVAILABLE) {
-            //byteBuffer.put(LinkOAMMessages.LINKSET_ALREADY_ACTIVE);
-            return FALSE;
+            throw new Exception(LinkOAMMessages.LINKSET_ALREADY_ACTIVE);
         }

         // TODO Start Dialogic Linkset
-        return FALSE;
+    }
+
+    @Override
+    public void deactivate() throws Exception {
+        throw new Exception(LinkOAMMessages.NOT_IMPLEMENTED);
+    }
+
+    @Override
+    public void activateLink(String linkName) throws Exception {
+        throw new Exception(LinkOAMMessages.OPERATION_NOT_SUPPORTED);
+    }
+
+    @Override
+    public void deactivateLink(String linkName) throws Exception {
+        throw new Exception(LinkOAMMessages.OPERATION_NOT_SUPPORTED);
     }

     /**
@@ -70,5 +84,4 @@
     public void deleteLink(String arg0) throws Exception {
         throw new Exception(LinkOAMMessages.NOT_IMPLEMENTED);
     }
-
-}
+}
=======================================
--- /trunk/protocols/ss7/hardware/m3ua/src/main/java/org/mobicents/ss7/m3ua/oam/M3UALinkset.java Mon Dec 27 09:29:37 2010 +++ /trunk/protocols/ss7/hardware/m3ua/src/main/java/org/mobicents/ss7/m3ua/oam/M3UALinkset.java Mon Dec 27 22:52:52 2010
@@ -1,7 +1,6 @@
 package org.mobicents.ss7.m3ua.oam;

 import java.io.IOException;
-import java.nio.ByteBuffer;

 import javolution.text.TextBuilder;
 import javolution.xml.XMLFormat;
@@ -59,17 +58,28 @@
     /**
      * Operations
      */
-
     @Override
-    public boolean noShutdown(ByteBuffer byteBuffer) {
+    public void activate() throws Exception {
         if (this.state == LinksetState.AVAILABLE) {
-            //byteBuffer.put(LinkOAMMessages.LINKSET_ALREADY_ACTIVE);
-            return FALSE;
+            throw new Exception(LinkOAMMessages.LINKSET_ALREADY_ACTIVE);
         }

-        // TODO : Add check that all parameters are set before starting the
-        // Link. Else send error message
-        return FALSE;
+        // TODO Start M3ua Linkset
+    }
+
+    @Override
+    public void deactivate() throws Exception {
+        throw new Exception(LinkOAMMessages.NOT_IMPLEMENTED);
+    }
+
+    @Override
+    public void activateLink(String linkName) throws Exception {
+        throw new Exception(LinkOAMMessages.OPERATION_NOT_SUPPORTED);
+    }
+
+    @Override
+    public void deactivateLink(String linkName) throws Exception {
+        throw new Exception(LinkOAMMessages.OPERATION_NOT_SUPPORTED);
     }

     /**

Reply via email to