Issue Details (XML | Word | Printable)

Key: DIRMINA-51
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Trustin Lee
Reporter: Trustin Lee
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
MINA

Object serialization filter

Created: 02/Jun/05 12:08 AM   Updated: 03/Dec/05 08:50 AM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: 0.9.0

Time Tracking:
Not Specified

File Attachments:
  Size
Java Source File Licensed for inclusion in ASF works SerializationFilter.java 2005-09-12 05:22 AM Matteo Merli 4 kB
Zip Archive Licensed for inclusion in ASF works TestSerialization.zip 2005-09-12 05:22 AM Matteo Merli 11 kB

Resolution Date: 29/Nov/05 02:18 PM


 Description  « Hide
Users with no time to implement PDUs will be able to get a lot of benefit from this filter to test their protocol logic implementation.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Matteo Merli added a comment - 12/Sep/05 05:22 AM
Hi Trustin,
I think is really a nice idea to provide such a serialization file, so here's a quick implementation I made.
Attached there is the filter and a small test/example that does use it.

Please review.

Trustin Lee added a comment - 12/Sep/05 10:41 AM
Wow, thank you so much for your contribution! :)

I looked at your code. It looks OK. I'll merge this into the trunk after some optimization on object serialization.

Thanks again!
Trustin

Trustin Lee added a comment - 21/Nov/05 06:19 PM
I checked the code again. It won't work if an object is splitted into multiple packets. We'll have to improve the implementation. But the ObjectInputStream itself is stream-based, so we need to introduce an additional field such as message length to suppress the interpretation until all data is received.


Matteo Merli added a comment - 26/Nov/05 08:45 PM
I see the problem. I took a look at xStream serialization framework and it looks very fine.
I only have a concern about how the serialization filter would work with UDP transport. If the xml stream it's breaked on multiple packets, with UDP there is no garanties that packets will be received in the correct order.
One solution can be that, when using UDP, the stream would be breaked in the filter and every packet would be carrying a sequence number.
Then when all packets will be received the stream will be de-serialized.

What do you think?

Matteo Merli added a comment - 28/Nov/05 04:25 AM
I reworked on the filter to resolve the issue with the stream being splitted in multiple packets. I'm dealing with the two different cases of TCP and UDP.

TCP is working fine. I've added a 4 bytes int containing the overall stream length at the beginning. Then the object is de-serialized when the entire-stream is received. The partial buffer is saved as an attribute session.

UDP is more difficult. I've implemented a packet fragmentation method that splits the stream and send every packet with attached sequence number.
The receiver will get the UDP packets in no particular order and can reconstruct the stream using the sequence number.
Problems arise because I can't save the received packets as a session attribute. Every time messageReceived() is called on the filter, the session object is different.

I thinked to use a message Id attached to every packet, and store them temporarely into a static Map instead of session. But then a new problem comes up: using session, all the saved data is cleared when a timeout event is fired. Using a static map, lost packets will remain there forever..

Any thoughs?
Is Udp support important or can it be droppen? I believe it's important, at least for a completeness point of view..



Trustin Lee added a comment - 28/Nov/05 02:31 PM
Supporting TCP only is sufficient IMHO. We can later add another filter that emulates the behavior of TCP/IP using message ID. WDYT?

Trustin Lee added a comment - 28/Nov/05 03:45 PM
Matteo, it would be great if you can provide the updated version of SerializationFilter so I can accept your contribution. :)

Matteo Merli added a comment - 29/Nov/05 08:30 AM
I'm just taking a look at the new method that you added to ByteBuffer get/putObject that do the same I implemented in the filter. So I'm going to clean-up the filter and make it use the putObject().. and remove (for now) the code for UDP, that is broken..

Trustin Lee added a comment - 29/Nov/05 02:18 PM
I needed this filter immediately, so I implemented it by myself quickly. I'd like to compare with your implementation, Marten. Please review mine:

http://svn.apache.org/viewcvs?rev=349650&view=rev

Trustin Lee added a comment - 03/Dec/05 08:50 AM
There was no objection on the implementation.