bitflicker64 commented on code in PR #3388:
URL: https://github.com/apache/hugegraph/pull/3388#discussion_r4409506260


##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/gremlin/GremlinRestExecutorFactory.java:
##########
@@ -0,0 +1,125 @@
+/*
+ * 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.hugegraph.api.gremlin;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.URI;
+import java.net.UnknownHostException;
+import java.nio.file.Path;
+
+import org.apache.hugegraph.auth.StandardAuthenticator;
+import org.apache.hugegraph.auth.WsAndHttpBasicAuthHandler;
+import org.apache.hugegraph.config.HugeConfig;
+import org.apache.hugegraph.config.ServerOptions;
+import org.apache.hugegraph.server.HugeGraphWsAndHttpChannelizer;
+import org.apache.hugegraph.util.E;
+import org.apache.tinkerpop.gremlin.server.GremlinServer;
+import org.apache.tinkerpop.gremlin.server.Settings;
+import org.apache.tinkerpop.gremlin.server.auth.AllowAllAuthenticator;
+
+public final class GremlinRestExecutorFactory {
+
+    private GremlinRestExecutorFactory() {
+    }
+
+    public static GremlinRestExecutor standalone(HugeConfig config) {
+        return new ForwardGremlinRestExecutor(config);
+    }
+
+    public static GremlinRestExecutor create(HugeConfig config, GremlinServer 
server,
+                                             String restConfigFile) throws 
IOException {
+        Settings settings = server.getServerGremlinExecutor().getSettings();
+        URI target = URI.create(config.get(ServerOptions.GREMLIN_SERVER_URL));
+        if (!targetsLocalServer(target, settings)) {
+            return new ForwardGremlinRestExecutor(config);
+        }
+        
E.checkArgument(HugeGraphWsAndHttpChannelizer.class.getName().equals(settings.channelizer),

Review Comment:
   Important: with the default local `gremlinserver.url`, a custom channelizer, 
a Gremlin authorizer, a custom `HugeAuthenticator` or a `tokens` path that 
differs from the REST config now aborts `HugeGraphServer` startup, although 
HTTP forwarding served these setups before and no option restores it. Return 
`ForwardGremlinRestExecutor` with a warning for unsupported local combinations 
instead of throwing.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to