fluent-plugin-mongo 0.6.13 → 0.7.0
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.
- data/ChangeLog +9 -0
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/bin/mongo-tail +2 -2
- data/fluent-plugin-mongo.gemspec +2 -2
- data/lib/fluent/plugin/in_mongo_tail.rb +1 -1
- data/lib/fluent/plugin/out_mongo.rb +10 -16
- data/lib/fluent/plugin/out_mongo_replset.rb +1 -1
- data/test/plugin/out_mongo.rb +11 -2
- metadata +8 -8
    
        data/ChangeLog
    CHANGED
    
    | @@ -1,3 +1,12 @@ | |
| 1 | 
            +
            Release 0.7.0 - 2012/03/20
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            	* Upgrade mongo gem least version to 1.8
         | 
| 4 | 
            +
            	* Upgrade fluentd gem least version to 0.10.9
         | 
| 5 | 
            +
            	* Use new classes with mongo gem version 1.8
         | 
| 6 | 
            +
            	* Replace safe with write_concern option in output plugins
         | 
| 7 | 
            +
            	* Change buffer_chunk_limit to 8MB when mongod version is 1.8 or later.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
             | 
| 1 10 | 
             
            Release 0.6.13 - 2012/01/15
         | 
| 2 11 |  | 
| 3 12 | 
             
            	* Add exclude_broken_fields config to output plugins
         | 
    
        data/README.rdoc
    CHANGED
    
    | @@ -208,7 +208,7 @@ MongoDB returns error or mongo-ruby-driver raises an exception. | |
| 208 208 |  | 
| 209 209 | 
             
            So, Mongo plugin resets _buffer_chunk_limit_ if configurated value is larger than above limitation:
         | 
| 210 210 | 
             
            - Before v1.8, max of _buffer_chunk_limit_ is 2MB
         | 
| 211 | 
            -
            - After | 
| 211 | 
            +
            - After  v1.8, max of _buffer_chunk_limit_ is 8MB
         | 
| 212 212 |  | 
| 213 213 | 
             
            == Disable collection check
         | 
| 214 214 |  | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0. | 
| 1 | 
            +
            0.7.0
         | 
    
        data/bin/mongo-tail
    CHANGED
    
    | @@ -29,10 +29,10 @@ OptionParser.new { |opt| | |
| 29 29 | 
             
            }
         | 
| 30 30 |  | 
| 31 31 | 
             
            def get_capped_collection(conf)
         | 
| 32 | 
            -
              db = Mongo:: | 
| 32 | 
            +
              db = Mongo::MongoClient.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  | 
| 35 | 
            +
                if collection.capped?
         | 
| 36 36 | 
             
                  collection
         | 
| 37 37 | 
             
                else
         | 
| 38 38 | 
             
                  puts "#{conf[:c]} is not capped. mongo-tail can not tail normal collection."
         | 
    
        data/fluent-plugin-mongo.gemspec
    CHANGED
    
    | @@ -16,8 +16,8 @@ Gem::Specification.new do |gem| | |
| 16 16 | 
             
              gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         | 
| 17 17 | 
             
              gem.require_paths = ['lib']
         | 
| 18 18 |  | 
| 19 | 
            -
              gem.add_dependency "fluentd", "~> 0.10. | 
| 20 | 
            -
              gem.add_dependency "mongo", "~> 1. | 
| 19 | 
            +
              gem.add_dependency "fluentd", "~> 0.10.9"
         | 
| 20 | 
            +
              gem.add_dependency "mongo", "~> 1.8.0"
         | 
| 21 21 | 
             
              gem.add_development_dependency "rake", ">= 0.9.2"
         | 
| 22 22 | 
             
              gem.add_development_dependency "simplecov", ">= 0.5.4"
         | 
| 23 23 | 
             
              gem.add_development_dependency "rr", ">= 1.0.0"
         | 
| @@ -70,7 +70,7 @@ class MongoTailInput < Input | |
| 70 70 | 
             
                  db = authenticate(Mongo::Connection.new(@host, @port).db(@database))
         | 
| 71 71 | 
             
                  raise ConfigError, "'#{@database}.#{@collection}' not found: node = #{@host}:#{@port}" unless db.collection_names.include?(@collection)
         | 
| 72 72 | 
             
                  collection = db.collection(@collection)
         | 
| 73 | 
            -
                  raise ConfigError, "'#{@database}.#{@collection}' is not capped: node = #{@host}:#{@port}" unless  | 
| 73 | 
            +
                  raise ConfigError, "'#{@database}.#{@collection}' is not capped: node = #{@host}:#{@port}" unless collection.capped?
         | 
