ascherbakoff commented on code in PR #2450:
URL: https://github.com/apache/ignite-3/pull/2450#discussion_r1307247481


##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/impl/IgniteRpcServer.java:
##########
@@ -52,10 +51,10 @@
 import org.apache.ignite.raft.jraft.rpc.impl.cli.ResetPeerRequestProcessor;
 import org.apache.ignite.raft.jraft.rpc.impl.cli.SnapshotRequestProcessor;
 import 
org.apache.ignite.raft.jraft.rpc.impl.cli.TransferLeaderRequestProcessor;
-import 
org.apache.ignite.raft.jraft.rpc.impl.core.AppendEntriesRequestProcessor;
+import 
org.apache.ignite.raft.jraft.rpc.impl.core.AppendEntriesRequestInterceptor;import
 org.apache.ignite.raft.jraft.rpc.impl.core.AppendEntriesRequestProcessor;

Review Comment:
   Why two imports on one line ?



##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/impl/ActionRequestProcessor.java:
##########
@@ -91,6 +87,8 @@ public void handleRequest(RpcContext rpcCtx, ActionRequest 
request) {
      * @param rpcCtx  The context.
      */
     private void applyWrite(Node node, ActionRequest request, RpcContext 
rpcCtx) {
+        Marshaller commandsMarshaller = 
node.getOptions().requiredCommandsMarshaller();

Review Comment:
   Checking each time for null doesn't make sense. A check can be done once on 
init.



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnAppendEntries.java:
##########
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.table.distributed.schema;
+
+import java.nio.ByteBuffer;
+import org.apache.ignite.internal.catalog.CatalogService;
+import org.apache.ignite.internal.logger.IgniteLogger;
+import org.apache.ignite.internal.logger.Loggers;
+import org.apache.ignite.raft.jraft.Node;
+import org.apache.ignite.raft.jraft.entity.EnumOutter.EntryType;
+import org.apache.ignite.raft.jraft.entity.RaftOutter;
+import org.apache.ignite.raft.jraft.entity.RaftOutter.EntryMeta;
+import org.apache.ignite.raft.jraft.error.RaftError;
+import org.apache.ignite.raft.jraft.rpc.Message;
+import org.apache.ignite.raft.jraft.rpc.RaftRpcFactory;
+import org.apache.ignite.raft.jraft.rpc.RaftServerService;
+import org.apache.ignite.raft.jraft.rpc.RpcRequestClosure;
+import org.apache.ignite.raft.jraft.rpc.RpcRequests.AppendEntriesRequest;
+import 
org.apache.ignite.raft.jraft.rpc.impl.core.AppendEntriesRequestInterceptor;
+import org.apache.ignite.raft.jraft.util.Marshaller;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * An {@link AppendEntriesRequestInterceptor} that rejects requests (by 
returning EBUSY error code) if any of the
+ * incoming commands requires catalog version that is not available locally 
yet.
+ */
+public class CheckCatalogVersionOnAppendEntries implements 
AppendEntriesRequestInterceptor {
+    private static final IgniteLogger LOG = 
Loggers.forClass(CheckCatalogVersionOnAppendEntries.class);
+
+    private static final int NO_VERSION_REQUIREMENT = Integer.MIN_VALUE;
+
+    private final CatalogService catalogService;
+
+    public CheckCatalogVersionOnAppendEntries(CatalogService catalogService) {
+        this.catalogService = catalogService;
+    }
+
+    @Override
+    public @Nullable Message intercept(RaftServerService service, 
AppendEntriesRequest request, RpcRequestClosure done) {
+        if (request.entriesList() == null || request.data() == null) {
+            return null;
+        }
+
+        Node node = (Node) service;
+
+        ByteBuffer allData = request.data().asReadOnlyByteBuffer();
+        int offset = 0;
+
+        for (RaftOutter.EntryMeta entry : request.entriesList()) {
+            int requiredCatalogVersion = 
readRequiredCatalogVersionForMeta(allData, entry, 
node.getOptions().requiredCommandsMarshaller());
+
+            if (requiredCatalogVersion != NO_VERSION_REQUIREMENT && 
!isMetadataAvailableFor(requiredCatalogVersion)) {
+                LOG.warn("Metadata not yet available, group {}, required level 
{}.", request.groupId(), requiredCatalogVersion);
+                return RaftRpcFactory.DEFAULT //

Review Comment:
   We need to keep an eye on a number of rejected messages, some new stat field 
would be great. Can be done as a separate ticket.



##########
modules/raft/src/main/java/org/apache/ignite/internal/raft/server/RaftGroupOptions.java:
##########
@@ -42,6 +43,9 @@ public class RaftGroupOptions {
     /** Configuration of own striped disruptor for FSMCaller service of raft 
node, {@code null} means use shared disruptor. */
     private @Nullable RaftNodeDisruptorConfiguration 
ownFsmCallerExecutorDisruptorConfig;
 
+    /** Marshaller to marshall/unmarshall commands. */
+    private @Nullable Marshaller commandsMarshaller;

Review Comment:
   Why do we need to override marshaller ? For test purposes ?



##########
modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java:
##########
@@ -513,12 +517,18 @@ public class IgniteImpl implements Ignite {
                 SchemaSynchronizationConfiguration.KEY
         );
 
+        LongSupplier delayDurationMsSupplier = () -> 
schemaSyncConfig.delayDuration().value();
+
         catalogManager = new CatalogManagerImpl(
                 new UpdateLogImpl(metaStorageMgr),
                 clockWaiter,
-                () -> schemaSyncConfig.delayDuration().value()
+                delayDurationMsSupplier

Review Comment:
   Why not pass a constant instead of closure ?



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