MapEventListener Query

58 views
Skip to first unread message

Vanitha Thadvai

unread,
Mar 17, 2015, 2:14:36 AM3/17/15
to java-ch...@googlegroups.com
Can't I use MapEventListener to the persited map.

I have the following scenario,when I start one java process I have  chronicle map created  without event listener ( for me this java process needs to be start first ) so the file where we will store the data will be created by this map
And now I have another java process which will create a persistence to the first map, while creating this map I am using the EventListener, but the eventListner to this map is showing as null and I am 

This is beacuse if we see the VanillaChronicle map code we are not assigning eventListener if the file exists , we are just returning the replicated map not the newMap of VanillaChronicleMap. I am atatching a JUnit for this.


Please let me know whether it is possible to add event listener to the replicated map as we need to do some other operations on the replicated map side when there are changes to the map

We are using 2.1.0 of chronicle-map



Enter code heif (file.exists() && file.length() > 0) {
        try (FileInputStream fis = new FileInputStream(file);
ObjectInputStream ois = new ObjectInputStream(fis)) {
Object m;
byte serialization = ois.readByte();
if (serialization == XML_SERIALIZATION) {
m = deserializeHeaderViaXStream(ois);
} else if (serialization == BINARY_SERIALIZATION) {
try {
m = ois.readObject();
} catch (ClassNotFoundException e) {
throw new AssertionError(e);
}
} else {
throw new IOException("Unknown map header serialization type: " +
serialization);
}
VanillaChronicleMap<K, ?, ?, V, ?, ?> map =
(VanillaChronicleMap<K, ?, ?, V, ?, ?>) m;
map.headerSize = roundUpMapHeaderSize(fis.getChannel().position());
map.createMappedStoreAndSegments(file);
// This is needed to property initialize key and value serialization builders,
// which are later used in replication
// TODO don't use SerializationBuilders in replication, extract marshallers
// needed to transmit to stateless clients directly from map instance
preMapConstruction(singleHashReplication != null || channel != null);
return establishReplication(map, singleHashReplication, channel);
}
}
if (file.createNewFile() || file.length() == 0) {
break;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new IOException(e);
}
}
// new file
if (!file.exists())
throw new FileNotFoundException("Unable to create " + file);

VanillaChronicleMap<K, ?, ?, V, ?, ?> map = newMap(singleHashReplication, channel);/////We will be assigning event listner only with new Chroicle Mapre...



Thanks
Vanitha


TestEventListenerMap.java

Roman Leventov

unread,
Mar 17, 2015, 3:03:48 AM3/17/15
to java-ch...@googlegroups.com
Unfortunately, it seems not possible to add different event listener in the different Java process, working with the map, in Chronicle Map 2.1. I don't see conceptual difficulties with this, but this is new functionality requiring substantial changes. Now we stopped Chronicle Map 2.1 development, releasing only bug fixes.

We will consider your case in Chronicle Map 3.x, which is being developed currently.

--
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.

Reply all
Reply to author
Forward
0 new messages