xiaokang commented on code in PR #44329:
URL: https://github.com/apache/doris/pull/44329#discussion_r1851224451


##########
extension/logstash/lib/logstash/outputs/doris.rb:
##########
@@ -90,17 +90,17 @@ def print_plugin_info()
    end
 
    def register
-      @http_query = "/api/#{db}/#{table}/_stream_load"
+      @http_query = "/api/#{@db}/#{@table}/_stream_load"
 
       @hostnames_pool =
-      parse_http_hosts(http_hosts,
+      parse_http_hosts(@http_hosts,
       ShortNameResolver.new(ttl: @host_resolve_ttl_sec, logger: @logger))
 
       @request_headers = make_request_headers
       @logger.info("request headers: ", @request_headers)
 
       @group_commit = false
-      if http_headers.has_key?("group_commit") && http_headers["group_commit"] 
!= "off_mode"
+      if @request_headers.has_key?("group_commit") && 
@request_headers["group_commit"] != "off_mode"

Review Comment:
   Is it a mistake to use http_headers?



##########
extension/logstash/lib/logstash/util/formater.rb:
##########
@@ -0,0 +1,65 @@
+# 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.
+
+require 'java'
+
+class Formater
+
+  # copied form 
https://www.rubydoc.info/gems/logstash-event/LogStash/Event#sprintf-instance_method
+  # modified by doris

Review Comment:
   explain the modified content and reason.



##########
extension/logstash/lib/logstash/outputs/doris.rb:
##########
@@ -211,7 +211,15 @@ def send_events(events)
          rescue => e
             @logger.warn("doris stream load response: #{response} is not a 
valid JSON")
          end
-         if response_json["Status"] == "Success"
+
+         status = response_json["Status"]
+
+         if status == 'Label Already Exists'
+           @logger.warn("Label already exists: #{response_json['Label']}")
+           break

Review Comment:
   What's the effect of break;



##########
extension/logstash/lib/logstash/outputs/doris.rb:
##########
@@ -90,17 +90,17 @@ def print_plugin_info()
    end
 
    def register
-      @http_query = "/api/#{db}/#{table}/_stream_load"
+      @http_query = "/api/#{@db}/#{@table}/_stream_load"

Review Comment:
   Is '@' necessary?



##########
extension/logstash/lib/logstash/outputs/doris.rb:
##########
@@ -252,13 +260,13 @@ def make_request(documents, http_headers, hosts, query, 
host = "")
 
       response = ""
       begin
-         response = RestClient.put(url, documents, http_headers) { |response, 
request, result|
-                case response.code
+         response = RestClient.put(url, documents, http_headers) { |res, 
request, result|

Review Comment:
   Why change response to res?



##########
extension/logstash/lib/logstash/outputs/doris.rb:
##########
@@ -211,7 +211,15 @@ def send_events(events)
          rescue => e
             @logger.warn("doris stream load response: #{response} is not a 
valid JSON")
          end
-         if response_json["Status"] == "Success"
+
+         status = response_json["Status"]
+
+         if status == 'Label Already Exists'
+           @logger.warn("Label already exists: #{response_json['Label']}")
+           break

Review Comment:
   It's more safe to change the lable and retry.



##########
extension/logstash/logstash-output-doris.gemspec:
##########
@@ -41,7 +41,7 @@ Gem::Specification.new do |s|
   s.add_runtime_dependency 'mini_cache', ">= 1.0.0", "< 2.0.0"
   s.add_runtime_dependency "rest-client", '~> 2.1'
 
-  s.add_development_dependency 'logstash-devutils', '~> 2.0', '>= 2.0.3'
-  s.add_development_dependency 'sinatra', '~> 2.0', '>= 2.0.8.1'
-  s.add_development_dependency 'webrick', '~> 1.6'
+  s.add_development_dependency 'logstash-devutils', '~> 1.3'

Review Comment:
   Why change version?



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