From 2291dd68822bf0e731eb2da2db53de17b5296623 Mon Sep 17 00:00:00 2001 From: Fernando Mendioroz Date: Sat, 24 Sep 2016 20:05:47 -0300 Subject: [PATCH] Fixed all compilations errors from previous commits. Added jdiameter-ha classes for both interfaces. Issues #37 and #38. PR #48 --- .../ClientSLgSessionDataReplicatedImpl.java | 64 ++++++++ .../ClientSLhSessionDataReplicatedImpl.java | 63 ++++++++ .../slg/SLgReplicatedSessionDataFactory.java | 71 ++++++++ .../slg/SLgSessionDataReplicatedImpl.java | 152 ++++++++++++++++++ .../slh/SLhReplicatedSessionDataFactory.java | 71 ++++++++ .../slh/SLhSessionDataReplicatedImpl.java | 152 ++++++++++++++++++ .../ha/data/ReplicatedSessionDatasource.java | 8 +- .../ServerSLgSessionDataReplicatedImpl.java | 63 ++++++++ .../ServerSLhSessionDataReplicatedImpl.java | 63 ++++++++ .../api/slg/events/LocationReportAnswer.java | 6 +- .../api/slg/events/ProvideLocationAnswer.java | 6 +- .../common/api/app/slg/ISLgSessionData.java | 4 +- .../app/slg/LocationReportAnswerImpl.java | 4 + .../app/slg/ProvideLocationAnswerImpl.java | 4 + .../impl/app/slg/SLgSessionFactoryImpl.java | 2 +- .../app/slh/LCSRoutingInfoAnswerImpl.java | 6 + 16 files changed, 732 insertions(+), 7 deletions(-) create mode 100644 core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slg/ClientSLgSessionDataReplicatedImpl.java create mode 100644 core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slh/ClientSLhSessionDataReplicatedImpl.java create mode 100644 core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgReplicatedSessionDataFactory.java create mode 100644 core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgSessionDataReplicatedImpl.java create mode 100644 core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhReplicatedSessionDataFactory.java create mode 100644 core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhSessionDataReplicatedImpl.java create mode 100644 core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slg/ServerSLgSessionDataReplicatedImpl.java create mode 100644 core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slh/ServerSLhSessionDataReplicatedImpl.java diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slg/ClientSLgSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slg/ClientSLgSessionDataReplicatedImpl.java new file mode 100644 index 000000000..7a9c159ee --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slg/ClientSLgSessionDataReplicatedImpl.java @@ -0,0 +1,64 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * 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.diameter.impl.ha.client.slg; + +import org.jboss.cache.Fqn; +import org.jdiameter.api.slg.ClientSLgSession; +import org.jdiameter.client.api.IContainer; +import org.jdiameter.client.impl.app.slg.IClientSLgSessionData; +import org.jdiameter.common.api.app.slg.SLgSessionState; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.common.slg.SLgSessionDataReplicatedImpl; +import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; + +/** + * + * @author Fernando Mendioroz (fernando.mendioroz@telestax.com) + * + */ +public class ClientSLgSessionDataReplicatedImpl extends SLgSessionDataReplicatedImpl implements IClientSLgSessionData { + + /** + * @param nodeFqn + * @param mobicentsCluster + * @param iface + */ + public ClientSLgSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); + + if (super.create()) { + setAppSessionIface(this, ClientSLgSession.class); + setSLgSessionState(SLgSessionState.IDLE); + } + } + + /** + * @param sessionId + * @param mobicentsCluster + * @param iface + */ + public ClientSLgSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); + } + +} + diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slh/ClientSLhSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slh/ClientSLhSessionDataReplicatedImpl.java new file mode 100644 index 000000000..08e905069 --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/client/slh/ClientSLhSessionDataReplicatedImpl.java @@ -0,0 +1,63 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * 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.diameter.impl.ha.client.slh; + +import org.jboss.cache.Fqn; +import org.jdiameter.api.slh.ClientSLhSession; +import org.jdiameter.client.api.IContainer; +import org.jdiameter.client.impl.app.slh.IClientSLhSessionData; +import org.jdiameter.common.api.app.slh.SLhSessionState; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.common.slh.SLhSessionDataReplicatedImpl; +import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; + +/** + * + * @author Fernando Mendioroz (fernando.mendioroz@telestax.com) + * + */ +public class ClientSLhSessionDataReplicatedImpl extends SLhSessionDataReplicatedImpl implements IClientSLhSessionData { + + /** + * @param nodeFqn + * @param mobicentsCluster + * @param iface + */ + public ClientSLhSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); + + if (super.create()) { + setAppSessionIface(this, ClientSLhSession.class); + setSLhSessionState(SLhSessionState.IDLE); + } + } + + /** + * @param sessionId + * @param mobicentsCluster + * @param iface + */ + public ClientSLhSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); + } + +} diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgReplicatedSessionDataFactory.java new file mode 100644 index 000000000..325eb5752 --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgReplicatedSessionDataFactory.java @@ -0,0 +1,71 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * 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.diameter.impl.ha.common.slg; + +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slg.ClientSLgSession; +import org.jdiameter.api.slg.ServerSLgSession; +import org.jdiameter.common.api.app.IAppSessionDataFactory; +import org.jdiameter.common.api.app.slg.ISLgSessionData; +import org.jdiameter.common.api.data.ISessionDatasource; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.client.slg.ClientSLgSessionDataReplicatedImpl; +import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; +import org.mobicents.diameter.impl.ha.server.slg.ServerSLgSessionDataReplicatedImpl; + +/** + * + * @author Fernando Mendioroz (fernando.mendioroz@telestax.com) + * + */ +public class SLgReplicatedSessionDataFactory implements IAppSessionDataFactory { + + private ReplicatedSessionDatasource replicatedSessionDataSource; + private MobicentsCluster mobicentsCluster; + + /** + * @param replicatedSessionDataSource + */ + public SLgReplicatedSessionDataFactory(ISessionDatasource replicatedSessionDataSource) { // Is this ok? + super(); + this.replicatedSessionDataSource = (ReplicatedSessionDatasource) replicatedSessionDataSource; + this.mobicentsCluster = this.replicatedSessionDataSource.getMobicentsCluster(); + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.IAppSessionDataFactory#getAppSessionData(java.lang.Class, java.lang.String) + */ + public ISLgSessionData getAppSessionData(Class clazz, String sessionId) { + if (clazz.equals(ClientSLgSession.class)) { + ClientSLgSessionDataReplicatedImpl data = new ClientSLgSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, this.replicatedSessionDataSource.getContainer()); + return data; + } + else if (clazz.equals(ServerSLgSession.class)) { + ServerSLgSessionDataReplicatedImpl data = new ServerSLgSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, this.replicatedSessionDataSource.getContainer()); + return data; + } + throw new IllegalArgumentException(); + } + +} diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgSessionDataReplicatedImpl.java new file mode 100644 index 000000000..cb4af62d8 --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgSessionDataReplicatedImpl.java @@ -0,0 +1,152 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * 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.diameter.impl.ha.common.slg; + +import java.io.Serializable; +import java.nio.ByteBuffer; + +import org.jboss.cache.Fqn; +import org.jdiameter.api.AvpDataException; +import org.jdiameter.api.Request; +import org.jdiameter.client.api.IContainer; +import org.jdiameter.client.api.IMessage; +import org.jdiameter.client.api.parser.IMessageParser; +import org.jdiameter.client.api.parser.ParseException; +import org.jdiameter.common.api.app.slg.SLgSessionState; +import org.jdiameter.common.api.app.slg.ISLgSessionData; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Fernando Mendioroz (fernando.mendioroz@telestax.com) + * + */ +public abstract class SLgSessionDataReplicatedImpl extends AppSessionDataReplicatedImpl implements ISLgSessionData { + + private static final Logger logger = LoggerFactory.getLogger(SLgSessionDataReplicatedImpl.class); + + private static final String STATE = "STATE"; + private static final String BUFFER = "BUFFER"; + private static final String TS_TIMERID = "TS_TIMERID"; + + private IMessageParser messageParser; + + /** + * @param nodeFqn + * @param mobicentsCluster + * @param iface + */ + public SLgSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster); + this.messageParser = container.getAssemblerFacility().getComponentInstance(IMessageParser.class); + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slg.ISLgSessionData#setSLgSessionState(org.jdiameter.common.api.app.slg.SLgSessionState) + */ + public void setSLgSessionState(SLgSessionState state) { + if (exists()) { + getNode().put(STATE, state); + } + else { + throw new IllegalStateException(); + } + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slg.ISLgSessionData#getSLgSessionState() + */ + public SLgSessionState getSLgSessionState() { + if (exists()) { + return (SLgSessionState) getNode().get(STATE); + } + else { + throw new IllegalStateException(); + } + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slg.ISLgSessionData#getTsTimerId() + */ + public Serializable getTsTimerId() { + if (exists()) { + return (Serializable) getNode().get(TS_TIMERID); + } + else { + throw new IllegalStateException(); + } + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slg.ISLgSessionData#setTsTimerId(java.io.Serializable) + */ + public void setTsTimerId(Serializable tid) { + if (exists()) { + getNode().put(TS_TIMERID, tid); + } + else { + throw new IllegalStateException(); + } + } + + public Request getBuffer() { + byte[] data = (byte[]) getNode().get(BUFFER); + if (data != null) { + try { + return (Request) this.messageParser.createMessage(ByteBuffer.wrap(data)); + } + catch (AvpDataException e) { + logger.error("Unable to recreate message from buffer."); + return null; + } + } + else { + return null; + } + } + + public void setBuffer(Request buffer) { + if (buffer != null) { + try { + byte[] data = this.messageParser.encodeMessage((IMessage) buffer).array(); + getNode().put(BUFFER, data); + } + catch (ParseException e) { + logger.error("Unable to encode message to buffer."); + } + } + else { + getNode().remove(BUFFER); + } + } +} diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhReplicatedSessionDataFactory.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhReplicatedSessionDataFactory.java new file mode 100644 index 000000000..58c5bdd62 --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhReplicatedSessionDataFactory.java @@ -0,0 +1,71 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * 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.diameter.impl.ha.common.slh; + +import org.jdiameter.api.app.AppSession; +import org.jdiameter.api.slh.ClientSLhSession; +import org.jdiameter.api.slh.ServerSLhSession; +import org.jdiameter.common.api.app.IAppSessionDataFactory; +import org.jdiameter.common.api.app.slh.ISLhSessionData; +import org.jdiameter.common.api.data.ISessionDatasource; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.client.slh.ClientSLhSessionDataReplicatedImpl; +import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; +import org.mobicents.diameter.impl.ha.server.slh.ServerSLhSessionDataReplicatedImpl; + +/** + * + * @author Fernando Mendioroz (fernando.mendioroz@telestax.com) + * + */ +public class SLhReplicatedSessionDataFactory implements IAppSessionDataFactory { + + private ReplicatedSessionDatasource replicatedSessionDataSource; + private MobicentsCluster mobicentsCluster; + + /** + * @param replicatedSessionDataSource + */ + public SLhReplicatedSessionDataFactory(ISessionDatasource replicatedSessionDataSource) { // Is this ok? + super(); + this.replicatedSessionDataSource = (ReplicatedSessionDatasource) replicatedSessionDataSource; + this.mobicentsCluster = this.replicatedSessionDataSource.getMobicentsCluster(); + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.IAppSessionDataFactory#getAppSessionData(java.lang.Class, java.lang.String) + */ + public ISLhSessionData getAppSessionData(Class clazz, String sessionId) { + if (clazz.equals(ClientSLhSession.class)) { + ClientSLhSessionDataReplicatedImpl data = new ClientSLhSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, this.replicatedSessionDataSource.getContainer()); + return data; + } + else if (clazz.equals(ServerSLhSession.class)) { + ServerSLhSessionDataReplicatedImpl data = new ServerSLhSessionDataReplicatedImpl(sessionId, this.mobicentsCluster, this.replicatedSessionDataSource.getContainer()); + return data; + } + throw new IllegalArgumentException(); + } + +} diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhSessionDataReplicatedImpl.java new file mode 100644 index 000000000..57bee93f8 --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/common/slh/SLhSessionDataReplicatedImpl.java @@ -0,0 +1,152 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * 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.diameter.impl.ha.common.slh; + +import java.io.Serializable; +import java.nio.ByteBuffer; + +import org.jboss.cache.Fqn; +import org.jdiameter.api.AvpDataException; +import org.jdiameter.api.Request; +import org.jdiameter.client.api.IContainer; +import org.jdiameter.client.api.IMessage; +import org.jdiameter.client.api.parser.IMessageParser; +import org.jdiameter.client.api.parser.ParseException; +import org.jdiameter.common.api.app.slh.SLhSessionState; +import org.jdiameter.common.api.app.slh.ISLhSessionData; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Fernando Mendioroz (fernando.mendioroz@telestax.com) + * + */ +public abstract class SLhSessionDataReplicatedImpl extends AppSessionDataReplicatedImpl implements ISLhSessionData { + + private static final Logger logger = LoggerFactory.getLogger(SLhSessionDataReplicatedImpl.class); + + private static final String STATE = "STATE"; + private static final String BUFFER = "BUFFER"; + private static final String TS_TIMERID = "TS_TIMERID"; + + private IMessageParser messageParser; + + /** + * @param nodeFqn + * @param mobicentsCluster + * @param iface + */ + public SLhSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster); + this.messageParser = container.getAssemblerFacility().getComponentInstance(IMessageParser.class); + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slh.ISLhSessionData#setSLhSessionState(org.jdiameter.common.api.app.slh.SLhSessionState) + */ + public void setSLhSessionState(SLhSessionState state) { + if (exists()) { + getNode().put(STATE, state); + } + else { + throw new IllegalStateException(); + } + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slh.ISLhSessionData#getSLhSessionState() + */ + public SLhSessionState getSLhSessionState() { + if (exists()) { + return (SLhSessionState) getNode().get(STATE); + } + else { + throw new IllegalStateException(); + } + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slh.ISLhSessionData#getTsTimerId() + */ + public Serializable getTsTimerId() { + if (exists()) { + return (Serializable) getNode().get(TS_TIMERID); + } + else { + throw new IllegalStateException(); + } + } + + /* + * (non-Javadoc) + * + * @see org.jdiameter.common.api.app.slh.ISLhSessionData#setTsTimerId(java.io.Serializable) + */ + public void setTsTimerId(Serializable tid) { + if (exists()) { + getNode().put(TS_TIMERID, tid); + } + else { + throw new IllegalStateException(); + } + } + + public Request getBuffer() { + byte[] data = (byte[]) getNode().get(BUFFER); + if (data != null) { + try { + return (Request) this.messageParser.createMessage(ByteBuffer.wrap(data)); + } + catch (AvpDataException e) { + logger.error("Unable to recreate message from buffer."); + return null; + } + } + else { + return null; + } + } + + public void setBuffer(Request buffer) { + if (buffer != null) { + try { + byte[] data = this.messageParser.encodeMessage((IMessage) buffer).array(); + getNode().put(BUFFER, data); + } + catch (ParseException e) { + logger.error("Unable to encode message to buffer."); + } + } + else { + getNode().remove(BUFFER); + } + } +} diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/data/ReplicatedSessionDatasource.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/data/ReplicatedSessionDatasource.java index cf0cee5c1..c645f29e8 100644 --- a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/data/ReplicatedSessionDatasource.java +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/data/ReplicatedSessionDatasource.java @@ -46,6 +46,8 @@ import org.jdiameter.common.api.app.ro.IRoSessionData; import org.jdiameter.common.api.app.s13.IS13SessionData; import org.jdiameter.common.api.app.sh.IShSessionData; +import org.jdiameter.common.api.app.slh.ISLhSessionData; +import org.jdiameter.common.api.app.slg.ISLgSessionData; import org.jdiameter.common.api.data.ISessionDatasource; import org.jdiameter.common.impl.data.LocalDataSource; import org.mobicents.cache.MobicentsCache; @@ -64,6 +66,8 @@ import org.mobicents.diameter.impl.ha.common.ro.RoReplicatedSessionDataFactory; import org.mobicents.diameter.impl.ha.common.s13.S13ReplicatedSessionDataFactory; import org.mobicents.diameter.impl.ha.common.sh.ShReplicatedSessionDataFactory; +import org.mobicents.diameter.impl.ha.common.slh.SLhReplicatedSessionDataFactory; +import org.mobicents.diameter.impl.ha.common.slg.SLgReplicatedSessionDataFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -116,7 +120,7 @@ public ReplicatedSessionDatasource(IContainer container, ISessionDatasource loca this.mobicentsCluster.startCluster(); this.container = container; - // this is coded, its tied to specific impl of SessionDatasource + // this is coded, it's tied to specific impl of SessionDatasource appSessionDataFactories.put(IAuthSessionData.class, new AuthReplicatedSessionDataFactory(this)); appSessionDataFactories.put(IAccSessionData.class, new AccReplicatedSessionDataFactory(this)); appSessionDataFactories.put(ICCASessionData.class, new CCAReplicatedSessionDataFactory(this)); @@ -127,6 +131,8 @@ public ReplicatedSessionDatasource(IContainer container, ISessionDatasource loca appSessionDataFactories.put(IGxSessionData.class, new GxReplicatedSessionDataFactory(this)); appSessionDataFactories.put(IRxSessionData.class, new RxReplicatedSessionDataFactory(this)); appSessionDataFactories.put(IS13SessionData.class, new S13ReplicatedSessionDataFactory(this)); + appSessionDataFactories.put(ISLhSessionData.class, new SLhReplicatedSessionDataFactory(this)); + appSessionDataFactories.put(ISLgSessionData.class, new SLgReplicatedSessionDataFactory(this)); } diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slg/ServerSLgSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slg/ServerSLgSessionDataReplicatedImpl.java new file mode 100644 index 000000000..67ecf6bfd --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slg/ServerSLgSessionDataReplicatedImpl.java @@ -0,0 +1,63 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * 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.diameter.impl.ha.server.slg; + +import org.jboss.cache.Fqn; +import org.jdiameter.api.slg.ServerSLgSession; +import org.jdiameter.client.api.IContainer; +import org.jdiameter.common.api.app.slg.SLgSessionState; +import org.jdiameter.server.impl.app.slg.IServerSLgSessionData; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.common.slg.SLgSessionDataReplicatedImpl; +import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; + +/** + * + * @author Fernando Mendioroz (fernando.mendioroz@telestax.com) + * + */ +public class ServerSLgSessionDataReplicatedImpl extends SLgSessionDataReplicatedImpl implements IServerSLgSessionData { + + /** + * @param nodeFqn + * @param mobicentsCluster + * @param iface + */ + public ServerSLgSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); + + if (super.create()) { + setAppSessionIface(this, ServerSLgSession.class); + setSLgSessionState(SLgSessionState.IDLE); + } + } + + /** + * @param sessionId + * @param mobicentsCluster + * @param iface + */ + public ServerSLgSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); + } + +} diff --git a/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slh/ServerSLhSessionDataReplicatedImpl.java b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slh/ServerSLhSessionDataReplicatedImpl.java new file mode 100644 index 000000000..3548061e5 --- /dev/null +++ b/core/jdiameter-ha/impl/src/main/java/org/mobicents/diameter/impl/ha/server/slh/ServerSLhSessionDataReplicatedImpl.java @@ -0,0 +1,63 @@ +/* + * TeleStax, Open Source Cloud Communications + * Copyright 2011-2016, Telestax Inc and individual contributors + * by the @authors tag. + * + * 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.diameter.impl.ha.server.slh; + +import org.jboss.cache.Fqn; +import org.jdiameter.api.slh.ServerSLhSession; +import org.jdiameter.client.api.IContainer; +import org.jdiameter.common.api.app.slh.SLhSessionState; +import org.jdiameter.server.impl.app.slh.IServerSLhSessionData; +import org.mobicents.cluster.MobicentsCluster; +import org.mobicents.diameter.impl.ha.common.slh.SLhSessionDataReplicatedImpl; +import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; + +/** + * + * @author Fernando Mendioroz (fernando.mendioroz@telestax.com) + * + */ +public class ServerSLhSessionDataReplicatedImpl extends SLhSessionDataReplicatedImpl implements IServerSLhSessionData { + + /** + * @param nodeFqn + * @param mobicentsCluster + * @param iface + */ + public ServerSLhSessionDataReplicatedImpl(Fqn nodeFqn, MobicentsCluster mobicentsCluster, IContainer container) { + super(nodeFqn, mobicentsCluster, container); + + if (super.create()) { + setAppSessionIface(this, ServerSLhSession.class); + setSLhSessionState(SLhSessionState.IDLE); + } + } + + /** + * @param sessionId + * @param mobicentsCluster + * @param iface + */ + public ServerSLhSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { + this(Fqn.fromRelativeElements(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); + } + +} diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportAnswer.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportAnswer.java index 205ef9573..90ee35978 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportAnswer.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/LocationReportAnswer.java @@ -21,6 +21,8 @@ package org.jdiameter.api.slg.events; +import org.jdiameter.api.app.AppAnswerEvent; + /** * @author fernando.mendioroz@telestax.com (Fernando Mendioroz) * @@ -31,12 +33,12 @@ * target UE to a GMLC, when a request for location has been implicitly issued or when a Delayed Location Reporting is triggered * after receipt of a request for location for a UE transiently not reachable. * - * The Location-Report-Answer (LRA) command, indicated by the Command-Code field set to 8388621 and the ‘R’ bit cleared in the + * The Location-Report-Answer (LRA) command, indicated by the Command-Code field set to 8388621 and the �R� bit cleared in the * Command Flags field, is sent by the GMLC to the MME or SGSN in response to the Location-Report-Request command (Subscriber * Location Report operation answer) */ -public interface LocationReportAnswer { +public interface LocationReportAnswer extends AppAnswerEvent{ public static final String _SHORT_NAME = "LRA"; public static final String _LONG_NAME = "Location-Report-Answer"; diff --git a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationAnswer.java b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationAnswer.java index 0787ba1b3..197787bd4 100644 --- a/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationAnswer.java +++ b/core/jdiameter/api/src/main/java/org/jdiameter/api/slg/events/ProvideLocationAnswer.java @@ -21,6 +21,8 @@ package org.jdiameter.api.slg.events; +import org.jdiameter.api.app.AppAnswerEvent; + /** * @author fernando.mendioroz@telestax.com (Fernando Mendioroz) * @@ -34,12 +36,12 @@ * the target UE from the SGSN at any time, as part of deferred MT-LR procedure. The response contains the acknowledgment of the * receipt of the request and other additional information. * - * The Provide-Location-Answer (PLA) command, indicated by the Command-Code field set to 8388620 and the ‘R’ bit cleared in the + * The Provide-Location-Answer (PLA) command, indicated by the Command-Code field set to 8388620 and the �R� bit cleared in the * Command Flags field, is sent by the MME or SGSN to the GMLC in response to the Provide-Location-Request command (Provide * Subscriber Location operation answer) */ -public interface ProvideLocationAnswer { +public interface ProvideLocationAnswer extends AppAnswerEvent{ public static final String _SHORT_NAME = "PLA"; public static final String _LONG_NAME = "Provide-Location-Answer"; diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionData.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionData.java index 7aea4cfef..e45d48369 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionData.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/api/app/slg/ISLgSessionData.java @@ -24,13 +24,14 @@ import java.io.Serializable; import org.jdiameter.api.Request; +import org.jdiameter.common.api.app.IAppSessionData; /** * @author fernando.mendioroz@telestax.com (Fernando Mendioroz) * */ -public interface ISLgSessionData { +public interface ISLgSessionData extends IAppSessionData { public void setSLgSessionState(SLgSessionState state); @@ -43,4 +44,5 @@ public interface ISLgSessionData { public void setBuffer(Request buffer); public Request getBuffer(); + } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportAnswerImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportAnswerImpl.java index 76acbfa70..f64f4af2b 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportAnswerImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/LocationReportAnswerImpl.java @@ -45,5 +45,9 @@ public LocationReportAnswerImpl(Message message) { message.setRequest(true); } + public Avp getResultCodeAvp() throws AvpDataException { + return null; + } + /*** TODO ***/ } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationAnswerImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationAnswerImpl.java index abc2ec479..ebbcac433 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationAnswerImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/ProvideLocationAnswerImpl.java @@ -45,6 +45,10 @@ public ProvideLocationAnswerImpl(Message message) { message.setRequest(true); } + public Avp getResultCodeAvp() throws AvpDataException { + return null; + } + /*** TODO ***/ } diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSessionFactoryImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSessionFactoryImpl.java index 6daddbcef..a051fe125 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSessionFactoryImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slg/SLgSessionFactoryImpl.java @@ -277,7 +277,7 @@ public void doLocationReportRequestEvent(ServerSLgSession appSession, LocationRe } public void doLocationReportAnswerEvent(ClientSLgSession appSession, LocationReportRequest request, - ProvideLocationAnswer answer) + LocationReportAnswer answer) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException { logger.info("Diameter SLg Session Factory :: doLocationReportAnswerEvent :: appSession[{}], Request[{}], Answer[{}]", new Object[] { appSession, request, answer }); diff --git a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoAnswerImpl.java b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoAnswerImpl.java index 93928733d..955f42abc 100644 --- a/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoAnswerImpl.java +++ b/core/jdiameter/impl/src/main/java/org/jdiameter/common/impl/app/slh/LCSRoutingInfoAnswerImpl.java @@ -21,6 +21,8 @@ package org.jdiameter.common.impl.app.slh; +import org.jdiameter.api.Avp; +import org.jdiameter.api.AvpDataException; import org.jdiameter.api.slh.events.LCSRoutingInfoAnswer; import org.jdiameter.api.slh.events.LCSRoutingInfoRequest; import org.jdiameter.common.impl.app.AppRequestEventImpl; @@ -44,6 +46,10 @@ public LCSRoutingInfoAnswerImpl(Message message) { message.setRequest(true); } + public Avp getResultCodeAvp() throws AvpDataException { + return null; + } + /*** TODO ***/ }