Skip to content

Commit

Permalink
Fix for issue RestComm#9 - failover & load balancing
Browse files Browse the repository at this point in the history
  • Loading branch information
Grzegorz Figiel committed Jan 16, 2017
1 parent 5d6dacf commit 82f6766
Show file tree
Hide file tree
Showing 18 changed files with 537 additions and 38 deletions.
43 changes: 30 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
# Java compiled #
#################
######## Java compiled #########
################################
*.class

# Eclipse #
###########
########### Eclipse ############
################################
.classpath
.project
.settings

# IntelliJ IDEA #
#################
.idea/
######## IntelliJ IDEA #########
################################
.idea
*.iml
*.iws

# Maven #
#########
########## NetBeans ############
################################
nbactions.xml

# Mobile Tools for Java (J2ME) #
################################
.mtj.tmp

############ Maven #############
################################
target
*.jar
*.war
*.ear

# OS generated files #
######################
###### OS generated files ######
################################
.directory
.Trashes
._*
*~
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

######## VM crash logs #########
################################
hs_err_pid*
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package net.java.slee.resource.diameter.base.events;

import net.java.slee.resource.diameter.base.events.avp.DiameterIdentity;

import org.jdiameter.api.Message;
import org.jdiameter.api.RouteException;

/**
* Event that represents delivery failure of a given message.
*/
public interface DeliveryFailure {

/**
* Returns an exception that made delivery of a given message impossible.
*
* @return exception
*/
RouteException getCause();

/**
* Returns the request that caused Tx timeout to expire due to no response from a remote peer.
*
* @return origin request
*/
Message getRequest();

/**
* Returns the name of the last selected remote peer that a given message has been routed to.
*
* @return peer name
*/
DiameterIdentity getLastPeer();

/**
* Returns true if last selected remote peer is present for a given message.
*
* @return true if peer name is present
*/
boolean hasLastPeer();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.mobicents.slee.resource.diameter.base.events;

import net.java.slee.resource.diameter.base.events.DeliveryFailure;
import net.java.slee.resource.diameter.base.events.avp.DiameterIdentity;

import org.jdiameter.api.Message;
import org.jdiameter.api.RouteException;

/**
* Delivery failure implementation.
*/
public class DeliveryFailureImpl implements DeliveryFailure {

protected RouteException cause = null;
protected Message request = null;
protected DiameterIdentity peer = null;

/**
* Constructor.
* @param request
* @param peer
*/
public DeliveryFailureImpl(RouteException cause, Message request, DiameterIdentity peer) {
this.cause = cause;
this.request = request;
this.peer = peer;
}

/*
* (non-Javadoc)
* @see net.java.slee.resource.diameter.base.events.DeliveryFailure#getCause()
*/
public RouteException getCause() {
return cause;
}

/*
* (non-Javadoc)
* @see net.java.slee.resource.diameter.base.events.DeliveryFailure#getRequest()
*/
public Message getRequest() {
return request;
}

/*
* (non-Javadoc)
* @see nnet.java.slee.resource.diameter.base.events.DeliveryFailure#getLastPeer()
*/
public DiameterIdentity getLastPeer() {
return peer;
}

/*
* (non-Javadoc)
* @see net.java.slee.resource.diameter.base.events.DeliveryFailure#hasLastPeer()
*/
public boolean hasLastPeer() {
return peer != null;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("\r\n");
sb.append("+--------------------------- Delivery failure ---------------------------------+\r\n");
sb.append("| Last selected peer: ").append(peer).append("\r\n");
sb.append("| Failure for message: ").append(request).append("\r\n");
sb.append("| Application-Id..........").append(request.getApplicationId()).append("\r\n");
sb.append("| Hop-By-Hop Identifier...").append(request.getHopByHopIdentifier()).append("\r\n");
sb.append("| End-To-End Identifier...").append(request.getEndToEndIdentifier()).append("\r\n");
sb.append("| Session-Id..............").append(request.getSessionId()).append("\r\n");
sb.append("| Root cause: ").append(cause).append("\r\n");
sb.append("+-----------------------------------------------------------------------------+\r\n");
return sb.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@
<entry>0.8</entry>
<entry>net.java.slee.resource. diameter.base.events. ErrorAnswer</entry>
</row>
<row>
<entry>net.java.slee.resource. diameter.base.events. DeliveryFailure</entry>
<entry>java.net</entry>
<entry>0.8</entry>
<entry>net.java.slee.resource. diameter.base.events. DeliveryFailure</entry>
</row>
</tbody>
</tgroup>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@
<event-class-name>net.java.slee.resource.diameter.base.events.SessionTerminationAnswer</event-class-name>
</event-definition>

<event-definition>
<event-type-name>net.java.slee.resource.diameter.base.events.DeliveryFailure</event-type-name>
<event-type-vendor>java.net</event-type-vendor>
<event-type-version>0.8</event-type-version>
<event-class-name>net.java.slee.resource.diameter.base.events.DeliveryFailure</event-class-name>
</event-definition>

<event-definition>
<event-type-name>net.java.slee.resource.diameter.base.events.ErrorAnswer</event-type-name>
<event-type-vendor>java.net</event-type-vendor>
Expand Down
4 changes: 2 additions & 2 deletions resources/diameter-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

<properties>
<!-- Mobicents Diameter Components Versions -->
<restcomm.diameter.jdiameter.version>1.7.0.77</restcomm.diameter.jdiameter.version>
<restcomm.diameter.mux.version>1.7.0.77</restcomm.diameter.mux.version>
<restcomm.diameter.jdiameter.version>1.7.0-SNAPSHOT</restcomm.diameter.jdiameter.version>
<restcomm.diameter.mux.version>1.7.0-SNAPSHOT</restcomm.diameter.mux.version>
<restcomm.slee.version>2.8.26</restcomm.slee.version>
<!-- Documentation Related Properties -->
<docs.profile>restcomm</docs.profile>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package net.java.slee.resource.diameter.cca.events;

import net.java.slee.resource.diameter.base.events.avp.DiameterIdentity;

import org.jdiameter.api.Message;

/**
* Tx timer as specified in RFC 4006:
*
* <pre>
* 13. Credit-Control Application Related Parameters
*
* Tx timer
*
* When real-time credit-control is required, the credit-control
* client contacts the credit-control server before and while the
* service is provided to an end user. Due to the real-time nature
* of the application, the communication delays SHOULD be minimized;
* e.g., to avoid an overly long service setup time experienced by
* the end user. The Tx timer is introduced to control the waiting
* time in the client in the Pending state. When the Tx timer
* elapses, the credit-control client takes an action to the end user
* according to the value of the Credit-Control-Failure-Handling AVP
* or Direct-Debiting-Failure-Handling AVP. The recommended value is
* 10 seconds.
* </pre>
*/
public interface RequestTxTimeout {

/**
* Returns the request that caused Tx timeout to expire due to no response from a remote peer.
*
* @return origin request
*/
Message getRequest();

/**
* Returns the name of the last selected remote peer that a given message has been routed to.
*
* @return peer name
*/
DiameterIdentity getLastPeer();

/**
* Returns true if last selected remote peer is present for a given message.
*
* @return true if peer name is present
*/
boolean hasLastPeer();

}
Loading

0 comments on commit 82f6766

Please sign in to comment.