Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated loadbalancing failover implementation to ease merging issue#36 #97

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b0ebcd2
updated failover logic to ease merging
bkrok Jun 22, 2017
7a2e62b
changed RequestType package
bkrok Jul 3, 2017
162287f
implemented additional method in testsuite
bkrok Jul 5, 2017
f31450b
1. Added new classes, back to previous versions IMessage and MessageImpl
bkrok Jul 4, 2017
1cedf9c
Cherry picked commits
bkrok Jul 5, 2017
5c8481c
1. replaced SESSION_INACTIVITY_TIMER_NAME with IDLE_SESSION_TIME_NAME
bkrok Jul 5, 2017
5f41df6
replaced RetransmissionTimeout with MessageTimeout
bkrok Jul 5, 2017
809679f
jdiameter-config_ext_routing_failover fixed
bkrok Jul 5, 2017
4700b9e
reformat code
bkrok Jul 5, 2017
0360248
fix
bkrok Jul 6, 2017
7583b7a
1. revert some changes from commit f31450bd41977c9ac874501354c816c26b…
bkrok Jul 6, 2017
5c2e50f
parameters order kept
bkrok Jul 6, 2017
7e099ff
1. testsuite ClassCastException fixed
bkrok Jul 11, 2017
e8bca24
deleted CCAMessage
bkrok Jul 26, 2017
4fd806e
removed getCcSessionFailover method
bkrok Jul 26, 2017
f96d30f
fix backward compability issue with ClientCCASessionImpl contructor
bkrok Jul 27, 2017
e94f273
fix to session inactivity timer
bkrok Jul 27, 2017
84d264c
Revert "fix to session inactivity timer"
bkrok Jul 27, 2017
1e7f457
Inactive session timer refactoring into idle session timeout
Jul 28, 2017
7f836ab
fixed cast exception
bkrok Aug 8, 2017
5a9c021
Get AVP index methods implemented
bkrok Aug 8, 2017
c5003b3
old timer commented
bkrok Aug 10, 2017
0dd40cd
moved constants from IMessage to IRoMessageFactory
bkrok Aug 18, 2017
4204f5b
old timer deleted
bkrok Aug 18, 2017
36a739d
removed session inactivity timeout, config for jdiameter updated
bkrok Aug 29, 2017
7eac72c
removed retransmission timeout
bkrok Aug 29, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Expand Up @@ -62,9 +62,9 @@
import org.slf4j.LoggerFactory;

