-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of interfaces SLh and SLg for LTE location services. I…
- Loading branch information
Fernando Mendioroz
committed
Jul 1, 2017
1 parent
2e6bc70
commit 7b1853c
Showing
93 changed files
with
17,447 additions
and
1 deletion.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
...in/java/org/mobicents/diameter/impl/ha/client/slg/ClientSLgSessionDataReplicatedImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.restcomm.cache.FqnWrapper; | ||
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.restcomm.cluster.MobicentsCluster; | ||
import org.mobicents.diameter.impl.ha.common.slg.SLgSessionDataReplicatedImpl; | ||
import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; | ||
|
||
/** | ||
* | ||
* @author <a href="mailto:[email protected]"> Fernando Mendioroz </a> | ||
* | ||
*/ | ||
public class ClientSLgSessionDataReplicatedImpl extends SLgSessionDataReplicatedImpl implements IClientSLgSessionData { | ||
|
||
/** | ||
* @param nodeFqnWrapper | ||
* @param mobicentsCluster | ||
* @param container | ||
*/ | ||
public ClientSLgSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster, IContainer container) { | ||
super(nodeFqnWrapper, mobicentsCluster, container); | ||
|
||
if (super.create()) { | ||
setAppSessionIface(this, ClientSLgSession.class); | ||
setSLgSessionState(SLgSessionState.IDLE); | ||
} | ||
} | ||
|
||
/** | ||
* @param sessionId | ||
* @param mobicentsCluster | ||
* @param container | ||
*/ | ||
public ClientSLgSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { | ||
this( | ||
FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); | ||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
...in/java/org/mobicents/diameter/impl/ha/client/slh/ClientSLhSessionDataReplicatedImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.slh; | ||
|
||
import org.restcomm.cache.FqnWrapper; | ||
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.restcomm.cluster.MobicentsCluster; | ||
import org.mobicents.diameter.impl.ha.common.slh.SLhSessionDataReplicatedImpl; | ||
import org.mobicents.diameter.impl.ha.data.ReplicatedSessionDatasource; | ||
|
||
/** | ||
* | ||
* @author <a href="mailto:[email protected]"> Fernando Mendioroz </a> | ||
* | ||
*/ | ||
public class ClientSLhSessionDataReplicatedImpl extends SLhSessionDataReplicatedImpl implements IClientSLhSessionData { | ||
|
||
/** | ||
* @param nodeFqnWrapper | ||
* @param mobicentsCluster | ||
* @param container | ||
*/ | ||
public ClientSLhSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster, IContainer container) { | ||
super(nodeFqnWrapper, mobicentsCluster, container); | ||
|
||
if (super.create()) { | ||
setAppSessionIface(this, ClientSLhSession.class); | ||
setSLhSessionState(SLhSessionState.IDLE); | ||
} | ||
} | ||
|
||
/** | ||
* @param sessionId | ||
* @param mobicentsCluster | ||
* @param container | ||
*/ | ||
public ClientSLhSessionDataReplicatedImpl(String sessionId, MobicentsCluster mobicentsCluster, IContainer container) { | ||
this( | ||
FqnWrapper.fromRelativeElementsWrapper(ReplicatedSessionDatasource.SESSIONS_FQN, sessionId), mobicentsCluster, container); | ||
} | ||
|
||
} |
72 changes: 72 additions & 0 deletions
72
.../main/java/org/mobicents/diameter/impl/ha/common/slg/SLgReplicatedSessionDataFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* 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.restcomm.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 <a href="mailto:[email protected]"> Fernando Mendioroz </a> | ||
* | ||
*/ | ||
public class SLgReplicatedSessionDataFactory implements IAppSessionDataFactory<ISLgSessionData> { | ||
|
||
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<? extends AppSession> 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(); | ||
} | ||
|
||
} |
150 changes: 150 additions & 0 deletions
150
...src/main/java/org/mobicents/diameter/impl/ha/common/slg/SLgSessionDataReplicatedImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/* | ||
* 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.restcomm.cache.FqnWrapper; | ||
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.restcomm.cluster.MobicentsCluster; | ||
import org.mobicents.diameter.impl.ha.common.AppSessionDataReplicatedImpl; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* | ||
* @author <a href="mailto:[email protected]"> Fernando Mendioroz </a> | ||
* | ||
*/ | ||
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 nodeFqnWrapper | ||
* @param mobicentsCluster | ||
* @param container | ||
*/ | ||
public SLgSessionDataReplicatedImpl(FqnWrapper nodeFqnWrapper, MobicentsCluster mobicentsCluster, IContainer container) { | ||
super(nodeFqnWrapper, 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); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.