File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Distributed Java and the fly likes Sending HashMap between 2 servers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Sending HashMap between 2 servers" Watch "Sending HashMap between 2 servers" New topic

Sending HashMap between 2 servers

victor kamat
Ranch Hand

Joined: Jan 10, 2007
Posts: 247
I am new to the area of distributed programming.

With that in mind what is involved in sending a hashMap from one server to another and keep it synchronized.
If someone can guide that would be nice.
Nitesh Kant

Joined: Feb 25, 2007
Posts: 1638

If you use RMI you do not have to do anything special for sending a HashMap across from one server to another.
However, the synchronization is a little tricky as the instance of HashMap will be different for the two JVMs you can not have a single lock monitor.
If you explain in detail by what do you mean by " keep it synchronized. ", we will be able to help more.

apigee, a better way to API!
Greg Bugaj

Joined: May 19, 2008
Posts: 3
If you want to send Hashmap over two http servers you can use XStream serializer or as the previous poster said RMI. But still this will not take care of your synchronization.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
The distributed computing solution would be to have a single instance of the hashmap shared by all applications.

What sort of activity does this hashmap have to support? How many lookups per second - how many changes per second?

Maris Orbidans
Ranch Hand

Joined: Mar 08, 2004
Posts: 149
I used JGroups for this. It's very easy to do it in JGroups.
Murthy Tanniru

Joined: Jun 03, 2008
Posts: 14
If you want to use caching you can take a look at jboss cache which internally it uses jgroups
I agree. Here's the link:
subject: Sending HashMap between 2 servers
It's not a secret anymore!