| 74 74 | 
             
                  collection
         | 
| 75 75 | 
             
                rescue Mongo::ConnectionFailure => e
         | 
| 76 76 | 
             
                  $log.fatal "Failed to connect to 'mongod'. Please restart 'fluentd' after 'mongod' started: #{e}"
         | 
| @@ -19,14 +19,14 @@ class MongoOutput < BufferedOutput | |
| 19 19 | 
             
              config_param :port, :integer, :default => 27017
         | 
| 20 20 | 
             
              config_param :ignore_invalid_record, :bool, :default => false
         | 
| 21 21 | 
             
              config_param :disable_collection_check, :bool, :default => nil
         | 
| 22 | 
            -
              config_param :safe, :bool, :default => true
         | 
| 23 22 | 
             
              config_param :exclude_broken_fields, :string, :default => nil
         | 
| 23 | 
            +
              config_param :write_concern, :integer, :default => nil
         | 
| 24 24 |  | 
| 25 25 | 
             
              # tag mapping mode
         | 
| 26 26 | 
             
              config_param :tag_mapped, :bool, :default => false
         | 
| 27 27 | 
             
              config_param :remove_tag_prefix, :string, :default => nil
         | 
| 28 28 |  | 
| 29 | 
            -
              attr_reader :collection_options
         | 
| 29 | 
            +
              attr_reader :collection_options, :connection_options
         | 
| 30 30 |  | 
| 31 31 | 
             
              def initialize
         | 
| 32 32 | 
             
                super
         | 
| @@ -55,7 +55,6 @@ class MongoOutput < BufferedOutput | |
| 55 55 |  | 
| 56 56 | 
             
                @exclude_broken_fields = @exclude_broken_fields.split(',') if @exclude_broken_fields
         | 
| 57 57 |  | 
| 58 | 
            -
                # capped configuration
         | 
| 59 58 | 
             
                if conf.has_key?('capped')
         | 
| 60 59 | 
             
                  raise ConfigError, "'capped_size' parameter is required on <store> of Mongo output" unless conf.has_key?('capped_size')
         | 
| 61 60 | 
             
                  @collection_options[:capped] = true
         | 
| @@ -63,7 +62,7 @@ class MongoOutput < BufferedOutput | |
| 63 62 | 
             
                  @collection_options[:max] = Config.size_value(conf['capped_max']) if conf.has_key?('capped_max')
         | 
| 64 63 | 
             
                end
         | 
| 65 64 |  | 
| 66 | 
            -
                @connection_options[: | 
| 65 | 
            +
                @connection_options[:w] = @write_concern unless @write_concern.nil?
         | 
| 67 66 |  | 
| 68 67 | 
             
                # MongoDB uses BSON's Date for time.
         | 
| 69 68 | 
             
                def @timef.format_nocache(time)
         | 
| @@ -78,11 +77,7 @@ class MongoOutput < BufferedOutput | |
| 78 77 | 
             
                get_or_create_collection(@collection) unless @tag_mapped
         | 
| 79 78 |  | 
| 80 79 | 
             
                # From configure for avoding complex method dependency...
         | 
| 81 | 
            -
                 | 
| 82 | 
            -
                  @buffer.buffer_chunk_limit = available_buffer_chunk_limit
         | 
| 83 | 
            -
                else
         | 
| 84 | 
            -
                  $log.warn "#{Fluent::VERSION} does not have :buffer_chunk_limit. Be careful when insert large documents to MongoDB"
         | 
| 85 | 
            -
                end
         | 
| 80 | 
            +
                @buffer.buffer_chunk_limit = available_buffer_chunk_limit
         | 
| 86 81 |  | 
| 87 82 | 
             
                super
         | 
| 88 83 | 
             
              end
         | 
| @@ -147,7 +142,7 @@ class MongoOutput < BufferedOutput | |
| 147 142 | 
             
                  new_record[BROKEN_DATA_KEY] = BSON::Binary.new(Marshal.dump(record))
         | 
| 148 143 | 
             
                  new_record
         | 
| 149 144 | 
             
                }
         | 
| 150 | 
            -
                collection.insert(converted_records) | 
| 145 | 
            +
                collection.insert(converted_records)
         | 
| 151 146 | 
             
              end
         | 
| 152 147 |  | 
| 153 148 | 
             
              def collect_records(chunk)
         | 
| @@ -177,7 +172,7 @@ class MongoOutput < BufferedOutput | |
| 177 172 | 
             
                if @db.collection_names.include?(collection_name)
         | 
| 178 173 | 
             
                  collection = @db.collection(collection_name)
         | 
