fluent-plugin-mongo 0.6.9 → 0.6.10

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,10 @@
1
+ Release 0.6.10 - 2012/10/17
2
+
3
+ * mongo-tail always flush STDOUT for pipeline usage.
4
+ https://github.com/fluent/fluent-plugin-mongo/issues/16
5
+ * Fix capped collection checking for 2.1.x or later versions.
6
+
7
+
1
8
  Release 0.6.9 - 2012/10/12
2
9
 
3
10
  * Fix invalid use of '~>' in gemspec.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.9
1
+ 0.6.10
data/bin/mongo-tail CHANGED
@@ -32,7 +32,7 @@ def get_capped_collection(conf)
32
32
  db = Mongo::Connection.new(conf[:h], conf[:p]).db(conf[:d])
33
33
  if db.collection_names.include?(conf[:c])
34
34
  collection = db.collection(conf[:c])
35
- if collection.capped?
35
+ if [1, true].include?(collection.stats['capped']) # older version(2.0.x or earlier) returns 1
36
36
  collection
37
37
  else
38
38
  puts "#{conf[:c]} is not capped. mongo-tail can not tail normal collection."
@@ -65,7 +65,8 @@ def tail_forever(collection, conf)
65
65
  cursor = Mongo::Cursor.new(collection, cursor_conf) unless cursor.alive?
66
66
 
67
67
  if doc = cursor.next_document
68
- puts doc.to_json
68
+ STDOUT.puts doc.to_json
69
+ STDOUT.flush
69
70
  else
70
71
  sleep 1
71
72
  end
@@ -71,6 +71,9 @@ class MongoOutput < BufferedOutput
71
71
  end
72
72
 
73
73
  def start
74
+ # Non tag mapped mode, we can check collection configuration before server start.
75
+ get_or_create_collection(@collection) unless @tag_mapped
76
+
74
77
  # From configure for avoding complex method dependency...
75
78
  if @buffer.respond_to?(:buffer_chunk_limit)
76
79
  @buffer.buffer_chunk_limit = available_buffer_chunk_limit
@@ -166,8 +169,11 @@ class MongoOutput < BufferedOutput
166
169
  if @db.collection_names.include?(collection_name)
167
170
  collection = @db.collection(collection_name)
168
171
  unless @disable_collection_check
169
- unless @collection_options[:capped] == collection.capped? # TODO: Verify capped configuration
170
- raise ConfigError, "New configuration is different from existing collection"
172
+ capped = [1, true].include?(collection.stats['capped']) # TODO: Remove this check after mongo gem upgrade to 1.7.x
173
+ unless @collection_options[:capped] == capped # TODO: Verify capped configuration
174
+ new_mode = format_collection_mode(@collection_options[:capped])
175
+ old_mode = format_collection_mode(capped)
176
+ raise ConfigError, "New configuration is different from existing collection: new = #{new_mode}, old = #{old_mode}"
171
177
  end
172
178
  end
173
179
  else
@@ -177,6 +183,10 @@ class MongoOutput < BufferedOutput
177
183
  @clients[collection_name] = collection
178
184
  end
179
185
 
186
+ def format_collection_mode(mode)
187
+ mode ? 'capped' : 'normal'
188
+ end
189
+
180
190
  def get_connection
181
191
  db = Mongo::Connection.new(@host, @port, @connection_options).db(@database)
182
192
  authenticate(db)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9
4
+ version: 0.6.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-11 00:00:00.000000000 Z
12
+ date: 2012-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -136,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  segments:
138
138
  - 0
139
- hash: -2718527282239700478
139
+ hash: 2791894013534395416
140
140
  required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  none: false
142
142
  requirements:
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  segments:
147
147
  - 0
148
- hash: -2718527282239700478
148
+ hash: 2791894013534395416
149
149
  requirements: []
150
150
  rubyforge_project:
151
151
  rubygems_version: 1.8.23