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