fluent-plugin-aerospike 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +13 -0
- data/README.md +60 -0
- data/Rakefile +11 -0
- data/fluent-plugin-aerospike.gemspec +26 -0
- data/lib/fluent/plugin/out_aerospike.rb +88 -0
- data/test/fluent/plugin/out_aerospike_test.rb +70 -0
- data/test/helper.rb +28 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 070dedcc9f21487d7958469da973cbd1371511cd
|
4
|
+
data.tar.gz: aa1e94e01a83b7d1efc49897cb55548c4e1cc2c7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8e9cb50464d0ed21d597751c6bada52653f5fc6c9cdf83ef02f41a0b8e09b94bf7fb6ae443bbabe5066e2ff1bd26851dab41d570a0df8eb9e1ec2c88b5559d75
|
7
|
+
data.tar.gz: 086e9860fdb88b1700065db5748fecf419ed08064877d6faeb1e926b70c9fdbda48d58b7d2bc4afe9b4bf52aff2d2b6605e2fa5220b90b30542f47f6c848cf65
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2014- Hatayama Hideharu
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Fluent::Plugin::Aerospike
|
2
|
+
|
3
|
+
Fluent BufferedOutput plugin for Aerospike
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'fluent-plugin-aerospike'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install fluent-plugin-aerospike
|
20
|
+
|
21
|
+
## Configuration
|
22
|
+
config | default | info
|
23
|
+
-------------------|-----------------|-----
|
24
|
+
address | 127.0.0.1:3000 | address of Aerospike
|
25
|
+
namespace | test | namespace name of Aerospike
|
26
|
+
set | fluent ${tag} | set name of Aerospike
|
27
|
+
ttl | 0 | time-to-live: If ttl = 0, the default ttl specified on the server side will be applied
|
28
|
+
time_key | | this time_key field or time of record is used
|
29
|
+
time_format | | (with time_key) the value of time_key will be parsed with this format
|
30
|
+
|
31
|
+
## Samples
|
32
|
+
### sample: access log
|
33
|
+
config
|
34
|
+
|
35
|
+
<match ***>
|
36
|
+
type aerospike
|
37
|
+
time_key request_time
|
38
|
+
time_format %d/%b/%Y:%H:%M:%S %Z
|
39
|
+
</match>
|
40
|
+
|
41
|
+
log
|
42
|
+
|
43
|
+
{"request_time":"24/Dec/2014:23:59:59 +0700","code":"100","response_time":"1000","site":"git"}
|
44
|
+
|
45
|
+
Aerospike
|
46
|
+
|
47
|
+
aql> select * from test
|
48
|
+
+---------------+------------------------------+-------+---------------+
|
49
|
+
| site | request_time | code | response_time |
|
50
|
+
+---------------+------------------------------+-------+---------------+
|
51
|
+
| "git" | "24/Dec/2014:23:59:59 +0700" | "100" | "1000" |
|
52
|
+
+---------------+------------------------------+-------+---------------+
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
1. Fork it ( https://github.com/[my-github-username]/fluent-plugin-aerospike/fork )
|
57
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
58
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
59
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
60
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "fluent-plugin-aerospike"
|
7
|
+
spec.version = "0.0.0"
|
8
|
+
spec.authors = ["Hatayama Hideharu"]
|
9
|
+
spec.email = ["h.hiddy@gmail.com"]
|
10
|
+
spec.description = %q{Fluent BufferedOutput plugin for Aerospike}
|
11
|
+
spec.summary = spec.description
|
12
|
+
spec.homepage = "https://bitbucket.org/hidepiy/fluent-plugin-aerospike"
|
13
|
+
spec.license = "APLv2"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_runtime_dependency "fluentd", "~> 0"
|
23
|
+
spec.add_dependency "aerospike", "0.1.3"
|
24
|
+
spec.add_dependency "uuidtools", "~> 2.1", ">= 2.1.5"
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Fluent
|
2
|
+
class AerospikeOutput < BufferedOutput
|
3
|
+
# First, register the plugin. NAME is the name of this plugin
|
4
|
+
# and identifies the plugin in the configuration file.
|
5
|
+
Plugin.register_output('aerospike', self)
|
6
|
+
|
7
|
+
# config_param defines a parameter. You can refer a parameter via @path instance variable
|
8
|
+
# Without :default, a parameter is required.
|
9
|
+
|
10
|
+
# Aerospike client settings
|
11
|
+
config_param :address, :string, :default => '127.0.0.1:3000'
|
12
|
+
config_param :namespace, :string, :default => 'test'
|
13
|
+
config_param :set, :string, :default => nil
|
14
|
+
config_param :time_key, :string, :default => nil
|
15
|
+
config_param :time_format, :string, :default => nil
|
16
|
+
config_param :ttl, :integer, :default => 0
|
17
|
+
|
18
|
+
attr_reader :write_policy
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
super
|
22
|
+
require 'aerospike'
|
23
|
+
require 'msgpack'
|
24
|
+
require 'uuidtools'
|
25
|
+
end
|
26
|
+
|
27
|
+
# This method is called before starting.
|
28
|
+
# 'conf' is a Hash that includes configuration parameters.
|
29
|
+
# If the configuration is invalid, raise Fluent::ConfigError.
|
30
|
+
def configure(conf)
|
31
|
+
super
|
32
|
+
# You can also refer raw parameter via conf[name].
|
33
|
+
write_policy = Aerospike::WritePolicy.new(
|
34
|
+
Aerospike::RecordExistsAction::CREATE_ONLY,
|
35
|
+
nil,
|
36
|
+
nil,
|
37
|
+
@ttl,
|
38
|
+
nil
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
# This method is called when starting.
|
43
|
+
# Open sockets or files here.
|
44
|
+
def start
|
45
|
+
super
|
46
|
+
@client = get_client(@address)
|
47
|
+
end
|
48
|
+
|
49
|
+
# This method is called when shutting down.
|
50
|
+
# Shutdown the thread and close sockets or files here.
|
51
|
+
def shutdown
|
52
|
+
@client.close
|
53
|
+
super
|
54
|
+
end
|
55
|
+
|
56
|
+
# This method is called when an event reaches to Fluentd.
|
57
|
+
# Convert the event to a raw string.
|
58
|
+
# [tag, time, record].to_json + "\n"
|
59
|
+
# Alternatively, use msgpack to serialize the object.
|
60
|
+
# [tag, time, record].to_msgpack
|
61
|
+
def format(tag, time, record)
|
62
|
+
[tag, time, record].to_msgpack
|
63
|
+
end
|
64
|
+
|
65
|
+
# This method is called every flush interval. Write the buffer chunk
|
66
|
+
# to files or databases here.
|
67
|
+
# 'chunk' is a buffer chunk that includes multiple formatted
|
68
|
+
# events. You can use 'data = chunk.read' to get all events and
|
69
|
+
# 'chunk.open {|io| ... }' to get IO objects.
|
70
|
+
#
|
71
|
+
# NOTE! This method is called by internal thread, not Fluentd's main thread. So IO wait doesn't affect other plugins.
|
72
|
+
# Optionally, you can use chunk.msgpack_each to deserialize objects.
|
73
|
+
def write(chunk)
|
74
|
+
chunk.msgpack_each {|(tag,time,record)|
|
75
|
+
# key_s = "#{time_key.nil? time : record[time_key]}-#{UUIDTools::UUID.random_create}"
|
76
|
+
key_s = "#{record[@time_key] || time}-#{UUIDTools::UUID.random_create}"
|
77
|
+
set_s = @set || tag
|
78
|
+
key = Aerospike::Key.new(@namespace, set_s, key_s)
|
79
|
+
@client.put(key, record, write_policy)
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
def get_client(address)
|
84
|
+
host_port = address.split(':', 2)
|
85
|
+
return Aerospike::Client.new(host_port[0], host_port[1])
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class DataCounterOutputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
end
|
7
|
+
|
8
|
+
DEFAULT_CONFIG = %[
|
9
|
+
]
|
10
|
+
|
11
|
+
DEFAULT_TAG = 'default_tag'
|
12
|
+
|
13
|
+
def create_driver(conf = DEFAULT_CONFIG, tag = DEFAULT_TAG)
|
14
|
+
Fluent::Test::BufferedOutputTestDriver.new(Fluent::AerospikeOutput, tag).configure(conf)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_configure_default
|
18
|
+
d = create_driver
|
19
|
+
assert_equal '127.0.0.1:3000', d.instance.address
|
20
|
+
assert_equal 'test', d.instance.namespace
|
21
|
+
assert_equal nil, d.instance.set
|
22
|
+
assert_equal nil, d.instance.time_key
|
23
|
+
assert_equal nil, d.instance.time_format
|
24
|
+
assert_equal 0, d.instance.ttl
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_configure
|
28
|
+
d = create_driver(DEFAULT_CONFIG + %[
|
29
|
+
address aerosmith:1234
|
30
|
+
namespace rock
|
31
|
+
set boston
|
32
|
+
ttl 1
|
33
|
+
])
|
34
|
+
assert_equal 'aerosmith:1234', d.instance.address
|
35
|
+
assert_equal 'rock', d.instance.namespace
|
36
|
+
assert_equal 'boston', d.instance.set
|
37
|
+
assert_equal 1, d.instance.ttl
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_format
|
41
|
+
d = create_driver
|
42
|
+
time = Time.parse("2112-09-03 01:23:45 UTC")
|
43
|
+
d.emit({"gerogero" => "Let's get Rocking!", "site" => "yapoo"}, time)
|
44
|
+
d.emit({"gerogero" => "Let's get Rocking!", "site" => "geegero"}, time)
|
45
|
+
d.expect_format "\x93\xABdefault_tag\xCF\x00\x00\x00\x01\f[\xC8\xA1\x82\xA8gerogero\xB2Let's get Rocking!\xA4site\xA5yapoo\x93\xABdefault_tag\xCF\x00\x00\x00\x01\f[\xC8\xA1\x82\xA8gerogero\xB2Let's get Rocking!\xA4site\xA7geegero"
|
46
|
+
# d.run
|
47
|
+
|
48
|
+
# time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
49
|
+
# d.emit({"a"=>1}, time)
|
50
|
+
# d.emit({"a"=>2}, time)
|
51
|
+
|
52
|
+
# d.expect_format %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n]
|
53
|
+
# d.expect_format %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n]
|
54
|
+
|
55
|
+
# d.run
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_write
|
59
|
+
d = create_driver
|
60
|
+
|
61
|
+
# time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
62
|
+
# d.emit({"a"=>1}, time)
|
63
|
+
# d.emit({"a"=>2}, time)
|
64
|
+
|
65
|
+
# ### FileOutput#write returns path
|
66
|
+
# path = d.run
|
67
|
+
# expect_path = "#{TMP_DIR}/out_file_test._0.log.gz"
|
68
|
+
# assert_equal expect_path, path
|
69
|
+
end
|
70
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
require 'fluent/test'
|
15
|
+
unless ENV.has_key?('VERBOSE')
|
16
|
+
nulllogger = Object.new
|
17
|
+
nulllogger.instance_eval {|obj|
|
18
|
+
def method_missing(method, *args)
|
19
|
+
# pass
|
20
|
+
end
|
21
|
+
}
|
22
|
+
$log = nulllogger
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'fluent/plugin/out_aerospike'
|
26
|
+
|
27
|
+
class Test::Unit::TestCase
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-aerospike
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hatayama Hideharu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fluentd
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: aerospike
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.1.3
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.1.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: uuidtools
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.1'
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.1.5
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '2.1'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.1.5
|
89
|
+
description: Fluent BufferedOutput plugin for Aerospike
|
90
|
+
email:
|
91
|
+
- h.hiddy@gmail.com
|
92
|
+
executables: []
|
93
|
+
extensions: []
|
94
|
+
extra_rdoc_files: []
|
95
|
+
files:
|
96
|
+
- ".gitignore"
|
97
|
+
- Gemfile
|
98
|
+
- LICENSE.txt
|
99
|
+
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- fluent-plugin-aerospike.gemspec
|
102
|
+
- lib/fluent/plugin/out_aerospike.rb
|
103
|
+
- test/fluent/plugin/out_aerospike_test.rb
|
104
|
+
- test/helper.rb
|
105
|
+
homepage: https://bitbucket.org/hidepiy/fluent-plugin-aerospike
|
106
|
+
licenses:
|
107
|
+
- APLv2
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.2.0
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Fluent BufferedOutput plugin for Aerospike
|
129
|
+
test_files:
|
130
|
+
- test/fluent/plugin/out_aerospike_test.rb
|
131
|
+
- test/helper.rb
|