logstash-input-azure_event_hubs 1.4.7 → 1.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 180938c864f4ab3d685ee1780acae884dec1041b1c950b935b12d5a48bf14667
4
- data.tar.gz: 2c411191905591ab555c6dfce60900c27b417bd6832fc72a909a88327d8f926b
3
+ metadata.gz: b6df7b5517ace2611b9fe482c3614e7955d31a2f43ba03b906e1426c0d475526
4
+ data.tar.gz: 7313f77d50d78a426238edba6d06c1ff1a9f199099db87c1e3c183f2856758f0
5
5
  SHA512:
6
- metadata.gz: c95ed7f2d117194bd58d3ad64dc94e4ec1abe8e5e9bbd9c0baf7d55cabb46be3ee516fc5a17d49e86c8039216d12b97beafcd4adfb6040b42367019f431bc0d8
7
- data.tar.gz: 6d0ef1ef16d8da554cf4caaf1285474015c2e47a51c1afec77fda85c1fb8e568ddaec43a539c658d3614d7916abc0f847419d664df6a3dfb0d967e78ce634ca8
6
+ metadata.gz: 1e3c437f56a83bc77d5d249d4879aa1d9e6f37c6c4a0730e49a73144aeca6edccde825f1cf4094f461d7ab1f78f3f88f8cc7838b62f1b063246673692cf00572
7
+ data.tar.gz: 87d3c7871814028f4ec7036460d3895111b2d86477f88a93038e89f4282bf61cae589f1806f7a66021122ac812dcc07958e63cf75142540efa021463de76f069
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.4.9
2
+ - Fixed issue with `getHostContext` method accessibility, causing plugin not to be able to run [#93](https://github.com/logstash-plugins/logstash-input-azure_event_hubs/pull/93)
3
+
4
+ ## 1.4.8
5
+ - Fixed connection placeholder replacements errors with Logstash `8.15.1` and `8.15.2` [#92](https://github.com/logstash-plugins/logstash-input-azure_event_hubs/pull/92)
6
+
1
7
  ## 1.4.7
2
8
  - [DOCS] Clarify examples for single and multiple event hubs [#90](https://github.com/logstash-plugins/logstash-input-azure_event_hubs/pull/90)
3
9
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.7
1
+ 1.4.9
@@ -332,8 +332,7 @@ class LogStash::Inputs::AzureEventHubs < LogStash::Inputs::Base
332
332
  connections = *params['event_hub_connections'] # ensure array
333
333
  connections.each.with_index do |_connection, i|
334
334
  begin
335
- connection = self.class.replace_placeholders(_connection) if self.class.respond_to? 'replace_placeholders' # 6.x
336
- connection = self.class.replace_env_placeholders(_connection) if self.class.respond_to? 'replace_env_placeholders' # 5.x
335
+ connection = replace_connection_placeholders(_connection)
337
336
  event_hub_name = ConnectionStringBuilder.new(connection).getEventHubName
338
337
  redacted_connection = connection.gsub(/(SharedAccessKey=)([0-9a-zA-Z=+]*)([;]*)(.*)/, '\\1<redacted>\\3\\4')
339
338
  params['event_hub_connections'][i] = redacted_connection # protect from leaking logs
@@ -361,6 +360,25 @@ class LogStash::Inputs::AzureEventHubs < LogStash::Inputs::Base
361
360
 
362
361
  attr_reader :event_hubs_exploded
363
362
 
363
+ def replace_connection_placeholders(value)
364
+ connection = value
365
+ if self.class.respond_to? :replace_placeholders
366
+ # Logstash 6.x
367
+ if self.class.method(:replace_placeholders).arity == 1
368
+ connection = self.class.replace_placeholders(connection)
369
+ else
370
+ # Logstash 8.15.1 and 8.15.2 changed the method arity including a new boolean parameter `refine`.
371
+ # This was fixed in 8.15.3. see https://github.com/elastic/logstash/pull/16485
372
+ connection = self.class.replace_placeholders(connection, false)
373
+ end
374
+ end
375
+
376
+ # Logstash 5.x
377
+ connection = self.class.replace_env_placeholders(connection) if self.class.respond_to? :replace_env_placeholders
378
+
379
+ connection
380
+ end
381
+
364
382
  def register
365
383
  # augment the exploded config with the defaults
366
384
  @event_hubs_exploded.each do |event_hub|
@@ -393,20 +411,7 @@ class LogStash::Inputs::AzureEventHubs < LogStash::Inputs::Base
393
411
  scheduled_executor_service)
394
412
  else
395
413
  @logger.warn("You have NOT specified a `storage_connection_string` for #{event_hub_name}. This configuration is only supported for a single Logstash instance.")
396
- checkpoint_manager = InMemoryCheckpointManager.new
397
- lease_manager = InMemoryLeaseManager.new
398
- event_processor_host = EventProcessorHost.new(
399
- EventProcessorHost.createHostName('logstash'),
400
- event_hub_name,
401
- event_hub['consumer_group'],
402
- event_hub['event_hub_connections'].first.value, #there will only be one in this array by the time it gets here
403
- checkpoint_manager,
404
- lease_manager,
405
- scheduled_executor_service,
406
- nil)
407
- #using java_send to avoid naming conflicts with 'initialize' method
408
- lease_manager.java_send :initialize, [HostContext], event_processor_host.getHostContext
409
- checkpoint_manager.java_send :initialize, [HostContext], event_processor_host.getHostContext
414
+ event_processor_host = create_in_memory_event_processor_host(event_hub, event_hub_name, scheduled_executor_service)
410
415
  end
411
416
  options = EventProcessorOptions.new
412
417
  options.setMaxBatchSize(max_batch_size)
@@ -478,4 +483,38 @@ class LogStash::Inputs::AzureEventHubs < LogStash::Inputs::Base
478
483
  @logger.debug("interrupted while waiting to close executor service, this can generally be ignored", :exception => e, :backtrace => e.backtrace) if e
479
484
  end
480
485
  end
486
+
487
+ def create_in_memory_event_processor_host(event_hub, event_hub_name, scheduled_executor_service)
488
+ checkpoint_manager = InMemoryCheckpointManager.new
489
+ lease_manager = InMemoryLeaseManager.new
490
+ event_processor_host = EventProcessorHost.new(
491
+ EventProcessorHost.createHostName('logstash'),
492
+ event_hub_name,
493
+ event_hub['consumer_group'],
494
+ event_hub['event_hub_connections'].first.value, #there will only be one in this array by the time it gets here
495
+ checkpoint_manager,
496
+ lease_manager,
497
+ scheduled_executor_service,
498
+ nil)
499
+ host_context = get_host_context(event_processor_host)
500
+ #using java_send to avoid naming conflicts with 'initialize' method
501
+ lease_manager.java_send :initialize, [HostContext], host_context
502
+ checkpoint_manager.java_send :initialize, [HostContext], host_context
503
+ event_processor_host
504
+ end
505
+
506
+ private
507
+
508
+ # This method is used to get around the fact that recent versions of jruby do not
509
+ # allow access to the package private protected method `getHostContext`
510
+ def get_host_context(event_processor_host)
511
+ call_private(event_processor_host, 'getHostContext')
512
+ end
513
+
514
+ def call_private(clazz, method)
515
+ method = clazz.java_class.declared_method(method)
516
+ method.accessible = true
517
+ method.invoke(clazz)
518
+ end
519
+
481
520
  end
@@ -207,10 +207,10 @@ describe LogStash::Inputs::AzureEventHubs do
207
207
  register_counter = java.util.concurrent.atomic.AtomicInteger.new
208
208
  unregister_counter = java.util.concurrent.atomic.AtomicInteger.new
209
209
  assertion_count = java.util.concurrent.atomic.AtomicInteger.new
210
+ allow(input).to receive(:get_host_context) {mock_host_context}
210
211
  allow_any_instance_of(InMemoryLeaseManager).to receive(:java_send)
211
212
  allow_any_instance_of(InMemoryCheckpointManager).to receive(:java_send)
212
213
 
213
- allow(mock_host).to receive(:getHostContext) {mock_host_context}
214
214
  allow(mock_host_context).to receive(:getEventHubPath) {"foo"}
215
215
 
216
216
  expect(mock_host).to receive(:registerEventProcessorFactory).at_most(3).times {
@@ -256,6 +256,11 @@ describe LogStash::Inputs::AzureEventHubs do
256
256
  expect(assertion_count.get).to be == 3
257
257
  end
258
258
 
259
+ it "can create an in memory EPH" do
260
+ #event_hub, event_hub_name, scheduled_executor_service
261
+ exploded_config = input.event_hubs_exploded
262
+ input.create_in_memory_event_processor_host(exploded_config[0], exploded_config[0]['event_hubs'].first, nil)
263
+ end
259
264
  end
260
265
 
261
266
  describe "Bad Basic Config" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-azure_event_hubs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.7
4
+ version: 1.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-07 00:00:00.000000000 Z
11
+ date: 2024-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -17,8 +17,8 @@ dependencies:
17
17
  - !ruby/object:Gem::Version
18
18
  version: '2.0'
19
19
  name: logstash-core-plugin-api
20
- prerelease: false
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
@@ -31,8 +31,8 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0'
33
33
  name: logstash-codec-plain
34
- prerelease: false
35
34
  type: :runtime
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
@@ -45,8 +45,8 @@ dependencies:
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  name: logstash-codec-json
48
- prerelease: false
49
48
  type: :runtime
49
+ prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
@@ -59,8 +59,8 @@ dependencies:
59
59
  - !ruby/object:Gem::Version
60
60
  version: 0.0.22
61
61
  name: stud
62
- prerelease: false
63
62
  type: :runtime
63
+ prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
@@ -73,8 +73,8 @@ dependencies:
73
73
  - !ruby/object:Gem::Version
74
74
  version: 1.0.0
75
75
  name: logstash-devutils
76
- prerelease: false
77
76
  type: :development
77
+ prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubygems_version: 3.2.33
134
+ rubygems_version: 3.3.26
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: Consumes events from Azure Event Hubs for use with Logstash