| 179 174 | 
             
                  unless @disable_collection_check
         | 
| 180 | 
            -
                    capped =  | 
| 175 | 
            +
                    capped = collection.capped?
         | 
| 181 176 | 
             
                    unless @collection_options[:capped] == capped # TODO: Verify capped configuration
         | 
| 182 177 | 
             
                      new_mode = format_collection_mode(@collection_options[:capped])
         | 
| 183 178 | 
             
                      old_mode = format_collection_mode(capped)
         | 
| @@ -196,17 +191,17 @@ class MongoOutput < BufferedOutput | |
| 196 191 | 
             
              end
         | 
| 197 192 |  | 
| 198 193 | 
             
              def get_connection
         | 
| 199 | 
            -
                db = Mongo:: | 
| 194 | 
            +
                db = Mongo::MongoClient.new(@host, @port, @connection_options).db(@database)
         | 
| 200 195 | 
             
                authenticate(db)
         | 
| 201 196 | 
             
              end
         | 
| 202 197 |  | 
| 203 198 | 
             
              # Following limits are heuristic. BSON is sometimes bigger than MessagePack and JSON.
         | 
| 204 | 
            -
              LIMIT_BEFORE_v1_8 = 2 * 1024 * 1024  # 2MB | 
| 205 | 
            -
              LIMIT_AFTER_v1_8 =  | 
| 199 | 
            +
              LIMIT_BEFORE_v1_8 = 2 * 1024 * 1024  # 2MB = 4MB  / 2
         | 
| 200 | 
            +
              LIMIT_AFTER_v1_8 =  8 * 1024 * 1024  # 8MB = 16MB / 2
         | 
| 206 201 |  | 
| 207 202 | 
             
              def available_buffer_chunk_limit
         | 
| 208 203 | 
             
                begin
         | 
| 209 | 
            -
                  limit = mongod_version >= "1.8.0" ? LIMIT_AFTER_v1_8 : LIMIT_BEFORE_v1_8 | 
| 204 | 
            +
                  limit = mongod_version >= "1.8.0" ? LIMIT_AFTER_v1_8 : LIMIT_BEFORE_v1_8
         | 
| 210 205 | 
             
                rescue Mongo::ConnectionFailure => e
         | 
| 211 206 | 
             
                  $log.fatal "Failed to connect to 'mongod'. Please restart 'fluentd' after 'mongod' started: #{e}"
         | 
| 212 207 | 
             
                  exit!
         | 
| @@ -214,7 +209,6 @@ class MongoOutput < BufferedOutput | |
| 214 209 | 
             
                  $log.fatal "Operation failed. Probably, 'mongod' needs an authentication: #{e}"
         | 
| 215 210 | 
             
                  exit!
         | 
| 216 211 | 
             
                rescue Exception => e
         | 
| 217 | 
            -
                  # TODO: should do exit?
         | 
| 218 212 | 
             
                  $log.warn "mongo unknown error #{e}, set #{LIMIT_BEFORE_v1_8} to chunk limit"
         | 
| 219 213 | 
             
                  limit = LIMIT_BEFORE_v1_8
         | 
| 220 214 | 
             
                end
         | 
| @@ -50,7 +50,7 @@ class MongoOutputReplset < MongoOutput | |
| 50 50 | 
             
              end
         | 
| 51 51 |  | 
| 52 52 | 
             
              def get_connection
         | 
| 53 | 
            -
                db = Mongo:: | 
| 53 | 
            +
                db = Mongo::MongoReplicaSetClient.new(@nodes, @connection_options).db(@database)
         | 
| 54 54 | 
             
                authenticate(db)
         | 
| 55 55 | 
             
              end
         | 
| 56 56 |  | 
    
        data/test/plugin/out_mongo.rb
    CHANGED
    
    | @@ -32,7 +32,7 @@ class MongoOutputTest < Test::Unit::TestCase | |
| 32 32 | 
             
                conf = conf + %[
         | 
| 33 33 | 
             
                  port #{@@mongod_port}
         | 
| 34 34 | 
             
                ]
         | 
| 35 | 
            -
                @db = Mongo:: | 
| 35 | 
            +
                @db = Mongo::MongoClient.new('localhost', @@mongod_port).db(MONGO_DB_DB)
         | 
| 36 36 | 
             
                Fluent::Test::BufferedOutputTestDriver.new(Fluent::MongoOutput).configure(conf)
         | 
| 37 37 | 
             
              end
         | 
