Permalink
Browse files

Added initial JMX support with both an SmppServerMXBean and SmppSessi…

…onMXBean
  • Loading branch information...
1 parent cdbb50a commit ab9a3181b46cc044a62a3120959eb439c58aa796 @jjlauer jjlauer committed May 5, 2011
View
@@ -15,6 +15,7 @@ SMPP Library
* Added support for counters in both sessions and server for tracking
various key metrics. Counters are enabled on an SmppServer by default, but
must be explicitly enabled on sessions.
+ * Added initial support for JMX management
* Added 2 new time measurements on asynchronous responses (window wait time,
and response time).
* Modified internals of SmppSession to call the "requestWindow"
@@ -26,6 +27,10 @@ SMPP Library
monitoring as a new feature.
* Added new demo performance client to load test an SMPP server.
* Large cleanup of javadocs and comments.
+ * Added new feature to allow an SmppServer to stopped and started over again
+ by moving some permanent resource cleanup code to new destroy() method.
+ Please make a change to calling code to possibly change stop() calls to
+ destroy() calls.
3.2 - 2011-04-28
* Upgraded netty dependency from 3.1.5 to 3.2.4 (to keep it current, not to
@@ -47,7 +47,7 @@
public static final long DEFAULT_BIND_TIMEOUT = 5000;
public static final long DEFAULT_REQUEST_EXPIRY_TIMEOUT = -1; // disabled
public static final long DEFAULT_WINDOW_MONITOR_INTERVAL = -1; // disabled
- public static final int DEFAULT_SERVER_MAX_CONNECTIONS = 100;
+ public static final int DEFAULT_SERVER_MAX_CONNECTION_SIZE = 100;
public static final boolean DEFAULT_SERVER_NON_BLOCKING_SOCKETS_ENABLED = true;
public static final boolean DEFAULT_SERVER_REUSE_ADDRESS = true;
@@ -14,6 +14,7 @@
package com.cloudhopper.smpp;
+import com.cloudhopper.smpp.type.SmppChannelException;
import org.jboss.netty.channel.group.ChannelGroup;
/**
@@ -22,10 +23,44 @@
* @author joelauer (twitter: @jjlauer or <a href="http://twitter.com/jjlauer" target=window>http://twitter.com/jjlauer</a>)
*/
public interface SmppServer {
+
+ /**
+ * Returns true if the SMPP server is started.
+ * @return True if started, otherwise false.
+ */
+ public boolean isStarted();
+
+ /**
+ * Returns true if the SMPP server is stopped.
+ * @return True if stopped, otherwise false.
+ */
+ public boolean isStopped();
+
+ /**
+ * Returns true if the SMPP server is destroyed.
+ * @return True if destroyed, otherwise false.
+ */
+ public boolean isDestroyed();
- public void start();
+ /**
+ * Starts the SMPP server. Binds all server socket connectors to configured
+ * ports.
+ */
+ public void start() throws SmppChannelException;
+ /**
+ * Stops the SMPP server. Closes all child sockets and then closes all server
+ * socket connectors by unbinding them from ports. Once stopped, the server
+ * can be started again. If a server will no longer be used, please follow
+ * a call to stop by calling {@see #shutdown()}
+ */
public void stop();
+
+ /**
+ * Destroys the SMPP server. Ensures the server is first stopped, then
+ * releases all resources, and unregisters from JMX (if it was enabled).
+ */
+ public void destroy();
public ChannelGroup getChannels();
@@ -35,9 +35,12 @@
// max number of connections/sessions this server will expect to handle
// this number corrosponds to the number of worker threads handling reading
// data from sockets and the thread things will be processed under
- private int maxConnections;
+ private int maxConnectionSize;
private boolean nonBlockingSocketsEnabled;
private boolean reuseAddress;
+ // jmx options
+ private boolean jmxEnabled;
+ private String jmxDomain;
// default request expiry timeout on server sessions
private int defaultWindowSize = SmppConstants.DEFAULT_WINDOW_SIZE;
private long defaultWindowWaitTimeout = SmppConstants.DEFAULT_WINDOW_WAIT_TIMEOUT;
@@ -52,15 +55,33 @@ public SmppServerConfiguration() {
this.systemId = "cloudhopper";
this.autoNegotiateInterfaceVersion = true;
this.interfaceVersion = SmppConstants.VERSION_3_4;
- this.maxConnections = SmppConstants.DEFAULT_SERVER_MAX_CONNECTIONS;
+ this.maxConnectionSize = SmppConstants.DEFAULT_SERVER_MAX_CONNECTION_SIZE;
this.nonBlockingSocketsEnabled = SmppConstants.DEFAULT_SERVER_NON_BLOCKING_SOCKETS_ENABLED;
this.reuseAddress = SmppConstants.DEFAULT_SERVER_REUSE_ADDRESS;
+ this.jmxEnabled = false;
+ this.jmxDomain = "com.cloudhopper.smpp";
this.defaultWindowSize = SmppConstants.DEFAULT_WINDOW_SIZE;
this.defaultWindowWaitTimeout = SmppConstants.DEFAULT_WINDOW_WAIT_TIMEOUT;
this.defaultRequestExpiryTimeout = SmppConstants.DEFAULT_REQUEST_EXPIRY_TIMEOUT;
this.defaultWindowMonitorInterval = SmppConstants.DEFAULT_WINDOW_MONITOR_INTERVAL;
}
+ public String getJmxDomain() {
+ return jmxDomain;
+ }
+
+ public void setJmxDomain(String jmxDomain) {
+ this.jmxDomain = jmxDomain;
+ }
+
+ public boolean isJmxEnabled() {
+ return jmxEnabled;
+ }
+
+ public void setJmxEnabled(boolean jmxEnabled) {
+ this.jmxEnabled = jmxEnabled;
+ }
+
public boolean isReuseAddress() {
return reuseAddress;
}
@@ -83,20 +104,20 @@ public void setNonBlockingSocketsEnabled(boolean nonBlockingSocketsEnabled) {
this.nonBlockingSocketsEnabled = nonBlockingSocketsEnabled;
}
- public int getMaxConnections() {
- return maxConnections;
+ public int getMaxConnectionSize() {
+ return maxConnectionSize;
}
/**
* Set the maximum number of connections this server is configured to
* handle.
- * @param maxConnections Max number of connections. Must be >= 1
+ * @param maxConnectionSize Max number of connections. Must be >= 1
*/
- public void setMaxConnections(int maxConnections) {
- if (this.maxConnections < 1) {
- throw new IllegalArgumentException("MaxConnections must be >= 1");
+ public void setMaxConnectionSize(int maxConnectionSize) {
+ if (this.maxConnectionSize < 1) {
+ throw new IllegalArgumentException("Max connection size must be >= 1");
}
- this.maxConnections = maxConnections;
+ this.maxConnectionSize = maxConnectionSize;
}
/**
@@ -20,6 +20,14 @@
*/
public interface SmppServerCounters {
+ /**
+ * Clears all counters (including session size(s)).
+ */
+ public void clear();
+
+ /**
+ * Resets counters that don't track any state (e.g. session size(s)).
+ */
public void reset();
public int getChannelConnects();
@@ -34,4 +42,12 @@
public int getSessionDestroyed();
+ public int getReceiverSessionSize();
+
+ public int getSessionSize();
+
+ public int getTransceiverSessionSize();
+
+ public int getTransmitterSessionSize();
+
}
@@ -14,7 +14,6 @@
package com.cloudhopper.smpp;
-import com.cloudhopper.smpp.impl.DefaultSmppSessionCounters;
import com.cloudhopper.smpp.type.SmppConnectionConfiguration;
import com.cloudhopper.smpp.type.LoggingOptions;
import com.cloudhopper.smpp.type.Address;
@@ -48,7 +48,6 @@
import org.jboss.netty.channel.group.DefaultChannelGroup;
import org.jboss.netty.channel.socket.ClientSocketChannelFactory;
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
-import org.jboss.netty.channel.socket.oio.OioClientSocketChannelFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -132,7 +131,7 @@ public DefaultSmppClient(ExecutorService executors, int expectedSessions, Schedu
this.monitorExecutor = monitorExecutor;
}
- public int getActiveConnections() {
+ public int getConnectionSize() {
return this.channels.size();
}
Oops, something went wrong.

0 comments on commit ab9a318

Please sign in to comment.