activerecord-crate-adapter 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -5
- data/README.md +24 -20
- data/activerecord-crate-adapter.gemspec +5 -6
- data/history.txt +7 -0
- data/lib/active_record/connection_adapters/crate_adapter.rb +6 -1
- data/lib/activerecord-crate-adapter/version.rb +1 -1
- data/spec/data_types/array_spec.rb +2 -1
- data/spec/data_types/object_spec.rb +2 -1
- data/spec/models/post_spec.rb +2 -1
- data/spec/spec_helper.rb +18 -3
- data/spec/test_server.rb +27 -38
- metadata +13 -16
- data/spec/travis_test_server.rb +0 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4ded4506bbde8a818b21084414eebea95deb49e
|
4
|
+
data.tar.gz: 4ad62050c12839e881c4c940aca845b6a45144d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac47bffc111c1dcef655bf62a5553f40d5b4ff42908e8f3ede12c2b34bbf5ff02bb362e912d9bb2c3fd4146b535ec8370e4b33cb096ebf6909f4261eb07735fa
|
7
|
+
data.tar.gz: a29e36b5e7cca424ab1233eb8d68884330e5befce62168180533c2b4b87c7cf257298ea1d7cf1ea77566e1b0d4aa390630dc10451aa8ab2927f97f4729e53676
|
data/.travis.yml
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
3
|
- "1.9.3"
|
4
|
-
- "2.1.1"
|
5
4
|
- "2.0.0"
|
5
|
+
- "2.1.5"
|
6
|
+
- "2.2.0"
|
6
7
|
# uncomment this line if your project needs to run something other than `rake`:
|
7
8
|
|
8
9
|
before_script:
|
9
|
-
- wget https://cdn.crate.io/downloads/releases/crate-0.
|
10
|
+
- wget https://cdn.crate.io/downloads/releases/crate-0.47.3.tar.gz -O /tmp/crate.tar.gz
|
10
11
|
- tar -xvf /tmp/crate.tar.gz
|
11
|
-
-
|
12
|
-
- echo $PWD
|
13
|
-
- bundle exec ruby spec/travis_test_server.rb $PWD/crate-0.39.0/ 4209
|
12
|
+
- bundle exec ruby spec/test_server.rb $PWD/crate-0.47.3/ true
|
14
13
|
|
15
14
|
script: bundle exec rspec spec
|
16
15
|
|
data/README.md
CHANGED
@@ -8,6 +8,8 @@ The [Crate](http://www.crate.io) adapter for ActiveRecord.
|
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
|
+
**Note:** `activerecord-crate-adapter` currently only works with Rails 4.1.x
|
12
|
+
|
11
13
|
Add this line to your application's Gemfile:
|
12
14
|
|
13
15
|
gem 'activerecord-crate-adapter'
|
@@ -44,20 +46,20 @@ please add an issue so we can discuss.
|
|
44
46
|
end
|
45
47
|
|
46
48
|
end
|
47
|
-
|
49
|
+
|
48
50
|
## Special Data Types
|
49
51
|
|
50
52
|
### Array
|
51
53
|
You can simply create Array columns by specifying t.array and passing array_type when you create a migration.
|
52
|
-
|
54
|
+
|
53
55
|
t.array :tags, array_type: :string
|
54
56
|
t.array :votes, array_type: :integer
|
55
57
|
t.array :bool_arr, array_type: :boolean
|
56
|
-
|
58
|
+
|
57
59
|
When you create an object just pass your Array directly
|
58
60
|
|
59
61
|
Post.create!(title: 'Arrays are awesome', tags: %w(hot fresh), votes: [1,2])
|
60
|
-
post = Post.where("'fresh' = ANY (tags)")
|
62
|
+
post = Post.where("'fresh' = ANY (tags)")
|
61
63
|
|
62
64
|
### Object
|
63
65
|
Crate allows you to define nested objects. I tried to make it as simply as possible to use and reuse existing AR functionality,
|
@@ -69,27 +71,27 @@ I tried to make your guys life easier and created a module that does this automa
|
|
69
71
|
and assign it in the initializer. So a serialized class should look like this:
|
70
72
|
|
71
73
|
require 'active_record/attribute_methods/crate_object'
|
72
|
-
|
74
|
+
|
73
75
|
class Address
|
74
76
|
attr_accessor :street, :city, :phones, :zip
|
75
|
-
|
77
|
+
|
76
78
|
include CrateObject
|
77
|
-
|
79
|
+
|
78
80
|
def initialize(opts)
|
79
81
|
@street = opts[:street]
|
80
82
|
@city = opts[:city]
|
81
83
|
@phones = opts[:phones]
|
82
84
|
@zip = opts[:zip]
|
83
85
|
end
|
84
|
-
|
86
|
+
|
85
87
|
end
|
86
88
|
|
87
|
-
Check out CrateObject module if you need to write your own serializer.
|
88
|
-
|
89
|
+
Check out CrateObject module if you need to write your own serializer.
|
90
|
+
|
89
91
|
Then in your model simply use #serialize to have objects working
|
90
92
|
|
91
|
-
class User < ActiveRecord::Base
|
92
|
-
serialize :address, Address
|
93
|
+
class User < ActiveRecord::Base
|
94
|
+
serialize :address, Address
|
93
95
|
end
|
94
96
|
|
95
97
|
Note: I do not plan to support nested objects inside objects.
|
@@ -97,11 +99,11 @@ Note: I do not plan to support nested objects inside objects.
|
|
97
99
|
#### Object Migrations
|
98
100
|
|
99
101
|
In the migrations you can create an object and specify the object behaviour(strict|dynamic|ignored) and it's schema.
|
100
|
-
|
102
|
+
|
101
103
|
t.object :address, object_schema_behaviour: :strict,
|
102
104
|
object_schema: {street: :string, city: :string, phones: {array: :string}, zip: :integer}
|
103
|
-
|
104
|
-
|
105
|
+
|
106
|
+
|
105
107
|
|
106
108
|
## Migrations
|
107
109
|
|
@@ -121,13 +123,14 @@ Crate does not support Joins (yet) so joins won't work.
|
|
121
123
|
|
122
124
|
## Tests
|
123
125
|
|
124
|
-
|
126
|
+
Start up the crate server before running the tests
|
127
|
+
|
128
|
+
ruby spec/test_server.rb /path/to/crate
|
125
129
|
|
126
|
-
|
130
|
+
Then run tests with
|
127
131
|
|
128
|
-
|
132
|
+
bundle exec rspec spec
|
129
133
|
|
130
|
-
$ rspec spec
|
131
134
|
|
132
135
|
## Contributing
|
133
136
|
|
@@ -141,4 +144,5 @@ Please refer to CONTRIBUTING.rst for further information.
|
|
141
144
|
* [Christoph Klocker](http://www.vedanova.com), [@corck](http://www.twitter.com/corck)
|
142
145
|
|
143
146
|
##License & Copyright
|
144
|
-
|
147
|
+
|
148
|
+
see LICENSE for details.
|
@@ -28,8 +28,8 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.version = ActiverecordCrateAdapter::VERSION
|
29
29
|
spec.authors = ["Christoph Klocker", "CRATE Technology GmbH"]
|
30
30
|
spec.email = ["office@crate.io"]
|
31
|
-
spec.summary = "ActiveRecord
|
32
|
-
spec.description = "ActiveRecord adapter for Crate
|
31
|
+
spec.summary = "ActiveRecord adapter for Crate"
|
32
|
+
spec.description = "ActiveRecord adapter for Crate, the distributed database for Docker."
|
33
33
|
spec.homepage = "https://crate.io"
|
34
34
|
spec.license = "Apache License, v2.0"
|
35
35
|
|
@@ -42,8 +42,7 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.add_development_dependency "rake"
|
43
43
|
spec.add_development_dependency "rspec", "~> 2.14"
|
44
44
|
|
45
|
-
spec.add_dependency('activerecord', '
|
46
|
-
spec.add_dependency('arel', '>=
|
47
|
-
spec.add_dependency('crate_ruby', '~> 0.0.
|
48
|
-
|
45
|
+
spec.add_dependency('activerecord', '~> 4.1.0')
|
46
|
+
spec.add_dependency('arel', '>= 5.0.0')
|
47
|
+
spec.add_dependency('crate_ruby', '~> 0.0.7')
|
49
48
|
end
|
data/history.txt
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
# coding: UTF-8
|
2
2
|
|
3
3
|
=== unreleased
|
4
|
+
|
5
|
+
=== 0.0.4
|
6
|
+
|
7
|
+
* Updated crate version to 0.45.7
|
8
|
+
|
4
9
|
=== 0.0.3
|
10
|
+
|
5
11
|
* now officially supported by Crate Data and available under the
|
6
12
|
Apache 2.0 License
|
7
13
|
|
8
14
|
=== 0.0.2
|
15
|
+
|
9
16
|
* Switched query execution to parameter substitution
|
10
17
|
|
11
18
|
=== 0.0.1
|
@@ -131,11 +131,16 @@ module ActiveRecord
|
|
131
131
|
|
132
132
|
def columns(table_name) #:nodoc:
|
133
133
|
cols = @connection.table_structure(table_name).map do |field|
|
134
|
-
|
134
|
+
name = dotted_name(field[2])
|
135
|
+
CrateColumn.new(name, nil, field[4], nil)
|
135
136
|
end
|
136
137
|
cols
|
137
138
|
end
|
138
139
|
|
140
|
+
def dotted_name(name)
|
141
|
+
name.gsub(%r(\[['"]), '.').delete(%{'"]})
|
142
|
+
end
|
143
|
+
|
139
144
|
def tables
|
140
145
|
@connection.tables
|
141
146
|
end
|
@@ -31,6 +31,7 @@ describe "User#object" do
|
|
31
31
|
object_schema: {street: :string, city: :string, phones: {array: :string}, zip: :integer}
|
32
32
|
end
|
33
33
|
end
|
34
|
+
ensure_status('yellow')
|
34
35
|
User.reset_column_information
|
35
36
|
end
|
36
37
|
|
@@ -56,4 +57,4 @@ describe "User#object" do
|
|
56
57
|
|
57
58
|
end
|
58
59
|
|
59
|
-
end
|
60
|
+
end
|
data/spec/models/post_spec.rb
CHANGED
@@ -30,6 +30,7 @@ describe Post do
|
|
30
30
|
t.integer :views
|
31
31
|
end
|
32
32
|
end
|
33
|
+
ensure_status('yellow')
|
33
34
|
Post.reset_column_information
|
34
35
|
end
|
35
36
|
|
@@ -61,7 +62,7 @@ describe Post do
|
|
61
62
|
end
|
62
63
|
|
63
64
|
it 'should persist the record to the database' do
|
64
|
-
@post.persisted?.should
|
65
|
+
@post.persisted?.should eq true
|
65
66
|
refresh_posts
|
66
67
|
Post.count.should eq 1
|
67
68
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -29,6 +29,9 @@ require 'dummy/app/models/address'
|
|
29
29
|
require 'dummy/app/models/post'
|
30
30
|
require 'dummy/app/models/user'
|
31
31
|
|
32
|
+
HOST = "127.0.0.1"
|
33
|
+
PORT = 44200
|
34
|
+
|
32
35
|
RSpec.configure do |config|
|
33
36
|
|
34
37
|
config.before(:each) do
|
@@ -49,8 +52,8 @@ def connect
|
|
49
52
|
'arunit' => {
|
50
53
|
adapter: 'crate',
|
51
54
|
min_messages: 'warning',
|
52
|
-
|
53
|
-
|
55
|
+
host: HOST,
|
56
|
+
port: PORT,
|
54
57
|
}
|
55
58
|
}
|
56
59
|
ActiveRecord::Base.establish_connection :arunit
|
@@ -61,4 +64,16 @@ end
|
|
61
64
|
# query for the primary key
|
62
65
|
def refresh_posts
|
63
66
|
Post.connection.raw_connection.refresh_table('posts')
|
64
|
-
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Wait till all table is synced to all shards
|
70
|
+
# this should be used after each create_table to prevent flaky tests
|
71
|
+
def ensure_status(expected_status)
|
72
|
+
req = Net::HTTP::Get.new("/_cluster/health?wait_for_status=#{expected_status}&timeout=10s")
|
73
|
+
resp = Net::HTTP.new(HOST, PORT)
|
74
|
+
response = resp.start { |http| http.request(req) }
|
75
|
+
actual_status = JSON.parse(response.body)['status']
|
76
|
+
raise WrongStatusError, "expected status #{expected_status}, got #{actual_status}" if actual_status != expected_status
|
77
|
+
end
|
78
|
+
|
79
|
+
class WrongStatusError < StandardError; end
|
data/spec/test_server.rb
CHANGED
@@ -21,57 +21,54 @@
|
|
21
21
|
# software solely pursuant to the terms of the relevant commercial agreement.
|
22
22
|
|
23
23
|
require 'net/http'
|
24
|
+
|
24
25
|
class TestServer
|
25
|
-
CRATE_PATH = "~/crate"
|
26
|
-
TEST_PORT = 4209
|
27
26
|
NAME = "TestCluster"
|
27
|
+
HOST = "127.0.0.1"
|
28
|
+
PORT = 44200
|
29
|
+
TIMEOUT = 30
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
@
|
32
|
-
@port = port || TEST_PORT
|
33
|
-
@host = host
|
31
|
+
def initialize(crate_home = '~/crate', run_in_background = false)
|
32
|
+
@crate_home = crate_home
|
33
|
+
@run_in_background = run_in_background
|
34
34
|
end
|
35
35
|
|
36
36
|
def start
|
37
|
-
cmd = "sh #{File.join(@crate_home, 'bin
|
38
|
-
@pid = spawn(cmd, :
|
37
|
+
cmd = "sh #{File.join(@crate_home, 'bin', 'crate')} #{start_params}"
|
38
|
+
@pid = spawn(cmd, out: "/tmp/crate_test_server.out",
|
39
|
+
err: "/tmp/crate_test_server.err")
|
39
40
|
Process.detach(@pid)
|
40
|
-
puts '
|
41
|
+
puts 'Starting Crate... (this will take a few seconds)'
|
41
42
|
time_slept = 0
|
43
|
+
interval = 2
|
42
44
|
while true
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
if !alive? and time_slept > TIMEOUT
|
46
|
+
puts "Crate hasn't started for #{TIMEOUT} seconds. Giving up now..."
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
if alive? and @run_in_background
|
50
|
+
exit
|
51
|
+
end
|
52
|
+
sleep(interval)
|
53
|
+
time_slept += interval
|
46
54
|
end
|
47
55
|
end
|
48
56
|
|
49
|
-
def stop
|
50
|
-
Process.kill("HUP", @pid)
|
51
|
-
end
|
52
|
-
|
53
57
|
private
|
54
58
|
|
55
|
-
|
56
|
-
def crate_exec
|
57
|
-
end
|
58
|
-
|
59
|
-
def crate_config
|
60
|
-
end
|
61
|
-
|
62
59
|
def start_params
|
63
60
|
"-Des.index.storage.type=memory " +
|
64
61
|
"-Des.node.name=#{NAME} " +
|
65
|
-
"-Des.cluster.name=Testing#{
|
66
|
-
"-Des.http.port=#{
|
62
|
+
"-Des.cluster.name=Testing#{PORT} " +
|
63
|
+
"-Des.http.port=#{PORT}-#{PORT} " +
|
67
64
|
"-Des.network.host=localhost " +
|
68
|
-
"-Des.discovery.
|
69
|
-
"-Des.
|
65
|
+
"-Des.discovery.zen.ping.multicast.enabled=false " +
|
66
|
+
"-Des.es.api.enabled=true"
|
70
67
|
end
|
71
68
|
|
72
69
|
def alive?
|
73
70
|
req = Net::HTTP::Get.new('/')
|
74
|
-
resp = Net::HTTP.new(
|
71
|
+
resp = Net::HTTP.new(HOST, PORT)
|
75
72
|
begin
|
76
73
|
response = resp.start { |http| http.request(req) }
|
77
74
|
response.code == "200" ? true : false
|
@@ -79,15 +76,7 @@ class TestServer
|
|
79
76
|
false
|
80
77
|
end
|
81
78
|
end
|
82
|
-
|
83
79
|
end
|
84
80
|
|
85
|
-
server = TestServer.new
|
81
|
+
server = TestServer.new(*ARGV)
|
86
82
|
server.start
|
87
|
-
|
88
|
-
trap("INT") do
|
89
|
-
puts "Script terminated by user."
|
90
|
-
server.stop
|
91
|
-
puts "Server stopped"
|
92
|
-
exit
|
93
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-crate-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christoph Klocker
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -57,46 +57,45 @@ dependencies:
|
|
57
57
|
name: activerecord
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 4.
|
62
|
+
version: 4.1.0
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 4.
|
69
|
+
version: 4.1.0
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: arel
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - '>='
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 5.0.0
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - '>='
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
83
|
+
version: 5.0.0
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: crate_ruby
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - ~>
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0.0.
|
90
|
+
version: 0.0.7
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - ~>
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 0.0.
|
98
|
-
description: ActiveRecord adapter for Crate
|
99
|
-
document-oriented cluster data store.
|
97
|
+
version: 0.0.7
|
98
|
+
description: ActiveRecord adapter for Crate, the distributed database for Docker.
|
100
99
|
email:
|
101
100
|
- office@crate.io
|
102
101
|
executables: []
|
@@ -132,7 +131,6 @@ files:
|
|
132
131
|
- spec/models/post_spec.rb
|
133
132
|
- spec/spec_helper.rb
|
134
133
|
- spec/test_server.rb
|
135
|
-
- spec/travis_test_server.rb
|
136
134
|
homepage: https://crate.io
|
137
135
|
licenses:
|
138
136
|
- Apache License, v2.0
|
@@ -153,10 +151,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
151
|
version: '0'
|
154
152
|
requirements: []
|
155
153
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.
|
154
|
+
rubygems_version: 2.4.6
|
157
155
|
signing_key:
|
158
156
|
specification_version: 4
|
159
|
-
summary: ActiveRecord
|
157
|
+
summary: ActiveRecord adapter for Crate
|
160
158
|
test_files:
|
161
159
|
- spec/activerecord/connection_adapters/crate/crate_adapter_spec.rb
|
162
160
|
- spec/activerecord/connection_adapters/crate/table_definition_spec.rb
|
@@ -168,4 +166,3 @@ test_files:
|
|
168
166
|
- spec/models/post_spec.rb
|
169
167
|
- spec/spec_helper.rb
|
170
168
|
- spec/test_server.rb
|
171
|
-
- spec/travis_test_server.rb
|
data/spec/travis_test_server.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8; -*-
|
3
|
-
#
|
4
|
-
# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
|
5
|
-
# license agreements. See the NOTICE file distributed with this work for
|
6
|
-
# additional information regarding copyright ownership. Crate licenses
|
7
|
-
# this file to you under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License. You may
|
9
|
-
# obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
-
# License for the specific language governing permissions and limitations
|
17
|
-
# under the License.
|
18
|
-
#
|
19
|
-
# However, if you have executed another commercial license agreement
|
20
|
-
# with Crate these terms will supersede the license and you may use the
|
21
|
-
# software solely pursuant to the terms of the relevant commercial agreement.
|
22
|
-
|
23
|
-
require 'net/http'
|
24
|
-
class TestServer
|
25
|
-
CRATE_PATH = "~/crate"
|
26
|
-
TEST_PORT = 4209
|
27
|
-
NAME = "TestCluster"
|
28
|
-
|
29
|
-
|
30
|
-
def initialize(crate_home = nil, port = nil)
|
31
|
-
@crate_home = crate_home
|
32
|
-
@port = port
|
33
|
-
@host = "127.0.0.1"
|
34
|
-
end
|
35
|
-
|
36
|
-
def start
|
37
|
-
cmd = "sh #{File.join(@crate_home, 'bin/crate')} #{start_params}"
|
38
|
-
@pid = spawn(cmd, :out => "/tmp/crate_test_server.out", :err => "/tmp/crate_test_server.err")
|
39
|
-
Process.detach(@pid)
|
40
|
-
puts 'starting'
|
41
|
-
time_slept = 0
|
42
|
-
while !alive?
|
43
|
-
puts "Crate not yet fully available. Waiting since #{time_slept} seconds..."
|
44
|
-
sleep(2)
|
45
|
-
time_slept += 2
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def start_params
|
52
|
-
"-Des.index.storage.type=memory " +
|
53
|
-
"-Des.node.name=#{NAME} " +
|
54
|
-
"-Des.cluster.name=Testing#{@port} " +
|
55
|
-
"-Des.http.port=#{@port}-#{@port} " +
|
56
|
-
"-Des.network.host=localhost " +
|
57
|
-
"-Des.discovery.type=zen " +
|
58
|
-
"-Des.discovery.zen.ping.multicast.enabled=false"
|
59
|
-
end
|
60
|
-
|
61
|
-
def alive?
|
62
|
-
req = Net::HTTP::Get.new('/')
|
63
|
-
resp = Net::HTTP.new(@host, @port)
|
64
|
-
begin
|
65
|
-
response = resp.start { |http| http.request(req) }
|
66
|
-
response.code == "200" ? true : false
|
67
|
-
rescue Errno::ECONNREFUSED
|
68
|
-
false
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
server = TestServer.new *ARGV
|
75
|
-
server.start
|