This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new c9582197c82 [fix](cloud-streamload) support stream load cluster load 
balance (#34336)
c9582197c82 is described below

commit c9582197c82b4d802c2c57b1a2eb67e40de29944
Author: HHoflittlefish777 <77738092+hhoflittlefish...@users.noreply.github.com>
AuthorDate: Tue Apr 30 20:03:32 2024 +0800

    [fix](cloud-streamload) support stream load cluster load balance (#34336)
---
 .../org/apache/doris/httpv2/rest/LoadAction.java   | 27 ++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java
index 692f0cc8ad3..c5f442ba832 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java
@@ -275,7 +275,18 @@ public class LoadAction extends RestBaseController {
                     return new RestBaseResult(e.getMessage());
                 }
             } else {
-                redirectAddr = selectRedirectBackend(request, groupCommit);
+                if (Config.isCloudMode()) {
+                    String cloudClusterName = getCloudClusterName(request);
+                    if (Strings.isNullOrEmpty(cloudClusterName)) {
+                        LOG.warn("cluster name is empty in stream load");
+                        return new RestBaseResult("No cloud cluster name 
selected.");
+                    }
+                    String reqHostStr = 
request.getHeader(HttpHeaderNames.HOST.toString());
+                    LOG.info("host header {}", reqHostStr);
+                    redirectAddr = 
selectCloudRedirectBackend(cloudClusterName, reqHostStr, groupCommit);
+                } else {
+                    redirectAddr = selectRedirectBackend(request, groupCommit);
+                }
             }
 
             LOG.info("redirect load action to destination={}, stream: {}, db: 
{}, tbl: {}, label: {}",
@@ -308,7 +319,19 @@ public class LoadAction extends RestBaseController {
                 return new RestBaseResult("No transaction operation(\'commit\' 
or \'abort\') selected.");
             }
 
-            TNetworkAddress redirectAddr = selectRedirectBackend(request, 
false);
+            TNetworkAddress redirectAddr;
+            if (Config.isCloudMode()) {
+                String cloudClusterName = getCloudClusterName(request);
+                if (Strings.isNullOrEmpty(cloudClusterName)) {
+                    LOG.warn("cluster name is empty in stream load");
+                    return new RestBaseResult("No cloud cluster name 
selected.");
+                }
+                String reqHostStr = 
request.getHeader(HttpHeaderNames.HOST.toString());
+                LOG.info("host header {}", reqHostStr);
+                redirectAddr = selectCloudRedirectBackend(cloudClusterName, 
reqHostStr, false);
+            } else {
+                redirectAddr = selectRedirectBackend(request, false);
+            }
             LOG.info("redirect stream load 2PC action to destination={}, db: 
{}, txn: {}, operation: {}",
                     redirectAddr.toString(), dbName, 
request.getHeader(TXN_ID_KEY), txnOperation);
 


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

Reply via email to