DongLiang-0 commented on code in PR #187:
URL: 
https://github.com/apache/doris-flink-connector/pull/187#discussion_r1311053611


##########
flink-doris-connector/src/main/java/org/apache/doris/flink/cfg/DorisConnectionOptions.java:
##########
@@ -27,19 +27,30 @@ public class DorisConnectionOptions implements Serializable 
{
 
     private static final long serialVersionUID = 1L;
 
-    protected final String fenodes;
+    protected String fenodes;
     protected final String username;
     protected final String password;
     protected String jdbcUrl;
+    protected String beNodes;
+    protected boolean enableIntranetAccess;

Review Comment:
   This is a good suggestion



##########
flink-doris-connector/src/main/java/org/apache/doris/flink/cfg/DorisOptions.java:
##########
@@ -107,11 +130,13 @@ public Builder setJdbcUrl(String jdbcUrl) {
         }
 
         public DorisOptions build() {
-            checkNotNull(fenodes, "No fenodes supplied.");

Review Comment:
   Of course



##########
flink-doris-connector/src/main/java/org/apache/doris/flink/sink/BackendUtil.java:
##########
@@ -19,30 +19,55 @@
 
 import org.apache.doris.flink.exception.DorisRuntimeException;
 import org.apache.doris.flink.rest.models.BackendV2;
+import org.apache.doris.flink.rest.models.BackendV2.BackendRowV2;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 public class BackendUtil {
     private static final Logger LOG = 
LoggerFactory.getLogger(BackendUtil.class);
-    private final List<BackendV2.BackendRowV2> backends;
+    private List<BackendV2.BackendRowV2> backends;
     private long pos;
 
     public BackendUtil(List<BackendV2.BackendRowV2> backends) {
         this.backends = backends;
         this.pos = 0;
     }
 
+    public BackendUtil(String beNodes) {
+        this.backends = initBackends(beNodes);
+        this.pos = 0;
+    }
+
+    public List<BackendV2.BackendRowV2> initBackends(String beNodes) {
+        List<BackendV2.BackendRowV2> backends = new ArrayList<>();
+        List<String> nodes = Arrays.asList(beNodes.split(","));
+        nodes.forEach(node -> {
+            if (tryHttpConnection(node)) {
+                node = node.trim();
+                String[] ipAndPort = node.split(":");
+                BackendRowV2 backendRowV2 = new BackendRowV2();
+                backendRowV2.setIp(ipAndPort[0]);
+                backendRowV2.setHttpPort(Integer.parseInt(ipAndPort[1]));
+                backendRowV2.setAlive(true);
+                backends.add(backendRowV2);
+            }
+        });
+        return backends;
+    }
+
     public String getAvailableBackend() {
         long tmp = pos + backends.size();
         while (pos < tmp) {
-            BackendV2.BackendRowV2 backend = backends.get((int) (pos % 
backends.size()));
+            BackendV2.BackendRowV2 backend = backends.get((int) (pos++ % 
backends.size()));

Review Comment:
   Thanks for pointing out the problem here, I've fixed it



##########
flink-doris-connector/src/main/java/org/apache/doris/flink/sink/BackendUtil.java:
##########
@@ -19,30 +19,55 @@
 
 import org.apache.doris.flink.exception.DorisRuntimeException;
 import org.apache.doris.flink.rest.models.BackendV2;
+import org.apache.doris.flink.rest.models.BackendV2.BackendRowV2;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 public class BackendUtil {
     private static final Logger LOG = 
LoggerFactory.getLogger(BackendUtil.class);
-    private final List<BackendV2.BackendRowV2> backends;
+    private List<BackendV2.BackendRowV2> backends;
     private long pos;
 
     public BackendUtil(List<BackendV2.BackendRowV2> backends) {
         this.backends = backends;
         this.pos = 0;
     }
 
+    public BackendUtil(String beNodes) {
+        this.backends = initBackends(beNodes);
+        this.pos = 0;
+    }
+
+    public List<BackendV2.BackendRowV2> initBackends(String beNodes) {

Review Comment:
   Of course



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to