fluent-plugin-cassandra 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.6.4"
12
+ gem "rcov", ">= 0"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.6.4)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.9.2)
10
+ rcov (0.9.10)
11
+ shoulda (2.11.3)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.0.0)
18
+ jeweler (~> 1.6.4)
19
+ rcov
20
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Kazutaka Tomita
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,44 @@
1
+ = fluent-plugin-cassandra
2
+
3
+ = MongoDB output plugin for Fluent
4
+
5
+ == Configuratin
6
+
7
+ <match **> # cassandra's key is tags + event.time.
8
+ type cassandra #
9
+ keyspace Keyspace1 # keyspace
10
+ columnfamily Standard1 # Columnfamily
11
+
12
+ # following attibutes are optional
13
+ host localhost # cassandra's hostname. default localhost
14
+ port 9160 # cassandra's thrft port. default 9160
15
+
16
+ </match>
17
+
18
+ == TODO
19
+
20
+ === More configuration
21
+
22
+ - Create Keyspace
23
+ - Create Columnfamily
24
+ - etc
25
+
26
+ === Infer collection name
27
+
28
+ Fluent tag and event.time is key in Cassandra.
29
+
30
+ == Contributing to fluent-plugin-cassandra
31
+
32
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
33
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
34
+ * Fork the project
35
+ * Start a feature/bugfix branch
36
+ * Commit and push until you are happy with your contribution
37
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
38
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
39
+
40
+ == Copyright
41
+
42
+ Copyright (c) 2011 Kazutaka Tomita. See LICENSE.txt for
43
+ further details.
44
+
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "fluent-plugin-cassandra"
18
+ gem.homepage = "http://github.com/tomitakazutaka/fluent-plugin-cassandra"
19
+ gem.license = "MIT"
20
+ gem.summary = "Cassandra output plugin for Fluent event collector"
21
+ gem.description = "Cassandra output plugin for Fluent event collector"
22
+ gem.email = "tomitakazutaka@gmail.com"
23
+ gem.authors = ["Kazutaka Tomita"]
24
+ gem.add_dependency "fluent", "~> 0.9.14"
25
+ gem.add_dependency "cassandra", "~> 0.12.1"
26
+
27
+ # dependencies defined in Gemfile
28
+ end
29
+ Jeweler::RubygemsDotOrgTasks.new
30
+
31
+ require 'rake/testtask'
32
+ Rake::TestTask.new(:test) do |test|
33
+ test.libs << 'lib' << 'test'
34
+ test.pattern = 'test/**/test_*.rb'
35
+ test.verbose = true
36
+ end
37
+
38
+ require 'rcov/rcovtask'
39
+ Rcov::RcovTask.new do |test|
40
+ test.libs << 'test'
41
+ test.pattern = 'test/**/test_*.rb'
42
+ test.verbose = true
43
+ test.rcov_opts << '--exclude "gems/*"'
44
+ end
45
+
46
+ task :default => :test
47
+
48
+ require 'rake/rdoctask'
49
+ Rake::RDocTask.new do |rdoc|
50
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "fluent-plugin-cassandra #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/fluent/plugin/*.rb')
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,63 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "fluent-plugin-cassandra"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kazutaka Tomita"]
12
+ s.date = "2011-10-03"
13
+ s.description = "Cassandra output plugin for Fluent event collector"
14
+ s.email = "tomitakazutaka@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "fluent-plugin-cassandra.gemspec",
28
+ "lib/fluent/plugin/out_cassandra.rb"
29
+ ]
30
+ s.homepage = "http://github.com/tomitakazutaka/fluent-plugin-cassandra"
31
+ s.licenses = ["MIT"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = "1.8.10"
34
+ s.summary = "Cassandra output plugin for Fluent event collector"
35
+
36
+ if s.respond_to? :specification_version then
37
+ s.specification_version = 3
38
+
39
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
40
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
41
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
42
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
43
+ s.add_development_dependency(%q<rcov>, [">= 0"])
44
+ s.add_runtime_dependency(%q<fluent>, ["~> 0.9.14"])
45
+ s.add_runtime_dependency(%q<cassandra>, ["~> 0.12.1"])
46
+ else
47
+ s.add_dependency(%q<shoulda>, [">= 0"])
48
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
49
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
50
+ s.add_dependency(%q<rcov>, [">= 0"])
51
+ s.add_dependency(%q<fluent>, ["~> 0.9.14"])
52
+ s.add_dependency(%q<cassandra>, ["~> 0.12.1"])
53
+ end
54
+ else
55
+ s.add_dependency(%q<shoulda>, [">= 0"])
56
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
57
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
58
+ s.add_dependency(%q<rcov>, [">= 0"])
59
+ s.add_dependency(%q<fluent>, ["~> 0.9.14"])
60
+ s.add_dependency(%q<cassandra>, ["~> 0.12.1"])
61
+ end
62
+ end
63
+
@@ -0,0 +1,51 @@
1
+ module Fluent
2
+
3
+
4
+ class CassandraOutput < BufferedOutput
5
+ Fluent::Plugin.register_output('cassandra', self)
6
+
7
+ def initialize
8
+ super
9
+ require 'cassandra'
10
+ require 'msgpack'
11
+ end
12
+
13
+ def configure(conf)
14
+ super
15
+
16
+ raise ConfigError, "'Keyspace' parameter is required on file output" unless @keyspace = conf['keyspace']
17
+ raise ConfigError, "'ColumnFamily' parameter is required on file output" unless @columnfamily = conf['columnfamily']
18
+
19
+ @host = conf.has_key?('host') ? conf['host'] : 'localhost'
20
+ @port = conf.has_key?('port') ? conf['port'] : 9160
21
+ end
22
+
23
+ def start
24
+ super
25
+ @connection = Cassandra.new(@keyspace, @host + ':' + @port )
26
+ end
27
+
28
+ def shutdown
29
+ super
30
+ end
31
+
32
+ def format(tag, event)
33
+ [tag,event.time,event.record].to_msgpack
34
+ end
35
+
36
+ def write(chunk)
37
+ chunk.open { |io|
38
+ begin
39
+ MessagePack::Unpacker.new(io).each { |record|
40
+ c_key = record[0] + "_" + record[1].to_s
41
+ @connection.insert(@columnfamily,c_key,record[2])
42
+ }
43
+ rescue EOFError
44
+ # EOFError always occured when reached end of chunk.
45
+ end
46
+ }
47
+ end
48
+ end
49
+
50
+
51
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-cassandra
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kazutaka Tomita
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-03 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: shoulda
16
+ requirement: &16887040 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *16887040
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &16886520 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *16886520
36
+ - !ruby/object:Gem::Dependency
37
+ name: jeweler
38
+ requirement: &16886040 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.6.4
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *16886040
47
+ - !ruby/object:Gem::Dependency
48
+ name: rcov
49
+ requirement: &16885560 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *16885560
58
+ - !ruby/object:Gem::Dependency
59
+ name: fluent
60
+ requirement: &16885080 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 0.9.14
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *16885080
69
+ - !ruby/object:Gem::Dependency
70
+ name: cassandra
71
+ requirement: &16884600 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 0.12.1
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: *16884600
80
+ description: Cassandra output plugin for Fluent event collector
81
+ email: tomitakazutaka@gmail.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files:
85
+ - LICENSE.txt
86
+ - README.rdoc
87
+ files:
88
+ - .document
89
+ - Gemfile
90
+ - Gemfile.lock
91
+ - LICENSE.txt
92
+ - README.rdoc
93
+ - Rakefile
94
+ - VERSION
95
+ - fluent-plugin-cassandra.gemspec
96
+ - lib/fluent/plugin/out_cassandra.rb
97
+ homepage: http://github.com/tomitakazutaka/fluent-plugin-cassandra
98
+ licenses:
99
+ - MIT
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ segments:
111
+ - 0
112
+ hash: 3147957507486541088
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 1.8.10
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: Cassandra output plugin for Fluent event collector
125
+ test_files: []