| 38 38 |  | 
| @@ -51,11 +51,20 @@ class MongoOutputTest < Test::Unit::TestCase | |
| 51 51 | 
             
                assert_equal('localhost', d.instance.host)
         | 
| 52 52 | 
             
                assert_equal(@@mongod_port, d.instance.port)
         | 
| 53 53 | 
             
                assert_equal({:capped => true, :size => 100}, d.instance.collection_options)
         | 
| 54 | 
            +
                assert(d.instance.connection_options.empty?)
         | 
| 54 55 | 
             
                # buffer_chunk_limit moved from configure to start
         | 
| 55 56 | 
             
                # I will move this test to correct space after BufferedOutputTestDriver supports start method invoking
         | 
| 56 57 | 
             
                # assert_equal(Fluent::MongoOutput::LIMIT_BEFORE_v1_8, d.instance.instance_variable_get(:@buffer).buffer_chunk_limit)
         | 
| 57 58 | 
             
              end
         | 
| 58 59 |  | 
| 60 | 
            +
              def test_configure_with_write_concern
         | 
| 61 | 
            +
                d = create_driver(default_config + %[
         | 
| 62 | 
            +
                  write_concern 2
         | 
| 63 | 
            +
                ])
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                assert_equal({:w => 2}, d.instance.connection_options)
         | 
| 66 | 
            +
              end
         | 
| 67 | 
            +
             | 
| 59 68 | 
             
              def test_format
         | 
| 60 69 | 
             
                d = create_driver
         | 
| 61 70 |  | 
| @@ -198,7 +207,7 @@ class MongoReplOutputTest < MongoOutputTest | |
| 198 207 | 
             
              end
         | 
| 199 208 |  | 
| 200 209 | 
             
              def create_driver(conf = default_config)
         | 
| 201 | 
            -
                @db = Mongo:: | 
| 210 | 
            +
                @db = Mongo::MongoReplicaSetClient.new(build_seeds(3), :name => @rs.name).db(MONGO_DB_DB)
         | 
| 202 211 | 
             
                Fluent::Test::BufferedOutputTestDriver.new(Fluent::MongoOutputReplset).configure(conf)
         | 
| 203 212 | 
             
              end
         | 
| 204 213 |  | 
    
        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. | 
| 4 | 
            +
              version: 0.7.0
         | 
| 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: 2013- | 
| 12 | 
            +
            date: 2013-03-19 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: fluentd
         | 
| @@ -18,7 +18,7 @@ dependencies: | |
| 18 18 | 
             
                requirements:
         | 
| 19 19 | 
             
                - - ~>
         | 
| 20 20 | 
             
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            -
                    version: 0.10. | 
| 21 | 
            +
                    version: 0.10.9
         | 
| 22 22 | 
             
              type: :runtime
         | 
| 23 23 | 
             
              prerelease: false
         | 
| 24 24 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| @@ -26,7 +26,7 @@ dependencies: | |
| 26 26 | 
             
                requirements:
         | 
| 27 27 | 
             
                - - ~>
         | 
| 28 28 | 
             
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            -
                    version: 0.10. | 
| 29 | 
            +
                    version: 0.10.9
         | 
| 30 30 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 31 31 | 
             
              name: mongo
         | 
| 32 32 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -34,7 +34,7 @@ dependencies: | |
| 34 34 | 
             
                requirements:
         | 
| 35 35 | 
             
                - - ~>
         | 
| 36 36 | 
             
                  - !ruby/object:Gem::Version
         | 
| 37 | 
            -
                    version: 1. | 
| 37 | 
            +
                    version: 1.8.0
         | 
| 38 38 | 
             
              type: :runtime
         | 
| 39 39 | 
             
              prerelease: false
         | 
| 40 40 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| @@ -42,7 +42,7 @@ dependencies: | |
| 42 42 | 
             
                requirements:
         | 
| 43 43 | 
             
                - - ~>
         | 
| 44 44 | 
             
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            -
                    version: 1. | 
| 45 | 
            +
                    version: 1.8.0
         | 
| 46 46 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 47 47 | 
             
              name: rake
         | 
| 48 48 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -136,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 136 136 | 
             
                  version: '0'
         | 
| 137 137 | 
             
                  segments:
         | 
| 138 138 | 
             
                  - 0
         | 
| 139 | 
            -
                  hash:  | 
| 139 | 
            +
                  hash: -2812294622738366735
         | 
| 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:  | 
| 148 | 
            +
                  hash: -2812294622738366735
         | 
| 149 149 | 
             
            requirements: []
         | 
| 150 150 | 
             
            rubyforge_project: 
         | 
| 151 151 | 
             
            rubygems_version: 1.8.23
         |