Revision: 22805
Author: [email protected]
Date: Tue Aug 21 02:40:43 2012
Log: MAP RA - onDialogTimeout fug fixing
http://code.google.com/p/mobicents/source/detail?r=22805
Added:
/trunk/servers/jain-slee/resources/map/ra/src/main/java/org/mobicents/slee/resource/map/MAPRAMarshaler.java
Modified:
/trunk/servers/jain-slee/resources/map/events/src/main/java/org/mobicents/slee/resource/map/events/DialogTimeout.java
/trunk/servers/jain-slee/resources/map/ra/src/main/java/org/mobicents/slee/resource/map/MAPResourceAdaptor.java
/trunk/servers/jain-slee/resources/map/ra/src/main/java/org/mobicents/slee/resource/map/service/mobility/wrappers/MAPDialogMobilityWrapper.java
/trunk/servers/jain-slee/resources/map/ra/src/main/java/org/mobicents/slee/resource/map/wrappers/MAPDialogWrapper.java
/trunk/servers/jain-slee/resources/map/ra/src/main/java/org/mobicents/slee/resource/map/wrappers/MAPProviderWrapper.java
=======================================
--- /dev/null
+++
/trunk/servers/jain-slee/resources/map/ra/src/main/java/org/mobicents/slee/resource/map/MAPRAMarshaler.java
Tue Aug 21 02:40:43 2012
@@ -0,0 +1,122 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * 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.map;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import javax.slee.resource.ActivityHandle;
+import javax.slee.resource.FireableEventType;
+import javax.slee.resource.Marshaler;
+
+/**
+ * @author Tomasz Domin [email protected]
+ */
+public class MAPRAMarshaler implements Marshaler {
+
+ // Events
-----------------------------------------------------------------
+
+ public int getEstimatedEventSize(FireableEventType eventType, Object
event) {
+ // TODO: return an estimation of the size (in bytes) of the
marshaled
+ // form of an Event object generated by the Resource
Adaptor. It
+ // can be used by the SLEE to help size appropriately any
+ // internal buffers used to store the marshaled form of
an Event.
+
+ throw new UnsupportedOperationException();
+ }
+
+ public ByteBuffer getEventBuffer(FireableEventType eventType, Object
event) {
+ // TODO: return a ByteBuffer containing an already marshaled
form of
+ // the Event object specified by the event argument. The
+ // eventType argument specifies the event type of the
Event. The
+ // exact purpose of this method is to give the Resource
Adaptor
+ // an opportunity to provide the SLEE with a view buffer
onto an
+ // existing buffer that already contains the marshaled
form of
+ // the Event object.
+
+ throw new UnsupportedOperationException();
+ }
+
+ public void releaseEventBuffer(FireableEventType eventType, Object event,
ByteBuffer buffer) {
+ // TODO: release any resources associated with the specified
ByteBuffer
+ // when this method is invoked as the SLEE will no longer
use the
+ // buffer.
+
+ throw new UnsupportedOperationException();
+ }
+
+ public void marshalEvent(FireableEventType eventType, Object event,
DataOutput out) throws IOException {
+ // TODO: return the marshaled form of an Event object. The
Resource
+ // Adaptor should write a serialized form of the Event
object
+ // specified by the event argument using the DataOutput
object
+ // specified by the out argument. The eventType argument
+ // identifies the event type of the Event object.
+
+ throw new UnsupportedOperationException();
+ }
+
+ public Object unmarshalEvent(FireableEventType eventType, DataInput in)
throws IOException {
+ // TODO: read the marshaled form of the Event object from the
DataInput
+ // object specified by the in argument and reconstruct
the Event
+ // object. The eventType argument identifies the event
type of
+ // the Event object that is marshaled and provides access
to the
+ // class name of the event type and a class loader that
can be
+ // used to load the event class if required.
+
+ throw new UnsupportedOperationException();
+ }
+
+ // Activity Handles
-------------------------------------------------------
+
+ public int getEstimatedHandleSize(ActivityHandle handle) {
+ // TODO: return an estimation of the size (in bytes) of the
marshaled
+ // form of an Activity Handle object generated by the
Resource
+ // Adaptor. It can be used by the SLEE to help size
appropriately
+ // any internal buffers used to store the marshaled form
of an
+ // Activity Handle.
+
+ throw new UnsupportedOperationException();
+ }
+
+ public void marshalHandle(ActivityHandle handle, DataOutput out) throws
IOException {
+ // TODO: return the marshaled form of an ActivityHandle object.
The
+ // Resource Adaptor should write a serialized form of the
+ // ActivityHandle object specified by the handle argument
using
+ // the DataOutput object specified by the out argument.
+
+ throw new UnsupportedOperationException();
+ }
+
+ public ActivityHandle unmarshalHandle(DataInput in) throws IOException {
+ // TODO: return an unmarshaled ActivityHandle object previously
+ // marshaled by the Resource Adaptor. The Resource
Adaptor should
+ // read the marshaled form of the Activity Handle from the
+ // DataInput object specified by the in argument and
reconstruct
+ // the ActivityHandle object.
+
+ throw new UnsupportedOperationException();
+ }
+
+}
=======================================
---
/trunk/servers/jain-slee/resources/map/events/src/main/java/org/mobicents/slee/resource/map/events/DialogTimeout.java
Thu May 24 07:46:27 2012
+++
/trunk/servers/jain-slee/resources/map/events/src/main/java/org/mobicents/slee/resource/map/events/DialogTimeout.java
Tue Aug 21 02:40:43 2012
@@ -30,7 +30,7 @@
*/
public class DialogTimeout extends MAPEvent {
- private static final String EVENT_TYPE_NAME = "ss7.map.DIALOG_TIMEOUT";
+ public static final String EVENT_TYPE_NAME = "ss7.map.DIALOG_TIMEOUT";
/**
* @param mapDialogWrapper
=======================================
---
/trunk/servers/jain-slee/resources/map/ra/src/main/java/org/mobicents/slee/resource/map/MAPResourceAdaptor.java
Fri Aug 17 05:17:36 2012
+++
/trunk/servers/jain-slee/resources/map/ra/src/main/java/org/mobicents/slee/resource/map/MAPResourceAdaptor.java
Tue Aug 21 02:40:43 2012
@@ -203,6 +203,8 @@
private EventIDCache eventIdCache = null;
+ private Marshaler marshaler = new MAPRAMarshaler();
+
/**
* tells the RA if an event with a specified ID should be filtered or
not
*/
@@ -252,6 +254,13 @@
tracer.fine("eventProcessingFailed:" + eventType + ":"
+ handle);
// used to inform the resource adaptor object that the
specified Event
// could not be processed successfully by the SLEE.
+
+ if
(eventType.getEventType().getName().equals(DialogTimeout.EVENT_TYPE_NAME)) {
+ MAPDialogActivityHandle dah = (MAPDialogActivityHandle)
handle;
+ MAPDialogWrapper dw = dah.getActivity();
+ if (dw != null)
+ releaseDialog(dw);
+ }
}
public void eventProcessingSuccessful(ActivityHandle handle,
FireableEventType eventType, Object event,
@@ -260,6 +269,13 @@
tracer.fine("eventProcessingSuccessful:" + eventType +
":" + handle);
// used to inform the resource adaptor object that the
specified Event
// was processed successfully by the SLEE.
+
+ if
(eventType.getEventType().getName().equals(DialogTimeout.EVENT_TYPE_NAME)) {
+ MAPDialogActivityHandle dah = (MAPDialogActivityHandle)
handle;
+ MAPDialogWrapper dw = dah.getActivity();
+ if (dw != null && !dw.checkDialogTimeoutProcKeeped())
+ releaseDialog(dw);
+ }
}
public void eventUnreferenced(ActivityHandle handle, FireableEventType
eventType, Object event, Address address,
@@ -270,6 +286,10 @@
// references an Event object which was previously fired by the
// resource adaptor object.
}
+
+ private void releaseDialog(MAPDialogWrapper dw) {
+ dw.release();
+ }
public Object getActivity(ActivityHandle handle) {
return ((MAPDialogActivityHandle) handle).getActivity();
@@ -287,8 +307,7 @@
}
public Marshaler getMarshaler() {
- // TODO Auto-generated method stub
- return null;
+ return marshaler;
}
public Object getResourceAdaptorInterface(String className) {
@@ -496,6 +515,10 @@
* Private methods
*/
private void fireEvent(String eventName, ActivityHandle handle, Object
event) {
+ fireEvent(eventName, handle, event, EventFlags.NO_FLAGS);
+ }
+
+ private void fireEvent(String eventName, ActivityHandle handle, Object
event, int flags) {
FireableEventType eventID =
eventIdCache.getEventId(this.resourceAdaptorContext.getEventLookupFacility(),
eventName);
@@ -507,7 +530,7 @@
} else {
try {
- sleeEndpoint.fireEvent(handle, eventID, event,
address, null);
+ sleeEndpoint.fireEvent(handle, eventID, event,
address, null, flags);
} catch (UnrecognizedActivityHandleException e) {
this.tracer.severe("Error while firing event",
e);
} catch (IllegalEventException e) {
@@ -529,6 +552,10 @@
// /////////////////
private MAPDialogActivityHandle onEvent(String eventName,
MAPDialogWrapper dw, MAPEvent event) {
+ return onEvent(eventName, dw, event, EventFlags.NO_FLAGS);
+ }
+
+ private MAPDialogActivityHandle onEvent(String eventName,
MAPDialogWrapper dw, MAPEvent event, int flags) {
if (dw == null) {
this.tracer.severe(String.format("Firing %s but MAPDialogWrapper
userObject is null", eventName));
return null;
@@ -721,9 +748,18 @@
this.tracer.fine(String.format("Rx : onDialogTimeout for DialogId=%d",
mapDialog.getDialogId()));
}
+// MAPDialogWrapper mapDialogWrapper = (MAPDialogWrapper)
mapDialog.getUserObject();
+// DialogTimeout dt = new DialogTimeout(mapDialogWrapper);
+// onEvent(dt.getEventTypeName(), mapDialogWrapper, dt);
+
+
+ mapDialog.keepAlive();
+
MAPDialogWrapper mapDialogWrapper = (MAPDialogWrapper)
mapDialog.getUserObject();
+ mapDialogWrapper.startDialogTimeoutProc();
DialogTimeout dt = new DialogTimeout(mapDialogWrapper);
- onEvent(dt.getEventTypeName(), mapDialogWrapper, dt);
+ onEvent(dt.getEventTypeName(), mapDialogWrapper, dt,
+ (EventFlags.REQUEST_PROCESSING_SUCCESSFUL_CALLBACK |
EventFlags.REQUEST_PROCESSING_FAILED_CALLBACK));
}
// ///////////////////////
=======================================
---
/trunk/servers/jain-slee/resources/map/ra/src/main/java/org/mobicents/slee/resource/map/service/mobility/wrappers/MAPDialogMobilityWrapper.java
Fri Aug 17 05:18:06 2012
+++
/trunk/servers/jain-slee/resources/map/ra/src/main/java/org/mobicents/slee/resource/map/service/mobility/wrappers/MAPDialogMobilityWrapper.java
Tue Aug 21 02:40:43 2012
@@ -132,15 +132,13 @@
@Override
public Long addCheckImeiRequest(long customInvokeTimeout, IMEI imei,
RequestedEquipmentInfo requestedEquipmentInfo, MAPExtensionContainer
extensionContainer)
throws MAPException {
- // TODO Auto-generated method stub
- return null;
+ return this.wrappedDialog.addCheckImeiRequest(customInvokeTimeout, imei,
requestedEquipmentInfo, extensionContainer);
}
@Override
public void addCheckImeiResponse(long invokeId, EquipmentStatus
equipmentStatus, UESBIIu bmuef, MAPExtensionContainer extensionContainer)
throws MAPException {
- // TODO Auto-generated method stub
-
+ this.wrappedDialog.addCheckImeiResponse(invokeId, equipmentStatus,
bmuef, extensionContainer);
}
}
=======================================
---
/trunk/servers/jain-slee/resources/map/ra/src/main/java/org/mobicents/slee/resource/map/wrappers/MAPDialogWrapper.java
Tue Aug 7 03:52:49 2012
+++
/trunk/servers/jain-slee/resources/map/ra/src/main/java/org/mobicents/slee/resource/map/wrappers/MAPDialogWrapper.java
Tue Aug 21 02:40:43 2012
@@ -30,6 +30,8 @@
protected final MAPResourceAdaptor ra;
protected T wrappedDialog;
+ private boolean keepedTimeout;
+
public MAPDialogWrapper(T wrappedDialog, MAPDialogActivityHandle
activityHandle, MAPResourceAdaptor ra) {
this.wrappedDialog = wrappedDialog;
this.activityHandle = activityHandle;
@@ -94,7 +96,16 @@
}
public void keepAlive() {
- this.wrappedDialog.keepAlive();
+// this.wrappedDialog.keepAlive();
+ this.keepedTimeout = true;
+ }
+
+ public void startDialogTimeoutProc() {
+ this.keepedTimeout = false;
+ }
+
+ public boolean checkDialogTimeoutProcKeeped() {
+ return this.keepedTimeout;
}
public void refuse(Reason arg0) throws MAPException {
=======================================
---
/trunk/servers/jain-slee/resources/map/ra/src/main/java/org/mobicents/slee/resource/map/wrappers/MAPProviderWrapper.java
Tue Aug 7 03:52:49 2012
+++
/trunk/servers/jain-slee/resources/map/ra/src/main/java/org/mobicents/slee/resource/map/wrappers/MAPProviderWrapper.java
Tue Aug 21 02:40:43 2012
@@ -34,7 +34,6 @@
import
org.mobicents.protocols.ss7.map.api.service.pdpContextActivation.MAPServicePdpContextActivation;
import org.mobicents.protocols.ss7.map.api.service.sms.MAPServiceSms;
import
org.mobicents.protocols.ss7.map.api.service.supplementary.MAPServiceSupplementary;
-import org.mobicents.slee.resource.map.MAPDialogActivityHandle;
import org.mobicents.slee.resource.map.MAPResourceAdaptor;
import
org.mobicents.slee.resource.map.service.callhandling.wrappers.MAPServiceCallHandlingWrapper;
import
org.mobicents.slee.resource.map.service.lsm.wrappers.MAPServiceLsmWrapper;
@@ -133,8 +132,9 @@
if (this.wrappedProvider == null) {
throw new IllegalStateException("RA is has not been
activated.");
}
- MAPDialogActivityHandle ah = new
MAPDialogActivityHandle(dialogId);
- return (MAPDialog) this.ra.getActivity(ah);
+
+ MAPDialog wrappedDialog =
this.wrappedProvider.getMAPDialog(dialogId);
+ return (MAPDialogWrapper)wrappedDialog.getUserObject();
}
public MAPServiceMobility getMAPServiceMobility() {