/**
*
* @author <a href="mailto:[email protected]"> Bartosz Baranowski </a>
* @author <a href="mailto:[email protected]"> Alexandre Mendonca </a>
* @author <a href="mailto:[email protected]"> Grzegorz Figiel (ProIDS sp. z o.o.)</a>
*/
public class ClientRoSessionDataReplicatedImpl extends AppSessionDataReplicatedImpl implements IClientRoSessionData {

Expand All @@ -74,18 +74,20 @@ public class ClientRoSessionDataReplicatedImpl extends AppSessionDataReplicatedI
private static final String REQUEST_TYPE = "REQUEST_TYPE";
private static final String STATE = "STATE";
private static final String TXTIMER_ID = "TXTIMER_ID";
private static final String RETRANSMISSION_TIMER_ID = "RETRANSMISSION_TIMER_ID";
private static final String TXTIMER_REQUEST = "TXTIMER_REQUEST";
private static final String BUFFER = "BUFFER";
private static final String GRA = "GRA";
private static final String GDDFH = "GDDFH";
private static final String GCCFH = "GCCFH";
private static final String GCCSF = "GCCSF";

private IMessageParser messageParser;

/**
* @param nodeFqn
* @param mobicentsCluster
* @param iface
* @param container
*/
public ClientRoSessionDataReplicatedImpl(Fqn<?> nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) {
super(nodeFqn, mobicentsCluster);
Expand All @@ -101,7 +103,7 @@ public ClientRoSessionDataReplicatedImpl(Fqn<?> nodeFqn, MobicentsCluster mobice
/**
* @param sessionId
* @param mobicentsCluster
* @param iface
* @param container
*/
public ClientRoSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) {
this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container);
Expand Down Expand Up @@ -187,6 +189,26 @@ public void setTxTimerId(Serializable txTimerId) {
}
}

@Override
public Serializable getRetransmissionTimerId() {
if (exists()) {
return (Serializable) getNode().get(RETRANSMISSION_TIMER_ID);
}
else {
throw new IllegalStateException();
}
}

@Override
public void setRetransmissionTimerId(Serializable txTimerId) {
if (exists()) {
getNode().put(RETRANSMISSION_TIMER_ID, txTimerId);
}
else {
throw new IllegalStateException();
}
}

@Override
public Request getTxTimerRequest() {
if (exists()) {
Expand Down Expand Up @@ -323,4 +345,24 @@ public void setGatheredDDFH(int gatheredDDFH) {
}
}

@Override
public int getGatheredCCSF() {
if (exists()) {
return toPrimitive((Integer) getNode().get(GCCSF));
}
else {
throw new IllegalStateException();
}
}

@Override
public void setGatheredCCSF(int gatheredCCSF) {
if (exists()) {
getNode().put(GCCSF, gatheredCCSF);
}
else {
throw new IllegalStateException();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

import org.jdiameter.api.BaseSession;
import org.jdiameter.client.api.IContainer;
import org.jdiameter.client.impl.BaseSessionImpl;
import org.jdiameter.common.api.data.ISessionDatasource;
import org.jdiameter.common.api.timer.ITimerFacility;
import org.jdiameter.common.impl.app.AppSessionImpl;
Expand Down Expand Up @@ -129,13 +130,25 @@ public void runTask() {
try {
DiameterTimerTaskData data = (DiameterTimerTaskData) getData();
BaseSession bSession = sessionDataSource.getSession(data.getSessionId());
if (bSession == null || !bSession.isAppSession()) {
if (bSession == null) {
// FIXME: error ?
logger.error("Base Session is null for sessionId: {}", data.getSessionId());
return;
}
else {
AppSessionImpl impl = (AppSessionImpl) bSession;
impl.onTimer(data.getTimerName());
try {
if (!bSession.isAppSession()) {
BaseSessionImpl impl = (BaseSessionImpl) bSession;
impl.onTimer(data.getTimerName());
}
else {
AppSessionImpl impl = (AppSessionImpl) bSession;
impl.onTimer(data.getTimerName());
}
}
catch (Exception e) {
logger.error("Caught exception from session object!", e);
}
}
}
catch (Exception e) {
Expand Down
15 changes: 15 additions & 0 deletions core/jdiameter/api/src/main/java/org/jdiameter/api/AvpSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ public interface AvpSet extends Iterable<Avp>, Serializable, Wrapper {
*/
AvpSet getAvps(int avpCode, long vendorId);

/**
* Get position of the first instance of the AVP
* @param avpCode code of the Avp
* @return index (position) of the first occurrence of the Avp. -1 in case Avp is not found
*/
int getAvpIndex(int avpCode);

/**
* Get position of the first instance of the AVP
* @param avpCode code of the Avp
* @param vendorId vendorId of the Avp
* @return index (position) of the first occurrence of the Avp. -1 in case Avp is not found
*/
int getAvpIndex(int avpCode, long vendorId);

/**
* Remove AVPs with avpCode
* @param avpCode code of Avp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,6 @@ public interface BaseSession {
* @return session-id as String (Session-Id AVP)
*/
String getSessionId();

String IDLE_SESSION_TIMER_NAME = "IDLE_SESSION_TIMER";
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ public interface Configuration {
*/
byte[] getByteArrayValue(int key, byte[] defaultValue);

/**
* Returns the int[] point value of the given key.
*
* @param key the key
* @param defaultValue the Default Value
* @return the value, or <code>defaultValue</code> if the key was not found or was found
* but was not a int[] point number
*/
int[] getIntArrayValue(int key, int[] defaultValue);

/**
* Returns the boolean point value of the given key.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ public interface MutableConfiguration extends Configuration {
*/
void setByteArrayValue(int key, byte[] value);

/**
* Set int array value to configuration
* @param key key of value
* @param value int array value
*/
void setIntArrayValue(int key, int[] value);

/**
* Set boolean value to configuration
* @param key key of value
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* TeleStax, Open Source Cloud Communications
* Copyright 2011-2016, TeleStax Inc. and individual contributors
* by the @authors tag.
*
* This program is free software: you can redistribute it and/or modify
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/

package org.jdiameter.api;

/**
* Signals that no peer is available for routing.
*
* @author <a href="mailto:[email protected]"> ProIDS sp. z o.o.</a>
*/
public class NoMorePeersAvailableException extends RouteException {

private static final long serialVersionUID = 1L;

private boolean sessionPersistentRoutingEnabled = false;
private int lastSelectedPeerRating = -1;
private String roundRobinContextDescription = null;

/**
* Constructor with reason string and routing details
*
* @param message reason string
*/
public NoMorePeersAvailableException(String message, boolean spre, String rrcd, int lspr) {
super(message);
this.setSessionPersistentRoutingEnabled(spre);
this.setRoundRobinContextDescription(rrcd);
this.setLastSelectedPeerRating(lspr);
}

/**
* Constructor with reason string and parent exception
*
* @param message message reason string
* @param cause parent exception
*/
public NoMorePeersAvailableException(String message, Throwable cause) {
super(message, cause);
}

/**
* Constructor with reason string
*
* @param message reason string
*/
public NoMorePeersAvailableException(String message) {
super(message);
}

public boolean isSessionPersistentRoutingEnabled() {
return sessionPersistentRoutingEnabled;
}

public void setSessionPersistentRoutingEnabled(boolean sessionPersistentRoutingEnabled) {
this.sessionPersistentRoutingEnabled = sessionPersistentRoutingEnabled;
}

public String getRoundRobinContextDescription() {
return roundRobinContextDescription;
}

public void setRoundRobinContextDescription(String roundRobinContextDescription) {
this.roundRobinContextDescription = roundRobinContextDescription;
}

public int getLastSelectedPeerRating() {
return lastSelectedPeerRating;
}

public void setLastSelectedPeerRating(int lastSelectedPeerRating) {
this.lastSelectedPeerRating = lastSelectedPeerRating;
}

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder
.append("NoMorePeersAvailableException [sessionPersistentRoutingEnabled=")
.append(sessionPersistentRoutingEnabled)
.append(", lastSelectedPeerRating=").append(lastSelectedPeerRating)
.append(", roundRobinContextDescription=")
.append(roundRobinContextDescription)
.append(", message=").append(getMessage())
.append("]");
return builder.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* TeleStax, Open Source Cloud Communications
* Copyright 2011-2016, TeleStax Inc. and individual contributors
* by the @authors tag.
*
* This program is free software: you can redistribute it and/or modify
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/

package org.jdiameter.api;

import java.util.List;

/**
* Enables to review and supervise the current state of session persistence map that is used
* for routing that preserves sticky sessions paradigm. Read only access is given for
* the sake of safety issues.
*/
public interface SessionPersistenceStorage {

/**
* Returns a list of all session persistence records that are currently in operation.
*
* @param maxLimit maximum number of records to be listed (0 corresponds to no limit)
* @return list of active records
*/
List<String> dumpStickySessions(int maxLimit);
}
Loading