@@ -31,29 +31,30 @@ def execution_priority
31
31
# The execute assume that the thread safety access of the pipeline
32
32
# is managed by the caller.
33
33
def execute ( agent , pipelines )
34
- pipeline =
34
+ new_pipeline =
35
35
if @pipeline_config . settings . get_value ( "pipeline.java_execution" )
36
36
LogStash ::JavaPipeline . new ( @pipeline_config , @metric , agent )
37
37
else
38
38
agent . exclusive do
39
39
# The Ruby pipeline initialization is not thread safe because of the module level
40
40
# shared state in LogsStash::Config::AST. When using multiple pipelines this gets
41
- # executed simultaneously in different threads and we need to synchonize this initialization.
41
+ # executed simultaneously in different threads and we need to synchronize this initialization.
42
42
LogStash ::Pipeline . new ( @pipeline_config , @metric , agent )
43
43
end
44
44
end
45
45
46
- status = nil
47
- pipelines . compute ( pipeline_id ) do |id , value |
48
- if value
49
- LogStash ::ConvergeResult ::ActionResult . create ( self , true )
46
+ result = nil
47
+ pipelines . compute ( pipeline_id ) do |_ , current_pipeline |
48
+ if current_pipeline
49
+ result = LogStash ::ConvergeResult ::FailedAction . new ( "Attempted to create a pipeline that already exists" )
50
+ current_pipeline
51
+ else
52
+ result = new_pipeline . start # block until the pipeline is correctly started or crashed
53
+ result ? new_pipeline : nil
50
54
end
51
- status = pipeline . start # block until the pipeline is correctly started or crashed
52
- pipeline # The pipeline is successfully started we can add it to the map
53
55
end
54
56
55
-
56
- LogStash ::ConvergeResult ::ActionResult . create ( self , status )
57
+ LogStash ::ConvergeResult ::ActionResult . create ( self , result )
57
58
end
58
59
59
60
0 commit comments