fluent-plugin-gc 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bb1437fa02731de3540d7ee9974693f29eb553a0
4
+ data.tar.gz: ba92d752f3347f2c7bce8465944aceb9ed6223b9
5
+ SHA512:
6
+ metadata.gz: 66be4e5f508caa70910d570985ae3b75d6f1e5f2e3b56d2ed01323836fd485257491861565b4ddcd8733bf110878ed52b0e7137b4c170bd3821da25bb4a76c3a
7
+ data.tar.gz: b42512bc252230228aedad80025d196ffc56d91bee92b6edac5c92242579ca7688e46e8d158dbb40db4e5eeb84b77400d0f68cdc448ba8ec44947e10fa4934d4
@@ -0,0 +1,13 @@
1
+ /*.gem
2
+ ~*
3
+ #*
4
+ *~
5
+ .bundle
6
+ Gemfile.lock
7
+ .rbenv-version
8
+ vendor
9
+ doc/*
10
+ tmp/*
11
+ coverage
12
+ .yardoc
13
+ pkg/*
File without changes
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Naotoshi SEO
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ # fluent-plugin-gc [![Build Status](https://secure.travis-ci.org/sonots/fluent-plugin-gc.png?branch=master)](http://travis-ci.org/sonots/fluent-plugin-gc)
2
+
3
+ Fluentd plugin to disable GC and start GC at arbitrary interval
4
+
5
+ ## Configuration
6
+
7
+ Example:
8
+
9
+ <source>
10
+ type gc
11
+ interval 5
12
+ disable yes
13
+ </match>
14
+
15
+ ## Parameters
16
+
17
+ - interval
18
+
19
+ The interval to start GC in seconds. Default is 5s.
20
+
21
+ - diable
22
+
23
+ Disable GC. Default is `no`.
24
+
25
+ - debug
26
+
27
+ Print out GC.stat on the fluentd log. Default is `no`.
28
+
29
+ ## ChangeLog
30
+
31
+ See [CHANGELOG.md](CHANGELOG.md) for details.
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new [Pull Request](../../pull/new/master)
40
+
41
+ ## Copyright
42
+
43
+ Copyright (c) 2013 Naotoshi Seo. See [LICENSE](LICENSE) for details.
44
+
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core'
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = FileList['spec/**/*_spec.rb']
8
+ end
9
+ task :default => :spec
10
+
11
+ desc 'Open an irb session preloaded with the gem library'
12
+ task :console do
13
+ sh 'irb -rubygems -I lib'
14
+ end
15
+ task :c => :console
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "fluent-plugin-gc"
6
+ s.version = "0.0.1"
7
+ s.authors = ["Naotoshi Seo"]
8
+ s.email = ["sonots@gmail.com"]
9
+ s.homepage = "https://github.com/sonots/fluent-plugin-gc"
10
+ s.summary = "Fluentd plugin to disable GC and start GC at arbitrary interval"
11
+ s.description = s.summary
12
+ s.licenses = ["MIT"]
13
+
14
+ s.rubyforge_project = "fluent-plugin-gc"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_runtime_dependency "fluentd"
22
+ s.add_development_dependency "rake"
23
+ s.add_development_dependency "rspec"
24
+ end
@@ -0,0 +1,52 @@
1
+ # encoding: UTF-8
2
+ class Fluent::GcInput < Fluent::Input
3
+ Fluent::Plugin.register_input('gc', self)
4
+
5
+ config_param :disable, :bool, :default => false
6
+ config_param :interval, :time, :default => 5
7
+ config_param :debug, :bool, :default => false
8
+ attr_accessor :last_checked
9
+
10
+ def configure(conf)
11
+ super
12
+
13
+ @interval = @interval.to_i
14
+ end
15
+
16
+ def start
17
+ super
18
+ GC.disable if @disable
19
+ @watcher = Thread.new(&method(:watcher))
20
+ end
21
+
22
+ def shutdown
23
+ super
24
+ @watcher.terminate
25
+ @watcher.join
26
+ end
27
+
28
+ # thread callback
29
+ def watcher
30
+ @last_checked = Fluent::Engine.now
31
+ while true
32
+ sleep 0.5
33
+ begin
34
+ if Fluent::Engine.now - @last_checked >= @interval
35
+ now = Fluent::Engine.now
36
+ start_gc
37
+ @last_checked = now
38
+ end
39
+ rescue => e
40
+ $log.warn "#{e.class} #{e.message} #{e.backtrace.first}"
41
+ end
42
+ end
43
+ end
44
+
45
+ def start_gc
46
+ $log.info "gc: before #{GC.stat}" if @debug # intentionally info level
47
+ disabled = GC.enable
48
+ GC.start
49
+ GC.disable if disabled
50
+ $log.info "gc: after #{GC.stat}" if @debug
51
+ end
52
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: UTF-8
2
+ require 'rubygems'
3
+ require 'bundler'
4
+ Bundler.setup(:default, :test)
5
+ Bundler.require(:default, :test)
6
+
7
+ require 'coveralls'
8
+ Coveralls.wear!
9
+
10
+ require 'fluent/test'
11
+ require 'rspec'
12
+
13
+ $TESTING=true
14
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
15
+ require 'fluent/plugin/in_gc'
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-gc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Naotoshi Seo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluentd
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Fluentd plugin to disable GC and start GC at arbitrary interval
56
+ email:
57
+ - sonots@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - CHANGELOG.md
64
+ - Gemfile
65
+ - LICENSE
66
+ - README.md
67
+ - Rakefile
68
+ - fluent-plugin-gc.gemspec
69
+ - lib/fluent/plugin/in_gc.rb
70
+ - spec/spec_helper.rb
71
+ homepage: https://github.com/sonots/fluent-plugin-gc
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project: fluent-plugin-gc
91
+ rubygems_version: 2.0.3
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Fluentd plugin to disable GC and start GC at arbitrary interval
95
+ test_files:
96
+ - spec/spec_helper.rb