rhoconnect 3.1.1 → 3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +7 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +26 -45
- data/Rakefile +2 -3
- data/bench/bench_runner.rb +37 -37
- data/bench/benchapp/Gemfile.lock +4 -5
- data/bench/benchapp/config.ru +1 -5
- data/bench/benchapp/spec/spec_helper.rb +0 -13
- data/bench/blobapp/Gemfile.lock +8 -9
- data/bench/blobapp/config.ru +1 -2
- data/bench/blobapp/spec/spec_helper.rb +0 -13
- data/bench/lib/bench/aws_utils.rb +0 -1
- data/bench/spec/bench_spec_helper.rb +1 -1
- data/doc/java-plugin.txt +176 -49
- data/doc/net-plugin.txt +150 -70
- data/doc/plugin-intro.txt +2 -2
- data/doc/supported-platforms.txt +12 -11
- data/generators/templates/application/config.ru +1 -2
- data/generators/templates/application/spec/spec_helper.rb +0 -15
- data/install.sh +3 -3
- data/installer/unix-like/create_texts.rb +2 -2
- data/installer/unix-like/rho_connect_install_constants.rb +3 -3
- data/installer/unix-like/rho_connect_install_utilities.rb +0 -1
- data/installer/utils/constants.rb +5 -5
- data/installer/utils/create_sha1.rb +26 -0
- data/installer/utils/delete_from_s3.rb +32 -0
- data/installer/utils/download_from_s3.rb +55 -0
- data/installer/utils/nix_install_test.rb +29 -19
- data/installer/utils/package_upload/repos.rake +52 -40
- data/installer/utils/package_upload/s3_upload.rb +7 -28
- data/installer/utils/verify_checksum.rb +33 -0
- data/installer/windows/rhosync.nsi +5 -5
- data/lib/rhoconnect.rb +1 -1
- data/lib/rhoconnect/app.rb +0 -3
- data/lib/rhoconnect/predefined_adapters/bench_adapter.rb +6 -0
- data/lib/rhoconnect/server.rb +27 -24
- data/lib/rhoconnect/stats/middleware.rb +13 -8
- data/lib/rhoconnect/store.rb +12 -10
- data/lib/rhoconnect/version.rb +1 -1
- data/rhoconnect.gemspec +2 -2
- data/spec/api/admin/api_token_spec.rb +0 -1
- data/spec/api/admin/stats_spec.rb +3 -0
- data/spec/api/api_helper.rb +2 -2
- data/spec/api/user/list_users_spec.rb +2 -2
- data/spec/api_token_spec.rb +0 -1
- data/spec/app_spec.rb +0 -1
- data/spec/bulk_data/bulk_data_spec.rb +0 -1
- data/spec/client_spec.rb +0 -1
- data/spec/client_sync_spec.rb +0 -2
- data/spec/document_spec.rb +0 -1
- data/spec/dynamic_adapter_spec.rb +0 -2
- data/spec/jobs/bulk_data_job_spec.rb +0 -1
- data/spec/jobs/ping_job_spec.rb +0 -1
- data/spec/jobs/source_job_spec.rb +0 -1
- data/spec/license_spec.rb +0 -1
- data/spec/perf/perf_spec_helper.rb +0 -1
- data/spec/ping/android_spec.rb +0 -1
- data/spec/ping/apple_spec.rb +0 -1
- data/spec/ping/blackberry_spec.rb +0 -1
- data/spec/read_state_spec.rb +0 -1
- data/spec/rhoconnect_spec.rb +0 -1
- data/spec/server/server_spec.rb +1 -12
- data/spec/source_adapter_spec.rb +0 -1
- data/spec/source_spec.rb +0 -1
- data/spec/source_sync_spec.rb +0 -1
- data/spec/spec_helper.rb +8 -19
- data/spec/stats/middleware_spec.rb +9 -0
- data/spec/stats/record_spec.rb +1 -0
- data/spec/store_spec.rb +6 -1
- data/spec/sync_states_spec.rb +0 -1
- data/spec/test_methods_spec.rb +0 -1
- data/spec/user_spec.rb +0 -1
- data/tasks/redis.rake +4 -2
- metadata +421 -436
- data/bin/thorhoconnect +0 -79
- data/installer/utils/package_upload/auto-repo.rb +0 -136
@@ -20,17 +20,11 @@ end #cmd
|
|
20
20
|
|
21
21
|
# Makes sure parameters are correctly formed
|
22
22
|
def check_params
|
23
|
-
if ARGV.size != 2
|
23
|
+
if ARGV.size != 2
|
24
24
|
puts "Wrong number of arguments (#{ARGV.size} for 2)"
|
25
25
|
exit
|
26
26
|
end #if
|
27
27
|
|
28
|
-
if ARGV.size == 3 && ARGV[2] == "true"
|
29
|
-
@raked = true
|
30
|
-
else
|
31
|
-
@raked = false
|
32
|
-
end #if
|
33
|
-
|
34
28
|
if !FileTest.directory?(START_DIR)
|
35
29
|
puts "#{START_DIR} is not a directory."
|
36
30
|
exit
|
@@ -38,7 +32,6 @@ def check_params
|
|
38
32
|
|
39
33
|
begin
|
40
34
|
found = AWS::S3::Bucket.find(BUCKET)
|
41
|
-
puts "#{BUCKET} is a valid bucket :)" unless @raked
|
42
35
|
rescue => e
|
43
36
|
puts "#{BUCKET} is not a valid bucket."
|
44
37
|
puts e.inspect
|
@@ -62,7 +55,6 @@ end #establish_s3_connection
|
|
62
55
|
|
63
56
|
# Uploads given file to the specified S3 bucket
|
64
57
|
def upload(file)
|
65
|
-
puts "Uploading #{file} to bucket #{BUCKET}..." unless @raked
|
66
58
|
# Upload the given file
|
67
59
|
AWS::S3::S3Object.store( file,
|
68
60
|
open( file ),
|
@@ -71,7 +63,6 @@ def upload(file)
|
|
71
63
|
|
72
64
|
# display the URL of the file just uploaded
|
73
65
|
puts AWS::S3::S3Object.url_for((file), BUCKET)[/[^?]+/]
|
74
|
-
puts unless @raked
|
75
66
|
end #upload
|
76
67
|
|
77
68
|
# Traverses list of file to upload and calls Upload to upload them
|
@@ -84,27 +75,15 @@ def upload_files
|
|
84
75
|
next
|
85
76
|
else
|
86
77
|
paths.push(path)
|
87
|
-
puts path unless @raked
|
88
78
|
number_of_files += 1
|
89
79
|
end
|
90
80
|
end
|
91
81
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end #if
|
98
|
-
|
99
|
-
if choice == 'y'
|
100
|
-
puts "Uploading #{number_of_files} files."
|
101
|
-
paths.each do |path|
|
102
|
-
upload path
|
103
|
-
end #do
|
104
|
-
puts "#{number_of_files} files uploaded."
|
105
|
-
else
|
106
|
-
puts "Exiting."
|
107
|
-
end #if
|
82
|
+
puts "Uploading #{number_of_files} files."
|
83
|
+
paths.each do |path|
|
84
|
+
upload path
|
85
|
+
end #do
|
86
|
+
puts "#{number_of_files} files uploaded."
|
108
87
|
end #upload_files
|
109
88
|
|
110
89
|
# SCRIPT
|
@@ -134,4 +113,4 @@ rescue => e
|
|
134
113
|
puts e.inspect
|
135
114
|
puts e.backtrace
|
136
115
|
exit 3
|
137
|
-
end #begin
|
116
|
+
end #begin
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'digest/sha1'
|
5
|
+
|
6
|
+
if ARGV.length != 2
|
7
|
+
puts "Usage: #{$0} checksum_file directory_to_compare"
|
8
|
+
exit 1
|
9
|
+
end #if
|
10
|
+
|
11
|
+
def cmd(cmd)
|
12
|
+
puts cmd
|
13
|
+
system(cmd)
|
14
|
+
end #cmd
|
15
|
+
|
16
|
+
checksum_file = ARGV[0]
|
17
|
+
dir_to_compare = ARGV[1]
|
18
|
+
|
19
|
+
# Downoad Packages from S3
|
20
|
+
cmd "ruby ./installer/utils/download_from_s3.rb #{dir_to_compare}"
|
21
|
+
|
22
|
+
# Create the checksum to compare against the one from the S3 repo
|
23
|
+
cmd "ruby ./installer/utils/create_sha1.rb #{dir_to_compare} ."
|
24
|
+
|
25
|
+
old_sha1 = File.open(checksum_file) { |f| f.readline }
|
26
|
+
new_sha1 = File.open('./checksum') { |f| f.readline }
|
27
|
+
|
28
|
+
if !new_sha1.eql?(old_sha1)
|
29
|
+
puts "Checksums do not match!"
|
30
|
+
exit 2
|
31
|
+
else
|
32
|
+
puts "Checksums match!"
|
33
|
+
end #if
|
@@ -99,7 +99,7 @@ section "uninstall"
|
|
99
99
|
Push "PATH"
|
100
100
|
Push "R"
|
101
101
|
Push "HKLM"
|
102
|
-
Push "$INSTDIR\redis-2.4.
|
102
|
+
Push "$INSTDIR\redis-2.4.10"
|
103
103
|
Call un.EnvVarUpdate
|
104
104
|
Pop $R0
|
105
105
|
|
@@ -170,25 +170,25 @@ Section "Redis" redisSection
|
|
170
170
|
|
171
171
|
SetOutPath $INSTDIR
|
172
172
|
|
173
|
-
File /r "redis-2.4.
|
173
|
+
File /r "redis-2.4.10"
|
174
174
|
|
175
175
|
;add to path here
|
176
176
|
|
177
177
|
Push "PATH"
|
178
178
|
Push "P"
|
179
179
|
Push "HKLM"
|
180
|
-
Push "$INSTDIR\redis-2.4.
|
180
|
+
Push "$INSTDIR\redis-2.4.10"
|
181
181
|
Call EnvVarUpdate
|
182
182
|
Pop $R0
|
183
183
|
|
184
184
|
Push "REDIS_HOME"
|
185
185
|
Push "P"
|
186
186
|
Push "HKLM"
|
187
|
-
Push "$INSTDIR\redis-2.4.
|
187
|
+
Push "$INSTDIR\redis-2.4.10"
|
188
188
|
Call EnvVarUpdate
|
189
189
|
Pop $R0
|
190
190
|
|
191
|
-
ExecWait '$INSTDIR\redis-2.4.
|
191
|
+
ExecWait '$INSTDIR\redis-2.4.10\redis-service.exe install' $0
|
192
192
|
StrCmp $0 "0" continue wrong
|
193
193
|
|
194
194
|
wrong:
|
data/lib/rhoconnect.rb
CHANGED
@@ -178,7 +178,7 @@ module Rhoconnect
|
|
178
178
|
if secret == '<changeme>'
|
179
179
|
log "*"*60+"\n\n"
|
180
180
|
log "WARNING: Change the session secret in config.ru from <changeme> to something secure."
|
181
|
-
log " i.e. running `rake secret` in
|
181
|
+
log " i.e. running `rake rhoconnect:secret` in your rhoconnect app directory will generate a secret you could use.\n\n"
|
182
182
|
log "*"*60
|
183
183
|
end
|
184
184
|
end
|
data/lib/rhoconnect/app.rb
CHANGED
@@ -16,6 +16,12 @@ module Rhoconnect
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def query(params=nil)
|
19
|
+
if @source.simulate_time > 0
|
20
|
+
#for i in 1..10
|
21
|
+
# RestClient.get('www.google.com')
|
22
|
+
#end
|
23
|
+
sleep @source.simulate_time
|
24
|
+
end
|
19
25
|
Rhoconnect::Store.lock(lock_name,1) do
|
20
26
|
@result = Rhoconnect::Store.get_data(db_name)
|
21
27
|
end
|
data/lib/rhoconnect/server.rb
CHANGED
@@ -25,16 +25,39 @@ module Rhoconnect
|
|
25
25
|
set :public_folder, "#{libdir}/server/public"
|
26
26
|
set :static, true
|
27
27
|
set :stats, false
|
28
|
-
|
29
28
|
# default secret
|
30
|
-
|
29
|
+
@secret = '<changeme>'
|
31
30
|
|
32
31
|
# Setup route and mimetype for bulk data downloads
|
33
32
|
# TODO: Figure out why "mime :data, 'application/octet-stream'" doesn't work
|
34
33
|
Rack::Mime::MIME_TYPES['.data'] = 'application/octet-stream'
|
35
34
|
|
36
35
|
include Rhoconnect
|
37
|
-
|
36
|
+
|
37
|
+
# Set rhoconnect middleware
|
38
|
+
set :use_middleware, Proc.new {
|
39
|
+
return false if @middleware_configured # Middleware might be configured only once!
|
40
|
+
|
41
|
+
use XDomainSessionWrapper
|
42
|
+
use Rack::Cors do |cfg|
|
43
|
+
cfg.allow do |allow|
|
44
|
+
allow.origins /.*/
|
45
|
+
allow.resource '/application', :headers => :any, :methods => [:get, :post, :put, :delete], :credentials => true
|
46
|
+
allow.resource '/application/*', :headers => :any, :methods => [:get, :post, :put, :delete], :credentials => true
|
47
|
+
allow.resource '/api/application', :headers => :any, :methods => [:get, :post, :put, :delete], :credentials => true
|
48
|
+
allow.resource '/api/application/*', :headers => :any, :methods => [:get, :post, :put, :delete], :credentials => true
|
49
|
+
end
|
50
|
+
end
|
51
|
+
use Rhoconnect::BodyContentTypeParser
|
52
|
+
use Rhoconnect::Stats::Middleware
|
53
|
+
Rhoconnect::Server.set :secret, @secret unless settings.respond_to?(:secret)
|
54
|
+
use Rack::Session::Cookie,
|
55
|
+
:key => 'rhoconnect_session', :expire_after => Rhoconnect.cookie_expire,
|
56
|
+
:secret => Rhoconnect::Server.secret
|
57
|
+
|
58
|
+
@middleware_configured ||= true
|
59
|
+
}
|
60
|
+
|
38
61
|
helpers do
|
39
62
|
def request_action
|
40
63
|
request.env['PATH_INFO'].split('/').last
|
@@ -177,34 +200,14 @@ module Rhoconnect
|
|
177
200
|
end
|
178
201
|
end
|
179
202
|
|
180
|
-
# TODO: Load middleware statically
|
181
|
-
# hook into new so we can enable middleware
|
182
203
|
def self.new
|
183
|
-
use XDomainSessionWrapper
|
184
|
-
use Rack::Cors do |cfg|
|
185
|
-
cfg.allow do |allow|
|
186
|
-
allow.origins /.*/
|
187
|
-
allow.resource '/application', :headers => :any, :methods => [:get, :post, :put, :delete], :credentials => true
|
188
|
-
allow.resource '/application/*', :headers => :any, :methods => [:get, :post, :put, :delete], :credentials => true
|
189
|
-
allow.resource '/api/application', :headers => :any, :methods => [:get, :post, :put, :delete], :credentials => true
|
190
|
-
allow.resource '/api/application/*', :headers => :any, :methods => [:get, :post, :put, :delete], :credentials => true
|
191
|
-
end
|
192
|
-
end
|
193
|
-
use Rhoconnect::BodyContentTypeParser
|
194
|
-
|
195
204
|
if settings.respond_to?(:stats) and settings.send(:stats) == true
|
196
|
-
use Rhoconnect::Stats::Middleware
|
197
205
|
Rhoconnect.stats = true
|
198
206
|
else
|
199
207
|
Rhoconnect::Server.disable :stats
|
200
208
|
Rhoconnect.stats = false
|
201
209
|
end
|
202
|
-
|
203
|
-
Rhoconnect::Server.set :secret, @@secret unless settings.respond_to?(:secret)
|
204
|
-
use Rack::Session::Cookie,
|
205
|
-
:key => 'rhoconnect_session',
|
206
|
-
:expire_after => Rhoconnect.cookie_expire,
|
207
|
-
:secret => Rhoconnect::Server.secret
|
210
|
+
settings.use_middleware
|
208
211
|
super
|
209
212
|
end
|
210
213
|
|
@@ -6,14 +6,19 @@ module Rhoconnect
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def call(env)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
if Rhoconnect.stats || Rhoconnect::Server.stats
|
10
|
+
start = Time.now.to_f
|
11
|
+
status, headers, body = @app.call(env)
|
12
|
+
finish = Time.now.to_f
|
13
|
+
metric = "http:#{env['REQUEST_METHOD']}:#{env['PATH_INFO']}"
|
14
|
+
source_name = env['rack.request.query_hash']["source_name"] if env['rack.request.query_hash']
|
15
|
+
metric << ":#{source_name}" if source_name
|
16
|
+
Record.save_average(metric,finish - start)
|
17
|
+
[status, headers, body]
|
18
|
+
else
|
19
|
+
status, headers, body = @app.call(env)
|
20
|
+
[status, headers, body]
|
21
|
+
end
|
17
22
|
end
|
18
23
|
end
|
19
24
|
end
|
data/lib/rhoconnect/store.rb
CHANGED
@@ -299,16 +299,18 @@ module Rhoconnect
|
|
299
299
|
data = Store.db.zrange(dockey, 0, -1)
|
300
300
|
ret = []
|
301
301
|
keys = []
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
302
|
+
unless data.nil?
|
303
|
+
scores = []
|
304
|
+
data.each do |zsetkey|
|
305
|
+
obj_hash = Store.get_data zsetkey
|
306
|
+
score,key,objkey = getelement(zsetkey)
|
307
|
+
if scores[-1] != score
|
308
|
+
ret << obj_hash
|
309
|
+
keys << key
|
310
|
+
scores << score
|
311
|
+
else
|
312
|
+
ret[-1].merge!(obj_hash)
|
313
|
+
end
|
312
314
|
end
|
313
315
|
end
|
314
316
|
[ret, keys]
|
data/lib/rhoconnect/version.rb
CHANGED
data/rhoconnect.gemspec
CHANGED
@@ -37,14 +37,14 @@ Gem::Specification.new do |s|
|
|
37
37
|
]
|
38
38
|
|
39
39
|
s.add_dependency('bundler', '~> 1.0')
|
40
|
-
s.add_dependency("rack", '~> 1.
|
40
|
+
# s.add_dependency("rack", '~> 1.4.0')
|
41
41
|
s.add_dependency("sinatra", '~> 1.3')
|
42
42
|
s.add_dependency('rake', '~> 0.9.2')
|
43
43
|
s.add_dependency('json', '~> 1.6.0')
|
44
44
|
s.add_dependency('rubyzip', '~> 0.9.4')
|
45
45
|
s.add_dependency('uuidtools', '>= 2.1.1')
|
46
46
|
s.add_dependency('redis', '>= 2.2.0')
|
47
|
-
s.add_dependency('resque', '~> 1.
|
47
|
+
s.add_dependency('resque', '~> 1.20.0')
|
48
48
|
s.add_dependency('rest-client', '~> 1.6.1')
|
49
49
|
s.add_dependency('templater', '~> 1.0.0')
|
50
50
|
end
|
@@ -9,10 +9,12 @@ describe "RhoconnectApiStats" do
|
|
9
9
|
|
10
10
|
before(:each) do
|
11
11
|
Rhoconnect::Server.set :stats, true
|
12
|
+
Rhoconnect.stats = true
|
12
13
|
end
|
13
14
|
|
14
15
|
after(:each) do
|
15
16
|
Rhoconnect::Server.set :stats, false
|
17
|
+
Rhoconnect.stats = false
|
16
18
|
end
|
17
19
|
|
18
20
|
it "should retrieve metric names" do
|
@@ -60,6 +62,7 @@ describe "RhoconnectApiStats" do
|
|
60
62
|
|
61
63
|
it "should raise error if stats not enabled" do
|
62
64
|
Rhoconnect::Server.set :stats, false
|
65
|
+
Rhoconnect.stats = false
|
63
66
|
post "/api/admin/stats", {
|
64
67
|
:api_token => @api_token,
|
65
68
|
:metric => 'foo'
|
data/spec/api/api_helper.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'rack/test'
|
2
2
|
require 'rspec'
|
3
3
|
|
4
|
-
require File.join(File.dirname(__FILE__),'..','..','lib','rhoconnect','server.rb')
|
5
4
|
require File.join(File.dirname(__FILE__),'..','spec_helper')
|
6
|
-
require File.join(File.dirname(__FILE__),
|
5
|
+
require File.join(File.dirname(__FILE__),'..','..','lib','rhoconnect','server.rb')
|
7
6
|
|
8
7
|
def app
|
9
8
|
Rhoconnect::Server.set :stats, false
|
9
|
+
Rhoconnect.stats = false
|
10
10
|
@app ||= Rhoconnect::Server.new
|
11
11
|
end
|
12
12
|
|
@@ -8,7 +8,7 @@ describe "RhoconnectApiListUsers" do
|
|
8
8
|
post "/api/user/create_user", params
|
9
9
|
last_response.should be_ok
|
10
10
|
post "/api/user/list_users", {:api_token => @api_token}
|
11
|
-
JSON.parse(last_response.body).should == ["testuser", "testuser1"]
|
11
|
+
JSON.parse(last_response.body).sort.should == ["testuser", "testuser1"].sort
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should handle empty user's list" do
|
@@ -23,7 +23,7 @@ describe "RhoconnectApiListUsers" do
|
|
23
23
|
post "/api/user/create_user", params
|
24
24
|
last_response.should be_ok
|
25
25
|
post "/api/list_users", {:api_token => @api_token}
|
26
|
-
JSON.parse(last_response.body).should == ["testuser", "testuser1"]
|
26
|
+
JSON.parse(last_response.body).sort.should == ["testuser", "testuser1"].sort
|
27
27
|
last_response.headers['Warning'].index('deprecated').should_not == nil
|
28
28
|
end
|
29
29
|
end
|
data/spec/api_token_spec.rb
CHANGED
data/spec/app_spec.rb
CHANGED
data/spec/client_spec.rb
CHANGED
data/spec/client_sync_spec.rb
CHANGED