SharedMaps: how use correctly
GenCloud opened this issue · 1 comments
Good afternoon, comrades, tell me about the use of distributed cards.
I have two test app instances that declare a shared map across 1 and the same file.
When writing data from the first application to the SharedMemoryStringMap and receiving, I see the recorded data.
I'm launching a second application that tries to read data using a key that was written by the first application in SharedMemoryStringMap. As a result, I get a zero result.
The second application can see the data in the file only after the first application calls the map.close () method.
Tell me what can I do wrong?
Current use case:
JVM 1:
final String file = "./data.dat";
final SharedMemoryStringMap<String> map = new SharedMemoryStringMap<>(65535, file, 4 * M);
map.setSerializer(String.class);
map.put("12345", "test-shared-str");
String s = map.get("12345");
System.out.println(s);
// start daemon thread ...
JVM 2:
final String file = "./data.dat";
final SharedMemoryStringMap<String> map = new SharedMemoryStringMap<>(65535, file, 4 * M);
map.setSerializer(String.class);
String s = map.get("12345"); <-- null value
System.out.println(s);
In current implementation SharedMemoryMap cannot be used concurrently in different processes.
The word shared in the name actually refers to the shared memory, not the shared map.