bluster 0.5.3-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +86 -0
- data/lib/bluster.rb +13 -0
- data/lib/bluster/cluster_config.rb +32 -0
- data/lib/bluster/listener.rb +21 -0
- data/lib/bluster/version.rb +5 -0
- data/lib/ordasity.rb +9 -0
- data/spec/bluster/cluster_config_spec.rb +37 -0
- data/spec/spec_helper.rb +7 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 31d744ce0e17ed492c2e1b2365555c95a9d3962b
|
4
|
+
data.tar.gz: ec3ba97d19f1b327c99166e7f8dcd424a4e7395c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ebb878c5e06ca0598e6c9e2b2e834ca3ecbc6bb1604f7451e766e71723835bae3c3c5caaccd71746903effd1c89537c46e746d3ed1f7dfa3ed848e127a9ba42e
|
7
|
+
data.tar.gz: 12b7c42903c9ef19e8a7ce2ee7be3fd7a39baa568e9994978a500ce4d313e8375a17a624363299fd2dbadcc3305de4bbb038172092786be08de14252cb7b24e6
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# bluster
|
2
|
+
|
3
|
+
Bluster is a thin JRuby wrapper around Boundary's [Ordasity](https://github.com/boundary/ordasity), and it's purpose is
|
4
|
+
merely to make the API a bit friendlier for (J)Ruby developers.
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
The [docs](https://github.com/boundary/ordasity) provided by Boundary are themselves well enough to get up and running,
|
9
|
+
even without the following example.
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
require 'bluster'
|
13
|
+
|
14
|
+
class SimpleListener < Bluster::ClusterListener
|
15
|
+
def joined(client)
|
16
|
+
puts "Joined cluster!"
|
17
|
+
puts "Got one of them ZooKeeper clients: #{client}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def start_work(unit)
|
21
|
+
puts "Woohoo! Claimed this one: #{unit}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def shutdown_work(unit)
|
25
|
+
puts "Booh! Shutting down this one: #{unit}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def left
|
29
|
+
puts 'Aww, bummer, leaving'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
cluster_options = {
|
34
|
+
hosts: 'localhost:2181',
|
35
|
+
zk_timeout: 5,
|
36
|
+
drain_time: 1,
|
37
|
+
rebalance_interval: 1,
|
38
|
+
}
|
39
|
+
|
40
|
+
cluster = Bluster.create_cluster('simple', SimpleListener.new, cluster_options)
|
41
|
+
cluster.join
|
42
|
+
|
43
|
+
sleep 3
|
44
|
+
|
45
|
+
cluster.shutdown
|
46
|
+
```
|
47
|
+
|
48
|
+
There is also a very similar example in ```examples/simple.rb```, though it
|
49
|
+
should be mentioned that it requires the ```zk``` gem as well (which is included
|
50
|
+
as a development dependency in the gemspec).
|
51
|
+
|
52
|
+
The aim of the examples was actually to have a cluster with two listeners, but
|
53
|
+
JMX didn't seem to like it when I started two listeners with the same name on
|
54
|
+
the same host, and I don't really have the time to debug that right now, so a
|
55
|
+
single listener will have to do.
|
56
|
+
|
57
|
+
## Installation
|
58
|
+
|
59
|
+
```
|
60
|
+
gem install bluster
|
61
|
+
```
|
62
|
+
|
63
|
+
## Known issues and limitations
|
64
|
+
|
65
|
+
* It is not possible to override ```#initialize``` when subclassing one of the
|
66
|
+
listener classes (```Bluster::ClusterListener```, ```Bluster::SmartListener```).
|
67
|
+
I'm not really sure _WHY_, but there's probably a good reason.
|
68
|
+
Thinking about adding some kind of convenience method / option to circumvent this.
|
69
|
+
|
70
|
+
## bluster?
|
71
|
+
|
72
|
+
Talk in a loud, aggressive, or indignant way with little effect.
|
73
|
+
|
74
|
+
## Copyright
|
75
|
+
Copyright 2013 Mathias Söderberg
|
76
|
+
|
77
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
78
|
+
this file except in compliance with the License. You may obtain a copy of the
|
79
|
+
License at
|
80
|
+
|
81
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
82
|
+
|
83
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
84
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
85
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
86
|
+
specific language governing permissions and limitations under the License.
|
data/lib/bluster.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'ordasity'
|
4
|
+
|
5
|
+
require 'bluster/cluster_config'
|
6
|
+
require 'bluster/listener'
|
7
|
+
|
8
|
+
module Bluster
|
9
|
+
def self.create_cluster(name, listener, options = {})
|
10
|
+
config = Bluster::ClusterConfig.create(options)
|
11
|
+
Ordasity::Cluster.new(name, listener, config)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Bluster
|
4
|
+
class ClusterConfig
|
5
|
+
def self.create(options = {})
|
6
|
+
config = Ordasity::ClusterConfig.new
|
7
|
+
|
8
|
+
options.each do |option, value|
|
9
|
+
config.send(wrap_with_prefix(option), value)
|
10
|
+
end
|
11
|
+
|
12
|
+
config
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.wrap_with_prefix(option)
|
16
|
+
[prefix_for(option), option].join(UNDERSCORE).to_sym
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.prefix_for(option)
|
20
|
+
PREFIXES[option] || SET_PREFIX
|
21
|
+
end
|
22
|
+
|
23
|
+
SET_PREFIX = 'set'.freeze
|
24
|
+
UNDERSCORE = '_'.freeze
|
25
|
+
|
26
|
+
PREFIXES = {
|
27
|
+
soft_handoff: 'set_use',
|
28
|
+
smart_balancing: 'use'
|
29
|
+
}.freeze
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Bluster
|
2
|
+
module RubyesqueListenerCallbacks
|
3
|
+
def joined(client); end
|
4
|
+
def start_work(*args); end
|
5
|
+
def shutdown_work(unit); end
|
6
|
+
def left; end
|
7
|
+
|
8
|
+
def onJoin(client); joined(client); end
|
9
|
+
def startWork(*args); start_work(*args); end
|
10
|
+
def shutdownWork(unit); shutdown_work(unit); end
|
11
|
+
def onLeave; left; end
|
12
|
+
end
|
13
|
+
|
14
|
+
class ClusterListener < Ordasity::ClusterListener
|
15
|
+
include RubyesqueListenerCallbacks
|
16
|
+
end
|
17
|
+
|
18
|
+
class SmartListener < Ordasity::SmartListener
|
19
|
+
include RubyesqueListenerCallbacks
|
20
|
+
end
|
21
|
+
end
|
data/lib/ordasity.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'ordasity-jars'
|
2
|
+
|
3
|
+
module Ordasity
|
4
|
+
java_import 'com.boundary.ordasity.Cluster'
|
5
|
+
java_import 'com.boundary.ordasity.ClusterConfig'
|
6
|
+
java_import 'com.boundary.ordasity.Listener'
|
7
|
+
java_import 'com.boundary.ordasity.ClusterListener'
|
8
|
+
java_import 'com.boundary.ordasity.SmartListener'
|
9
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Bluster
|
4
|
+
describe ClusterConfig do
|
5
|
+
describe '.create' do
|
6
|
+
let :config do
|
7
|
+
Bluster::ClusterConfig.create({
|
8
|
+
hosts: 'localhost:2181,localhost:2182',
|
9
|
+
auto_rebalance: true,
|
10
|
+
rebalance_interval: 10,
|
11
|
+
drain_time: 10,
|
12
|
+
smart_balancing: true,
|
13
|
+
zk_timeout: 2000,
|
14
|
+
work_unit_name: 'work-units',
|
15
|
+
work_unit_short_name: 'work',
|
16
|
+
node_id: '1234',
|
17
|
+
soft_handoff: true,
|
18
|
+
handoff_shutdown_delay: 10
|
19
|
+
})
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'creates a Ordasity::ClusterConfig object with given options' do
|
23
|
+
config.hosts.should == 'localhost:2181,localhost:2182'
|
24
|
+
config.enableAutoRebalance.should be_true
|
25
|
+
config.autoRebalanceInterval.should == 10
|
26
|
+
config.drainTime.should == 10
|
27
|
+
config.useSmartBalancing.should be_true
|
28
|
+
config.zkTimeout.should == 2000
|
29
|
+
config.workUnitName.should == 'work-units'
|
30
|
+
config.workUnitShortName.should == 'work'
|
31
|
+
config.nodeId.should_not be_nil
|
32
|
+
config.useSoftHandoff.should be_true
|
33
|
+
config.handoffShutdownDelay.should == 10
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bluster
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.3
|
5
|
+
platform: java
|
6
|
+
authors:
|
7
|
+
- Mathias Söderberg
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ordasity-jars
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.5.3
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - '='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.5.3
|
25
|
+
prerelease: false
|
26
|
+
type: :runtime
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: zk
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
prerelease: false
|
40
|
+
type: :development
|
41
|
+
description: |
|
42
|
+
Bluster is a thin JRuby wrapper for Ordasity
|
43
|
+
email:
|
44
|
+
- mths@sdrbrg.se
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- lib/bluster.rb
|
50
|
+
- lib/ordasity.rb
|
51
|
+
- lib/bluster/cluster_config.rb
|
52
|
+
- lib/bluster/listener.rb
|
53
|
+
- lib/bluster/version.rb
|
54
|
+
- README.md
|
55
|
+
- spec/spec_helper.rb
|
56
|
+
- spec/bluster/cluster_config_spec.rb
|
57
|
+
homepage: http://github.com/mthssdrbrg/bluster
|
58
|
+
licenses:
|
59
|
+
- Apache License 2.0
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.9.2
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.0.5
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Bluster is a thin JRuby wrapper for Ordasity
|
81
|
+
test_files:
|
82
|
+
- spec/spec_helper.rb
|
83
|
+
- spec/bluster/cluster_config_spec.rb
|