mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-321 Initial commit for FilePerMap implementation - make lastVal work.
This commit is contained in:
@@ -4,18 +4,26 @@ package net.openhft.chronicle.map;
|
||||
* Created by daniel on 23/04/15.
|
||||
*/
|
||||
public class FPMEvent {
|
||||
public enum EventType {NEW, UPDATE, DELETE}
|
||||
|
||||
private EventType eventType;
|
||||
private boolean programmatic;
|
||||
private String key;
|
||||
private String value;
|
||||
private String lastValue;
|
||||
|
||||
public FPMEvent(EventType eventType, boolean programmatic, String key, String value) {
|
||||
public FPMEvent(EventType eventType, boolean programmatic, String key, String lastValue, String value) {
|
||||
this.eventType = eventType;
|
||||
this.programmatic = programmatic;
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
this.lastValue = lastValue;
|
||||
}
|
||||
|
||||
public String getLastValue() {
|
||||
return lastValue;
|
||||
}
|
||||
|
||||
public void setLastValue(String lastValue) {
|
||||
this.lastValue = lastValue;
|
||||
}
|
||||
|
||||
public EventType getEventType() {
|
||||
@@ -57,6 +65,11 @@ public class FPMEvent {
|
||||
", programmatic=" + programmatic +
|
||||
", key='" + key + '\'' +
|
||||
", value='" + value + '\'' +
|
||||
", lastValue='" + lastValue + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public enum EventType {NEW, UPDATE, DELETE}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -270,17 +270,20 @@ public class FilePerKeyMap implements Map<String, String> {
|
||||
String mapVal = getFileContents(p);
|
||||
lastUpdate.put(p.toFile(), mapVal);
|
||||
if(isProgrammaticUpdate(p.toFile())){
|
||||
fireEvent(new FPMEvent(FPMEvent.EventType.NEW, true, mapKey,mapVal));
|
||||
fireEvent(new FPMEvent(FPMEvent.EventType.NEW, true, mapKey,null, mapVal));
|
||||
}else {
|
||||
fireEvent(new FPMEvent(FPMEvent.EventType.NEW, false, mapKey, mapVal));
|
||||
fireEvent(new FPMEvent(FPMEvent.EventType.NEW, false, mapKey, null, mapVal));
|
||||
}
|
||||
} else if (kind == StandardWatchEventKinds.ENTRY_DELETE) {
|
||||
Path p = dirPath.resolve(fileName);
|
||||
|
||||
String lastVal = lastUpdate.get(p.toFile());
|
||||
lastUpdate.remove(p.toFile());
|
||||
|
||||
if(isProgrammaticUpdate(p.toFile())){
|
||||
fireEvent(new FPMEvent(FPMEvent.EventType.DELETE, true, mapKey, null));
|
||||
fireEvent(new FPMEvent(FPMEvent.EventType.DELETE, true, mapKey, lastVal, null));
|
||||
}else {
|
||||
fireEvent(new FPMEvent(FPMEvent.EventType.DELETE, false, mapKey, null));
|
||||
fireEvent(new FPMEvent(FPMEvent.EventType.DELETE, false, mapKey, lastVal, null));
|
||||
}
|
||||
} else if (kind == StandardWatchEventKinds.ENTRY_MODIFY) {
|
||||
Path p = dirPath.resolve(fileName);
|
||||
@@ -296,9 +299,9 @@ public class FilePerKeyMap implements Map<String, String> {
|
||||
}
|
||||
|
||||
if(isProgrammaticUpdate(p.toFile())){
|
||||
fireEvent(new FPMEvent(FPMEvent.EventType.UPDATE, true, mapKey,mapVal));
|
||||
fireEvent(new FPMEvent(FPMEvent.EventType.UPDATE, true, mapKey,lastVal,mapVal));
|
||||
}else {
|
||||
fireEvent(new FPMEvent(FPMEvent.EventType.UPDATE, false, mapKey, mapVal));
|
||||
fireEvent(new FPMEvent(FPMEvent.EventType.UPDATE, false, mapKey,lastVal,mapVal));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user