Commit 7cfc2018 authored by Roque's avatar Roque

workaround to keep backward compatibility

parent db891b8b
...@@ -148,7 +148,7 @@ module Embulk ...@@ -148,7 +148,7 @@ module Embulk
@logger.error(data_stream_count["error_message"], print=TRUE) @logger.error(data_stream_count["error_message"], print=TRUE)
@logger.abortExecution() @logger.abortExecution()
end end
data_stream_list = @wendelin.getDataStreamList(@data_set, data_stream_count["result"], @batch_size) data_stream_list = @wendelin.getDataStreamList(@data_set, data_stream_count["result"], @batch_size)
if data_stream_list["status_code"] == 0 if data_stream_list["status_code"] == 0
task['data_streams'] = data_stream_list["result"] task['data_streams'] = data_stream_list["result"]
else else
......
...@@ -185,11 +185,15 @@ class WendelinClient ...@@ -185,11 +185,15 @@ class WendelinClient
end end
def getDataStreamList(data_set_reference, data_stream_count, batch_size) def getDataStreamList(data_set_reference, data_stream_count, batch_size)
#keep backward compatibility
if data_stream_count = -1
return getDataStreams(data_set_reference)
end
data_stream_list = [] data_stream_list = []
total_batches = data_stream_count/batch_size.ceil() total_batches = data_stream_count/batch_size.ceil()
if total_batches > 4 if total_batches > 4
puts puts
@logger.warn("Due to its size, the remote file list will be fetch in batches. This could take some minutes.", print=TRUE) @logger.info("Due to its size, the remote file list will be fetch in batches. This could take some minutes.", print=TRUE)
end end
nbatch = 0 nbatch = 0
while nbatch <= total_batches while nbatch <= total_batches
...@@ -234,19 +238,24 @@ class WendelinClient ...@@ -234,19 +238,24 @@ class WendelinClient
return {'status_code': 0, 'result': []} return {'status_code': 0, 'result': []}
end end
def getDataStreamCount(data_set_reference) def getDataStreamCount(data_set_reference)
uri = URI(URI.escape("#{@erp5_url}ERP5Site_getDataStreamCount?data_set_reference=#{data_set_reference}")) uri = URI(URI.escape("#{@erp5_url}ERP5Site_getDataStreamCount?data_set_reference=#{data_set_reference}"))
response = handleRequest(uri) response = handleRequest(uri)
if response["success"] == FALSE if response["success"] == FALSE
@logger.abortExecution() #keep backward compatibiliy if script doesn't exist in wendelin instance
if response["message"] == 404
@logger.info("Continue with backward compatibility...", print=TRUE)
return {"status_code"=>0, "result"=>-1}
else
@logger.abortExecution()
end
end end
str = response["message"] str = response["message"]
if not str.nil? if not str.nil?
str.gsub!(/(\,)(\S)/, "\\1 \\2") str.gsub!(/(\,)(\S)/, "\\1 \\2")
return YAML::load(str) return YAML::load(str)
end end
return {'status_code': 0, 'result': 0} return {"status_code"=>0, "result"=>0}
end end
private private
...@@ -300,6 +309,8 @@ class WendelinClient ...@@ -300,6 +309,8 @@ class WendelinClient
elsif res.code == '400' elsif res.code == '400'
@logger.error(HTTP_MESSAGE_400, print=TRUE) @logger.error(HTTP_MESSAGE_400, print=TRUE)
@logger.abortExecution() @logger.abortExecution()
elsif res.code == '404'
return {"success"=>FALSE, "message"=>404}
else else
@logger.error(HTTP_MESSAGE_OTHER, print=TRUE) @logger.error(HTTP_MESSAGE_OTHER, print=TRUE)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment