GoGoWen commented on code in PR #193:
URL: 
https://github.com/apache/doris-flink-connector/pull/193#discussion_r1332713571


##########
flink-doris-connector/src/main/java/org/apache/doris/flink/sink/writer/CacheRecordBuffer.java:
##########
@@ -0,0 +1,107 @@
+// 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.doris.flink.sink.writer;
+
+import org.apache.flink.util.Preconditions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.concurrent.BlockingDeque;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
+
+/**
+ * Channel of record stream and HTTP data stream.
+ */
+public class CacheRecordBuffer extends RecordBuffer{

Review Comment:
   Done



##########
flink-doris-connector/src/main/java/org/apache/doris/flink/sink/writer/CacheRecordBuffer.java:
##########
@@ -0,0 +1,107 @@
+// 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.doris.flink.sink.writer;
+
+import org.apache.flink.util.Preconditions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.concurrent.BlockingDeque;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
+
+/**
+ * Channel of record stream and HTTP data stream.
+ */
+public class CacheRecordBuffer extends RecordBuffer{
+    private static final Logger LOG = 
LoggerFactory.getLogger(CacheRecordBuffer.class);
+    BlockingDeque<ByteBuffer> bufferCache;
+    LinkedBlockingQueue<ByteBuffer> bufferPool;
+
+    public CacheRecordBuffer(int capacity, int queueSize) {
+        super(capacity, queueSize);
+        bufferCache = new LinkedBlockingDeque<>();
+        bufferPool = new LinkedBlockingQueue<>();
+    }
+
+    @Override
+    public void startBufferData() throws IOException{
+        LOG.info("start buffer data, read queue size {}, write queue size {}, 
buffer cache size {}, buffer poll size {}",

Review Comment:
   Done



##########
flink-doris-connector/src/main/java/org/apache/doris/flink/sink/writer/DorisWriter.java:
##########
@@ -182,23 +185,38 @@ private void checkDone() {
                 return;
             }
 
-            // double check to interrupt when loading is true and 
dorisStreamLoad.getPendingLoadFuture().isDone
-            // fix issue #139
+            // double-check the future, to avoid getting the old future
             if (dorisStreamLoad.getPendingLoadFuture() != null
                     && dorisStreamLoad.getPendingLoadFuture().isDone()) {
-                // TODO: introduce cache for reload instead of throwing 
exceptions.
-                String errorMsg;
-                try {
-                    RespContent content = 
dorisStreamLoad.handlePreCommitResponse(dorisStreamLoad.getPendingLoadFuture().get());
-                    errorMsg = content.getMessage();
-                } catch (Exception e) {
-                    errorMsg = e.getMessage();
+                // error happened when loading, now we should stop receive data
+                // and abort previous txn(stream load) and start a new 
txn(stream load)
+                // use send cached data to new txn, then notify to restart the 
stream
+                if (executionOptions.isUseCache()) {
+                    try {
+                        
this.dorisStreamLoad.setHostPort(RestService.getBackend(dorisOptions, 
dorisReadOptions, LOG));

Review Comment:
   Done



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