fluent-plugin-zookeeper 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 6da100a74494bf6aee6e6f99dd565349cb0b3f94
4
- data.tar.gz: 3226d0a38ea8d2d7c822064bfa144c3d9cbe530e
3
+ metadata.gz: 6ae092a2de92fad8b379a960104c0db3e407422a
4
+ data.tar.gz: 3a6b02377da167826d0f3a9663a39bf1d2141f9c
5
5
  SHA512:
6
- metadata.gz: e3e5bd2c6ca6f7f55ae8ef7d43e1c5c6fab97eb28e77e3d3091827d7bda952437cafaf001ea9401d31eeae8faa5f0e99c563ebec7796d0f02d1e921d72348892
7
- data.tar.gz: efc470264baeb4e87f3c3a446b008d48819f937ab16b6f46137e33ee58abe3bb5ac8ef62d6494a946f296612be4306a2a22ef4af2c8286e2b31ff0d5e2617e63
6
+ metadata.gz: d1d1208b37d537ce23ca660fbfdf2f1bff77733abab07b3cf92e391145b1533a9b3b51f75b74319843e59063ed164ce371f721d47c4308cfd4aafdad9403d24f
7
+ data.tar.gz: 2ce896b6aab4ec0979481df4e2e5fbcf62779e0b9a1affb11cd0cd53bc6b820131abd78c6d172ecd6d87eebcc57b84e4d8f813a649250473993714a13d0e190e
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "fluent-plugin-zookeeper"
6
- spec.version = "0.1.1"
6
+ spec.version = "0.1.2"
7
7
  spec.authors = ["Anton Tikhomirov"]
8
8
  spec.email = ["anton.tikhomirov@cdnetworks.com"]
9
9
 
@@ -39,19 +39,29 @@ DESC
39
39
  end
40
40
 
41
41
  def init_client(raise_exception = true)
42
+ log.info "Initializing connection to Zookeeper"
42
43
  begin
43
- @zk = Zookeeper.new(@servers)
44
+ if @zk.nil?
45
+ @zk = Zookeeper.new(@servers)
46
+ else
47
+ @zk.reopen
48
+ end
44
49
 
45
- case @type
46
- when 'ephemeral'
47
- @zk.create({path: @path, ephemeral: true})
48
- when 'sequence'
49
- @zk.create({path: @path, sequence: true})
50
+ if @zk.connected?
51
+ case @type
52
+ when 'ephemeral'
53
+ @zk.create({path: @path, ephemeral: true})
54
+ when 'sequence'
55
+ @zk.create({path: @path, sequence: true})
56
+ else
57
+ # persistent (or anything else)
58
+ @zk.create({path: @path})
59
+ end
60
+ log.info "Connection to Zookeeper service [#@servers] has been initialized"
61
+ @con_lost_msg = "Connection to Zookeeper was lost"
50
62
  else
51
- # persistent (or anything else)
52
- @zk.create({path: @path})
63
+ log.warn "Cannot establish connection to Zookeeper"
53
64
  end
54
- log.info "Connection to Zookeeper service [#@servers] has been initialized"
55
65
  rescue Exception => e
56
66
  if raise_exception
57
67
  raise e
@@ -91,27 +101,35 @@ DESC
91
101
  end
92
102
 
93
103
  def process(tag, es)
94
- if !@zk.connected?
95
- init_client(false)
96
- end
97
-
98
- begin
99
- es.each do |time, record|
100
- begin
101
- data = @formatter_proc.call(record)
102
- rescue StandardError => e
103
- log.warn "Failed to format record:", :error => e.to_s, :record => record
104
- next
105
- end
106
- if @ignore_empty_msg && data == "{}"
107
- log.debug "Skipping empty record"
108
- next
104
+ if @zk.connected?
105
+ begin
106
+ es.each do |time, record|
107
+ begin
108
+ data = @formatter_proc.call(record)
109
+ rescue StandardError => e
110
+ log.warn "Failed to format record:", :error => e.to_s, :record => record
111
+ next
112
+ end
113
+ if @ignore_empty_msg && data == "{}"
114
+ log.debug "Skipping empty record"
115
+ next
116
+ end
117
+ @zk.set({path: @path, data: data})
109
118
  end
110
- @zk.set({path: @path, data: data})
119
+ rescue Exception => e
120
+ log.error "Exception occurred while sending data: #{e}"
121
+ # Connection will be reinitialized on next call
122
+ @zk.close
123
+ end
124
+ elsif !@zk.connecting?
125
+ # We are not connected and not connecting; it's time to reinit the client
126
+ @zk.close if !@zk.closed?
127
+ init_client(false)
128
+ else
129
+ if !@con_lost_msg.nil?
130
+ log.warn "#@con_lost_msg"
131
+ @con_lost_msg = nil
111
132
  end
112
- rescue Exception => e
113
- log.warn "Exception occurred while sending data: #{e}"
114
- raise e
115
133
  end
116
134
  end
117
135
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-zookeeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Tikhomirov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-10 00:00:00.000000000 Z
11
+ date: 2018-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  requirements: []
137
137
  rubyforge_project:
138
- rubygems_version: 2.5.1
138
+ rubygems_version: 2.5.2.1
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: Fluentd plugin for Apache Zookeeper