开发者

Keep remote objects updated

Having two object A, B, of the same Class (for example HashMaps).

At different computers connected by internet

One (A) is the source and the other (B) is just as an updated copy...

Is there a standard/recommended way to keep them "connected" or "updated"?

Example

I am using a TCP connection and writeObject

ObjectOutputStream bufferObj = new ObjectOutputStream (out);

bufferObj.writeObject(A)

and in the copy side something like this

ObjectInputStream bufferObj = new ObjectInputStream(in);

Object B = bufferOb开发者_如何学编程j.readObject();

But this have the problem that the whole object is sent in every synchronization (for example periodically or everytime a modification occur)

I would like a way of sending only the differences (specially useful for Java collections), but knowing the difference is not an easy thing at least

I would like to have something like this (overly simple/optimistic scheme)

At the server source

ObjectA.serverUpdatesWarehouseAt(Port);

At the client copy

ObjectTemp.updateItRemotelyFrom(IP,Port);

ObjectB.merge(ObjectTemp); //update the differences adding/deleting as needed

Is anything like this already made ? so here I am, trying to avoid reinvent the wheel

thanks for reading


It sounds like you might benefit from a Distributed Hash Map ( http://en.wikipedia.org/wiki/Distributed_hash_table ).

There are quite a few frameworks which provide such functionality - http://code.google.com/p/hazelcast/ is one example.

At the risk of stating the obvious - if your update rate is high you can use up a lot of bandwidth keeping the two in sync.


If you use RMI you can have a distributed object, so you don't have to worry about keeping them updated at all. Once you have a reference to the object (on the client) it is automagically kept in sync with the server's object.


You could have a look at Terracotta which does exactly this kind of thing. They allow creation of shared objects between JVM which are kept synchronized.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