-
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.
Fixed all compilations errors from previous commits. Added jdiameter-…
- Loading branch information
Fernando Mendioroz
committed
Sep 24, 2016
1 parent
a5ef466
commit 2291dd6
Showing
16 changed files
with
732 additions
and
7 deletions.
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.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 ([email protected]) | ||
* | ||
*/ | ||
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); | ||
} | ||
|
||
} | ||
|
63 changes: 63 additions & 0 deletions
63
...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,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 ([email protected]) | ||
* | ||
*/ | ||
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); | ||
} | ||
|
||
} |
71 changes: 71 additions & 0 deletions
71
.../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,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 ([email protected]) | ||
* | ||
*/ | ||
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(); | ||
} | ||
|
||
} |
152 changes: 152 additions & 0 deletions
152
...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,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 ([email protected]) | ||
* | ||
*/ | ||
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.