From 26739026e34cee5d6b307fb20a3b05abdb02df4b Mon Sep 17 00:00:00 2001 From: Olena Radiboh Date: Fri, 1 Dec 2017 18:28:41 +0200 Subject: [PATCH] Esme Threshold Parameters fixes per SMSC-348 --- .../main/resources/help/smpp_esme_create.txt | 27 +- .../main/resources/help/smpp_esme_modify.txt | 20 +- .../src/main/java/org/restcomm/smpp/Esme.java | 2537 ++++++++--------- .../java/org/restcomm/smpp/EsmeCluster.java | 2 +- .../java/org/restcomm/smpp/EsmeMBean.java | 2 +- .../org/restcomm/smpp/EsmeManagement.java | 736 ++--- .../restcomm/smpp/oam/SmppOamMessages.java | 2 + .../restcomm/smpp/oam/SmppShellExecutor.java | 77 +- .../src/main/webapp/modules/esmes.html | 7 +- 9 files changed, 1715 insertions(+), 1695 deletions(-) diff --git a/core/oam/clismpp/src/main/resources/help/smpp_esme_create.txt b/core/oam/clismpp/src/main/resources/help/smpp_esme_create.txt index 311cc27..8c6e3cb 100644 --- a/core/oam/clismpp/src/main/resources/help/smpp_esme_create.txt +++ b/core/oam/clismpp/src/main/resources/help/smpp_esme_create.txt @@ -19,9 +19,9 @@ SYNOPSIS ratelimit-hour ratelimit-day national-language-single-shift national-language-locking-shift - dest-addr-send-limit - min-message-length - max-message-length + dest-addr-send-limit min-message-length + max-message-length + overload-threshold normal-threshold DESCRIPTION This command is used to configure a new ESME. @@ -378,7 +378,7 @@ PARAMETERS and can be overwritten for each ESME created. Default value: 0 - no limitations - min-message-length - This paramter is used to specify the minimum + min-message-length - This parameter is used to specify the minimum message length (in characters) acceptable to the SMSC GW, for messages coming from this ESME. @@ -389,7 +389,7 @@ PARAMETERS implies "no limitations". Any other negative value also implies "no limitations". - max-message-length - This paramter is used to specify the maximum + max-message-length - This parameter is used to specify the maximum message length (in characters) acceptable to the SMSC GW, for messages coming from this ESME. @@ -399,6 +399,23 @@ PARAMETERS The default value for this parameter is "-1" and it implies "no limitations". Any other negative value also implies "no limitations". + + overload-threshold - This value may be used by application to compare + messages queue size with it and based on outcome mark ESME + as 'overloaded'. Then based on this state further + functionality may be applied by application, such as + bypassing this ESME while sending new messages. + Default value is -1, otherwise non-positive value + will be ignored. Overload Threshold cannot be set unless + Normal Threshold has been already defined + + normal-threshold - This value is opposite to overload-threshold and might + be used as a condition to mark current ESME state as + not 'overloaded' and consequent resuming of sending new messages + through this ESME. + Default value is -1, otherwise negative value will be ignored. + It won't be possible to set Normal Threshold to -1 if + Overload Threshold is currently set. EXAMPLES smpp esme create test test 127.0.0.1 -1 TRANSCEIVER SERVER password yyyy esme-range 6667 diff --git a/core/oam/clismpp/src/main/resources/help/smpp_esme_modify.txt b/core/oam/clismpp/src/main/resources/help/smpp_esme_modify.txt index 34f8134..9502d86 100644 --- a/core/oam/clismpp/src/main/resources/help/smpp_esme_modify.txt +++ b/core/oam/clismpp/src/main/resources/help/smpp_esme_modify.txt @@ -17,9 +17,9 @@ SYNOPSIS ratelimit-hour ratelimit-day national-language-locking-shift national-language-single-shift - dest-addr-send-limit - min-message-length - max-message-length + dest-addr-send-limit min-message-length + max-message-length + overload-threshold normal-threshold DESCRIPTION This command is used to modify the settings of an existing ESME configuration. @@ -383,6 +383,20 @@ PARAMETERS The default value for this parameter is "-1" and it implies "no limitations". Any other negative value also implies "no limitations". + + overload-threshold - This value may be used by application to compare + messages queue size with it and based on outcome mark ESME + as 'overloaded'. Then based on this state further + functionality may be applied by application, such as + bypassing this ESME while sending new messages. + + normal-threshold - This value is opposite to overload-threshold and might + be used as a condition to mark current ESME state as + not 'overloaded' and consequent resuming of sending new messages + through this ESME. + Default value is -1, otherwise negative value will be ignored. + It won't be possible to set Normal Threshold to -1 if + Overload Threshold is currently set. EXAMPLES smpp esme modify test password yyyy diff --git a/core/smpp-extensions/src/main/java/org/restcomm/smpp/Esme.java b/core/smpp-extensions/src/main/java/org/restcomm/smpp/Esme.java index 7aed54e..84835ac 100644 --- a/core/smpp-extensions/src/main/java/org/restcomm/smpp/Esme.java +++ b/core/smpp-extensions/src/main/java/org/restcomm/smpp/Esme.java @@ -48,54 +48,54 @@ */ public class Esme extends SslConfigurationWrapper implements XMLSerializable, EsmeMBean { - /** - * - */ - private static final long serialVersionUID = 1L; + /** + * + */ + private static final long serialVersionUID = 1L; - private static final Logger logger = Logger.getLogger(Esme.class); + private static final Logger logger = Logger.getLogger(Esme.class); - private static final String ESME_NAME = "name"; + private static final String ESME_NAME = "name"; - private static final String ESME_CLUSTER_NAME = "clusterName"; + private static final String ESME_CLUSTER_NAME = "clusterName"; - private static final String ESME_SYSTEM_ID = "systemId"; - private static final String ESME_PASSWORD = "password"; - private static final String REMOTE_HOST_IP = "host"; - private static final String REMOTE_HOST_PORT = "port"; + private static final String ESME_SYSTEM_ID = "systemId"; + private static final String ESME_PASSWORD = "password"; + private static final String REMOTE_HOST_IP = "host"; + private static final String REMOTE_HOST_PORT = "port"; private static final String NETWORK_ID = "networkId"; private static final String SPLIT_LONG_MESSAGES = "splitLongMessages"; - private static final String SMPP_BIND_TYPE = "smppBindType"; + private static final String SMPP_BIND_TYPE = "smppBindType"; - private static final String SMPP_SESSION_TYPE = "smppSessionType"; + private static final String SMPP_SESSION_TYPE = "smppSessionType"; - private static final String ESME_SYSTEM_TYPE = "systemType"; - private static final String ESME_INTERFACE_VERSION = "smppVersion"; - private static final String ESME_TON = "ton"; - private static final String ESME_NPI = "npi"; - private static final String ESME_ADDRESS_RANGE = "addressRange"; + private static final String ESME_SYSTEM_TYPE = "systemType"; + private static final String ESME_INTERFACE_VERSION = "smppVersion"; + private static final String ESME_TON = "ton"; + private static final String ESME_NPI = "npi"; + private static final String ESME_ADDRESS_RANGE = "addressRange"; - private static final String SOURCE_TON = "sourceTon"; - private static final String SOURCE_NPI = "sourceNpi"; - private static final String SOURCE_ADDRESS_RANGE = "sourceAddressRange"; + private static final String SOURCE_TON = "sourceTon"; + private static final String SOURCE_NPI = "sourceNpi"; + private static final String SOURCE_ADDRESS_RANGE = "sourceAddressRange"; - private static final String ROUTING_TON = "routingTon"; - private static final String ROUTING_NPI = "routingNpi"; - private static final String ROUTING_ADDRESS_RANGE = "routingAddressRange"; + private static final String ROUTING_TON = "routingTon"; + private static final String ROUTING_NPI = "routingNpi"; + private static final String ROUTING_ADDRESS_RANGE = "routingAddressRange"; - private static final String CHARGING_ENABLED = "chargingEnabled"; + private static final String CHARGING_ENABLED = "chargingEnabled"; - private static final String WINDOW_SIZE = "windowSize"; - private static final String CONNECT_TIMEOUT = "connectTimeout"; - private static final String REQUEST_EXPIRY_TIMEOUT = "requestExpiryTimeout"; - private static final String CLIENT_BIND_TIMEOUT = "clientBindTimeout"; - private static final String WINDOW_MONITOR_INTERVAL = "windowMonitorInterval"; - private static final String WINDOW_WAIT_TIMEOUT = "windowWaitTimeout"; + private static final String WINDOW_SIZE = "windowSize"; + private static final String CONNECT_TIMEOUT = "connectTimeout"; + private static final String REQUEST_EXPIRY_TIMEOUT = "requestExpiryTimeout"; + private static final String CLIENT_BIND_TIMEOUT = "clientBindTimeout"; + private static final String WINDOW_MONITOR_INTERVAL = "windowMonitorInterval"; + private static final String WINDOW_WAIT_TIMEOUT = "windowWaitTimeout"; - private static final String ENQUIRE_LINK_DELAY = "enquireLinkDelay"; - private static final String ENQUIRE_LINK_DELAY_SERVER = "enquireLinkDelayServer"; - private static final String LINK_DROP_SERVER = "linkDropServer"; - private static final String COUNTERS_ENABLED = "countersEnabled"; + private static final String ENQUIRE_LINK_DELAY = "enquireLinkDelay"; + private static final String ENQUIRE_LINK_DELAY_SERVER = "enquireLinkDelayServer"; + private static final String LINK_DROP_SERVER = "linkDropServer"; + private static final String COUNTERS_ENABLED = "countersEnabled"; private static final String RATE_LIMIT_PER_SECOND = "rateLimitPerSecond"; private static final String RATE_LIMIT_PER_MINUTE = "rateLimitPerMinute"; @@ -108,108 +108,104 @@ public class Esme extends SslConfigurationWrapper implements XMLSerializable, Es private static final String MIN_MESSAGE_LENGTH = "minMessageLength"; private static final String MAX_MESSAGE_LENGTH = "maxMessageLength"; - private static final String STARTED = "started"; - - private static final String OVERLOAD_THRESHOLD = "overloadThreshold"; - private static final String NORMAL_THRESHOLD = "normalThreshold"; - - private String name; - private String clusterName; - private String systemId; - private String password; - private String host; - private int port; - private String systemType; - private SmppInterfaceVersionType smppVersion = null; + private static final String STARTED = "started"; + + private static final String OVERLOAD_THRESHOLD = "overloadThreshold"; + private static final String NORMAL_THRESHOLD = "normalThreshold"; + + private String name; + private String clusterName; + private String systemId; + private String password; + private String host; + private int port; + private String systemType; + private SmppInterfaceVersionType smppVersion = null; private int networkId; // long messages will be split before sending to this destination private boolean splitLongMessages; - // These are configured ESME TON, NPI and Address Range. If ESME is acting - // as Server, incoming BIND request should match there TON, NPI and address - // range. If ESME is acting as Client, these values will be set in outgoing - // BIND request. if TON and NPI are -1 or esmeAddressRange is null they are - // ignored - private int esmeTon = -1; - private int esmeNpi = -1; - private String esmeAddressRange = null; - - // Incoming SMS should match these TON, NPI and addressRange. TON and NPI - // can be -1 which means SMSC doesn't care for these fields and only - // addressRange (pattern) should match - private int sourceTon = -1; - private int sourceNpi = -1; - private String sourceAddressRange = "^[0-9a-zA-Z]*"; - private Pattern sourceAddressRangePattern = null; - - // Outgoing SMS should match these TON, NPI and addressRange. TON and NPI - // can be -1 which means SMSC doesn't care for these fields and only - // addressRange (pattern) should match - private int routingTon; - private int routingNpi; - private String routingAddressRange; - private Pattern routingAddressRangePattern; - - private SmppBindType smppBindType; - private boolean chargingEnabled = false; - - private boolean countersEnabled = true; - - private int enquireLinkDelay = 30000; - private int enquireLinkDelayServer = 0; - - private long linkDropServer = 0L; - private boolean linkRecvMessCheck = false; - private boolean linkStartFirstTime = false; - - private AtomicBoolean inConnectingQueue = new AtomicBoolean(false); - private AtomicLong localSessionId = new AtomicLong(0L); - - // Default Server - private SmppSession.Type smppSessionType = SmppSession.Type.SERVER; + // These are configured ESME TON, NPI and Address Range. If ESME is acting + // as Server, incoming BIND request should match there TON, NPI and address + // range. If ESME is acting as Client, these values will be set in outgoing + // BIND request. if TON and NPI are -1 or esmeAddressRange is null they are + // ignored + private int esmeTon = -1; + private int esmeNpi = -1; + private String esmeAddressRange = null; + + // Incoming SMS should match these TON, NPI and addressRange. TON and NPI + // can be -1 which means SMSC doesn't care for these fields and only + // addressRange (pattern) should match + private int sourceTon = -1; + private int sourceNpi = -1; + private String sourceAddressRange = "^[0-9a-zA-Z]*"; + private Pattern sourceAddressRangePattern = null; + + // Outgoing SMS should match these TON, NPI and addressRange. TON and NPI + // can be -1 which means SMSC doesn't care for these fields and only + // addressRange (pattern) should match + private int routingTon; + private int routingNpi; + private String routingAddressRange; + private Pattern routingAddressRangePattern; + + private SmppBindType smppBindType; + private boolean chargingEnabled = false; + + private boolean countersEnabled = true; + + private int enquireLinkDelay = 30000; + private int enquireLinkDelayServer = 0; + + private long linkDropServer = 0L; + private boolean linkRecvMessCheck = false; + private boolean linkStartFirstTime = false; + + private AtomicBoolean inConnectingQueue = new AtomicBoolean(false); + private AtomicLong localSessionId = new AtomicLong(0L); + + // Default Server + private SmppSession.Type smppSessionType = SmppSession.Type.SERVER; // national single and locking shift tables for the case when a message is SMPP originated and does not have included UDH - // 0 means gsm7 default table - // -1 means: take SMSC general nationalLanguage table (this is a default value) + // 0 means gsm7 default table + // -1 means: take SMSC general nationalLanguage table (this is a default value) private int nationalLanguageSingleShift = -1; private int nationalLanguageLockingShift = -1; private int destAddrSendLimit = 0; - + // min and max side of an incoming message from SMPP connector. // If an incoming message size (in characters) less the the min value or more the max value, it will be rejected // -1 (default value) means no limitations private int minMessageLength = -1; private int maxMessageLength = -1; - // Client side config. Defaul 100 - private int windowSize; - private long connectTimeout; - private long clientBindTimeout; - - /** - * Set the amount of time(ms) to wait for an endpoint to respond to a - * request before it expires. Defaults to disabled (-1). - */ - private long requestExpiryTimeout; - - /** - * Sets the amount of time between executions of monitoring the window for - * requests that expire. It's recommended that this generally either matches - * or is half the value of requestExpiryTimeout. Therefore, at worst a - * request would could take up 1.5X the requestExpiryTimeout to clear out. - */ - private long windowMonitorInterval; - - /** - * Set the amount of time to wait until a slot opens up in the sendWindow. - * Defaults to 60000. - */ + // Client side config. Defaul 100 + private int windowSize; + private long connectTimeout; + private long clientBindTimeout; + + /** + * Set the amount of time(ms) to wait for an endpoint to respond to a request before it expires. Defaults to disabled (-1). + */ + private long requestExpiryTimeout; + + /** + * Sets the amount of time between executions of monitoring the window for requests that expire. It's recommended that this + * generally either matches or is half the value of requestExpiryTimeout. Therefore, at worst a request would could take up + * 1.5X the requestExpiryTimeout to clear out. + */ + private long windowMonitorInterval; + + /** + * Set the amount of time to wait until a slot opens up in the sendWindow. Defaults to 60000. + */ private long windowWaitTimeout; /** - * Set limits for message count received from ESME per a second, minute, - * hour or a day. Zero values means "no restrictions". + * Set limits for message count received from ESME per a second, minute, hour or a day. Zero values means "no restrictions". */ private long rateLimitPerSecond = 0; private long rateLimitPerMinute = 0; @@ -225,29 +221,29 @@ public class Esme extends SslConfigurationWrapper implements XMLSerializable, Es private AtomicLong extraMsgPerHour = new AtomicLong(); private AtomicLong extraMsgPerDay = new AtomicLong(); - protected transient EsmeManagement esmeManagement = null; + protected transient EsmeManagement esmeManagement = null; - private boolean started = false; - private boolean serverBound = false; - private int enquireLinkFailCnt = 0; - private int rxEnquireLinkCounter = -1; - private int rxDlrRespCounter = -1; - private int rxDataSmRespCounter = -1; - private int rxSubmitSmRespCount = -1; + private boolean started = false; + private boolean serverBound = false; + private int enquireLinkFailCnt = 0; + private int rxEnquireLinkCounter = -1; + private int rxDlrRespCounter = -1; + private int rxDataSmRespCounter = -1; + private int rxSubmitSmRespCount = -1; private String state = SmppSession.STATES[SmppSession.STATE_CLOSED]; private String localState = SmppSession.STATES[SmppSession.STATE_CLOSED]; - private transient DefaultSmppSession defaultSmppSession = null; - - private int overloadThreshold; - private int normalThreshold; - - private boolean overloaded; + private transient DefaultSmppSession defaultSmppSession = null; + + private int overloadThreshold; + private int normalThreshold; - public Esme() { + private boolean overloaded; - } + public Esme() { + + } /** * @param name @@ -297,61 +293,61 @@ public Esme(String name, String systemId, String password, String host, int port SmppBindType smppBindType, Type smppSessionType, int windowSize, long connectTimeout, long requestExpiryTimeout, long clientBindTimeout, long windowMonitorInterval, long windowWaitTimeout, String clusterName, boolean countersEnabled, int enquireLinkDelay, int enquireLinkDelayServer, long linkDropServer, int sourceTon, - int sourceNpi, String sourceAddressRange, int routingTon, int routingNpi, String routingAddressRange, - int networkId, boolean splitLongMessages, long rateLimitPerSecond, long rateLimitPerMinute, long rateLimitPerHour, - long rateLimitPerDay, int nationalLanguageSingleShift, int nationalLanguageLockingShift, int destAddrSendLimit, int minMessageLength, - int maxMessageLength, int overloadThreshold, int normalThreshold + int sourceNpi, String sourceAddressRange, int routingTon, int routingNpi, String routingAddressRange, int networkId, + boolean splitLongMessages, long rateLimitPerSecond, long rateLimitPerMinute, long rateLimitPerHour, + long rateLimitPerDay, int nationalLanguageSingleShift, int nationalLanguageLockingShift, int destAddrSendLimit, + int minMessageLength, int maxMessageLength, int overloadThreshold, int normalThreshold ) { - this.name = name; + this.name = name; - this.systemId = systemId; - this.password = password; - this.host = host; - this.port = port; + this.systemId = systemId; + this.password = password; + this.host = host; + this.port = port; - this.chargingEnabled = chargingEnabled; + this.chargingEnabled = chargingEnabled; - this.systemType = systemType; - this.smppVersion = smppVersion; - this.esmeTon = esmeTon; - this.esmeNpi = esmeNpi; - this.esmeAddressRange = esmeAddressRange; - this.smppBindType = smppBindType; + this.systemType = systemType; + this.smppVersion = smppVersion; + this.esmeTon = esmeTon; + this.esmeNpi = esmeNpi; + this.esmeAddressRange = esmeAddressRange; + this.smppBindType = smppBindType; - this.smppSessionType = smppSessionType; + this.smppSessionType = smppSessionType; - this.windowSize = windowSize; - this.connectTimeout = connectTimeout; - this.requestExpiryTimeout = requestExpiryTimeout; - this.clientBindTimeout = clientBindTimeout; + this.windowSize = windowSize; + this.connectTimeout = connectTimeout; + this.requestExpiryTimeout = requestExpiryTimeout; + this.clientBindTimeout = clientBindTimeout; - this.windowMonitorInterval = windowMonitorInterval; - this.windowWaitTimeout = windowWaitTimeout; + this.windowMonitorInterval = windowMonitorInterval; + this.windowWaitTimeout = windowWaitTimeout; - this.clusterName = clusterName; + this.clusterName = clusterName; - this.countersEnabled = countersEnabled; + this.countersEnabled = countersEnabled; - this.enquireLinkDelay = enquireLinkDelay; - this.enquireLinkDelayServer = enquireLinkDelayServer; - this.linkDropServer = linkDropServer; + this.enquireLinkDelay = enquireLinkDelay; + this.enquireLinkDelayServer = enquireLinkDelayServer; + this.linkDropServer = linkDropServer; - this.sourceTon = sourceTon; - this.sourceNpi = sourceNpi; - this.sourceAddressRange = sourceAddressRange; + this.sourceTon = sourceTon; + this.sourceNpi = sourceNpi; + this.sourceAddressRange = sourceAddressRange; - if (this.sourceAddressRange != null) { - this.sourceAddressRangePattern = Pattern.compile(this.sourceAddressRange); - } + if (this.sourceAddressRange != null) { + this.sourceAddressRangePattern = Pattern.compile(this.sourceAddressRange); + } - this.routingTon = routingTon; - this.routingNpi = routingNpi; - this.routingAddressRange = routingAddressRange; + this.routingTon = routingTon; + this.routingNpi = routingNpi; + this.routingAddressRange = routingAddressRange; - if (this.routingAddressRange != null) { - this.routingAddressRangePattern = Pattern.compile(this.routingAddressRange); - } + if (this.routingAddressRange != null) { + this.routingAddressRangePattern = Pattern.compile(this.routingAddressRange); + } this.networkId = networkId; this.splitLongMessages = splitLongMessages; @@ -366,124 +362,118 @@ public Esme(String name, String systemId, String password, String host, int port this.destAddrSendLimit = destAddrSendLimit; this.minMessageLength = minMessageLength; this.maxMessageLength = maxMessageLength; - + this.overloadThreshold = overloadThreshold; this.normalThreshold = normalThreshold; - } + } - - public AtomicBoolean getInConnectingQueue() { + public AtomicBoolean getInConnectingQueue() { return inConnectingQueue; } public Long nextLocalSessionId() { return this.localSessionId.getAndIncrement(); } - + public Long getLocalSessionId() { return this.localSessionId.get(); } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @return the clusterName - */ - public String getClusterName() { - return clusterName; - } - - /** - * @param clusterName - * the clusterName to set - */ - protected void setClusterName(String clusterName) { - this.clusterName = clusterName; - this.store(); - } - - /** - * Every As has unique name - * - * @return String name of this As - */ - public String getSystemId() { - return this.systemId; - } - - /** - * @param systemId - * the systemId to set - */ - public void setSystemId(String systemId) { - this.systemId = systemId; - this.store(); - } - - /** - * @return the password - */ - public String getPassword() { - return password; - } - - /** - * @param password - * the password to set - */ - public void setPassword(String password) { - this.password = password; - this.store(); - } - - /** - * @return the host - */ - @Override - public String getHost() { - return host; - } - - /** - * @param host - * the host to set - */ - public void setHost(String host) { - this.host = host; - this.store(); - } - - /** - * @return the port - */ - @Override - public int getPort() { - return port; - } - - /** - * @param port - * the port to set - */ - public void setPort(int port) { - this.port = port; - this.store(); - } - - @Override - public int getNetworkId() { - return networkId; - } - - public void setNetworkId(int networkId) { - this.networkId = networkId; - this.store(); - } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @return the clusterName + */ + public String getClusterName() { + return clusterName; + } + + /** + * @param clusterName the clusterName to set + */ + protected void setClusterName(String clusterName) { + this.clusterName = clusterName; + this.store(); + } + + /** + * Every As has unique name + * + * @return String name of this As + */ + public String getSystemId() { + return this.systemId; + } + + /** + * @param systemId the systemId to set + */ + public void setSystemId(String systemId) { + this.systemId = systemId; + this.store(); + } + + /** + * @return the password + */ + public String getPassword() { + return password; + } + + /** + * @param password the password to set + */ + public void setPassword(String password) { + this.password = password; + this.store(); + } + + /** + * @return the host + */ + @Override + public String getHost() { + return host; + } + + /** + * @param host the host to set + */ + public void setHost(String host) { + this.host = host; + this.store(); + } + + /** + * @return the port + */ + @Override + public int getPort() { + return port; + } + + /** + * @param port the port to set + */ + public void setPort(int port) { + this.port = port; + this.store(); + } + + @Override + public int getNetworkId() { + return networkId; + } + + public void setNetworkId(int networkId) { + this.networkId = networkId; + this.store(); + } @Override public boolean getSplitLongMessages() { @@ -496,167 +486,164 @@ public void setSplitLongMessages(boolean splitLongMessages) { this.store(); } - public SmppBindType getSmppBindType() { - return smppBindType; - } - - protected void setSmppBindType(SmppBindType smppBindType) { - this.smppBindType = smppBindType; - this.store(); - } - - /** - * @return the systemType - */ - public String getSystemType() { - return systemType; - } - - /** - * @param systemType - * the systemType to set - */ - public void setSystemType(String systemType) { - this.systemType = systemType; - this.store(); - } - - /** - * @return the smppVersion - */ - public SmppInterfaceVersionType getSmppVersion() { - return smppVersion; - } - - /** - * @param smppVersion - * the smppVersion to set - */ - public void setSmppVersion(SmppInterfaceVersionType smppVersion) { - this.smppVersion = smppVersion; - this.store(); - } - - @Override - public int getSourceTon() { - return sourceTon; - } - - @Override - public void setSourceTon(int sourceTon) { - this.sourceTon = sourceTon; - this.store(); - } - - @Override - public int getSourceNpi() { - return sourceNpi; - } - - @Override - public void setSourceNpi(int sourceNpi) { - this.sourceNpi = sourceNpi; - this.store(); - } - - @Override - public String getSourceAddressRange() { - return sourceAddressRange; - } - - @Override - public void setSourceAddressRange(String sourceAddressRange) { - this.sourceAddressRange = sourceAddressRange; - if (this.sourceAddressRange != null) { - this.sourceAddressRangePattern = Pattern.compile(this.sourceAddressRange); - } - this.store(); - } - - @Override - public int getRoutingTon() { - return routingTon; - } - - @Override - public void setRoutingTon(int routingTon) { - this.routingTon = routingTon; - this.store(); - } - - @Override - public int getRoutingNpi() { - return routingNpi; - } - - @Override - public void setRoutingNpi(int routingNpi) { - this.routingNpi = routingNpi; - this.store(); - } - - @Override - public String getRoutingAddressRange() { - return routingAddressRange; - } - - @Override - public void setRoutingAddressRange(String routingAddressRange) { - this.routingAddressRange = routingAddressRange; - if (this.routingAddressRange != null) { - this.routingAddressRangePattern = Pattern.compile(this.routingAddressRange); - } - this.store(); - } - - @Override - public int getEsmeTon() { - return esmeTon; - } - - @Override - public void setEsmeTon(int esmeTon) { - this.esmeTon = esmeTon; - this.store(); - } - - @Override - public int getEsmeNpi() { - return esmeNpi; - } - - @Override - public void setEsmeNpi(int esmeNpi) { - this.esmeNpi = esmeNpi; - this.store(); - } - - @Override - public String getEsmeAddressRange() { - return esmeAddressRange; - } - - @Override - public void setEsmeAddressRange(String esmeAddressRange) { - this.esmeAddressRange = esmeAddressRange; - this.store(); - } - - /** - * @return the smppSessionType - */ - public SmppSession.Type getSmppSessionType() { - return smppSessionType; - } - - /** - * @param smppSessionType - * the smppSessionType to set - */ - public void setSmppSessionType(SmppSession.Type smppSessionType) { - this.smppSessionType = smppSessionType; - this.store(); - } + public SmppBindType getSmppBindType() { + return smppBindType; + } + + protected void setSmppBindType(SmppBindType smppBindType) { + this.smppBindType = smppBindType; + this.store(); + } + + /** + * @return the systemType + */ + public String getSystemType() { + return systemType; + } + + /** + * @param systemType the systemType to set + */ + public void setSystemType(String systemType) { + this.systemType = systemType; + this.store(); + } + + /** + * @return the smppVersion + */ + public SmppInterfaceVersionType getSmppVersion() { + return smppVersion; + } + + /** + * @param smppVersion the smppVersion to set + */ + public void setSmppVersion(SmppInterfaceVersionType smppVersion) { + this.smppVersion = smppVersion; + this.store(); + } + + @Override + public int getSourceTon() { + return sourceTon; + } + + @Override + public void setSourceTon(int sourceTon) { + this.sourceTon = sourceTon; + this.store(); + } + + @Override + public int getSourceNpi() { + return sourceNpi; + } + + @Override + public void setSourceNpi(int sourceNpi) { + this.sourceNpi = sourceNpi; + this.store(); + } + + @Override + public String getSourceAddressRange() { + return sourceAddressRange; + } + + @Override + public void setSourceAddressRange(String sourceAddressRange) { + this.sourceAddressRange = sourceAddressRange; + if (this.sourceAddressRange != null) { + this.sourceAddressRangePattern = Pattern.compile(this.sourceAddressRange); + } + this.store(); + } + + @Override + public int getRoutingTon() { + return routingTon; + } + + @Override + public void setRoutingTon(int routingTon) { + this.routingTon = routingTon; + this.store(); + } + + @Override + public int getRoutingNpi() { + return routingNpi; + } + + @Override + public void setRoutingNpi(int routingNpi) { + this.routingNpi = routingNpi; + this.store(); + } + + @Override + public String getRoutingAddressRange() { + return routingAddressRange; + } + + @Override + public void setRoutingAddressRange(String routingAddressRange) { + this.routingAddressRange = routingAddressRange; + if (this.routingAddressRange != null) { + this.routingAddressRangePattern = Pattern.compile(this.routingAddressRange); + } + this.store(); + } + + @Override + public int getEsmeTon() { + return esmeTon; + } + + @Override + public void setEsmeTon(int esmeTon) { + this.esmeTon = esmeTon; + this.store(); + } + + @Override + public int getEsmeNpi() { + return esmeNpi; + } + + @Override + public void setEsmeNpi(int esmeNpi) { + this.esmeNpi = esmeNpi; + this.store(); + } + + @Override + public String getEsmeAddressRange() { + return esmeAddressRange; + } + + @Override + public void setEsmeAddressRange(String esmeAddressRange) { + this.esmeAddressRange = esmeAddressRange; + this.store(); + } + + /** + * @return the smppSessionType + */ + public SmppSession.Type getSmppSessionType() { + return smppSessionType; + } + + /** + * @param smppSessionType the smppSessionType to set + */ + public void setSmppSessionType(SmppSession.Type smppSessionType) { + this.smppSessionType = smppSessionType; + this.store(); + } public int getNationalLanguageSingleShift() { return nationalLanguageSingleShift; @@ -668,14 +655,14 @@ public void setNationalLanguageSingleShift(int nationalLanguageSingleShift) { } public int getDestAddrSendLimit() { - return destAddrSendLimit; + return destAddrSendLimit; } - + public void setDestAddrSendLimit(int destAddrSendLimit) { - this.destAddrSendLimit = destAddrSendLimit; - store(); + this.destAddrSendLimit = destAddrSendLimit; + store(); } - + public int getMinMessageLength() { return minMessageLength; } @@ -703,111 +690,105 @@ public void setNationalLanguageLockingShift(int nationalLanguageLockingShift) { this.store(); } - /** - * @return the windowSize - */ - @Override - public int getWindowSize() { - return windowSize; - } - - /** - * @param windowSize - * the windowSize to set - */ - @Override - public void setWindowSize(int windowSize) { - this.windowSize = windowSize; - this.store(); - } - - /** - * @return the connectTimeout - */ - @Override - public long getConnectTimeout() { - return connectTimeout; - } - - /** - * @param connectTimeout - * the connectTimeout to set - */ - @Override - public void setConnectTimeout(long connectTimeout) { - this.connectTimeout = connectTimeout; - this.store(); - } - - /** - * @return the requestExpiryTimeout - */ - @Override - public long getRequestExpiryTimeout() { - return requestExpiryTimeout; - } - - /** - * @param requestExpiryTimeout - * the requestExpiryTimeout to set - */ - @Override - public void setRequestExpiryTimeout(long requestExpiryTimeout) { - this.requestExpiryTimeout = requestExpiryTimeout; - this.store(); - } - - /** - * @return the clientBindTimeout - */ - public long getClientBindTimeout() { - return this.clientBindTimeout; - } - - /** - * @param clientBindTimeout - * the clientBindTimeout to set - */ - public void setClientBindTimeout(long clientBindTimeout) { - this.clientBindTimeout = clientBindTimeout; - this.store(); - } - - /** - * @return the windowMonitorInterval - */ - @Override - public long getWindowMonitorInterval() { - return windowMonitorInterval; - } - - /** - * @param windowMonitorInterval - * the windowMonitorInterval to set - */ - @Override - public void setWindowMonitorInterval(long windowMonitorInterval) { - this.windowMonitorInterval = windowMonitorInterval; - this.store(); - } - - /** - * @return the windowWaitTimeout - */ - @Override - public long getWindowWaitTimeout() { - return windowWaitTimeout; - } - - /** - * @param windowWaitTimeout - * the windowWaitTimeout to set - */ - @Override - public void setWindowWaitTimeout(long windowWaitTimeout) { - this.windowWaitTimeout = windowWaitTimeout; - this.store(); - } + /** + * @return the windowSize + */ + @Override + public int getWindowSize() { + return windowSize; + } + + /** + * @param windowSize the windowSize to set + */ + @Override + public void setWindowSize(int windowSize) { + this.windowSize = windowSize; + this.store(); + } + + /** + * @return the connectTimeout + */ + @Override + public long getConnectTimeout() { + return connectTimeout; + } + + /** + * @param connectTimeout the connectTimeout to set + */ + @Override + public void setConnectTimeout(long connectTimeout) { + this.connectTimeout = connectTimeout; + this.store(); + } + + /** + * @return the requestExpiryTimeout + */ + @Override + public long getRequestExpiryTimeout() { + return requestExpiryTimeout; + } + + /** + * @param requestExpiryTimeout the requestExpiryTimeout to set + */ + @Override + public void setRequestExpiryTimeout(long requestExpiryTimeout) { + this.requestExpiryTimeout = requestExpiryTimeout; + this.store(); + } + + /** + * @return the clientBindTimeout + */ + public long getClientBindTimeout() { + return this.clientBindTimeout; + } + + /** + * @param clientBindTimeout the clientBindTimeout to set + */ + public void setClientBindTimeout(long clientBindTimeout) { + this.clientBindTimeout = clientBindTimeout; + this.store(); + } + + /** + * @return the windowMonitorInterval + */ + @Override + public long getWindowMonitorInterval() { + return windowMonitorInterval; + } + + /** + * @param windowMonitorInterval the windowMonitorInterval to set + */ + @Override + public void setWindowMonitorInterval(long windowMonitorInterval) { + this.windowMonitorInterval = windowMonitorInterval; + this.store(); + } + + /** + * @return the windowWaitTimeout + */ + @Override + public long getWindowWaitTimeout() { + return windowWaitTimeout; + } + + /** + * @param windowWaitTimeout the windowWaitTimeout to set + */ + @Override + public void setWindowWaitTimeout(long windowWaitTimeout) { + this.windowWaitTimeout = windowWaitTimeout; + this.store(); + } @Override public long getRateLimitPerSecond() { @@ -842,209 +823,203 @@ public void setRateLimitPerHour(long value) { this.store(); } - @Override - public long getRateLimitPerDay() { - return rateLimitPerDay; + @Override + public long getRateLimitPerDay() { + return rateLimitPerDay; + } + + @Override + public void setRateLimitPerDay(long value) { + this.rateLimitPerDay = value; + this.store(); + } + + /** + * @return the started + */ + @Override + public boolean isStarted() { + return started; + } + + /** + * @param started the started to set + */ + protected void setStarted(boolean started) { + this.started = started; + if (started) + this.clearDayMsgCounter(); + } + + /** + * @return the server status + */ + public boolean isServerBound() { + return serverBound; + } + + /** + * @param serverBound the server status to set + */ + protected void setServerBound(boolean serverBound) { + this.serverBound = serverBound; + } + + /** + * @return the smppSession + */ + public DefaultSmppSession getSmppSession() { + return defaultSmppSession; + } + + /** + * @param smppSession the smppSession to set + */ + public void setSmppSession(DefaultSmppSession smppSession) { + this.defaultSmppSession = smppSession; + } + + @Override + public int getEnquireLinkDelay() { + return enquireLinkDelay; + } + + @Override + public void setEnquireLinkDelay(int enquireLinkDelay) { + this.enquireLinkDelay = enquireLinkDelay; + this.store(); + } + + @Override + public int getEnquireLinkDelayServer() { + return this.enquireLinkDelayServer; + } + + @Override + public void setEnquireLinkDelayServer(int enquireLinkDelayServer) { + this.enquireLinkDelayServer = enquireLinkDelayServer; + this.store(); + } + + @Override + public long getLinkDropServer() { + return this.linkDropServer; + } + + @Override + public void setLinkDropServer(long linkDropServer) { + this.linkDropServer = linkDropServer; + this.store(); + } + + @Override + public boolean isCountersEnabled() { + return countersEnabled; + } + + @Override + public void setCountersEnabled(boolean countersEnabled) { + this.countersEnabled = countersEnabled; + this.store(); + } + + @Override + public boolean isChargingEnabled() { + return chargingEnabled; + } + + @Override + public void setChargingEnabled(boolean chargingEnabled) { + this.chargingEnabled = chargingEnabled; + this.store(); + } + + public boolean isSourceAddressMatching(Address sourceAddress) { + + // Check sourceTon + if (this.sourceTon != -1 && this.sourceTon != sourceAddress.getTon()) { + return false; + } + + // Check sourceNpi + if (this.sourceNpi != -1 && this.sourceNpi != sourceAddress.getNpi()) { + return false; + } + + // Check sourceAddress + Matcher m = this.sourceAddressRangePattern.matcher(sourceAddress.getAddress()); + if (m.matches()) { + return true; + } + + return false; } - @Override - public void setRateLimitPerDay(long value) { - this.rateLimitPerDay = value; - this.store(); - } + public boolean isRoutingAddressMatching(int destTon, int destNpi, String destAddress) { + // Check sourceTon + if (this.routingTon != -1 && this.routingTon != destTon) { + return false; + } - /** - * @return the started - */ - @Override - public boolean isStarted() { - return started; - } + // Check sourceNpi + if (this.routingNpi != -1 && this.routingNpi != destNpi) { + return false; + } - /** - * @param started - * the started to set - */ - protected void setStarted(boolean started) { - this.started = started; - if (started) - this.clearDayMsgCounter(); - } + // Check sourceAddress + Matcher m = this.routingAddressRangePattern.matcher(destAddress); + if (m.matches()) { + return true; + } - /** - * @return the server status - */ - public boolean isServerBound() { - return serverBound; + return false; } - /** - * @param serverBound - * the server status to set - */ - protected void setServerBound(boolean serverBound) { - this.serverBound = serverBound; + public int getEnquireLinkFail() { + return this.enquireLinkFailCnt; } - /** - * @return the smppSession - */ - public DefaultSmppSession getSmppSession() { - return defaultSmppSession; - } - - /** - * @param smppSession - * the smppSession to set - */ - public void setSmppSession(DefaultSmppSession smppSession) { - this.defaultSmppSession = smppSession; - } - - @Override - public int getEnquireLinkDelay() { - return enquireLinkDelay; - } - - @Override - public void setEnquireLinkDelay(int enquireLinkDelay) { - this.enquireLinkDelay = enquireLinkDelay; - this.store(); - } - - @Override - public int getEnquireLinkDelayServer() { - return this.enquireLinkDelayServer; - } - - @Override - public void setEnquireLinkDelayServer(int enquireLinkDelayServer) { - this.enquireLinkDelayServer = enquireLinkDelayServer; - this.store(); - } - - @Override - public long getLinkDropServer() { - return this.linkDropServer; - } - - @Override - public void setLinkDropServer(long linkDropServer) { - this.linkDropServer = linkDropServer; - this.store(); - } - - @Override - public boolean isCountersEnabled() { - return countersEnabled; - } - - @Override - public void setCountersEnabled(boolean countersEnabled) { - this.countersEnabled = countersEnabled; - this.store(); - } - - @Override - public boolean isChargingEnabled() { - return chargingEnabled; - } - - @Override - public void setChargingEnabled(boolean chargingEnabled) { - this.chargingEnabled = chargingEnabled; - this.store(); - } - - public boolean isSourceAddressMatching(Address sourceAddress) { - - // Check sourceTon - if (this.sourceTon != -1 && this.sourceTon != sourceAddress.getTon()) { - return false; - } - - // Check sourceNpi - if (this.sourceNpi != -1 && this.sourceNpi != sourceAddress.getNpi()) { - return false; - } - - // Check sourceAddress - Matcher m = this.sourceAddressRangePattern.matcher(sourceAddress.getAddress()); - if (m.matches()) { - return true; - } - - return false; - } - - public boolean isRoutingAddressMatching(int destTon, int destNpi, String destAddress) { - - // Check sourceTon - if (this.routingTon != -1 && this.routingTon != destTon) { - return false; - } - - // Check sourceNpi - if (this.routingNpi != -1 && this.routingNpi != destNpi) { - return false; - } - - // Check sourceAddress - Matcher m = this.routingAddressRangePattern.matcher(destAddress); - if (m.matches()) { - return true; - } - - return false; - } - - public int getEnquireLinkFail() { - return this.enquireLinkFailCnt; - } - - public void resetEnquireLinkFail() { - this.enquireLinkFailCnt = 0; - } - - public void incEnquireLinkFail() { - this.enquireLinkFailCnt ++; - } - - public boolean getEnquireClientEnabled() { - if (this.enquireLinkDelay <= 0) { - return false; - } - - return true; - } + public void resetEnquireLinkFail() { + this.enquireLinkFailCnt = 0; + } + + public void incEnquireLinkFail() { + this.enquireLinkFailCnt++; + } + + public boolean getEnquireClientEnabled() { + if (this.enquireLinkDelay <= 0) { + return false; + } + + return true; + } public boolean getEnquireServerEnabled() { if (this.enquireLinkDelayServer <= 0) { - return false; + return false; } return true; } - public boolean getLinkDropServerEnabled() { - if (!this.getEnquireServerEnabled() && this.linkDropServer > 0L) { - return true; - } + public boolean getLinkDropServerEnabled() { + if (!this.getEnquireServerEnabled() && this.linkDropServer > 0L) { + return true; + } - return false; - } + return false; + } - public boolean checkLinkRecvMessage() { + public boolean checkLinkRecvMessage() { int currentEnqLinkCounter = this.defaultSmppSession.getCounters().getRxEnquireLink().getRequest(); int currentDlrRespCounter = this.defaultSmppSession.getCounters().getTxDeliverSM().getResponse(); int currentDataSmRespCounter = this.defaultSmppSession.getCounters().getTxDataSM().getResponse(); int currentSubmitSmRespCounter = this.defaultSmppSession.getCounters().getTxSubmitSM().getResponse(); - if (this.rxEnquireLinkCounter < currentEnqLinkCounter - || this.rxSubmitSmRespCount < currentSubmitSmRespCounter - || this.rxDlrRespCounter < currentDlrRespCounter - || this.rxDataSmRespCounter < currentDataSmRespCounter) { + if (this.rxEnquireLinkCounter < currentEnqLinkCounter || this.rxSubmitSmRespCount < currentSubmitSmRespCounter + || this.rxDlrRespCounter < currentDlrRespCounter || this.rxDataSmRespCounter < currentDataSmRespCounter) { this.linkRecvMessCheck = true; } @@ -1055,40 +1030,40 @@ public boolean checkLinkRecvMessage() { this.rxSubmitSmRespCount = currentSubmitSmRespCounter; return this.linkRecvMessCheck; - } + } - public void resetLinkRecvMessage() { - this.rxEnquireLinkCounter = -1; - this.rxDlrRespCounter = -1; - this.rxDataSmRespCounter = -1; - this.rxSubmitSmRespCount = -1; - } + public void resetLinkRecvMessage() { + this.rxEnquireLinkCounter = -1; + this.rxDlrRespCounter = -1; + this.rxDataSmRespCounter = -1; + this.rxSubmitSmRespCount = -1; + } - public void setLinkRecvMessage(boolean recveivedMessage) { - this.linkRecvMessCheck = recveivedMessage; - } + public void setLinkRecvMessage(boolean recveivedMessage) { + this.linkRecvMessCheck = recveivedMessage; + } - public boolean getLinkStartFirstTime () { - return linkStartFirstTime; - } + public boolean getLinkStartFirstTime() { + return linkStartFirstTime; + } - public void setLinkStartFirstTime (boolean linkStarted) { - this.linkStartFirstTime = linkStarted; - } + public void setLinkStartFirstTime(boolean linkStarted) { + this.linkStartFirstTime = linkStarted; + } /** - * XML Serialization/Deserialization - */ - protected static final XMLFormat ESME_XML = new XMLFormat(Esme.class) { - - @Override - public void read(javolution.xml.XMLFormat.InputElement xml, Esme esme) throws XMLStreamException { - esme.name = xml.getAttribute(ESME_NAME, ""); - esme.clusterName = xml.getAttribute(ESME_CLUSTER_NAME, ""); - esme.systemId = xml.getAttribute(ESME_SYSTEM_ID, ""); - esme.password = xml.getAttribute(ESME_PASSWORD, null); - esme.host = xml.getAttribute(REMOTE_HOST_IP, ""); - esme.port = xml.getAttribute(REMOTE_HOST_PORT, -1); + * XML Serialization/Deserialization + */ + protected static final XMLFormat ESME_XML = new XMLFormat(Esme.class) { + + @Override + public void read(javolution.xml.XMLFormat.InputElement xml, Esme esme) throws XMLStreamException { + esme.name = xml.getAttribute(ESME_NAME, ""); + esme.clusterName = xml.getAttribute(ESME_CLUSTER_NAME, ""); + esme.systemId = xml.getAttribute(ESME_SYSTEM_ID, ""); + esme.password = xml.getAttribute(ESME_PASSWORD, null); + esme.host = xml.getAttribute(REMOTE_HOST_IP, ""); + esme.port = xml.getAttribute(REMOTE_HOST_PORT, -1); esme.networkId = xml.getAttribute(NETWORK_ID, 0); esme.splitLongMessages = xml.getAttribute(SPLIT_LONG_MESSAGES, false); @@ -1097,56 +1072,55 @@ public void read(javolution.xml.XMLFormat.InputElement xml, Esme esme) throws XM esme.rateLimitPerHour = xml.getAttribute(RATE_LIMIT_PER_HOUR, 0L); esme.rateLimitPerDay = xml.getAttribute(RATE_LIMIT_PER_DAY, 0L); - String smppBindTypeStr = xml.getAttribute(SMPP_BIND_TYPE, "TRANSCEIVER"); - - if (SmppBindType.TRANSCEIVER.toString().equals(smppBindTypeStr)) { - esme.smppBindType = SmppBindType.TRANSCEIVER; - } else if (SmppBindType.TRANSMITTER.toString().equals(smppBindTypeStr)) { - esme.smppBindType = SmppBindType.TRANSMITTER; - } else if (SmppBindType.RECEIVER.toString().equals(smppBindTypeStr)) { - esme.smppBindType = SmppBindType.RECEIVER; - } - - String smppSessionTypeStr = xml.getAttribute(SMPP_SESSION_TYPE, "SERVER"); - esme.smppSessionType = SmppSession.Type.valueOf(smppSessionTypeStr); - - esme.started = xml.getAttribute(STARTED, false); - - esme.systemType = xml.getAttribute(ESME_SYSTEM_TYPE, ""); - esme.smppVersion = SmppInterfaceVersionType.getInterfaceVersionType(xml.getAttribute( - ESME_INTERFACE_VERSION, "")); - - esme.esmeTon = xml.getAttribute(ESME_TON, (byte) 0); - esme.esmeNpi = xml.getAttribute(ESME_NPI, (byte) 0); - esme.esmeAddressRange = xml.getAttribute(ESME_ADDRESS_RANGE, null); - - esme.windowSize = xml.getAttribute(WINDOW_SIZE, 0); - esme.connectTimeout = xml.getAttribute(CONNECT_TIMEOUT, 0L); - esme.requestExpiryTimeout = xml.getAttribute(REQUEST_EXPIRY_TIMEOUT, 0L); - esme.clientBindTimeout = xml.getAttribute(CLIENT_BIND_TIMEOUT, SmppConstants.DEFAULT_BIND_TIMEOUT); - - esme.windowMonitorInterval = xml.getAttribute(WINDOW_MONITOR_INTERVAL, 0L); - esme.windowWaitTimeout = xml.getAttribute(WINDOW_WAIT_TIMEOUT, 0L); - esme.countersEnabled = xml.getAttribute(COUNTERS_ENABLED, true); - esme.enquireLinkDelay = xml.getAttribute(ENQUIRE_LINK_DELAY, 30000); - esme.enquireLinkDelayServer = xml.getAttribute(ENQUIRE_LINK_DELAY_SERVER, 0); - esme.linkDropServer = xml.getAttribute(LINK_DROP_SERVER, 0L); - - esme.chargingEnabled = xml.getAttribute(CHARGING_ENABLED, false); - - esme.sourceTon = xml.getAttribute(SOURCE_TON, -1); - esme.sourceNpi = xml.getAttribute(SOURCE_NPI, -1); - esme.sourceAddressRange = xml.getAttribute(SOURCE_ADDRESS_RANGE, "^[0-9a-zA-Z]*"); - esme.sourceAddressRangePattern = Pattern.compile(esme.sourceAddressRange); - - esme.routingTon = xml.getAttribute(ROUTING_TON, -1); - esme.routingNpi = xml.getAttribute(ROUTING_NPI, -1); - // default value we are using here is esme.esmeAddressRange to be - // backward compatible - esme.routingAddressRange = xml.getAttribute(ROUTING_ADDRESS_RANGE, esme.esmeAddressRange); - if (esme.routingAddressRange != null) { - esme.routingAddressRangePattern = Pattern.compile(esme.routingAddressRange); - } + String smppBindTypeStr = xml.getAttribute(SMPP_BIND_TYPE, "TRANSCEIVER"); + + if (SmppBindType.TRANSCEIVER.toString().equals(smppBindTypeStr)) { + esme.smppBindType = SmppBindType.TRANSCEIVER; + } else if (SmppBindType.TRANSMITTER.toString().equals(smppBindTypeStr)) { + esme.smppBindType = SmppBindType.TRANSMITTER; + } else if (SmppBindType.RECEIVER.toString().equals(smppBindTypeStr)) { + esme.smppBindType = SmppBindType.RECEIVER; + } + + String smppSessionTypeStr = xml.getAttribute(SMPP_SESSION_TYPE, "SERVER"); + esme.smppSessionType = SmppSession.Type.valueOf(smppSessionTypeStr); + + esme.started = xml.getAttribute(STARTED, false); + + esme.systemType = xml.getAttribute(ESME_SYSTEM_TYPE, ""); + esme.smppVersion = SmppInterfaceVersionType.getInterfaceVersionType(xml.getAttribute(ESME_INTERFACE_VERSION, "")); + + esme.esmeTon = xml.getAttribute(ESME_TON, (byte) 0); + esme.esmeNpi = xml.getAttribute(ESME_NPI, (byte) 0); + esme.esmeAddressRange = xml.getAttribute(ESME_ADDRESS_RANGE, null); + + esme.windowSize = xml.getAttribute(WINDOW_SIZE, 0); + esme.connectTimeout = xml.getAttribute(CONNECT_TIMEOUT, 0L); + esme.requestExpiryTimeout = xml.getAttribute(REQUEST_EXPIRY_TIMEOUT, 0L); + esme.clientBindTimeout = xml.getAttribute(CLIENT_BIND_TIMEOUT, SmppConstants.DEFAULT_BIND_TIMEOUT); + + esme.windowMonitorInterval = xml.getAttribute(WINDOW_MONITOR_INTERVAL, 0L); + esme.windowWaitTimeout = xml.getAttribute(WINDOW_WAIT_TIMEOUT, 0L); + esme.countersEnabled = xml.getAttribute(COUNTERS_ENABLED, true); + esme.enquireLinkDelay = xml.getAttribute(ENQUIRE_LINK_DELAY, 30000); + esme.enquireLinkDelayServer = xml.getAttribute(ENQUIRE_LINK_DELAY_SERVER, 0); + esme.linkDropServer = xml.getAttribute(LINK_DROP_SERVER, 0L); + + esme.chargingEnabled = xml.getAttribute(CHARGING_ENABLED, false); + + esme.sourceTon = xml.getAttribute(SOURCE_TON, -1); + esme.sourceNpi = xml.getAttribute(SOURCE_NPI, -1); + esme.sourceAddressRange = xml.getAttribute(SOURCE_ADDRESS_RANGE, "^[0-9a-zA-Z]*"); + esme.sourceAddressRangePattern = Pattern.compile(esme.sourceAddressRange); + + esme.routingTon = xml.getAttribute(ROUTING_TON, -1); + esme.routingNpi = xml.getAttribute(ROUTING_NPI, -1); + // default value we are using here is esme.esmeAddressRange to be + // backward compatible + esme.routingAddressRange = xml.getAttribute(ROUTING_ADDRESS_RANGE, esme.esmeAddressRange); + if (esme.routingAddressRange != null) { + esme.routingAddressRangePattern = Pattern.compile(esme.routingAddressRange); + } esme.nationalLanguageSingleShift = xml.getAttribute(NATIONAL_LANGUAGE_SINGLE_SHIFT, -1); esme.nationalLanguageLockingShift = xml.getAttribute(NATIONAL_LANGUAGE_LOCKING_SHIFT, -1); @@ -1156,49 +1130,47 @@ public void read(javolution.xml.XMLFormat.InputElement xml, Esme esme) throws XM esme.overloadThreshold = xml.getAttribute(OVERLOAD_THRESHOLD, -1); esme.normalThreshold = xml.getAttribute(NORMAL_THRESHOLD, -1); - // SSL - esme.useSsl = xml.getAttribute(USE_SSL, false); - esme.wrappedSslConfig.setCertAlias(xml.getAttribute(CERT_ALIAS, null)); - esme.wrappedSslConfig.setCrlPath(xml.getAttribute(CRL_PATH, null)); - esme.wrappedSslConfig.setKeyManagerFactoryAlgorithm(xml.getAttribute(KEY_MANAGER_FACTORY_ALGORITHM, - "SunX509")); - esme.wrappedSslConfig.setKeyManagerPassword(xml.getAttribute(KEY_MANAGER_PASSWORD, null)); - esme.wrappedSslConfig.setKeyStorePassword(xml.getAttribute(KEY_STORE_PASSWORD, null)); - esme.wrappedSslConfig.setKeyStoreProvider(xml.getAttribute(KEY_STORE_PROVIDER, null)); - esme.wrappedSslConfig.setKeyStorePath(xml.getAttribute(KEY_STORE_PATH, null)); - esme.wrappedSslConfig.setKeyStoreType(xml.getAttribute(KEY_STORE_TYPE, "JKS")); - esme.wrappedSslConfig.setMaxCertPathLength(xml.getAttribute(MAX_CERT_PATH_LENGTH, -1)); - esme.wrappedSslConfig.setNeedClientAuth(xml.getAttribute(NEED_CLIENT_AUTH, false)); - esme.wrappedSslConfig.setOcspResponderURL(xml.getAttribute(OCS_RESPONDER_URL, null)); - esme.wrappedSslConfig.setProtocol(xml.getAttribute(PROTOCOL, "TLS")); - esme.wrappedSslConfig.setProvider(xml.getAttribute(PROVIDER, null)); - esme.wrappedSslConfig.setSecureRandomAlgorithm(xml.getAttribute(SECURE_RANDOM_ALGORITHM, null)); - esme.wrappedSslConfig.setSslSessionCacheSize(xml.getAttribute(SSL_SESSION_CACHE_SIZE, 0)); - esme.wrappedSslConfig.setSslSessionTimeout(xml.getAttribute(SSL_SESSION_TIMEOUT, 0)); - esme.wrappedSslConfig.setTrustManagerFactoryAlgorithm(xml.getAttribute(TRUST_MANAGER_FACTORY_ALGORITHM, - "PKIX")); - esme.wrappedSslConfig.setTrustStorePassword(xml.getAttribute(TRUST_STORE_PASSWORD, null)); - esme.wrappedSslConfig.setTrustStorePath(xml.getAttribute(TRUST_STORE_PATH, null)); - esme.wrappedSslConfig.setTrustStoreProvider(xml.getAttribute(TRUST_STORE_PROVIDER, null)); - esme.wrappedSslConfig.setTrustStoreType(xml.getAttribute(TRUST_STORE_TYPE, "JKS")); - esme.wrappedSslConfig.setWantClientAuth(xml.getAttribute(WANT_CLIENT_AUTH, false)); - esme.wrappedSslConfig.setAllowRenegotiate(xml.getAttribute(ALLOW_RENEGOTIATE, true)); - esme.wrappedSslConfig.setEnableCRLDP(xml.getAttribute(ENABLE_CRLDP, false)); - esme.wrappedSslConfig.setSessionCachingEnabled(xml.getAttribute(SESSION_CACHING_ENABLED, true)); - esme.wrappedSslConfig.setTrustAll(xml.getAttribute(TRUST_ALL, true)); - esme.wrappedSslConfig.setValidateCerts(xml.getAttribute(VALIDATE_CERTS, false)); - esme.wrappedSslConfig.setValidatePeerCerts(xml.getAttribute(VALIDATE_PEER_CERTS, false)); - - } - - @Override - public void write(Esme esme, javolution.xml.XMLFormat.OutputElement xml) throws XMLStreamException { - xml.setAttribute(ESME_NAME, esme.name); - xml.setAttribute(ESME_CLUSTER_NAME, esme.clusterName); - xml.setAttribute(ESME_SYSTEM_ID, esme.systemId); - xml.setAttribute(ESME_PASSWORD, esme.password); - xml.setAttribute(REMOTE_HOST_IP, esme.host); - xml.setAttribute(REMOTE_HOST_PORT, esme.port); + // SSL + esme.useSsl = xml.getAttribute(USE_SSL, false); + esme.wrappedSslConfig.setCertAlias(xml.getAttribute(CERT_ALIAS, null)); + esme.wrappedSslConfig.setCrlPath(xml.getAttribute(CRL_PATH, null)); + esme.wrappedSslConfig.setKeyManagerFactoryAlgorithm(xml.getAttribute(KEY_MANAGER_FACTORY_ALGORITHM, "SunX509")); + esme.wrappedSslConfig.setKeyManagerPassword(xml.getAttribute(KEY_MANAGER_PASSWORD, null)); + esme.wrappedSslConfig.setKeyStorePassword(xml.getAttribute(KEY_STORE_PASSWORD, null)); + esme.wrappedSslConfig.setKeyStoreProvider(xml.getAttribute(KEY_STORE_PROVIDER, null)); + esme.wrappedSslConfig.setKeyStorePath(xml.getAttribute(KEY_STORE_PATH, null)); + esme.wrappedSslConfig.setKeyStoreType(xml.getAttribute(KEY_STORE_TYPE, "JKS")); + esme.wrappedSslConfig.setMaxCertPathLength(xml.getAttribute(MAX_CERT_PATH_LENGTH, -1)); + esme.wrappedSslConfig.setNeedClientAuth(xml.getAttribute(NEED_CLIENT_AUTH, false)); + esme.wrappedSslConfig.setOcspResponderURL(xml.getAttribute(OCS_RESPONDER_URL, null)); + esme.wrappedSslConfig.setProtocol(xml.getAttribute(PROTOCOL, "TLS")); + esme.wrappedSslConfig.setProvider(xml.getAttribute(PROVIDER, null)); + esme.wrappedSslConfig.setSecureRandomAlgorithm(xml.getAttribute(SECURE_RANDOM_ALGORITHM, null)); + esme.wrappedSslConfig.setSslSessionCacheSize(xml.getAttribute(SSL_SESSION_CACHE_SIZE, 0)); + esme.wrappedSslConfig.setSslSessionTimeout(xml.getAttribute(SSL_SESSION_TIMEOUT, 0)); + esme.wrappedSslConfig.setTrustManagerFactoryAlgorithm(xml.getAttribute(TRUST_MANAGER_FACTORY_ALGORITHM, "PKIX")); + esme.wrappedSslConfig.setTrustStorePassword(xml.getAttribute(TRUST_STORE_PASSWORD, null)); + esme.wrappedSslConfig.setTrustStorePath(xml.getAttribute(TRUST_STORE_PATH, null)); + esme.wrappedSslConfig.setTrustStoreProvider(xml.getAttribute(TRUST_STORE_PROVIDER, null)); + esme.wrappedSslConfig.setTrustStoreType(xml.getAttribute(TRUST_STORE_TYPE, "JKS")); + esme.wrappedSslConfig.setWantClientAuth(xml.getAttribute(WANT_CLIENT_AUTH, false)); + esme.wrappedSslConfig.setAllowRenegotiate(xml.getAttribute(ALLOW_RENEGOTIATE, true)); + esme.wrappedSslConfig.setEnableCRLDP(xml.getAttribute(ENABLE_CRLDP, false)); + esme.wrappedSslConfig.setSessionCachingEnabled(xml.getAttribute(SESSION_CACHING_ENABLED, true)); + esme.wrappedSslConfig.setTrustAll(xml.getAttribute(TRUST_ALL, true)); + esme.wrappedSslConfig.setValidateCerts(xml.getAttribute(VALIDATE_CERTS, false)); + esme.wrappedSslConfig.setValidatePeerCerts(xml.getAttribute(VALIDATE_PEER_CERTS, false)); + + } + + @Override + public void write(Esme esme, javolution.xml.XMLFormat.OutputElement xml) throws XMLStreamException { + xml.setAttribute(ESME_NAME, esme.name); + xml.setAttribute(ESME_CLUSTER_NAME, esme.clusterName); + xml.setAttribute(ESME_SYSTEM_ID, esme.systemId); + xml.setAttribute(ESME_PASSWORD, esme.password); + xml.setAttribute(REMOTE_HOST_IP, esme.host); + xml.setAttribute(REMOTE_HOST_PORT, esme.port); xml.setAttribute(NETWORK_ID, esme.networkId); xml.setAttribute(SPLIT_LONG_MESSAGES, esme.splitLongMessages); @@ -1207,18 +1179,18 @@ public void write(Esme esme, javolution.xml.XMLFormat.OutputElement xml) throws xml.setAttribute(RATE_LIMIT_PER_HOUR, esme.rateLimitPerHour); xml.setAttribute(RATE_LIMIT_PER_DAY, esme.rateLimitPerDay); - xml.setAttribute(SMPP_BIND_TYPE, esme.smppBindType.toString()); - xml.setAttribute(SMPP_SESSION_TYPE, esme.smppSessionType.toString()); + xml.setAttribute(SMPP_BIND_TYPE, esme.smppBindType.toString()); + xml.setAttribute(SMPP_SESSION_TYPE, esme.smppSessionType.toString()); - xml.setAttribute(STARTED, esme.started); + xml.setAttribute(STARTED, esme.started); - xml.setAttribute(ESME_INTERFACE_VERSION, esme.smppVersion.getType()); - if (esme.systemType != null) { - xml.setAttribute(ESME_SYSTEM_TYPE, esme.systemType); - } - xml.setAttribute(ESME_TON, esme.esmeTon); - xml.setAttribute(ESME_NPI, esme.esmeNpi); - xml.setAttribute(ESME_ADDRESS_RANGE, esme.esmeAddressRange); + xml.setAttribute(ESME_INTERFACE_VERSION, esme.smppVersion.getType()); + if (esme.systemType != null) { + xml.setAttribute(ESME_SYSTEM_TYPE, esme.systemType); + } + xml.setAttribute(ESME_TON, esme.esmeTon); + xml.setAttribute(ESME_NPI, esme.esmeNpi); + xml.setAttribute(ESME_ADDRESS_RANGE, esme.esmeAddressRange); xml.setAttribute(NATIONAL_LANGUAGE_SINGLE_SHIFT, esme.nationalLanguageSingleShift); xml.setAttribute(NATIONAL_LANGUAGE_LOCKING_SHIFT, esme.nationalLanguageLockingShift); @@ -1226,65 +1198,65 @@ public void write(Esme esme, javolution.xml.XMLFormat.OutputElement xml) throws xml.setAttribute(MIN_MESSAGE_LENGTH, esme.minMessageLength); xml.setAttribute(MAX_MESSAGE_LENGTH, esme.maxMessageLength); - xml.setAttribute(WINDOW_SIZE, esme.windowSize); - xml.setAttribute(CONNECT_TIMEOUT, esme.connectTimeout); - xml.setAttribute(REQUEST_EXPIRY_TIMEOUT, esme.requestExpiryTimeout); - xml.setAttribute(CLIENT_BIND_TIMEOUT, esme.clientBindTimeout); - - xml.setAttribute(WINDOW_MONITOR_INTERVAL, esme.windowMonitorInterval); - xml.setAttribute(WINDOW_WAIT_TIMEOUT, esme.windowWaitTimeout); - xml.setAttribute(COUNTERS_ENABLED, esme.countersEnabled); - xml.setAttribute(ENQUIRE_LINK_DELAY, esme.enquireLinkDelay); - xml.setAttribute(ENQUIRE_LINK_DELAY_SERVER, esme.enquireLinkDelayServer); - xml.setAttribute(LINK_DROP_SERVER, esme.linkDropServer); - - xml.setAttribute(CHARGING_ENABLED, esme.chargingEnabled); - - xml.setAttribute(SOURCE_TON, esme.sourceTon); - xml.setAttribute(SOURCE_NPI, esme.sourceNpi); - xml.setAttribute(SOURCE_ADDRESS_RANGE, esme.sourceAddressRange); - - xml.setAttribute(ROUTING_TON, esme.routingTon); - xml.setAttribute(ROUTING_NPI, esme.routingNpi); - xml.setAttribute(ROUTING_ADDRESS_RANGE, esme.routingAddressRange); - - xml.setAttribute(OVERLOAD_THRESHOLD, esme.overloadThreshold); - xml.setAttribute(NORMAL_THRESHOLD, esme.normalThreshold); - - // SSl - xml.setAttribute(USE_SSL, esme.useSsl); - xml.setAttribute(CERT_ALIAS, esme.wrappedSslConfig.getCertAlias()); - xml.setAttribute(CRL_PATH, esme.wrappedSslConfig.getCrlPath()); - xml.setAttribute(KEY_MANAGER_FACTORY_ALGORITHM, esme.wrappedSslConfig.getKeyManagerFactoryAlgorithm()); - xml.setAttribute(KEY_MANAGER_PASSWORD, esme.wrappedSslConfig.getKeyManagerPassword()); - xml.setAttribute(KEY_STORE_PASSWORD, esme.wrappedSslConfig.getKeyStorePassword()); - xml.setAttribute(KEY_STORE_PROVIDER, esme.wrappedSslConfig.getKeyStoreProvider()); - xml.setAttribute(KEY_STORE_PATH, esme.wrappedSslConfig.getKeyStorePath()); - xml.setAttribute(KEY_STORE_TYPE, esme.wrappedSslConfig.getKeyStoreType()); - xml.setAttribute(MAX_CERT_PATH_LENGTH, esme.wrappedSslConfig.getMaxCertPathLength()); - xml.setAttribute(NEED_CLIENT_AUTH, esme.wrappedSslConfig.getNeedClientAuth()); - xml.setAttribute(OCS_RESPONDER_URL, esme.wrappedSslConfig.getOcspResponderURL()); - xml.setAttribute(PROTOCOL, esme.wrappedSslConfig.getProtocol()); - xml.setAttribute(PROVIDER, esme.wrappedSslConfig.getProvider()); - xml.setAttribute(SECURE_RANDOM_ALGORITHM, esme.wrappedSslConfig.getSecureRandomAlgorithm()); - xml.setAttribute(SSL_SESSION_CACHE_SIZE, esme.wrappedSslConfig.getSslSessionCacheSize()); - xml.setAttribute(SSL_SESSION_TIMEOUT, esme.wrappedSslConfig.getSslSessionTimeout()); - xml.setAttribute(TRUST_MANAGER_FACTORY_ALGORITHM, esme.wrappedSslConfig.getTrustManagerFactoryAlgorithm()); - xml.setAttribute(TRUST_STORE_PASSWORD, esme.wrappedSslConfig.getTrustStorePassword()); - xml.setAttribute(TRUST_STORE_PATH, esme.wrappedSslConfig.getTrustStorePath()); - xml.setAttribute(TRUST_STORE_PROVIDER, esme.wrappedSslConfig.getTrustStoreProvider()); - xml.setAttribute(TRUST_STORE_TYPE, esme.wrappedSslConfig.getTrustStoreType()); - xml.setAttribute(WANT_CLIENT_AUTH, esme.wrappedSslConfig.getWantClientAuth()); - xml.setAttribute(ALLOW_RENEGOTIATE, esme.wrappedSslConfig.isAllowRenegotiate()); - xml.setAttribute(ENABLE_CRLDP, esme.wrappedSslConfig.isEnableCRLDP()); - xml.setAttribute(SESSION_CACHING_ENABLED, esme.wrappedSslConfig.isSessionCachingEnabled()); - xml.setAttribute(TRUST_ALL, esme.wrappedSslConfig.isTrustAll()); - xml.setAttribute(VALIDATE_CERTS, esme.wrappedSslConfig.isValidateCerts()); - xml.setAttribute(VALIDATE_PEER_CERTS, esme.wrappedSslConfig.isValidatePeerCerts()); - } - }; - - public void show(StringBuffer sb) { + xml.setAttribute(WINDOW_SIZE, esme.windowSize); + xml.setAttribute(CONNECT_TIMEOUT, esme.connectTimeout); + xml.setAttribute(REQUEST_EXPIRY_TIMEOUT, esme.requestExpiryTimeout); + xml.setAttribute(CLIENT_BIND_TIMEOUT, esme.clientBindTimeout); + + xml.setAttribute(WINDOW_MONITOR_INTERVAL, esme.windowMonitorInterval); + xml.setAttribute(WINDOW_WAIT_TIMEOUT, esme.windowWaitTimeout); + xml.setAttribute(COUNTERS_ENABLED, esme.countersEnabled); + xml.setAttribute(ENQUIRE_LINK_DELAY, esme.enquireLinkDelay); + xml.setAttribute(ENQUIRE_LINK_DELAY_SERVER, esme.enquireLinkDelayServer); + xml.setAttribute(LINK_DROP_SERVER, esme.linkDropServer); + + xml.setAttribute(CHARGING_ENABLED, esme.chargingEnabled); + + xml.setAttribute(SOURCE_TON, esme.sourceTon); + xml.setAttribute(SOURCE_NPI, esme.sourceNpi); + xml.setAttribute(SOURCE_ADDRESS_RANGE, esme.sourceAddressRange); + + xml.setAttribute(ROUTING_TON, esme.routingTon); + xml.setAttribute(ROUTING_NPI, esme.routingNpi); + xml.setAttribute(ROUTING_ADDRESS_RANGE, esme.routingAddressRange); + + xml.setAttribute(OVERLOAD_THRESHOLD, esme.overloadThreshold); + xml.setAttribute(NORMAL_THRESHOLD, esme.normalThreshold); + + // SSl + xml.setAttribute(USE_SSL, esme.useSsl); + xml.setAttribute(CERT_ALIAS, esme.wrappedSslConfig.getCertAlias()); + xml.setAttribute(CRL_PATH, esme.wrappedSslConfig.getCrlPath()); + xml.setAttribute(KEY_MANAGER_FACTORY_ALGORITHM, esme.wrappedSslConfig.getKeyManagerFactoryAlgorithm()); + xml.setAttribute(KEY_MANAGER_PASSWORD, esme.wrappedSslConfig.getKeyManagerPassword()); + xml.setAttribute(KEY_STORE_PASSWORD, esme.wrappedSslConfig.getKeyStorePassword()); + xml.setAttribute(KEY_STORE_PROVIDER, esme.wrappedSslConfig.getKeyStoreProvider()); + xml.setAttribute(KEY_STORE_PATH, esme.wrappedSslConfig.getKeyStorePath()); + xml.setAttribute(KEY_STORE_TYPE, esme.wrappedSslConfig.getKeyStoreType()); + xml.setAttribute(MAX_CERT_PATH_LENGTH, esme.wrappedSslConfig.getMaxCertPathLength()); + xml.setAttribute(NEED_CLIENT_AUTH, esme.wrappedSslConfig.getNeedClientAuth()); + xml.setAttribute(OCS_RESPONDER_URL, esme.wrappedSslConfig.getOcspResponderURL()); + xml.setAttribute(PROTOCOL, esme.wrappedSslConfig.getProtocol()); + xml.setAttribute(PROVIDER, esme.wrappedSslConfig.getProvider()); + xml.setAttribute(SECURE_RANDOM_ALGORITHM, esme.wrappedSslConfig.getSecureRandomAlgorithm()); + xml.setAttribute(SSL_SESSION_CACHE_SIZE, esme.wrappedSslConfig.getSslSessionCacheSize()); + xml.setAttribute(SSL_SESSION_TIMEOUT, esme.wrappedSslConfig.getSslSessionTimeout()); + xml.setAttribute(TRUST_MANAGER_FACTORY_ALGORITHM, esme.wrappedSslConfig.getTrustManagerFactoryAlgorithm()); + xml.setAttribute(TRUST_STORE_PASSWORD, esme.wrappedSslConfig.getTrustStorePassword()); + xml.setAttribute(TRUST_STORE_PATH, esme.wrappedSslConfig.getTrustStorePath()); + xml.setAttribute(TRUST_STORE_PROVIDER, esme.wrappedSslConfig.getTrustStoreProvider()); + xml.setAttribute(TRUST_STORE_TYPE, esme.wrappedSslConfig.getTrustStoreType()); + xml.setAttribute(WANT_CLIENT_AUTH, esme.wrappedSslConfig.getWantClientAuth()); + xml.setAttribute(ALLOW_RENEGOTIATE, esme.wrappedSslConfig.isAllowRenegotiate()); + xml.setAttribute(ENABLE_CRLDP, esme.wrappedSslConfig.isEnableCRLDP()); + xml.setAttribute(SESSION_CACHING_ENABLED, esme.wrappedSslConfig.isSessionCachingEnabled()); + xml.setAttribute(TRUST_ALL, esme.wrappedSslConfig.isTrustAll()); + xml.setAttribute(VALIDATE_CERTS, esme.wrappedSslConfig.isValidateCerts()); + xml.setAttribute(VALIDATE_PEER_CERTS, esme.wrappedSslConfig.isValidatePeerCerts()); + } + }; + + public void show(StringBuffer sb) { sb.append(SmppOamMessages.SHOW_ESME_NAME).append(this.name).append(SmppOamMessages.SHOW_ESME_SYSTEM_ID) .append(this.systemId).append(SmppOamMessages.SHOW_ESME_STATE).append(this.getStateName()) .append(SmppOamMessages.SHOW_ESME_PASSWORD).append(this.password).append(SmppOamMessages.SHOW_ESME_HOST) @@ -1316,241 +1288,240 @@ public void show(StringBuffer sb) { .append(SmppOamMessages.MIN_MESSAGE_LENGTH).append(this.getMinMessageLength()) .append(SmppOamMessages.MAX_MESSAGE_LENGTH).append(this.getMaxMessageLength()) .append(SmppOamMessages.OVERLOAD_THRESHOLD).append(this.overloadThreshold) - .append(SmppOamMessages.NORMAL_THRESHOLD).append(this.normalThreshold) - .append(SmppOamMessages.SPLIT_LONG_MESSAGES).append(this.splitLongMessages); + .append(SmppOamMessages.NORMAL_THRESHOLD).append(this.normalThreshold).append(SmppOamMessages.OVERLOADED) + .append(this.overloaded).append(SmppOamMessages.SPLIT_LONG_MESSAGES).append(this.splitLongMessages); sb.append(SmppOamMessages.NEW_LINE); - } - - @Override - public void close() { - if (this.defaultSmppSession != null) { - try { - defaultSmppSession.close(); - } catch (Exception e) { - logger.error(String.format("Failed to close smpp session for %s.", - defaultSmppSession.getConfiguration().getName())); - } - } - } - - @Override - public void close(long arg0) { - if (this.defaultSmppSession != null) { - try { - defaultSmppSession.close(arg0); - } catch (Exception e) { - logger.error(String.format("Failed to close smpp session for %s.", - defaultSmppSession.getConfiguration().getName())); - } - } - } - - @Override - public void destroy() { - if (this.defaultSmppSession != null) { - this.defaultSmppSession.destroy(); - } - } - - @Override - public void disableLogBytes() { - if (this.defaultSmppSession != null) { - this.defaultSmppSession.disableLogBytes(); - } - } - - @Override - public void disableLogPdu() { - if (this.defaultSmppSession != null) { - this.defaultSmppSession.disableLogPdu(); - } - } - - @Override - public String[] dumpWindow() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.dumpWindow(); - } - - return null; - } - - @Override - public void enableLogBytes() { - if (this.defaultSmppSession != null) { - this.defaultSmppSession.enableLogBytes(); - } - } - - @Override - public void enableLogPdu() { - if (this.defaultSmppSession != null) { - this.defaultSmppSession.enableLogPdu(); - } - } - - @Override - public String getBindTypeName() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getBindTypeName(); - } - return this.smppBindType.toString(); - } - - @Override - public String getBoundDuration() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getBoundDuration(); - } - return null; - } - - @Override - public String getInterfaceVersionName() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getInterfaceVersionName(); - } - return this.smppVersion.getType(); - } - - @Override - public String getLocalAddressAndPort() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getLocalAddressAndPort(); - } - return null; - } - - @Override - public String getLocalTypeName() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getLocalTypeName(); - } - return this.smppSessionType.toString(); - } - - @Override - public int getMaxWindowSize() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getMaxWindowSize(); - } - return 0; - } - - @Override - public int getNextSequenceNumber() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getNextSequenceNumber(); - } - return 0; - } - - @Override - public String getRemoteAddressAndPort() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getRemoteAddressAndPort(); - } - return null; - } - - @Override - public String getRemoteTypeName() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getRemoteTypeName(); - } - - if (this.smppSessionType == SmppSession.Type.SERVER) { - return SmppSession.Type.CLIENT.toString(); - } else { - return SmppSession.Type.SERVER.toString(); - } - } - - @Override - public String getRxDataSMCounter() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getRxDataSMCounter(); - } - return null; - } - - @Override - public String getRxDeliverSMCounter() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getRxDeliverSMCounter(); - } - return null; - } - - @Override - public String getRxEnquireLinkCounter() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getRxEnquireLinkCounter(); - } - return null; - } - - @Override - public String getRxSubmitSMCounter() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getRxSubmitSMCounter(); - } - return null; - } - - @Override - public String getStateName() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getStateName(); - } - return this.state; - } - - protected void setStateName(String name) { - this.state = name; - } - - - public String getLocalStateName() { + } + + @Override + public void close() { + if (this.defaultSmppSession != null) { + try { + defaultSmppSession.close(); + } catch (Exception e) { + logger.error( + String.format("Failed to close smpp session for %s.", defaultSmppSession.getConfiguration().getName())); + } + } + } + + @Override + public void close(long arg0) { + if (this.defaultSmppSession != null) { + try { + defaultSmppSession.close(arg0); + } catch (Exception e) { + logger.error( + String.format("Failed to close smpp session for %s.", defaultSmppSession.getConfiguration().getName())); + } + } + } + + @Override + public void destroy() { + if (this.defaultSmppSession != null) { + this.defaultSmppSession.destroy(); + } + } + + @Override + public void disableLogBytes() { + if (this.defaultSmppSession != null) { + this.defaultSmppSession.disableLogBytes(); + } + } + + @Override + public void disableLogPdu() { + if (this.defaultSmppSession != null) { + this.defaultSmppSession.disableLogPdu(); + } + } + + @Override + public String[] dumpWindow() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.dumpWindow(); + } + + return null; + } + + @Override + public void enableLogBytes() { + if (this.defaultSmppSession != null) { + this.defaultSmppSession.enableLogBytes(); + } + } + + @Override + public void enableLogPdu() { + if (this.defaultSmppSession != null) { + this.defaultSmppSession.enableLogPdu(); + } + } + + @Override + public String getBindTypeName() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getBindTypeName(); + } + return this.smppBindType.toString(); + } + + @Override + public String getBoundDuration() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getBoundDuration(); + } + return null; + } + + @Override + public String getInterfaceVersionName() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getInterfaceVersionName(); + } + return this.smppVersion.getType(); + } + + @Override + public String getLocalAddressAndPort() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getLocalAddressAndPort(); + } + return null; + } + + @Override + public String getLocalTypeName() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getLocalTypeName(); + } + return this.smppSessionType.toString(); + } + + @Override + public int getMaxWindowSize() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getMaxWindowSize(); + } + return 0; + } + + @Override + public int getNextSequenceNumber() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getNextSequenceNumber(); + } + return 0; + } + + @Override + public String getRemoteAddressAndPort() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getRemoteAddressAndPort(); + } + return null; + } + + @Override + public String getRemoteTypeName() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getRemoteTypeName(); + } + + if (this.smppSessionType == SmppSession.Type.SERVER) { + return SmppSession.Type.CLIENT.toString(); + } else { + return SmppSession.Type.SERVER.toString(); + } + } + + @Override + public String getRxDataSMCounter() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getRxDataSMCounter(); + } + return null; + } + + @Override + public String getRxDeliverSMCounter() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getRxDeliverSMCounter(); + } + return null; + } + + @Override + public String getRxEnquireLinkCounter() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getRxEnquireLinkCounter(); + } + return null; + } + + @Override + public String getRxSubmitSMCounter() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getRxSubmitSMCounter(); + } + return null; + } + + @Override + public String getStateName() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getStateName(); + } + return this.state; + } + + protected void setStateName(String name) { + this.state = name; + } + + public String getLocalStateName() { return this.localState; } - - public void setLocalStateName(String name) { + + public void setLocalStateName(String name) { this.localState = name; } - @Override - public String getTxDataSMCounter() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getTxDataSMCounter(); - } - return null; - } - - @Override - public String getTxDeliverSMCounter() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getTxDeliverSMCounter(); - } - return null; - } - - @Override - public String getTxEnquireLinkCounter() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getTxEnquireLinkCounter(); - } - return null; - } - - @Override - public String getTxSubmitSMCounter() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.getTxSubmitSMCounter(); - } - return null; - } + @Override + public String getTxDataSMCounter() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getTxDataSMCounter(); + } + return null; + } + + @Override + public String getTxDeliverSMCounter() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getTxDeliverSMCounter(); + } + return null; + } + + @Override + public String getTxEnquireLinkCounter() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getTxEnquireLinkCounter(); + } + return null; + } + + @Override + public String getTxSubmitSMCounter() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.getTxSubmitSMCounter(); + } + return null; + } @Override public String getRxDataSMCounterAndReset() { @@ -1616,136 +1587,133 @@ public String getTxSubmitSMCounterAndReset() { return null; } - @Override - public boolean isBinding() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.isBinding(); - } - return false; - } - - @Override - public boolean isBound() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.isBound(); - } - return false; - } - - @Override - public boolean isClosed() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.isClosed(); - } - return true; - } - - @Override - public boolean isOpen() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.isOpen(); - } - return false; - } - - @Override - public boolean isUnbinding() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.isUnbinding(); - } - return false; - } - - @Override - public boolean isWindowMonitorEnabled() { - if (this.defaultSmppSession != null) { - return this.defaultSmppSession.isWindowMonitorEnabled(); - } - return false; - } - - @Override - public void resetCounters() { - if (this.defaultSmppSession != null) { - this.defaultSmppSession.resetCounters(); - } + @Override + public boolean isBinding() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.isBinding(); + } + return false; + } + + @Override + public boolean isBound() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.isBound(); + } + return false; + } - this.rxEnquireLinkCounter = 0; - } + @Override + public boolean isClosed() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.isClosed(); + } + return true; + } + + @Override + public boolean isOpen() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.isOpen(); + } + return false; + } - @Override - public void unbind(long arg0) { - if (this.defaultSmppSession != null) { - try { - defaultSmppSession.unbind(arg0); - } catch (Exception e) { - logger.error(String.format("Failed to unbind smpp session for %s.", - defaultSmppSession.getConfiguration().getName())); - } - } + @Override + public boolean isUnbinding() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.isUnbinding(); + } + return false; + } + + @Override + public boolean isWindowMonitorEnabled() { + if (this.defaultSmppSession != null) { + return this.defaultSmppSession.isWindowMonitorEnabled(); + } + return false; + } + + @Override + public void resetCounters() { + if (this.defaultSmppSession != null) { + this.defaultSmppSession.resetCounters(); + } + + this.rxEnquireLinkCounter = 0; + } - } + @Override + public void unbind(long arg0) { + if (this.defaultSmppSession != null) { + try { + defaultSmppSession.unbind(arg0); + } catch (Exception e) { + logger.error(String.format("Failed to unbind smpp session for %s.", + defaultSmppSession.getConfiguration().getName())); + } + } + } /** - * On receiving of every message from this ESME this method should be - * invoked. This method updates a counter of received messages and checks if - * a seconds / minute / hour / day limits are exceeded + * On receiving of every message from this ESME this method should be invoked. This method updates a counter of received + * messages and checks if a seconds / minute / hour / day limits are exceeded * - * @param count - * received messages count + * @param count received messages count * @return checking result */ - public CheckMessageLimitResult onMessageReceived(int count) { - -// if (getLinkDropServerEnabled()) { -// synchronized (linkDropWaitObject) { -// if (!linkRecvMessCheck) { -// linkRecvMessCheck = true; -// } -// } -// } + public CheckMessageLimitResult onMessageReceived(int count) { + + // if (getLinkDropServerEnabled()) { + // synchronized (linkDropWaitObject) { + // if (!linkRecvMessCheck) { + // linkRecvMessCheck = true; + // } + // } + // } linkRecvMessCheck = true; - long cntSecond = this.receivedMsgPerSecond.addAndGet(count); + long cntSecond = this.receivedMsgPerSecond.addAndGet(count); if (rateLimitPerSecond > 0 && cntSecond > rateLimitPerSecond) { this.receivedMsgPerSecond.addAndGet(-count); if (this.extraMsgPerSecond.addAndGet(1) == 1) - return new CheckMessageLimitResult(CheckMessageLimitResult.Result.firstFault, "RateLimitPerSecond is exceeded for ESME=" + this.name, - CheckMessageLimitResult.Domain.perSecond); + return new CheckMessageLimitResult(CheckMessageLimitResult.Result.firstFault, + "RateLimitPerSecond is exceeded for ESME=" + this.name, CheckMessageLimitResult.Domain.perSecond); else - return new CheckMessageLimitResult(CheckMessageLimitResult.Result.nextFault, "RateLimitPerSecond is exceeded for ESME=" + this.name, - CheckMessageLimitResult.Domain.perSecond); + return new CheckMessageLimitResult(CheckMessageLimitResult.Result.nextFault, + "RateLimitPerSecond is exceeded for ESME=" + this.name, CheckMessageLimitResult.Domain.perSecond); } long cntMinute = this.receivedMsgPerMinute.addAndGet(count); if (rateLimitPerMinute > 0 && cntMinute > rateLimitPerMinute) { this.receivedMsgPerMinute.addAndGet(-count); if (this.extraMsgPerMinute.addAndGet(1) == 1) - return new CheckMessageLimitResult(CheckMessageLimitResult.Result.firstFault, "RateLimitPerMinute is exceeded for ESME=" + this.name, - CheckMessageLimitResult.Domain.perMinute); + return new CheckMessageLimitResult(CheckMessageLimitResult.Result.firstFault, + "RateLimitPerMinute is exceeded for ESME=" + this.name, CheckMessageLimitResult.Domain.perMinute); else - return new CheckMessageLimitResult(CheckMessageLimitResult.Result.nextFault, "RateLimitPerMinute is exceeded for ESME=" + this.name, - CheckMessageLimitResult.Domain.perMinute); + return new CheckMessageLimitResult(CheckMessageLimitResult.Result.nextFault, + "RateLimitPerMinute is exceeded for ESME=" + this.name, CheckMessageLimitResult.Domain.perMinute); } long cntHour = this.receivedMsgPerHour.addAndGet(count); if (rateLimitPerHour > 0 && cntHour > rateLimitPerHour) { this.receivedMsgPerHour.addAndGet(-count); if (this.extraMsgPerHour.addAndGet(1) == 1) - return new CheckMessageLimitResult(CheckMessageLimitResult.Result.firstFault, "RateLimitPerHour is exceeded for ESME=" + this.name, - CheckMessageLimitResult.Domain.perHour); + return new CheckMessageLimitResult(CheckMessageLimitResult.Result.firstFault, + "RateLimitPerHour is exceeded for ESME=" + this.name, CheckMessageLimitResult.Domain.perHour); else - return new CheckMessageLimitResult(CheckMessageLimitResult.Result.nextFault, "RateLimitPerHour is exceeded for ESME=" + this.name, - CheckMessageLimitResult.Domain.perHour); + return new CheckMessageLimitResult(CheckMessageLimitResult.Result.nextFault, + "RateLimitPerHour is exceeded for ESME=" + this.name, CheckMessageLimitResult.Domain.perHour); } long cntDay = this.receivedMsgPerDay.addAndGet(count); if (rateLimitPerDay > 0 && cntDay > rateLimitPerDay) { this.receivedMsgPerDay.addAndGet(-count); if (this.extraMsgPerDay.addAndGet(1) == 1) - return new CheckMessageLimitResult(CheckMessageLimitResult.Result.firstFault, "RateLimitPerDay is exceeded for ESME=" + this.name, - CheckMessageLimitResult.Domain.perDay); + return new CheckMessageLimitResult(CheckMessageLimitResult.Result.firstFault, + "RateLimitPerDay is exceeded for ESME=" + this.name, CheckMessageLimitResult.Domain.perDay); else - return new CheckMessageLimitResult(CheckMessageLimitResult.Result.nextFault, "RateLimitPerDay is exceeded for ESME=" + this.name, - CheckMessageLimitResult.Domain.perDay); + return new CheckMessageLimitResult(CheckMessageLimitResult.Result.nextFault, + "RateLimitPerDay is exceeded for ESME=" + this.name, CheckMessageLimitResult.Domain.perDay); } return new CheckMessageLimitResult(CheckMessageLimitResult.Result.ok, null, null); @@ -1814,10 +1782,18 @@ public int getOverloadThreshold() { @Override public void setOverloadThreshold(int overloadThreshold) { - if (overloadThreshold >= 0) { + boolean update = false; + if (overloadThreshold > 0) { + if (normalThreshold >= 0 && overloadThreshold > normalThreshold) { + update = true; + } + } else if (overloadThreshold == -1) { + update = true; + } + if (update) { this.overloadThreshold = overloadThreshold; + this.store(); } - this.store(); } @Override @@ -1827,14 +1803,23 @@ public int getNormalThreshold() { @Override public void setNormalThreshold(int normalThreshold) { - if(normalThreshold >= 0) { + boolean update = false; + if (normalThreshold >= 0) { + if ((overloadThreshold > 0 && overloadThreshold > normalThreshold) || overloadThreshold == -1) { + update = true; + } + } else if (normalThreshold == -1 && overloadThreshold == -1) { + update = true; + } + + if (update) { this.normalThreshold = normalThreshold; + this.store(); } - this.store(); } @Override - public boolean isOverloaded() { + public boolean getOverloaded() { return overloaded; } @@ -1844,31 +1829,31 @@ public void setOverloaded(boolean overloaded) { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Esme other = (Esme) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } - - public void store() { - this.esmeManagement.store(); - } + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Esme other = (Esme) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + public void store() { + this.esmeManagement.store(); + } } diff --git a/core/smpp-extensions/src/main/java/org/restcomm/smpp/EsmeCluster.java b/core/smpp-extensions/src/main/java/org/restcomm/smpp/EsmeCluster.java index e3dc362..b6ed416 100644 --- a/core/smpp-extensions/src/main/java/org/restcomm/smpp/EsmeCluster.java +++ b/core/smpp-extensions/src/main/java/org/restcomm/smpp/EsmeCluster.java @@ -92,7 +92,7 @@ synchronized Esme getNextEsme() { } Esme esme = this.esmesToSendPdu.get(this.index); - if (esme.isBound() && !esme.isOverloaded()) { + if (esme.isBound() && !esme.getOverloaded()) { return esme; } } diff --git a/core/smpp-extensions/src/main/java/org/restcomm/smpp/EsmeMBean.java b/core/smpp-extensions/src/main/java/org/restcomm/smpp/EsmeMBean.java index ba303e8..7d5a48c 100644 --- a/core/smpp-extensions/src/main/java/org/restcomm/smpp/EsmeMBean.java +++ b/core/smpp-extensions/src/main/java/org/restcomm/smpp/EsmeMBean.java @@ -359,7 +359,7 @@ public interface EsmeMBean extends DefaultSmppSessionMXBean, SslConfigurationWra void setNormalThreshold(int normalThreshold); - boolean isOverloaded(); + boolean getOverloaded(); void setOverloaded(boolean overloaded); diff --git a/core/smpp-extensions/src/main/java/org/restcomm/smpp/EsmeManagement.java b/core/smpp-extensions/src/main/java/org/restcomm/smpp/EsmeManagement.java index 195b5d8..07d28c1 100644 --- a/core/smpp-extensions/src/main/java/org/restcomm/smpp/EsmeManagement.java +++ b/core/smpp-extensions/src/main/java/org/restcomm/smpp/EsmeManagement.java @@ -66,41 +66,41 @@ */ public class EsmeManagement implements EsmeManagementMBean { - private static final Logger logger = Logger.getLogger(EsmeManagement.class); + private static final Logger logger = Logger.getLogger(EsmeManagement.class); - private static final String ESME_LIST = "esmeList"; - private static final String TAB_INDENT = "\t"; - private static final String CLASS_ATTRIBUTE = "type"; - private static final XMLBinding binding = new XMLBinding(); - private static final String PERSIST_FILE_NAME = "esme.xml"; + private static final String ESME_LIST = "esmeList"; + private static final String TAB_INDENT = "\t"; + private static final String CLASS_ATTRIBUTE = "type"; + private static final XMLBinding binding = new XMLBinding(); + private static final String PERSIST_FILE_NAME = "esme.xml"; - private final String name; + private final String name; - private String persistDir = null; + private String persistDir = null; - protected FastList esmes = new FastList(); + protected FastList esmes = new FastList(); - protected FastMap esmesServer = new FastMap(); + protected FastMap esmesServer = new FastMap(); - protected FastMap esmeClusters = new FastMap(); + protected FastMap esmeClusters = new FastMap(); - private final TextBuilder persistFile = TextBuilder.newInstance(); + private final TextBuilder persistFile = TextBuilder.newInstance(); - private SmppClientManagement smppClient = null; + private SmppClientManagement smppClient = null; private MBeanServer mbeanServer = null; private Timer timer; private TimerTask timerTask; - private static EsmeManagement instance = null; + private static EsmeManagement instance = null; - protected EsmeManagement(String name) { - this.name = name; + protected EsmeManagement(String name) { + this.name = name; - binding.setClassAttribute(CLASS_ATTRIBUTE); - binding.setAlias(Esme.class, "esme"); - } + binding.setClassAttribute(CLASS_ATTRIBUTE); + binding.setAlias(Esme.class, "esme"); + } protected static EsmeManagement getInstance(String name) { if (instance == null) { @@ -113,99 +113,98 @@ protected static void setInstance(EsmeManagement instance) { EsmeManagement.instance = instance; } - public static EsmeManagement getInstance() { - return instance; - } + public static EsmeManagement getInstance() { + return instance; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public String getPersistDir() { - return persistDir; - } + public String getPersistDir() { + return persistDir; + } - public void setPersistDir(String persistDir) { - this.persistDir = persistDir; - } + public void setPersistDir(String persistDir) { + this.persistDir = persistDir; + } - public void setMbeanServer(MBeanServer mbeanServer) { - this.mbeanServer = mbeanServer; - } + public void setMbeanServer(MBeanServer mbeanServer) { + this.mbeanServer = mbeanServer; + } - /** - * @param smppClient - * the smppClient to set - */ - protected void setSmppClient(SmppClientManagement smppClient) { - this.smppClient = smppClient; - } + /** + * @param smppClient the smppClient to set + */ + protected void setSmppClient(SmppClientManagement smppClient) { + this.smppClient = smppClient; + } @Override public FastList getEsmes() { return esmes; } - @Override - public Esme getEsmeByName(String esmeName) { - for (FastList.Node n = esmes.head(), end = esmes.tail(); (n = n.getNext()) != end;) { - Esme esme = n.getValue(); - if (esme.getName().equals(esmeName)) { - return esme; - } - } - return null; - } - - @Override - public Esme getEsmeByClusterName(String esmeClusterName) { - EsmeCluster esmeCluster = this.esmeClusters.get(esmeClusterName); - if (esmeCluster != null) { - return esmeCluster.getNextEsme(); - } - return null; - } - - protected Esme getEsmeByPrimaryKey(String SystemId, String host, int port, SmppBindType smppBindType) { - - // Check for actual SystemId, host and port - for (FastList.Node n = esmes.head(), end = esmes.tail(); (n = n.getNext()) != end;) { - Esme esme = n.getValue(); - - if (esme.getSystemId().equals(SystemId) && esme.getSmppBindType() == smppBindType) { - //discoveredEsme = esme; - if (esme.getHost().equals(host) && esme.getPort() == port) { - // exact match found - return esme; - } - - if (esme.getHost().equals(host) && esme.getPort() == -1) { - // Hosts match but port is any - if (esme.getLocalStateName().equals(com.cloudhopper.smpp.SmppSession.STATES[SmppSession.STATE_CLOSED])) { - return esme; - } - } - - if (esme.getHost().equals("-1") && esme.getPort() == port) { - // Host is any but port matches - if (esme.getLocalStateName().equals(com.cloudhopper.smpp.SmppSession.STATES[SmppSession.STATE_CLOSED])) { - return esme; - } - } - - if (esme.getHost().equals("-1") && esme.getPort() == -1) { - // Host is any and port is also any - if (esme.getLocalStateName().equals(com.cloudhopper.smpp.SmppSession.STATES[SmppSession.STATE_CLOSED])) { - return esme; - } - } - - }// esme.getSystemId().equals(SystemId) && esme.getSmppBindType() == - // smppBindType - } - - return null; - } + @Override + public Esme getEsmeByName(String esmeName) { + for (FastList.Node n = esmes.head(), end = esmes.tail(); (n = n.getNext()) != end;) { + Esme esme = n.getValue(); + if (esme.getName().equals(esmeName)) { + return esme; + } + } + return null; + } + + @Override + public Esme getEsmeByClusterName(String esmeClusterName) { + EsmeCluster esmeCluster = this.esmeClusters.get(esmeClusterName); + if (esmeCluster != null) { + return esmeCluster.getNextEsme(); + } + return null; + } + + protected Esme getEsmeByPrimaryKey(String SystemId, String host, int port, SmppBindType smppBindType) { + + // Check for actual SystemId, host and port + for (FastList.Node n = esmes.head(), end = esmes.tail(); (n = n.getNext()) != end;) { + Esme esme = n.getValue(); + + if (esme.getSystemId().equals(SystemId) && esme.getSmppBindType() == smppBindType) { + // discoveredEsme = esme; + if (esme.getHost().equals(host) && esme.getPort() == port) { + // exact match found + return esme; + } + + if (esme.getHost().equals(host) && esme.getPort() == -1) { + // Hosts match but port is any + if (esme.getLocalStateName().equals(com.cloudhopper.smpp.SmppSession.STATES[SmppSession.STATE_CLOSED])) { + return esme; + } + } + + if (esme.getHost().equals("-1") && esme.getPort() == port) { + // Host is any but port matches + if (esme.getLocalStateName().equals(com.cloudhopper.smpp.SmppSession.STATES[SmppSession.STATE_CLOSED])) { + return esme; + } + } + + if (esme.getHost().equals("-1") && esme.getPort() == -1) { + // Host is any and port is also any + if (esme.getLocalStateName().equals(com.cloudhopper.smpp.SmppSession.STATES[SmppSession.STATE_CLOSED])) { + return esme; + } + } + + } // esme.getSystemId().equals(SystemId) && esme.getSmppBindType() == + // smppBindType + } + + return null; + } public Esme createEsme(String name, String systemId, String password, String host, int port, boolean chargingEnabled, String smppBindType, String systemType, String smppIntVersion, byte ton, byte npi, String address, @@ -214,256 +213,256 @@ public Esme createEsme(String name, String systemId, String password, String hos int enquireLinkDelay, int enquireLinkDelayServer, long linkDropServer, int sourceTon, int sourceNpi, String sourceAddressRange, int routingTon, int routingNpi, String routingAddressRange, int networkId, boolean splitLongMessages, long rateLimitPerSecond, long rateLimitPerMinute, long rateLimitPerHour, - long rateLimitPerDay, int nationalLanguageSingleShift, int nationalLanguageLockingShift, int destAddrSendLimit, int minMessageLength, - int maxMessageLength, int overloadThreshold, int normalThreshold) throws Exception { - - SmppBindType smppBindTypeOb = SmppBindType.valueOf(smppBindType); - - if (smppBindTypeOb == null) { - throw new Exception("SmppBindType must be either of TRANSCEIVER, TRANSMITTER or RECEIVER. Passed is " - + smppBindType); - } - - SmppSession.Type smppSessionTypeObj = SmppSession.Type.valueOf(smppSessionType); - if (smppSessionTypeObj == null) { - throw new Exception("SmppSession.Type must be either of SERVER or CLIENT. Passed is " + smppSessionType); - } - - SmppInterfaceVersionType smppInterfaceVersionTypeObj = SmppInterfaceVersionType - .getInterfaceVersionType(smppIntVersion); - - if (smppInterfaceVersionTypeObj == null) { - smppInterfaceVersionTypeObj = SmppInterfaceVersionType.SMPP34; - } - - if (smppSessionTypeObj == SmppSession.Type.CLIENT) { - if (port < 1) { - throw new Exception(SmppOamMessages.CREATE_EMSE_FAIL_PORT_CANNOT_BE_LESS_THAN_ZERO); - } - - if (host == null || host.equals("-1")) { - throw new Exception(SmppOamMessages.CREATE_EMSE_FAIL_HOST_CANNOT_BE_ANONYMOUS); - } - } - - for (FastList.Node n = esmes.head(), end = esmes.tail(); (n = n.getNext()) != end;) { - Esme esme = n.getValue(); - - // Name should be unique - if (esme.getName().equals(name)) { - throw new Exception(String.format(SmppOamMessages.CREATE_EMSE_FAIL_ALREADY_EXIST, name)); - } - - // SystemId:IP:Port:SmppBindType combination should be unique for - // CLIENT. For SERVER it accepts multiple incoming binds as far as - // host is anonymous (-1) and/or port is -1 -// String primaryKey = systemId + smppBindType; -// String existingPrimaryKey = esme.getSystemId() + esme.getSmppBindType().name(); -// -// if (smppSessionTypeObj == SmppSession.Type.SERVER) { -// if (!host.equals("-1") && port != -1) { -// primaryKey = primaryKey + host + port; -// existingPrimaryKey = existingPrimaryKey + esme.getHost() + esme.getPort(); -// } else { -// // Let the ESME be created -// primaryKey = "X"; -// existingPrimaryKey = "Y"; -// } -// } else { -// primaryKey = primaryKey + host + port; -// existingPrimaryKey = existingPrimaryKey + esme.getHost() + esme.getPort(); -// } -// -// if (primaryKey.equals(existingPrimaryKey)) { -// throw new Exception(String.format(SmppOamMessages.CREATE_EMSE_FAIL_PRIMARY_KEY_ALREADY_EXIST, systemId, -// host, port, smppBindType)); -// } - }// for loop - - EsmeCluster esmeCluster = this.esmeClusters.get(clusterName); + long rateLimitPerDay, int nationalLanguageSingleShift, int nationalLanguageLockingShift, int destAddrSendLimit, + int minMessageLength, int maxMessageLength, int overloadThreshold, int normalThreshold) throws Exception { + + SmppBindType smppBindTypeOb = SmppBindType.valueOf(smppBindType); + + if (smppBindTypeOb == null) { + throw new Exception( + "SmppBindType must be either of TRANSCEIVER, TRANSMITTER or RECEIVER. Passed is " + smppBindType); + } + + SmppSession.Type smppSessionTypeObj = SmppSession.Type.valueOf(smppSessionType); + if (smppSessionTypeObj == null) { + throw new Exception("SmppSession.Type must be either of SERVER or CLIENT. Passed is " + smppSessionType); + } + + SmppInterfaceVersionType smppInterfaceVersionTypeObj = SmppInterfaceVersionType.getInterfaceVersionType(smppIntVersion); + + if (smppInterfaceVersionTypeObj == null) { + smppInterfaceVersionTypeObj = SmppInterfaceVersionType.SMPP34; + } + + if (smppSessionTypeObj == SmppSession.Type.CLIENT) { + if (port < 1) { + throw new Exception(SmppOamMessages.CREATE_EMSE_FAIL_PORT_CANNOT_BE_LESS_THAN_ZERO); + } + + if (host == null || host.equals("-1")) { + throw new Exception(SmppOamMessages.CREATE_EMSE_FAIL_HOST_CANNOT_BE_ANONYMOUS); + } + } + + for (FastList.Node n = esmes.head(), end = esmes.tail(); (n = n.getNext()) != end;) { + Esme esme = n.getValue(); + + // Name should be unique + if (esme.getName().equals(name)) { + throw new Exception(String.format(SmppOamMessages.CREATE_EMSE_FAIL_ALREADY_EXIST, name)); + } + + // SystemId:IP:Port:SmppBindType combination should be unique for + // CLIENT. For SERVER it accepts multiple incoming binds as far as + // host is anonymous (-1) and/or port is -1 + // String primaryKey = systemId + smppBindType; + // String existingPrimaryKey = esme.getSystemId() + esme.getSmppBindType().name(); + // + // if (smppSessionTypeObj == SmppSession.Type.SERVER) { + // if (!host.equals("-1") && port != -1) { + // primaryKey = primaryKey + host + port; + // existingPrimaryKey = existingPrimaryKey + esme.getHost() + esme.getPort(); + // } else { + // // Let the ESME be created + // primaryKey = "X"; + // existingPrimaryKey = "Y"; + // } + // } else { + // primaryKey = primaryKey + host + port; + // existingPrimaryKey = existingPrimaryKey + esme.getHost() + esme.getPort(); + // } + // + // if (primaryKey.equals(existingPrimaryKey)) { + // throw new Exception(String.format(SmppOamMessages.CREATE_EMSE_FAIL_PRIMARY_KEY_ALREADY_EXIST, systemId, + // host, port, smppBindType)); + // } + } // for loop + + EsmeCluster esmeCluster = this.esmeClusters.get(clusterName); if (esmeCluster != null) { if (esmeCluster.getNetworkId() != networkId) { - throw new Exception(String.format(SmppOamMessages.CREATE_EMSE_FAIL_WRONG_NETWORKID_IN_ESMECLUSTER, esmeCluster.getNetworkId(), networkId)); + throw new Exception(String.format(SmppOamMessages.CREATE_EMSE_FAIL_WRONG_NETWORKID_IN_ESMECLUSTER, + esmeCluster.getNetworkId(), networkId)); } } - if (clusterName == null) { - clusterName = name; - } + if (clusterName == null) { + clusterName = name; + } Esme esme = new Esme(name, systemId, password, host, port, chargingEnabled, systemType, smppInterfaceVersionTypeObj, ton, npi, address, smppBindTypeOb, smppSessionTypeObj, windowSize, connectTimeout, requestExpiryTimeout, clientBindTimeout, windowMonitorInterval, windowWaitTimeout, clusterName, countersEnabled, enquireLinkDelay, enquireLinkDelayServer, linkDropServer, sourceTon, sourceNpi, sourceAddressRange, routingTon, routingNpi, routingAddressRange, networkId, splitLongMessages, rateLimitPerSecond, rateLimitPerMinute, rateLimitPerHour, - rateLimitPerDay, nationalLanguageSingleShift, nationalLanguageLockingShift, destAddrSendLimit, minMessageLength, maxMessageLength, overloadThreshold, normalThreshold); + rateLimitPerDay, nationalLanguageSingleShift, nationalLanguageLockingShift, destAddrSendLimit, minMessageLength, + maxMessageLength, overloadThreshold, normalThreshold); - esme.esmeManagement = this; + esme.esmeManagement = this; - esmes.add(esme); + esmes.add(esme); - if (esmeCluster == null) { - esmeCluster = new EsmeCluster(clusterName, networkId); - this.esmeClusters.put(clusterName, esmeCluster); - } + if (esmeCluster == null) { + esmeCluster = new EsmeCluster(clusterName, networkId); + this.esmeClusters.put(clusterName, esmeCluster); + } - esmeCluster.addEsme(esme); + esmeCluster.addEsme(esme); - this.store(); + this.store(); - this.registerEsmeMbean(esme); + this.registerEsmeMbean(esme); - return esme; - } + return esme; + } - public Esme destroyEsme(String esmeName) throws Exception { - Esme esme = this.getEsmeByName(esmeName); - if (esme == null) { - throw new Exception(String.format(SmppOamMessages.DELETE_ESME_FAILED_NO_ESME_FOUND, esmeName)); - } + public Esme destroyEsme(String esmeName) throws Exception { + Esme esme = this.getEsmeByName(esmeName); + if (esme == null) { + throw new Exception(String.format(SmppOamMessages.DELETE_ESME_FAILED_NO_ESME_FOUND, esmeName)); + } - if (esme.isStarted()) { - throw new Exception(String.format(SmppOamMessages.DELETE_ESME_FAILED_ESME_STARTED)); - } + if (esme.isStarted()) { + throw new Exception(String.format(SmppOamMessages.DELETE_ESME_FAILED_ESME_STARTED)); + } - esmes.remove(esme); + esmes.remove(esme); - EsmeCluster esmeCluster = this.esmeClusters.get(esme.getClusterName()); - esmeCluster.removeEsme(esme); + EsmeCluster esmeCluster = this.esmeClusters.get(esme.getClusterName()); + esmeCluster.removeEsme(esme); - if (!esmeCluster.hasMoreEsmes()) { - this.esmeClusters.remove(esme.getClusterName()); - } + if (!esmeCluster.hasMoreEsmes()) { + this.esmeClusters.remove(esme.getClusterName()); + } - this.store(); + this.store(); - this.unregisterEsmeMbean(esme.getName()); + this.unregisterEsmeMbean(esme.getName()); - return esme; - } + return esme; + } - @Override - public void startEsme(String esmeName) throws Exception { - Esme esme = this.getEsmeByName(esmeName); - if (esme == null) { - throw new Exception(String.format(SmppOamMessages.DELETE_ESME_FAILED_NO_ESME_FOUND, esmeName)); - } + @Override + public void startEsme(String esmeName) throws Exception { + Esme esme = this.getEsmeByName(esmeName); + if (esme == null) { + throw new Exception(String.format(SmppOamMessages.DELETE_ESME_FAILED_NO_ESME_FOUND, esmeName)); + } - if (esme.isStarted()) { - throw new Exception(String.format(SmppOamMessages.START_ESME_FAILED_ALREADY_STARTED, esmeName)); - } + if (esme.isStarted()) { + throw new Exception(String.format(SmppOamMessages.START_ESME_FAILED_ALREADY_STARTED, esmeName)); + } - esme.setStarted(true); - this.store(); + esme.setStarted(true); + this.store(); - if (esme.getSmppSessionType().equals(SmppSession.Type.CLIENT)) { - this.smppClient.startSmppClientSession(esme); - } + if (esme.getSmppSessionType().equals(SmppSession.Type.CLIENT)) { + this.smppClient.startSmppClientSession(esme); + } - } + } - @Override - public void stopEsme(String esmeName) throws Exception { - Esme esme = this.getEsmeByName(esmeName); - if (esme == null) { - throw new Exception(String.format(SmppOamMessages.DELETE_ESME_FAILED_NO_ESME_FOUND, esmeName)); - } + @Override + public void stopEsme(String esmeName) throws Exception { + Esme esme = this.getEsmeByName(esmeName); + if (esme == null) { + throw new Exception(String.format(SmppOamMessages.DELETE_ESME_FAILED_NO_ESME_FOUND, esmeName)); + } - esme.setStarted(false); + esme.setStarted(false); - if (esme.getLinkDropServerEnabled()) { - esme.resetLinkRecvMessage(); - } + if (esme.getLinkDropServerEnabled()) { + esme.resetLinkRecvMessage(); + } - this.store(); + this.store(); - this.stopWrappedSession(esme); - } + this.stopWrappedSession(esme); + } - private void stopWrappedSession(Esme esme) { - if (esme.getSmppSessionType().equals(SmppSession.Type.SERVER)) { - DefaultSmppSession smppSession = esme.getSmppSession(); + private void stopWrappedSession(Esme esme) { + if (esme.getSmppSessionType().equals(SmppSession.Type.SERVER)) { + DefaultSmppSession smppSession = esme.getSmppSession(); - if (smppSession != null) { - // TODO can server side send UNBIND? - // smppSession.unbind(5000); - try { - smppSession.close(); - } catch (Exception e) { - logger.error(String.format("Failed to close smpp session for %s.", - smppSession.getConfiguration().getName())); - } + if (smppSession != null) { + // TODO can server side send UNBIND? + // smppSession.unbind(5000); + try { + smppSession.close(); + } catch (Exception e) { + logger.error( + String.format("Failed to close smpp session for %s.", smppSession.getConfiguration().getName())); + } -// // firing of onPduRequestTimeout() for sent messages for which we do not have responses -// Window wind = smppSession.getSendWindow(); -// Map> futures = wind.createSortedSnapshot(); -// for (WindowFuture future : futures.values()) { -// this.logger.warn("Firing of onPduRequestTimeout from EsmeManagement.stopWrappedSession() - 1: " -// + future.getRequest().toString()); -// smppSession.expired(future); -// } + // // firing of onPduRequestTimeout() for sent messages for which we do not have responses + // Window wind = smppSession.getSendWindow(); + // Map> futures = wind.createSortedSnapshot(); + // for (WindowFuture future : futures.values()) { + // this.logger.warn("Firing of onPduRequestTimeout from EsmeManagement.stopWrappedSession() - 1: " + // + future.getRequest().toString()); + // smppSession.expired(future); + // } smppSession.destroy(); - } - } else { - if (this.smppClient != null) { - this.smppClient.stopSmppClientSession(esme); - } - } - } + } + } else { + if (this.smppClient != null) { + this.smppClient.stopSmppClientSession(esme); + } + } + } - public void start() throws Exception { + public void start() throws Exception { try { - if (this.mbeanServer == null) { - this.mbeanServer = JBossMbeanLocator.locateJBoss(); - } + if (this.mbeanServer == null) { + this.mbeanServer = JBossMbeanLocator.locateJBoss(); + } } catch (Exception e) { } - this.persistFile.clear(); + this.persistFile.clear(); - if (persistDir != null) { - this.persistFile.append(persistDir).append(File.separator).append(this.name).append("_") - .append(PERSIST_FILE_NAME); - } else { - persistFile - .append(System.getProperty(SmppManagement.SMSC_PERSIST_DIR_KEY, - System.getProperty(SmppManagement.USER_DIR_KEY))).append(File.separator).append(this.name) - .append("_").append(PERSIST_FILE_NAME); - } + if (persistDir != null) { + this.persistFile.append(persistDir).append(File.separator).append(this.name).append("_").append(PERSIST_FILE_NAME); + } else { + persistFile + .append(System.getProperty(SmppManagement.SMSC_PERSIST_DIR_KEY, + System.getProperty(SmppManagement.USER_DIR_KEY))) + .append(File.separator).append(this.name).append("_").append(PERSIST_FILE_NAME); + } - logger.info(String.format("Loading ESME configuration from %s", persistFile.toString())); + logger.info(String.format("Loading ESME configuration from %s", persistFile.toString())); - try { - this.load(); - } catch (FileNotFoundException e) { - logger.warn(String.format("Failed to load the ESME configuration file. \n%s", e.getMessage())); - } + try { + this.load(); + } catch (FileNotFoundException e) { + logger.warn(String.format("Failed to load the ESME configuration file. \n%s", e.getMessage())); + } - for (FastList.Node n = esmes.head(), end = esmes.tail(); (n = n.getNext()) != end;) { - Esme esme = n.getValue(); - this.registerEsmeMbean(esme); - } + for (FastList.Node n = esmes.head(), end = esmes.tail(); (n = n.getNext()) != end;) { + Esme esme = n.getValue(); + this.registerEsmeMbean(esme); + } - // setting a timer for cleaning of + // setting a timer for cleaning of this.clearMessageClearTimer(); this.timer = new Timer(); this.timerTask = new MessageCleanerTimerTask(); this.timer.scheduleAtFixedRate(timerTask, 0, 1000); - } + } - public void stop() throws Exception { + public void stop() throws Exception { this.clearMessageClearTimer(); this.store(); - for (FastList.Node n = esmes.head(), end = esmes.tail(); (n = n.getNext()) != end;) { - Esme esme = n.getValue(); - this.stopWrappedSession(esme); - this.unregisterEsmeMbean(esme.getName()); - } - } + for (FastList.Node n = esmes.head(), end = esmes.tail(); (n = n.getNext()) != end;) { + Esme esme = n.getValue(); + this.stopWrappedSession(esme); + this.unregisterEsmeMbean(esme.getName()); + } + } private void clearMessageClearTimer() { if (timerTask != null) { @@ -476,38 +475,39 @@ private void clearMessageClearTimer() { } } - /** - * Persist - */ - public void store() { - - // TODO : Should we keep reference to Objects rather than recreating - // everytime? - try { - XMLObjectWriter writer = XMLObjectWriter.newInstance(new FileOutputStream(persistFile.toString())); - writer.setBinding(binding); - // Enables cross-references. - // writer.setReferenceResolver(new XMLReferenceResolver()); - writer.setIndentation(TAB_INDENT); - writer.write(esmes, ESME_LIST, FastList.class); - - writer.close(); - } catch (Exception e) { - logger.error("Error while persisting the Rule state in file", e); - } - } - - /** - * Load and create LinkSets and Link from persisted file - * - * @throws Exception - */ - public void load() throws FileNotFoundException { - - // backward compatibility: rename old file name to new one + /** + * Persist + */ + public void store() { + + // TODO : Should we keep reference to Objects rather than recreating + // everytime? + try { + XMLObjectWriter writer = XMLObjectWriter.newInstance(new FileOutputStream(persistFile.toString())); + writer.setBinding(binding); + // Enables cross-references. + // writer.setReferenceResolver(new XMLReferenceResolver()); + writer.setIndentation(TAB_INDENT); + writer.write(esmes, ESME_LIST, FastList.class); + + writer.close(); + } catch (Exception e) { + logger.error("Error while persisting the Rule state in file", e); + } + } + + /** + * Load and create LinkSets and Link from persisted file + * + * @throws Exception + */ + public void load() throws FileNotFoundException { + + // backward compatibility: rename old file name to new one if (persistDir != null) { TextBuilder oldFileName = new TextBuilder(); - oldFileName.append(persistDir).append(File.separator).append("SmscManagement").append("_").append(PERSIST_FILE_NAME); + oldFileName.append(persistDir).append(File.separator).append("SmscManagement").append("_") + .append(PERSIST_FILE_NAME); Path oldPath = FileSystems.getDefault().getPath(oldFileName.toString()); Path newPath = FileSystems.getDefault().getPath(persistFile.toString()); @@ -521,69 +521,69 @@ public void load() throws FileNotFoundException { } } - XMLObjectReader reader = null; - try { - reader = XMLObjectReader.newInstance(new FileInputStream(persistFile.toString())); + XMLObjectReader reader = null; + try { + reader = XMLObjectReader.newInstance(new FileInputStream(persistFile.toString())); - reader.setBinding(binding); - this.esmes = reader.read(ESME_LIST, FastList.class); + reader.setBinding(binding); + this.esmes = reader.read(ESME_LIST, FastList.class); - // Populate cluster - for (FastList.Node n = this.esmes.head(), end = this.esmes.tail(); (n = n.getNext()) != end;) { - Esme esme = n.getValue(); + // Populate cluster + for (FastList.Node n = this.esmes.head(), end = this.esmes.tail(); (n = n.getNext()) != end;) { + Esme esme = n.getValue(); - esme.esmeManagement = this; + esme.esmeManagement = this; - String esmeClusterName = esme.getClusterName(); - EsmeCluster esmeCluster = this.esmeClusters.get(esmeClusterName); - if (esmeCluster == null) { - esmeCluster = new EsmeCluster(esmeClusterName, esme.getNetworkId()); - this.esmeClusters.put(esmeClusterName, esmeCluster); + String esmeClusterName = esme.getClusterName(); + EsmeCluster esmeCluster = this.esmeClusters.get(esmeClusterName); + if (esmeCluster == null) { + esmeCluster = new EsmeCluster(esmeClusterName, esme.getNetworkId()); + this.esmeClusters.put(esmeClusterName, esmeCluster); } else { esme.setNetworkId(esmeCluster.getNetworkId()); } esmeCluster.addEsme(esme); - } + } - reader.close(); - } catch (XMLStreamException ex) { - // this.logger.info( - // "Error while re-creating Linksets from persisted file", ex); - } - } + reader.close(); + } catch (XMLStreamException ex) { + // this.logger.info( + // "Error while re-creating Linksets from persisted file", ex); + } + } - private void registerEsmeMbean(Esme esme) { - try { - ObjectName esmeObjNname = new ObjectName(SmppManagement.JMX_DOMAIN + ":layer=Esme,name=" + esme.getName()); - StandardMBean esmeMxBean = new StandardMBean(esme, EsmeMBean.class, true); + private void registerEsmeMbean(Esme esme) { + try { + ObjectName esmeObjNname = new ObjectName(SmppManagement.JMX_DOMAIN + ":layer=Esme,name=" + esme.getName()); + StandardMBean esmeMxBean = new StandardMBean(esme, EsmeMBean.class, true); if (this.mbeanServer != null) this.mbeanServer.registerMBean(esmeMxBean, esmeObjNname); - } catch (InstanceAlreadyExistsException e) { - logger.error(String.format("Error while registering MBean for ESME %s", esme.getName()), e); - } catch (MBeanRegistrationException e) { - logger.error(String.format("Error while registering MBean for ESME %s", esme.getName()), e); - } catch (NotCompliantMBeanException e) { - logger.error(String.format("Error while registering MBean for ESME %s", esme.getName()), e); - } catch (MalformedObjectNameException e) { - logger.error(String.format("Error while registering MBean for ESME %s", esme.getName()), e); - } - } - - private void unregisterEsmeMbean(String esmeName) { - - try { - ObjectName esmeObjNname = new ObjectName(SmppManagement.JMX_DOMAIN + ":layer=Esme,name=" + esmeName); + } catch (InstanceAlreadyExistsException e) { + logger.error(String.format("Error while registering MBean for ESME %s", esme.getName()), e); + } catch (MBeanRegistrationException e) { + logger.error(String.format("Error while registering MBean for ESME %s", esme.getName()), e); + } catch (NotCompliantMBeanException e) { + logger.error(String.format("Error while registering MBean for ESME %s", esme.getName()), e); + } catch (MalformedObjectNameException e) { + logger.error(String.format("Error while registering MBean for ESME %s", esme.getName()), e); + } + } + + private void unregisterEsmeMbean(String esmeName) { + + try { + ObjectName esmeObjNname = new ObjectName(SmppManagement.JMX_DOMAIN + ":layer=Esme,name=" + esmeName); if (this.mbeanServer != null) this.mbeanServer.unregisterMBean(esmeObjNname); - } catch (MBeanRegistrationException e) { - logger.error(String.format("Error while unregistering MBean for ESME %s", esmeName), e); - } catch (InstanceNotFoundException e) { - logger.error(String.format("Error while unregistering MBean for ESME %s", esmeName), e); - } catch (MalformedObjectNameException e) { - logger.error(String.format("Error while unregistering MBean for ESME %s", esmeName), e); - } - } + } catch (MBeanRegistrationException e) { + logger.error(String.format("Error while unregistering MBean for ESME %s", esmeName), e); + } catch (InstanceNotFoundException e) { + logger.error(String.format("Error while unregistering MBean for ESME %s", esmeName), e); + } catch (MalformedObjectNameException e) { + logger.error(String.format("Error while unregistering MBean for ESME %s", esmeName), e); + } + } private class MessageCleanerTimerTask extends TimerTask { diff --git a/core/smpp-extensions/src/main/java/org/restcomm/smpp/oam/SmppOamMessages.java b/core/smpp-extensions/src/main/java/org/restcomm/smpp/oam/SmppOamMessages.java index 490abe3..9e82947 100644 --- a/core/smpp-extensions/src/main/java/org/restcomm/smpp/oam/SmppOamMessages.java +++ b/core/smpp-extensions/src/main/java/org/restcomm/smpp/oam/SmppOamMessages.java @@ -152,5 +152,7 @@ public interface SmppOamMessages { public static final String OVERLOAD_THRESHOLD = " overloadThreshold="; public static final String NORMAL_THRESHOLD = " normalThreshold="; + + public static final String OVERLOADED = " overloaded="; } diff --git a/core/smpp-extensions/src/main/java/org/restcomm/smpp/oam/SmppShellExecutor.java b/core/smpp-extensions/src/main/java/org/restcomm/smpp/oam/SmppShellExecutor.java index d0f667d..5b5dc38 100644 --- a/core/smpp-extensions/src/main/java/org/restcomm/smpp/oam/SmppShellExecutor.java +++ b/core/smpp-extensions/src/main/java/org/restcomm/smpp/oam/SmppShellExecutor.java @@ -67,31 +67,30 @@ public SmppManagement getSmppManagement() { } /** - * @param smppManagement - * the SmppManagement to set + * @param smppManagement the SmppManagement to set */ public void setSmppManagement(SmppManagement smppManagement) { this.smppManagement = smppManagement; } /** - * Command is smpp esme modify password networkid split-long-messages - * esme-ton esme-npi esme-range window-size - * connect-timeout request-expiry-timeout client-bind-timeout + * Command is smpp esme modify password networkid split-long-messages esme-ton + * esme-npi esme-range window-size connect-timeout + * request-expiry-timeout client-bind-timeout * window-monitor-interval window-wait-timeout counters-enabled * enquire-link-delay <30000> enquire-link-delay-server <0> link-drop-server <0> charging-enabled source-ton * source-npi source-range routing-ton routing-npi routing-range ratelimit-second * ratelimit-minute ratelimit-hour ratelimit-day * national-language-locking-shift national-language-single-shift - * dest-addr-send-limit - * min-message-length max-message-length + * dest-addr-send-limit min-message-length + * max-message-length * * @param args * @return */ private String modifyEsme(String[] args) throws Exception { - if (args.length < 6 || args.length > 58) { + if (args.length < 6 || args.length > 100) { return SmppOamMessages.INVALID_COMMAND; } @@ -203,9 +202,9 @@ private String modifyEsme(String[] args) throws Exception { } else if (key.equals("national-language-single-shift")) { int val = Integer.parseInt(args[count++]); esme.setNationalLanguageSingleShift(val); - } else if(key.equals("dest-addr-send-limit")) { - int val = Integer.parseInt(args[count++]); - esme.setDestAddrSendLimit(val); + } else if (key.equals("dest-addr-send-limit")) { + int val = Integer.parseInt(args[count++]); + esme.setDestAddrSendLimit(val); } else if (key.equals("min-message-length")) { int val = Integer.parseInt(args[count++]); esme.setMinMessageLength(val); @@ -245,7 +244,7 @@ private String modifyEsme(String[] args) throws Exception { * @return */ private String createEsme(String[] args) throws Exception { - if (args.length < 9 || args.length > 69) { + if (args.length < 9 || args.length > 100) { return SmppOamMessages.INVALID_COMMAND; } @@ -329,7 +328,7 @@ private String createEsme(String[] args) throws Exception { int destAddrSendLimit = 0; int minMessageLength = -1; int maxMessageLength = -1; - + int overloadThreshold = -1; int normalThreshold = -1; @@ -362,8 +361,8 @@ private String createEsme(String[] args) throws Exception { connectTimeout = Long.parseLong(args[count++]); } else if (key.equals("request-expiry-timeout")) { requestExpiryTimeout = Long.parseLong(args[count++]); - } else if (key.equals("client-bind-timeout")) { - clientBindTimeout = Long.parseLong(args[count++]); + } else if (key.equals("client-bind-timeout")) { + clientBindTimeout = Long.parseLong(args[count++]); } else if (key.equals("window-monitor-interval")) { windowMonitorInterval = Long.parseLong(args[count++]); } else if (key.equals("window-wait-timeout")) { @@ -407,7 +406,7 @@ private String createEsme(String[] args) throws Exception { } else if (key.equals("national-language-locking-shift")) { nationalLanguageLockingShift = Integer.parseInt(args[count++]); } else if (key.equals("dest-addr-send-limit")) { - destAddrSendLimit = Integer.parseInt(args[count++]); + destAddrSendLimit = Integer.parseInt(args[count++]); } else if (key.equals("min-message-length")) { minMessageLength = Integer.parseInt(args[count++]); } else if (key.equals("max-message-length")) { @@ -422,14 +421,14 @@ private String createEsme(String[] args) throws Exception { } - Esme esme = this.smppManagement.getEsmeManagement().createEsme(name, systemId, password, host, intPort, - chargingEnabled, smppBindTypeStr, systemType, smppVersionType, esmeTonType, esmeNpiType, esmeAddrRange, - smppSessionTypeStr, windowSize, connectTimeout, requestExpiryTimeout, clientBindTimeout, windowMonitorInterval, - windowWaitTimeout, clusterName, countersEnabled, enquireLinkDelay, enquireLinkDelayServer, linkDropServer, - sourceTon, sourceNpi, sourceAddressRange, routinigTon, routingNpi, routingAddressRange, networkId, - splitLongMessages, rateLimitPerSecond, rateLimitPerMinute, rateLimitPerHour, rateLimitPerDay, - nationalLanguageSingleShift, nationalLanguageLockingShift, destAddrSendLimit, minMessageLength, maxMessageLength, - overloadThreshold, normalThreshold); + Esme esme = this.smppManagement.getEsmeManagement().createEsme(name, systemId, password, host, intPort, chargingEnabled, + smppBindTypeStr, systemType, smppVersionType, esmeTonType, esmeNpiType, esmeAddrRange, smppSessionTypeStr, + windowSize, connectTimeout, requestExpiryTimeout, clientBindTimeout, windowMonitorInterval, windowWaitTimeout, + clusterName, countersEnabled, enquireLinkDelay, enquireLinkDelayServer, linkDropServer, sourceTon, sourceNpi, + sourceAddressRange, routinigTon, routingNpi, routingAddressRange, networkId, splitLongMessages, + rateLimitPerSecond, rateLimitPerMinute, rateLimitPerHour, rateLimitPerDay, nationalLanguageSingleShift, + nationalLanguageLockingShift, destAddrSendLimit, minMessageLength, maxMessageLength, overloadThreshold, + normalThreshold); return String.format(SmppOamMessages.CREATE_ESME_SUCCESSFULL, esme.getName()); } @@ -450,7 +449,7 @@ private String destroyEsme(String[] args) throws Exception { return SmppOamMessages.INVALID_COMMAND; } - Esme esme = this.smppManagement.getEsmeManagement().destroyEsme(esmeName); + this.smppManagement.getEsmeManagement().destroyEsme(esmeName); return String.format(SmppOamMessages.DELETE_ESME_SUCCESSFUL, esmeName); } @@ -523,9 +522,9 @@ private String manageSmppServerSet(String[] options) throws Exception { } else if (parName.equals("maxconnectionsize")) { int val = Integer.parseInt(options[4]); smppServerManagement.setMaxConnectionSize(val); - } else if(parName.equals("smppactivitytimeout")) { - int val = Integer.parseInt(options[4]); - smppServerManagement.setSmppActivityTimeout(val); + } else if (parName.equals("smppactivitytimeout")) { + int val = Integer.parseInt(options[4]); + smppServerManagement.setSmppActivityTimeout(val); } else if (parName.equals("defaultwindowsize")) { int val = Integer.parseInt(options[4]); smppServerManagement.setDefaultWindowSize(val); @@ -541,10 +540,10 @@ private String manageSmppServerSet(String[] options) throws Exception { } else if (parName.equals("defaultsessioncountersenabled")) { boolean val = Boolean.parseBoolean(options[4]); smppServerManagement.setDefaultSessionCountersEnabled(val); - } else if (parName.equals("bindipaddress")) { - String val = options[4]; - smppServerManagement.setBindIpAddress(val); - } else { + } else if (parName.equals("bindipaddress")) { + String val = options[4]; + smppServerManagement.setBindIpAddress(val); + } else { return SmppOamMessages.INVALID_COMMAND; } @@ -583,7 +582,7 @@ private String manageSmppServerGet(String[] options) throws Exception { } else if (parName.equals("maxconnectionsize")) { sb.append(smppServerManagement.getMaxConnectionSize()); } else if (parName.equals("smppactivitytimeout")) { - sb.append(smppServerManagement.getSmppActivityTimeout()); + sb.append(smppServerManagement.getSmppActivityTimeout()); } else if (parName.equals("defaultwindowsize")) { sb.append(smppServerManagement.getDefaultWindowSize()); } else if (parName.equals("defaultwindowwaittimeout")) { @@ -595,8 +594,8 @@ private String manageSmppServerGet(String[] options) throws Exception { } else if (parName.equals("defaultsessioncountersenabled")) { sb.append(smppServerManagement.isDefaultSessionCountersEnabled()); } else if (parName.equals("bindipaddress")) { - sb.append(smppServerManagement.getBindIpAddress()); - }else { + sb.append(smppServerManagement.getBindIpAddress()); + } else { return SmppOamMessages.INVALID_COMMAND; } @@ -607,9 +606,9 @@ private String manageSmppServerGet(String[] options) throws Exception { sb.append(smppServerManagement.getBindPort()); sb.append("\n"); - sb.append("bind-ip-address = "); - sb.append(smppServerManagement.getBindIpAddress()); - sb.append("\n"); + sb.append("bind-ip-address = "); + sb.append(smppServerManagement.getBindIpAddress()); + sb.append("\n"); sb.append("bind-timeout = "); sb.append(smppServerManagement.getBindTimeout()); @@ -638,7 +637,7 @@ private String manageSmppServerGet(String[] options) throws Exception { sb.append("smpp-activity-timeout = "); sb.append(smppServerManagement.getSmppActivityTimeout()); sb.append("\n"); - + sb.append("default-window-size = "); sb.append(smppServerManagement.getDefaultWindowSize()); sb.append("\n"); diff --git a/management/ui-management/src/main/webapp/modules/esmes.html b/management/ui-management/src/main/webapp/modules/esmes.html index 5102239..ba3ad85 100644 --- a/management/ui-management/src/main/webapp/modules/esmes.html +++ b/management/ui-management/src/main/webapp/modules/esmes.html @@ -27,6 +27,7 @@

SystemId Type State + Overloaded Actions @@ -417,14 +418,14 @@

Create ESME

- + Overload Threshold
- + Normal Threshold @@ -596,6 +597,7 @@

Create ESME

var systemId = response.value.SystemId; var localType = response.value.LocalTypeName; var state = response.value.StateName; + var overloadStatus = response.value.Overloaded; var systemType = response.value.SystemType; var bindType = response.value.BindTypeName; @@ -690,6 +692,7 @@

Create ESME

'' + systemId + '' + '' + localType + '' + '' + state + '' + + '' + overloadStatus + '' + '' + ' ' + ' ' +