sashapolo commented on code in PR #1887:
URL: https://github.com/apache/ignite-3/pull/1887#discussion_r1159448613


##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/raft/MetaStorageListener.java:
##########
@@ -77,159 +67,89 @@ public void onRead(Iterator<CommandClosure<ReadCommand>> 
iter) {
 
             ReadCommand command = clo.command();
 
-            if (command instanceof GetCommand) {
-                GetCommand getCmd = (GetCommand) command;
-
-                Entry e;
-
-                if (getCmd.revision() != 0) {
-                    e = storage.get(getCmd.key(), getCmd.revision());
-                } else {
-                    e = storage.get(getCmd.key());
-                }
-
-                clo.result(e);
-            } else if (command instanceof GetAllCommand) {
-                GetAllCommand getAllCmd = (GetAllCommand) command;
-
-                Collection<Entry> entries;
-
-                if (getAllCmd.revision() != 0) {
-                    entries = storage.getAll(getAllCmd.keys(), 
getAllCmd.revision());
-                } else {
-                    entries = storage.getAll(getAllCmd.keys());
-                }
-
-                clo.result((Serializable) entries);
-            } else {
-                assert false : "Command was not found [cmd=" + command + ']';
-            }
-        }
-    }
-
-    @Override
-    public void onWrite(Iterator<CommandClosure<WriteCommand>> iter) {
-        while (iter.hasNext()) {
-            CommandClosure<WriteCommand> clo = iter.next();
-
-            if (writeHandler.handleWriteCommand(clo)) {
-                continue;
-            }
-
-            WriteCommand command = clo.command();
-
-            if (command instanceof CreateRangeCursorCommand) {
-                var rangeCmd = (CreateRangeCursorCommand) command;
-
-                IgniteUuid cursorId = rangeCmd.cursorId();
-
-                Cursor<Entry> cursor = rangeCmd.revUpperBound() != -1
-                        ? storage.range(rangeCmd.keyFrom(), rangeCmd.keyTo(), 
rangeCmd.revUpperBound(), rangeCmd.includeTombstones())
-                        : storage.range(rangeCmd.keyFrom(), rangeCmd.keyTo(), 
rangeCmd.includeTombstones());
-
-                var cursorMeta = new CursorMeta(cursor, 
rangeCmd.requesterNodeId());
-
-                cursors.put(cursorId, cursorMeta);
-
-                clo.result(cursorId);
-            } else if (command instanceof CreatePrefixCursorCommand) {
-                var prefixCmd = (CreatePrefixCursorCommand) command;
-
-                IgniteUuid cursorId = prefixCmd.cursorId();
-
-                Cursor<Entry> cursor = prefixCmd.revUpperBound() == -1
-                        ? storage.prefix(prefixCmd.prefix(), 
prefixCmd.includeTombstones())
-                        : storage.prefix(prefixCmd.prefix(), 
prefixCmd.revUpperBound(), prefixCmd.includeTombstones());
-
-                var cursorMeta = new CursorMeta(cursor, 
prefixCmd.requesterNodeId());
-
-                cursors.put(cursorId, cursorMeta);
+            try {
+                if (command instanceof GetCommand) {
+                    GetCommand getCmd = (GetCommand) command;
 
-                clo.result(cursorId);
-            } else if (command instanceof NextBatchCommand) {
-                var nextBatchCommand = (NextBatchCommand) command;
+                    Entry e;
 
-                CursorMeta cursorMeta = 
cursors.get(nextBatchCommand.cursorId());
+                    if (getCmd.revision() != 0) {

Review Comment:
   I didn't write this code and haven't looked at it, but I think this part is 
incorrect, we usually use `-1` as the "current" revision. I'll fix this. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to