PakhomovAlexander commented on code in PR #2941:
URL: https://github.com/apache/ignite-3/pull/2941#discussion_r1424386297
##########
modules/rest/src/main/java/org/apache/ignite/internal/rest/authentication/NodeOnlyEndpointsFilter.java:
##########
@@ -78,6 +65,15 @@ public Publisher<MutableHttpResponse<?>>
doFilter(HttpRequest<?> request, Server
throw new IgniteException(Common.INTERNAL_ERR, e);
}
+ if (!restManager.isRestEnabled()) {
+ return Publishers.just(HttpProblemResponse.from(
+ Problem.fromHttpCode(HttpCode.NOT_ACCEPTABLE)
+ .detail("Cluster initialization in progress."
+ + " REST is not available until
initialization finished.")
Review Comment:
"REST is not available until initialization finished" <- This is confusing.
`If` statement here checks if the rest is enabled. But if it is not, we
return the message that does not
logically relate to the if statement. Why do we say: "Cluster initialization
in progress"? Where does this knowledge come from? I think this is a naming
problem. If we "block" REST while the cluster is being initialized, maybe then
we can rename the method from `isRestEnabled` to `isClusterInitializing`? Just
food for thought.
##########
modules/rest/src/main/java/org/apache/ignite/internal/rest/authentication/NodeOnlyEndpointsFilter.java:
##########
@@ -78,6 +65,15 @@ public Publisher<MutableHttpResponse<?>>
doFilter(HttpRequest<?> request, Server
throw new IgniteException(Common.INTERNAL_ERR, e);
}
+ if (!restManager.isRestEnabled()) {
Review Comment:
I think we have to check enable/disable at the start of the method.
##########
modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java:
##########
@@ -863,6 +872,8 @@ public CompletableFuture<Ignite> start(Path configPath) {
}, startupExecutor)
.thenRunAsync(() -> {
try {
+ //Enable REST component on start complete.
+ restComponent.enable();
// Transfer the node to the STARTED state.
lifecycleManager.onStartComplete();
Review Comment:
btw, lifecycleManager can be a good candidate to manage the rest state there
or notify the rest component.
##########
modules/rest/src/main/java/org/apache/ignite/internal/rest/RestManager.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.rest;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.internal.logger.IgniteLogger;
+import org.apache.ignite.internal.logger.Loggers;
+
+/**
+ * Rest manager.
+ */
+public class RestManager {
Review Comment:
To be honest I don't really get what this class is responsible for. It has
two obvious ways of usage:
1) Check if the url path can be used before cluster init.
2) Change the internal state of some flag that indicates whether the REST is
enabled or not.
What confuses me is that this class manages nothing. It does decide nothing.
The naming is misused here.
--
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]