Revision: 16072
Author: [email protected]
Date: Mon Dec 27 22:51:46 2010
Log: api for activate/deactivate
http://code.google.com/p/mobicents/source/detail?r=16072
Modified:
/trunk/protocols/ss7/management/linkset/src/main/java/org/mobicents/ss7/linkset/oam/Link.java
/trunk/protocols/ss7/management/linkset/src/main/java/org/mobicents/ss7/linkset/oam/LinkOAMMessages.java
/trunk/protocols/ss7/management/linkset/src/main/java/org/mobicents/ss7/linkset/oam/Linkset.java
/trunk/protocols/ss7/management/linkset/src/main/java/org/mobicents/ss7/linkset/oam/LinksetManager.java
=======================================
---
/trunk/protocols/ss7/management/linkset/src/main/java/org/mobicents/ss7/linkset/oam/Link.java
Mon Dec 27 04:21:44 2010
+++
/trunk/protocols/ss7/management/linkset/src/main/java/org/mobicents/ss7/linkset/oam/Link.java
Mon Dec 27 22:51:46 2010
@@ -1,7 +1,5 @@
package org.mobicents.ss7.linkset.oam;
-import java.nio.ByteBuffer;
-
import javolution.xml.XMLFormat;
import javolution.xml.XMLSerializable;
import javolution.xml.stream.XMLStreamException;
@@ -21,8 +19,8 @@
protected Linkset linkSet;
/**
- * Define attributes of xml
- */
+ * Define attributes of xml
+ */
private static final String LINK_NAME = "name";
private static final String LINK_STATE = "state";
private static final String LINK_MODE = "mode";
@@ -30,14 +28,6 @@
protected static final boolean TRUE = true;
protected static final boolean FALSE = false;
- /**
- * Pre defined messages
- */
- public static final byte[] LINK_ALREADY_ACTIVE = "Link already active"
- .getBytes();
- public static final byte[] LINK_NOT_CONFIGURED = "Not all mandatory
parameters are set"
- .getBytes();
-
public Link() {
}
@@ -45,7 +35,7 @@
this.linkName = linkName;
}
- protected abstract void init();
+ protected abstract void init() throws Exception;
public String getLinkName() {
return linkName;
@@ -76,9 +66,11 @@
}
/**
- * Operation
- */
- public abstract boolean noShutdown(ByteBuffer byteBuffer);
+ * Operation
+ */
+ public abstract void deactivate() throws Exception;
+
+ public abstract void activate() throws Exception;
protected static final XMLFormat<Link> LINK_XML = new XMLFormat<Link>(
Link.class) {
@@ -89,8 +81,6 @@
link.linkName = xml.getAttribute(LINK_NAME).toString();
link.state = xml.getAttribute(LINK_STATE,
LinkState.UNAVAILABLE);
link.mode = xml.getAttribute(LINK_MODE,
LinkMode.UNCONFIGURED);
-
- link.init();
}
@Override
=======================================
---
/trunk/protocols/ss7/management/linkset/src/main/java/org/mobicents/ss7/linkset/oam/LinkOAMMessages.java
Mon Dec 27 09:28:32 2010
+++
/trunk/protocols/ss7/management/linkset/src/main/java/org/mobicents/ss7/linkset/oam/LinkOAMMessages.java
Mon Dec 27 22:51:46 2010
@@ -52,4 +52,8 @@
public static final String CANT_DELETE_LINK = "Link is Active. Can't
delete. Please Shutdown first";
-}
+ public static final String LINK_ALREADY_ACTIVE = "Link already active";
+ public static final String LINK_NOT_CONFIGURED = "Not all mandatory
parameters are set";
+
+ public static String OPERATION_NOT_SUPPORTED = "Operation not
supported";
+}
=======================================
---
/trunk/protocols/ss7/management/linkset/src/main/java/org/mobicents/ss7/linkset/oam/Linkset.java
Mon Dec 27 09:28:32 2010
+++
/trunk/protocols/ss7/management/linkset/src/main/java/org/mobicents/ss7/linkset/oam/Linkset.java
Mon Dec 27 22:51:46 2010
@@ -1,7 +1,6 @@
package org.mobicents.ss7.linkset.oam;
import java.io.IOException;
-import java.nio.ByteBuffer;
import javolution.util.FastMap;
import javolution.xml.XMLFormat;
@@ -60,7 +59,7 @@
}
// Initialize the Link. Depends on Type of Link
- protected abstract void init();
+ protected abstract void init() throws Exception;
public int getDpc() {
return dpc;
@@ -121,7 +120,13 @@
return this.links.get(linkName);
}
- public abstract boolean noShutdown(ByteBuffer byteBuffer);
+ public abstract void activate() throws Exception;
+
+ public abstract void deactivate() throws Exception;
+
+ public abstract void activateLink(String linkName) throws Exception;
+
+ public abstract void deactivateLink(String linkName) throws Exception;
// Poll the LinkSets for readiness
protected abstract boolean poll(int operation, int timeout);
=======================================
---
/trunk/protocols/ss7/management/linkset/src/main/java/org/mobicents/ss7/linkset/oam/LinksetManager.java
Mon Dec 27 09:28:32 2010
+++
/trunk/protocols/ss7/management/linkset/src/main/java/org/mobicents/ss7/linkset/oam/LinksetManager.java
Mon Dec 27 22:51:46 2010
@@ -105,8 +105,15 @@
*/
/**
+ * <p>
* Expected command is "linkset create <linkset-type> <options>
- * <linkset-name>"
+ * <linkset-name>". linkset is
+ * {...@link org.mobicents.ss7.management.console.Subject}
+ * </p>
+ * <p>
+ * For example for creation of dahdi linkset, the command is : linkset
+ * create dahdi opc 1 apc 2 ni 3 linkset1
+ * </p>
*
* @param options
* @return
@@ -156,17 +163,83 @@
}
this.linksets.remove(linksetName);
-
+
this.store();
return LinkOAMMessages.LINKSET_SUCCESSFULLY_REMOVED;
}
/**
+ * Expected command is "linkset activate linkset1"
+ *
+ * @param options
+ * @return
+ * @throws Exception
+ */
+ public String activateLinkset(String[] options) throws Exception {
+
+ if (options == null) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
+ }
+
+ // The last option is Linkset name
+ String linksetName = options[(options.length - 1)];
+
+ if (linksetName == null) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
+ }
+ Linkset linkset = this.linksets.get(linksetName);
+
+ if (linkset == null) {
+ throw new Exception(LinkOAMMessages.LINKSET_DOESNT_EXIST);
+ }
+
+ linkset.activate();
+
+ return LinkOAMMessages.NOSHUTDOWN_LINK_SUCCESSFULLY;
+ }
+
+ /**
+ * Expected command is "linkset deactivate linkset1"
+ *
+ * @param options
+ * @return
+ * @throws Exception
+ */
+ public String deactivateLinkset(String[] options) throws Exception {
+
+ if (options == null) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
+ }
+
+ // The second last option is Linkset name
+ String linksetName = options[(options.length - 1)];
+
+ if (linksetName == null) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
+ }
+ Linkset linkset = this.linksets.get(linksetName);
+
+ if (linkset == null) {
+ throw new Exception(LinkOAMMessages.LINKSET_DOESNT_EXIST);
+ }
+
+ linkset.deactivate();
+
+ return LinkOAMMessages.NOSHUTDOWN_LINK_SUCCESSFULLY;
+ }
+
+ /**
+ * <p>
* Create new Link. The expected command is "linkset link create
<options>
* linkset1 link1" where linkset1 is the linkset name and "link1" is
link
* name to be created and associated with "linkset1". The <options>
depends
* on type of link to be created
+ * </p>
+ * <p>
+ * For example to create link for Dahdi linkset type is : linkset link
+ * create span 1 code 1 channel 1 linkset1 link1
+ * </p>
*
* @param options
* @return
@@ -228,6 +301,76 @@
return LinkOAMMessages.LINK_SUCCESSFULLY_REMOVED;
}
+
+ /**
+ * Expected command is "linkset link activate linkset1 link1"
+ *
+ * @param options
+ * @return
+ * @throws Exception
+ */
+ public String activateLink(String[] options) throws Exception {
+
+ if (options == null) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
+ }
+
+ // The second last option is Linkset name
+ String linksetName = options[(options.length - 2)];
+
+ if (linksetName == null) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
+ }
+ Linkset linkset = this.linksets.get(linksetName);
+
+ if (linkset == null) {
+ throw new Exception(LinkOAMMessages.LINKSET_DOESNT_EXIST);
+ }
+
+ String linkName = options[(options.length - 1)];
+ if (linkName == null) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
+ }
+
+ linkset.activateLink(linkName);
+
+ return LinkOAMMessages.NOSHUTDOWN_LINK_SUCCESSFULLY;
+ }
+
+ /**
+ * Expected command is "linkset link deactivate linkset1 link1"
+ *
+ * @param options
+ * @return
+ * @throws Exception
+ */
+ public String deactivateLink(String[] options) throws Exception {
+
+ if (options == null) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
+ }
+
+ // The second last option is Linkset name
+ String linksetName = options[(options.length - 2)];
+
+ if (linksetName == null) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
+ }
+ Linkset linkset = this.linksets.get(linksetName);
+
+ if (linkset == null) {
+ throw new Exception(LinkOAMMessages.LINKSET_DOESNT_EXIST);
+ }
+
+ String linkName = options[(options.length - 1)];
+ if (linkName == null) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
+ }
+
+ linkset.deactivateLink(linkName);
+
+ return LinkOAMMessages.NOSHUTDOWN_LINK_SUCCESSFULLY;
+ }
/**
* Persist