Chronicle Map replication mechanism question

72 views
Skip to first unread message

gaz...@gmail.com

unread,
Jun 29, 2015, 10:43:24 PM6/29/15
to java-ch...@googlegroups.com
Hi all,

This question is not a bug or usage problem but just want to know the underlying implementation of chronicle map replication.

Image we have a ChronicleMap<CharSequence,SomeObject>, how did it detect SomeObject changed (called setXXX()) after i get from the Map (or getUsing/acquireUsing) and do replication to another server?

Cheers,


Peter Lawrey

unread,
Jun 30, 2015, 2:05:30 AM6/30/15
to java-ch...@googlegroups.com

Hello Gazitgu,
   There is a bitmap one for each the key/values. When an entry is changes the bit is set to 1 and when it is replicated it is set to 0. This works like a fixed size queue (worst case, every entry has changed)

Regards, Peter.

--
You received this message because you are subscribed to the Google Groups "Chronicle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-chronicl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

gaz...@gmail.com

unread,
Jun 30, 2015, 3:01:50 AM6/30/15
to java-ch...@googlegroups.com
Thanks Peter,

I am still not very clear about what you say "when an entry is changes", how do you know the entry is changed when a CustomizedObject which implements Serializable  called setXXX() and changed the variable?

After the entry changed, the bit set to 1, will the replicate thread scan the ‘queue’ to sync all the bit=1 entry periodically?  is the action event driven or time driven?

Thanks,

Gazit


Rob Austin

unread,
Jun 30, 2015, 3:36:14 AM6/30/15
to java-ch...@googlegroups.com
>Image we have a ChronicleMap<CharSequence,SomeObject>, how did it detect SomeObject changed

Rob Austin

unread,
Jun 30, 2015, 3:40:01 AM6/30/15
to java-ch...@googlegroups.com

gaz...@gmail.com

unread,
Jun 30, 2015, 4:06:40 AM6/30/15
to java-ch...@googlegroups.com
Thanks Rob,

According to the description, the "sender " first need identify what time the object changed and then push it to other servers, the problem is that how you know the object changed? (compare the two objects periodically say 10ns?)

class SomeObject implements Serizaliable{
private int ivar;

public void setIvar(int ivar){
this.ivar = ivar
}

public int getIvar(){
return ivar;
}


}

Thanks,

Gazit

Rob Austin

unread,
Jun 30, 2015, 4:09:39 AM6/30/15
to java-ch...@googlegroups.com
every time the map is changed “ another words put() is called on the map”, the entry in the map is marked dirty. If you changed a value in <SomeObject> you must call put again on the map to notify the map that it has changed.

gaz...@gmail.com

unread,
Jun 30, 2015, 4:17:52 AM6/30/15
to java-ch...@googlegroups.com
say:

ChronicleMap<CharSequence,SomeObject> map1=....;
SomeObject someObject = new SomeObject();
map1.put("test",someObject); //this will trigger dirty mark 

someObject = map1.acquireUsing("test",someObject)
someObject.setIvar(1);//  will this trigger dirty mark? 
someObject.setIvar(2);//  will this trigger dirty mark? 

Thanks,

Gazit

Rob Austin

unread,
Jun 30, 2015, 4:48:45 AM6/30/15
to java-ch...@googlegroups.com

gaz...@gmail.com

unread,
Jun 30, 2015, 6:35:03 AM6/30/15
to java-ch...@googlegroups.com

Hi Rob,

Not sure if acquireUsing will affect the dirty mark. but i will do some test.

Rob Austin

unread,
Jun 30, 2015, 10:20:06 AM6/30/15
to java-ch...@googlegroups.com
you should use acquireUsingLocked which will.

On 30 Jun 2015, at 11:35, gaz...@gmail.com wrote:


Hi Rob,

Not sure if acquireUsing will affect the dirty mark. but i will do some test.

gaz...@gmail.com

unread,
Jul 1, 2015, 3:49:36 AM7/1/15
to java-ch...@googlegroups.com
Hi Rob,

I checked some chronicle map source code, here is the summary of the answer of my question, please confirm:

For Chronicle map, you have to manually call put(K,V) so that the map knows the value (or key) changed and marked as dirty, the replication thread will periodically check the dirty mark and sync those dirty marked to remote server.

There is an exception for above explain: acquireUsingLock, since you have to use try-with-resource for it, and the try-with-resource will call put when close invoked, so acquireUsingLock don't have to call put manually to trigger the dirty mark.

two small questions;

1: how long the dirty check happens to sync to remote server?
2: when i call put but the value not changed, will it marked dirty anyway and replicate to remote server? 

Thanks,

Gazit

Rob Austin

unread,
Jul 1, 2015, 8:11:19 AM7/1/15
to java-ch...@googlegroups.com
>1: how long the dirty check happens to sync to remote server?
usually within a few milliseconds

>2: when i call put but the value not changed, will it marked dirty anyway and replicate to remote server? 
Yes - the entry will be marked dirty when ever you call put() and replicated, regardless of the value changing locally.

gaz...@gmail.com

unread,
Jul 1, 2015, 8:35:49 PM7/1/15
to java-ch...@googlegroups.com
Got it, thanks.
Reply all
Reply to author
Forward
0 new messages