TsukiokaKogane commented on code in PR #60557:
URL: https://github.com/apache/doris/pull/60557#discussion_r2780638429


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/doris/FeServiceClient.java:
##########
@@ -173,42 +301,462 @@ public RemoteOlapTable getOlapTable(String dbName, 
String table, long tableId, L
                 removedPartitions = new ArrayList<>();
             }
             remoteOlapTable.rebuildPartitions(partitions, updatedPartitions, 
removedPartitions);
+            // rebuild temp partitions
+            if (result.isSetUpdatedTempPartitions() && 
result.getUpdatedTempPartitionsSize() > 0) {
+                updatedPartitions = new 
ArrayList<>(result.getUpdatedTempPartitionsSize());
+                for (ByteBuffer buffer : result.getUpdatedTempPartitions()) {
+                    try (ByteArrayInputStream in =
+                            new ByteArrayInputStream(buffer.array(), 
buffer.position(), buffer.remaining());
+                            DataInputStream dataInputStream = new 
DataInputStream(in)) {
+                        String partitionStr = Text.readString(dataInputStream);
+                        Partition partition = 
GsonUtils.GSON.fromJson(partitionStr, Partition.class);
+                        updatedPartitions.add(partition);
+                    }
+                }
+            }
+            removedPartitions = result.getRemovedTempPartitions();
+            if (removedPartitions == null) {
+                removedPartitions = new ArrayList<>();
+            }
+            remoteOlapTable.rebuildTempPartitions(tempPartitions, 
updatedPartitions, removedPartitions);
             return remoteOlapTable;
-        }, msg, timeout);
+        }, msg, timeoutMs);
+    }
+
+    public TBeginRemoteTxnResult beginRemoteTxn(TBeginRemoteTxnRequest 
request) throws Exception {
+        request.setUser(user);
+        request.setPasswd(password);
+        String msg = String.format("failed to begin remote txn from remote 
doris:%s, label=%s", name,
+                request.getLabel());
+        long startTime = System.currentTimeMillis();
+        TBeginRemoteTxnResult result;
+        try {
+            result = masterCallWithRetry(client -> 
client.beginRemoteTxn(request), msg,
+                    Math.max(timeoutMs, (int) request.getTimeoutMs()));
+        } catch (Exception e) {
+            long costMs = System.currentTimeMillis() - startTime;
+            LOG.warn("begin remote txn for catalog {} failed, cost={}ms", 
name, costMs, e);
+            throw e;
+        }
+
+        long costMs = System.currentTimeMillis() - startTime;
+        LOG.info("begin remote txn for catalog {} finished, cost={}ms, 
statusCode={}",
+                name, costMs, result.getStatus().getStatusCode());
+        return result;
+    }
+
+    public TCommitRemoteTxnResult commitRemoteTxn(TCommitRemoteTxnRequest 
request) throws Exception {
+        request.setUser(user);
+        request.setPasswd(password);
+        String msg = String.format("failed to commit remote txn from remote 
doris:%s, txnId=%d", name,
+                request.getTxnId());
+        long startTime = System.currentTimeMillis();
+        TCommitRemoteTxnResult result;
+        try {
+            result = masterCallWithRetry(client -> 
client.commitRemoteTxn(request), msg,
+                    Math.max(timeoutMs, (int) 
request.getInsertVisibleTimeoutMs()));
+        } catch (Exception e) {
+            long costMs = System.currentTimeMillis() - startTime;
+            LOG.warn("commit remote txn for catalog {} failed, txnId={}, 
cost={}ms",
+                    name, request.getTxnId(), costMs, e);
+            throw e;
+        }
+
+        long costMs = System.currentTimeMillis() - startTime;
+        LOG.info("commit remote txn for catalog {} finished, txnId={}, 
cost={}ms, statusCode={}",
+                name, request.getTxnId(), costMs, 
result.getStatus().getStatusCode());
+        return result;
+    }
+
+    public TAbortRemoteTxnResult abortRemoteTxn(TAbortRemoteTxnRequest 
request) throws Exception {
+        request.setUser(user);
+        request.setPasswd(password);
+        String msg = String.format("failed to abort remote txn from remote 
doris:%s, txnId=%d", name,
+                request.getTxnId());
+        long startTime = System.currentTimeMillis();
+        TAbortRemoteTxnResult result;
+        try {
+            result = masterCallWithRetry(client -> 
client.abortRemoteTxn(request), msg, timeoutMs);
+        } catch (Exception e) {
+            long costMs = System.currentTimeMillis() - startTime;
+            LOG.warn("abort remote txn for catalog {} failed, txnId={}, 
cost={}ms",
+                    name, request.getTxnId(), costMs, e);
+            throw e;
+        }
+
+        long costMs = System.currentTimeMillis() - startTime;
+        LOG.info("abort remote txn for catalog {} finished, txnId={}, 
cost={}ms, statusCode={}",
+                name, request.getTxnId(), costMs, 
result.getStatus().getStatusCode());
+        return result;
     }
 
     private interface ThriftCall<T> {
         public T call(FrontendService.Client client) throws Exception;
     }
 
-    private static class MasterResult<T> {
-        boolean isMaster = true;
-        T result;
-        boolean hasError = false;
-        String errorMsg;
+    public TNetworkAddress getMasterAddress() throws RuntimeException {
+        TMasterAddressRequest request = new TMasterAddressRequest();
+        request.setUser(user);
+        request.setPasswd(password);
+        long startTime = System.currentTimeMillis();
+        TMasterAddressResult result;
+        try {
+            result = masterCallWithRetry(client -> 
client.getMasterAddress(request),
+                    "failed to get master address from remote doris:" + name, 
timeoutMs);
+            if (result.isSetMasterAddress()) {
+                master = result.getMasterAddress();
+            }
+            if (result.getStatus().getStatusCode() != TStatusCode.OK) {
+                throw new 
RuntimeException(result.getStatus().getErrorMsgs().get(0));
+            }
+        } catch (Exception e) {
+            long costMs = System.currentTimeMillis() - startTime;
+            LOG.warn("get master address for catalog {} failed, cost={}ms", 
name, costMs, e);
+            throw new RuntimeException(e.getMessage());

Review Comment:
   do you mean getRootCauseStack?



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