简体   繁体   English

如何远程同步两套?

[英]How to remotely synchronize two sets?

I need to synchronize two large sets of strings in Java, one of the on the client and the other on the server. 我需要在Java中同步两个大的字符串集,一个在客户端上,另一个在服务器上。 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. 我觉得像版本控制这样的东西会是最佳的,但我恐怕不能这样做。

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. 然后,它可以集成这些更改,并且(如果适用)发回自上次同步以来任何剩余的客户端更改。

你可以使用套接字,首先同步所有成员然后使用自定义方法添加和删除本地集中的成员并发送数据+指令到另一端你也可以使用jmx active mq

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM