1

I need to synchronize two large sets of strings in Java, one of the on the client and the other on the server. Most probably the client is missing a couple of entries which it should receive from the server. I don't want to transfer all members, I want to minimize the communication and the computation on the server (the client may work harder).

Any idea besides divide-and-conquer?

I'm not asking about the communication technology or alike, I'm only interested in a good algorithm. I think something like what version control does would be optimal, but I'm afraid I can't do it this way.

Community
  • 1
  • 1
maaartinus
  • 44,714
  • 32
  • 161
  • 320

2 Answers2

3

You can keep a generation counter for the set on the server along with a change log for each generation. The client can request all changes since the last synchronization. It can then integrate those changes and also (if applicable) send back any remaining client-side changes since the last synchronization.

Ted Hopp
  • 232,168
  • 48
  • 399
  • 521
  • I'm not sure if this is the right thing to do, I need to think more about it. But for the question as stated you gave the right answer. – maaartinus Mar 22 '11 at 21:29
1

you can use socket, at first synchronize all members ans then using custom methods which add and remove members in local set and send data+instruction to other end you can also use jmx active mq

Nirmal- thInk beYond
  • 11,847
  • 8
  • 35
  • 46