add comments to DatabaseStateMachine
Change-Id: I775e2f6c0250ac158e301408e423ebdb29d75668
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseStateMachine.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseStateMachine.java
index 891de41..6d8d5bd 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseStateMachine.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseStateMachine.java
@@ -89,6 +89,8 @@
@Command
public List<InternalWriteResult> write(List<WriteRequest> requests) {
+
+ // applicability check
boolean abort = false;
List<InternalWriteResult.Status> validationResults = new ArrayList<>(requests.size());
for (WriteRequest request : requests) {
@@ -132,8 +134,13 @@
return results;
}
+ // apply changes
for (WriteRequest request : requests) {
Map<String, VersionedValue> table = state.getTables().get(request.tableName());
+ // FIXME: If this method could be called by multiple thread,
+ // synchronization scope is wrong.
+ // Whole function including applicability check needs to be protected.
+ // Confirm copycat's thread safety requirement for StateMachine
synchronized (table) {
VersionedValue previousValue =
table.put(request.key(), new VersionedValue(request.newValue(), state.nextVersion()));