rhoconnect 3.1.2 → 3.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +14 -2
- data/CREDITS +151 -10
- data/Gemfile +16 -5
- data/Gemfile.lock +58 -23
- data/Rakefile +70 -50
- data/bench/bench_runner.rb +2 -2
- data/bench/benchapp/Gemfile +6 -0
- data/bench/benchapp/Gemfile.lock +5 -0
- data/bench/benchapp/config.ru +2 -0
- data/bench/lib/bench/cli.rb +2 -0
- data/bench/lib/bench/distr_runner.rb +3 -2
- data/bench/lib/bench/runner.rb +1 -1
- data/bench/lib/bench.rb +10 -1
- data/bench/run_bench.sh +1 -1
- data/bench/scripts/test_query_script.rb +2 -1
- data/bench/spec/bench_spec_helper.rb +1 -0
- data/bin/rhoconnect +9 -27
- data/bin/rhoconnect-benchmark +10 -1
- data/commands/commands/dtach_commands/dtach_about.rb +6 -0
- data/commands/commands/dtach_commands/dtach_install.rb +30 -0
- data/commands/commands/redis_commands/redis_about.rb +6 -0
- data/commands/commands/redis_commands/redis_attach.rb +6 -0
- data/commands/commands/redis_commands/redis_download.rb +33 -0
- data/commands/commands/redis_commands/redis_install.rb +26 -0
- data/commands/commands/redis_commands/redis_make.rb +9 -0
- data/commands/commands/redis_commands/redis_restart.rb +7 -0
- data/commands/commands/redis_commands/redis_runner.rb +67 -0
- data/commands/commands/redis_commands/redis_start.rb +6 -0
- data/commands/commands/redis_commands/redis_startbg.rb +6 -0
- data/commands/commands/redis_commands/redis_stop.rb +6 -0
- data/commands/commands/rhoconnect/attach.rb +7 -0
- data/commands/commands/rhoconnect/clean_start.rb +9 -0
- data/commands/commands/rhoconnect/config.rb +15 -0
- data/commands/commands/rhoconnect/console.rb +15 -0
- data/commands/commands/rhoconnect/console_helper.rb +3 -0
- data/commands/commands/rhoconnect/create_user.rb +18 -0
- data/commands/commands/rhoconnect/delete_device.rb +9 -0
- data/commands/commands/rhoconnect/delete_user.rb +8 -0
- data/commands/commands/rhoconnect/flushdb.rb +14 -0
- data/commands/commands/rhoconnect/get_token.rb +25 -0
- data/commands/commands/rhoconnect/reset.rb +16 -0
- data/commands/commands/rhoconnect/reset_refresh.rb +11 -0
- data/commands/commands/rhoconnect/restart.rb +7 -0
- data/commands/commands/rhoconnect/secret.rb +11 -0
- data/commands/commands/rhoconnect/set_admin_password.rb +26 -0
- data/commands/commands/rhoconnect/spec.rb +15 -0
- data/commands/commands/rhoconnect/start.rb +18 -0
- data/commands/commands/rhoconnect/startbg.rb +34 -0
- data/commands/commands/rhoconnect/startdebug.rb +35 -0
- data/commands/commands/rhoconnect/stop.rb +11 -0
- data/commands/commands/rhoconnect/war.rb +32 -0
- data/commands/commands/rhoconnect/web.rb +7 -0
- data/commands/execute.rb +35 -0
- data/commands/generators/app.rb +6 -0
- data/commands/generators/source.rb +6 -0
- data/commands/utilities/dtach_installed.rb +10 -0
- data/doc/benchmarks-running.txt +5 -0
- data/doc/command-line.txt +216 -27
- data/doc/heroku-addon.txt +1 -1
- data/doc/preparing-production.txt +20 -1
- data/doc/public/cli.txt +191 -0
- data/doc/push-backend-setup.txt +148 -0
- data/doc/push-client-setup.txt +61 -0
- data/doc/push-server-setup.txt +91 -0
- data/doc/push.txt +8 -137
- data/doc/rest-api.txt +96 -0
- data/doc/settings.txt +1 -1
- data/doc/supported-platforms.txt +2 -1
- data/doc/tutorial.txt +6 -4
- data/examples/simple/Gemfile +39 -0
- data/examples/simple/Rakefile +7 -12
- data/examples/simple/config.ru +16 -31
- data/examples/simple/settings/settings.yml +5 -4
- data/examples/simple/sources/product.rb +51 -0
- data/generators/templates/application/Gemfile +7 -0
- data/generators/templates/application/Rakefile +5 -18
- data/generators/templates/application/config.ru +11 -19
- data/install.sh +24 -49
- data/installer/unix-like/create_texts.rb +71 -123
- data/installer/unix-like/post_install.sh +3 -0
- data/installer/unix-like/post_uninstall.sh +2 -0
- data/installer/unix-like/pre_install.sh +5 -3
- data/installer/unix-like/pre_uninstall.sh +14 -6
- data/installer/unix-like/rho_connect_install_checkers.rb +1 -1
- data/installer/unix-like/rho_connect_install_constants.rb +6 -10
- data/installer/unix-like/rho_connect_install_debian.rb +2 -2
- data/installer/unix-like/rho_connect_install_dnd.rb +2 -5
- data/installer/unix-like/rho_connect_install_installers.rb +15 -23
- data/installer/unix-like/rho_connect_install_yum.rb +2 -2
- data/installer/utils/constants.rb +4 -4
- data/installer/utils/create_sha1.rb +1 -1
- data/installer/utils/nix_install_test.rb +32 -31
- data/installer/utils/nix_installation.rake +1 -1
- data/installer/utils/package_upload/repos.rake +34 -30
- data/installer/utils/package_upload/s3_upload.rb +3 -3
- data/lib/rhoconnect/api/source/fast_delete.rb +10 -0
- data/lib/rhoconnect/api/source/fast_insert.rb +10 -0
- data/lib/rhoconnect/api/source/fast_update.rb +10 -0
- data/lib/rhoconnect/api/source/get_source_params.rb +1 -1
- data/lib/rhoconnect/api/source/list_sources.rb +2 -2
- data/lib/rhoconnect/api/source/save_adapter.rb +1 -1
- data/lib/rhoconnect/api/source/update_source_params.rb +6 -0
- data/lib/rhoconnect/async.rb +82 -0
- data/lib/rhoconnect/bulk_data/bulk_data.rb +5 -1
- data/lib/rhoconnect/client_sync.rb +18 -3
- data/lib/rhoconnect/console/rhoconnect_api.rb +2 -2
- data/lib/rhoconnect/console/server.rb +5 -32
- data/lib/rhoconnect/console.rb +2 -2
- data/lib/rhoconnect/graph_helper.rb +225 -0
- data/lib/rhoconnect/jobs/bulk_data_job.rb +24 -2
- data/lib/rhoconnect/server.rb +31 -11
- data/lib/rhoconnect/source.rb +10 -5
- data/lib/rhoconnect/source_sync.rb +32 -2
- data/lib/rhoconnect/tasks.rb +19 -108
- data/lib/rhoconnect/test_methods.rb +20 -0
- data/lib/rhoconnect/utilities.rb +118 -0
- data/lib/rhoconnect/version.rb +1 -1
- data/lib/rhoconnect/web-console/controllers/admins.js +245 -0
- data/lib/rhoconnect/web-console/models/adapter.js +53 -0
- data/lib/rhoconnect/web-console/models/client.js +105 -0
- data/lib/rhoconnect/web-console/models/doc.js +113 -0
- data/lib/rhoconnect/web-console/models/session.js +40 -0
- data/lib/rhoconnect/web-console/models/source.js +115 -0
- data/lib/rhoconnect/web-console/models/stats.js +84 -0
- data/lib/rhoconnect/web-console/models/user.js +111 -0
- data/lib/rhoconnect/web-console/public/backbone.js +1432 -0
- data/lib/rhoconnect/web-console/public/bootstrap.css +3990 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/excanvas.min.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.barRenderer.min.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.canvasAxisLabelRenderer.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.canvasAxisTickRenderer.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.canvasTextRenderer.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.categoryAxisRenderer.min.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.cursor.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.dateAxisRenderer.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.dateAxisRenderer.min.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.pointLabels.min.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jquery-1.4.2.min.js +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jquery.jqplot.min.css +0 -0
- data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jquery.jqplot.min.js +0 -0
- data/lib/rhoconnect/web-console/public/jquery-1.7.1.min.js +154 -0
- data/lib/rhoconnect/web-console/public/rhoconnect-web.js +15 -0
- data/lib/rhoconnect/web-console/public/underscore.js +999 -0
- data/lib/rhoconnect/web-console/server.rb +55 -0
- data/lib/rhoconnect/web-console/templates/index.erb +90 -0
- data/lib/rhoconnect/web-console/templates/jqplot.erb +60 -0
- data/lib/rhoconnect/web-console/views/api_token.js +16 -0
- data/lib/rhoconnect/web-console/views/doc.js +63 -0
- data/lib/rhoconnect/web-console/views/edit_user.js +43 -0
- data/lib/rhoconnect/web-console/views/home.js +56 -0
- data/lib/rhoconnect/web-console/views/index.js +63 -0
- data/lib/rhoconnect/web-console/views/new_ping.js +58 -0
- data/lib/rhoconnect/web-console/views/new_user.js +29 -0
- data/lib/rhoconnect/web-console/views/server_doc.js +103 -0
- data/lib/rhoconnect/web-console/views/set_adapter.js +38 -0
- data/lib/rhoconnect/web-console/views/settings.js +53 -0
- data/lib/rhoconnect/web-console/views/show_device.js +56 -0
- data/lib/rhoconnect/web-console/views/show_user.js +38 -0
- data/lib/rhoconnect/web-console/views/source_docs.js +30 -0
- data/lib/rhoconnect/web-console/views/stats.js +69 -0
- data/lib/rhoconnect/web-console/views/users.js +20 -0
- data/lib/rhoconnect.rb +2 -1
- data/rhoconnect.gemspec +3 -1
- data/spec/api/application/rhoconnect_api_spec.rb +3 -5
- data/spec/api/source/fast_delete_spec.rb +27 -0
- data/spec/api/source/fast_insert_spec.rb +28 -0
- data/spec/api/source/fast_update_spec.rb +51 -0
- data/spec/api/source/get_source_params_spec.rb +1 -0
- data/spec/api/source/update_source_params_spec.rb +24 -0
- data/spec/async_spec.rb +19 -0
- data/spec/client_sync_spec.rb +19 -2
- data/spec/javascripts/PlayerSpec.js +58 -0
- data/spec/javascripts/admins_routes_spec.js +117 -0
- data/spec/javascripts/admins_spec.js +27 -0
- data/spec/javascripts/doc_view_spec.js +37 -0
- data/spec/javascripts/edit_user_view_spec.js +44 -0
- data/spec/javascripts/helpers/SpecHelper.js +9 -0
- data/spec/javascripts/helpers/jasmine-jquery.js +305 -0
- data/spec/javascripts/helpers/jasmine-sinon.js +43 -0
- data/spec/javascripts/helpers/sinon-1.3.2.js +3551 -0
- data/spec/javascripts/home_view_spec.js +39 -0
- data/spec/javascripts/index_view_spec.js +42 -0
- data/spec/javascripts/new_ping_view_spec.js +48 -0
- data/spec/javascripts/new_user_view_spec.js +42 -0
- data/spec/javascripts/server_doc_view_spec.js +39 -0
- data/spec/javascripts/set_adapter_view_spec.js +32 -0
- data/spec/javascripts/show_device_view_spec.js +41 -0
- data/spec/javascripts/show_user_view_spec.js +46 -0
- data/spec/javascripts/source_docs_view_spec.js +36 -0
- data/spec/javascripts/support/jasmine.yml +79 -0
- data/spec/javascripts/support/jasmine_config.rb +23 -0
- data/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/spec/javascripts/users_view_spec.js +35 -0
- data/spec/jobs/bulk_data_job_spec.rb +10 -2
- data/spec/perf/bulk_data_perf_spec.rb +1 -0
- data/spec/server/server_spec.rb +3 -1
- data/spec/source_sync_spec.rb +14 -1
- data/spec/spec_helper.rb +51 -0
- data/spec/store_spec.rb +6 -0
- data/spec/test_methods_spec.rb +11 -0
- data/tasks/redis.rake +3 -1
- metadata +172 -64
- data/doc/contributing.txt +0 -60
- data/lib/rhoconnect/console/app/helpers/auth_helper.rb +0 -22
- data/lib/rhoconnect/console/app/helpers/extensions.rb +0 -19
- data/lib/rhoconnect/console/app/helpers/helpers.rb +0 -57
- data/lib/rhoconnect/console/app/public/ThickBox.css +0 -649
- data/lib/rhoconnect/console/app/public/home.css +0 -431
- data/lib/rhoconnect/console/app/public/images/foot_logo_rhoconnect.png +0 -0
- data/lib/rhoconnect/console/app/public/images/header_halo.jpg +0 -0
- data/lib/rhoconnect/console/app/public/images/land_separator.gif +0 -0
- data/lib/rhoconnect/console/app/public/images/landing_header.jpg +0 -0
- data/lib/rhoconnect/console/app/public/images/logo_rhoconnect.png +0 -0
- data/lib/rhoconnect/console/app/public/images/tabs_separator.png +0 -0
- data/lib/rhoconnect/console/app/public/main.css +0 -7
- data/lib/rhoconnect/console/app/public/reset.css +0 -76
- data/lib/rhoconnect/console/app/public/style.css +0 -2201
- data/lib/rhoconnect/console/app/public/text.txt +0 -0
- data/lib/rhoconnect/console/app/routes/adapter.rb +0 -28
- data/lib/rhoconnect/console/app/routes/auth.rb +0 -29
- data/lib/rhoconnect/console/app/routes/client.rb +0 -31
- data/lib/rhoconnect/console/app/routes/docs.rb +0 -145
- data/lib/rhoconnect/console/app/routes/heroku.rb +0 -19
- data/lib/rhoconnect/console/app/routes/home.rb +0 -63
- data/lib/rhoconnect/console/app/routes/timing.rb +0 -242
- data/lib/rhoconnect/console/app/routes/user.rb +0 -122
- data/lib/rhoconnect/console/app/views/adapter.erb +0 -16
- data/lib/rhoconnect/console/app/views/client.erb +0 -30
- data/lib/rhoconnect/console/app/views/content.erb +0 -14
- data/lib/rhoconnect/console/app/views/doc.erb +0 -8
- data/lib/rhoconnect/console/app/views/docdata.erb +0 -28
- data/lib/rhoconnect/console/app/views/docs.erb +0 -30
- data/lib/rhoconnect/console/app/views/edituser.erb +0 -13
- data/lib/rhoconnect/console/app/views/headermenu.erb +0 -40
- data/lib/rhoconnect/console/app/views/home.erb +0 -24
- data/lib/rhoconnect/console/app/views/index.erb +0 -58
- data/lib/rhoconnect/console/app/views/jqplot.erb +0 -52
- data/lib/rhoconnect/console/app/views/layout.erb +0 -153
- data/lib/rhoconnect/console/app/views/login.erb +0 -26
- data/lib/rhoconnect/console/app/views/newuser.erb +0 -17
- data/lib/rhoconnect/console/app/views/ping.erb +0 -40
- data/lib/rhoconnect/console/app/views/result.erb +0 -11
- data/lib/rhoconnect/console/app/views/rightboxlinks.erb +0 -15
- data/lib/rhoconnect/console/app/views/select_doc.erb +0 -17
- data/lib/rhoconnect/console/app/views/upload_doc.erb +0 -23
- data/lib/rhoconnect/console/app/views/user.erb +0 -29
- data/lib/rhoconnect/console/app/views/users.erb +0 -19
- data/lib/rhoconnect/server/views/index.erb +0 -13
data/bench/benchapp/config.ru
CHANGED
@@ -25,6 +25,8 @@ Rhoconnect::Server.set :secret, 'cf8e8a1d3653fcfb2332d8b1af9f6762c3c45e
|
|
25
25
|
Rhoconnect::Server.set :root, ROOT_PATH
|
26
26
|
Rhoconnect::Server.use Rack::Static, :urls => ["/data"], :root => Rhoconnect::Server.root
|
27
27
|
Rhoconnect::Server.disable :logging
|
28
|
+
#Rhoconnect::Server.set :use_async_model, false # true by default
|
29
|
+
#Rhoconnect::Server.set :fiberpool_size, 50 # default is 100
|
28
30
|
|
29
31
|
# Load our rhoconnect application
|
30
32
|
require "#{ROOT_PATH}/application"
|
data/bench/lib/bench/cli.rb
CHANGED
@@ -14,6 +14,7 @@ module Bench
|
|
14
14
|
Bench.concurrency = params[2].to_i unless params[2].nil?
|
15
15
|
Bench.iterations = params[3].to_i unless params[3].nil?
|
16
16
|
Bench.datasize = params[4].to_i unless params[4].nil?
|
17
|
+
Bench.simtime = params[5].to_i unless params[5].nil?
|
17
18
|
Bench.admin_login = login
|
18
19
|
Bench.admin_password = password
|
19
20
|
load(script)
|
@@ -39,6 +40,7 @@ module Bench
|
|
39
40
|
Bench.concurrency = params[2].to_i unless params[2].nil?
|
40
41
|
Bench.iterations = params[3].to_i unless params[3].nil?
|
41
42
|
Bench.datasize = params[4].to_i unless params[4].nil?
|
43
|
+
Bench.simtime = params[5].to_i unless params[5].nil?
|
42
44
|
Bench.admin_login = login
|
43
45
|
Bench.admin_password = password
|
44
46
|
load(script)
|
@@ -8,7 +8,7 @@ module Bench
|
|
8
8
|
@clients_group = clientgroup
|
9
9
|
end
|
10
10
|
|
11
|
-
def run(server, sync_key, payload, concurrency, niterations, result_filename=nil)
|
11
|
+
def run(server, sync_key, payload, concurrency, niterations, result_filename=nil, sim_time = 0)
|
12
12
|
# 1) Extract server name
|
13
13
|
server ||= 'default'
|
14
14
|
if server != 'default'
|
@@ -33,7 +33,8 @@ module Bench
|
|
33
33
|
Bench.user_name = "benchuser"
|
34
34
|
Bench.password = "password"
|
35
35
|
Bench.set_server_state("test_db_storage:application:#{Bench.user_name}",expected_data)
|
36
|
-
Bench.reset_refresh_time('RhoInternalBenchmarkAdapter')
|
36
|
+
Bench.reset_refresh_time('RhoInternalBenchmarkAdapter', 0)
|
37
|
+
Bench.set_simulate_time('RhoInternalBenchmarkAdapter', sim_time)
|
37
38
|
|
38
39
|
#6) set the sync key
|
39
40
|
@start_time = Time.now + 10.0
|
data/bench/lib/bench/runner.rb
CHANGED
@@ -12,7 +12,7 @@ module Bench
|
|
12
12
|
def test(concurrency,iterations,&block)
|
13
13
|
total_times = times do
|
14
14
|
0.upto(concurrency - 1) do |thread_id|
|
15
|
-
sleep rand(2)
|
15
|
+
#sleep rand(2)
|
16
16
|
threads << Thread.new(block) do |t|
|
17
17
|
0.upto(iterations - 1) do |iteration|
|
18
18
|
s = Session.new(thread_id, iteration)
|
data/bench/lib/bench.rb
CHANGED
@@ -25,7 +25,7 @@ module Bench
|
|
25
25
|
include TestData
|
26
26
|
include Utils
|
27
27
|
|
28
|
-
attr_accessor :concurrency, :iterations, :admin_login
|
28
|
+
attr_accessor :concurrency, :iterations, :admin_login, :simtime
|
29
29
|
attr_accessor :admin_password, :user_name
|
30
30
|
attr_accessor :password, :base_url, :host, :token
|
31
31
|
attr_accessor :total_time, :sessions, :verify_error
|
@@ -108,6 +108,15 @@ module Bench
|
|
108
108
|
:content_type => :json)
|
109
109
|
end
|
110
110
|
|
111
|
+
def set_simulate_time(source_name,simulate_time=0)
|
112
|
+
token = get_token
|
113
|
+
RestClient.post("#{@host}/api/source/update_source_params",
|
114
|
+
{:api_token => token, :source_name => source_name,
|
115
|
+
:user_name => @user_name,
|
116
|
+
:data => {:simulate_time => simulate_time}}.to_json,
|
117
|
+
:content_type => :json)
|
118
|
+
end
|
119
|
+
|
111
120
|
def get_token
|
112
121
|
unless @token
|
113
122
|
@token = RestClient.post("#{@host}/api/admin/login",
|
data/bench/run_bench.sh
CHANGED
@@ -20,7 +20,8 @@ Bench.config do |config|
|
|
20
20
|
config.reset_app
|
21
21
|
@expected = Bench.get_test_data(@datasize)
|
22
22
|
config.set_server_state("test_db_storage:application:#{config.user_name}",@expected)
|
23
|
-
config.reset_refresh_time('RhoInternalBenchmarkAdapter')
|
23
|
+
config.reset_refresh_time('RhoInternalBenchmarkAdapter', 0)
|
24
|
+
config.set_simulate_time('RhoInternalBenchmarkAdapter', Bench.simtime)
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
data/bin/rhoconnect
CHANGED
@@ -1,34 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
|
5
|
-
require
|
6
|
-
|
7
|
-
require File.join(File.dirname(__FILE__), '..','lib','rhoconnect')
|
8
|
-
|
9
|
-
# Stub this method to force 1.8 compatibility (come on templater!)
|
10
|
-
class Encoding
|
11
|
-
def find
|
12
|
-
"utf-8"
|
13
|
-
end
|
14
|
-
|
15
|
-
def dummy?
|
16
|
-
false
|
17
|
-
end
|
4
|
+
if File.exists?(File.join(Dir.pwd,'Gemfile'))
|
5
|
+
require 'bundler'
|
6
|
+
Bundler.require
|
18
7
|
end
|
19
8
|
|
20
|
-
|
21
|
-
def force_encoding(enc)
|
22
|
-
return self
|
23
|
-
end
|
24
|
-
def encoding
|
25
|
-
if RUBY_VERSION =~ /1\.8/ and Encoding.responds_to?('new')
|
26
|
-
Encoding.new
|
27
|
-
else
|
28
|
-
Encoding.default_external
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
9
|
+
$:.unshift File.join(File.dirname(__FILE__),'..')
|
32
10
|
|
11
|
+
require 'templater'
|
12
|
+
require 'generators/rhoconnect'
|
13
|
+
require 'lib/rhoconnect'
|
14
|
+
require 'commands/execute'
|
33
15
|
|
34
|
-
|
16
|
+
Execute.start
|
data/bin/rhoconnect-benchmark
CHANGED
@@ -73,6 +73,11 @@ def parse_options
|
|
73
73
|
options[:title] = title
|
74
74
|
end
|
75
75
|
|
76
|
+
options[:simtime] = 0
|
77
|
+
opts.on('-S', '--simtime NUMBER', "Force the source adapter to simulate NUMBER seconds communication roundtrip with the backend") do |simtime|
|
78
|
+
options[:simtime] = simtime
|
79
|
+
end
|
80
|
+
|
76
81
|
opts.on( '-A', '--advanced', 'This convinience option combines -m 10 and -x 500') do
|
77
82
|
options[:max_payload] = 500
|
78
83
|
options[:payload] = 500
|
@@ -80,6 +85,7 @@ def parse_options
|
|
80
85
|
options[:num_clients] = 10
|
81
86
|
options[:title] ||= "QUERY"
|
82
87
|
options[:save_results] = '.'
|
88
|
+
options[:simtime] = 0
|
83
89
|
end
|
84
90
|
|
85
91
|
options[:distributed] = nil
|
@@ -91,6 +97,7 @@ def parse_options
|
|
91
97
|
options[:title] ||= "QUERY"
|
92
98
|
options[:save_results] = '.'
|
93
99
|
options[:distributed] = fname
|
100
|
+
options[:simtime] = 0
|
94
101
|
end
|
95
102
|
|
96
103
|
# This displays the help screen, all programs are
|
@@ -236,11 +243,13 @@ begin
|
|
236
243
|
bench_args[7] = options[:num_iterations]
|
237
244
|
# datasize
|
238
245
|
bench_args[8] = payload
|
246
|
+
# simulate backend delay
|
247
|
+
bench_args[9] = options[:simtime]
|
239
248
|
|
240
249
|
# now execute Bench
|
241
250
|
if(options[:distributed])
|
242
251
|
sync_key = "#{options[:title]}_#{payload}"
|
243
|
-
options[:distr_runner].run(Bench.base_url, sync_key, payload, concurrency, options[:num_iterations], result_fname)
|
252
|
+
options[:distr_runner].run(Bench.base_url, sync_key, payload, concurrency, options[:num_iterations], result_fname, options[:simtime])
|
244
253
|
else
|
245
254
|
Bench::Cli.start bench_args
|
246
255
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc 'dtach-install', 'Install dtach 0.8 from source'
|
3
|
+
def dtach_install
|
4
|
+
invoke :dtach_about
|
5
|
+
|
6
|
+
unless windows?
|
7
|
+
Dir.chdir('/tmp/')
|
8
|
+
unless File.exists?('/tmp/dtach-0.8.tar.gz')
|
9
|
+
require 'net/http'
|
10
|
+
|
11
|
+
url = 'http://downloads.sourceforge.net/project/dtach/dtach/0.8/dtach-0.8.tar.gz'
|
12
|
+
open('/tmp/dtach-0.8.tar.gz', 'wb') do |file| file.write(open(url).read) end
|
13
|
+
end #do
|
14
|
+
|
15
|
+
unless File.directory?('/tmp/dtach-0.8')
|
16
|
+
system('tar xzf dtach-0.8.tar.gz')
|
17
|
+
end #unless
|
18
|
+
|
19
|
+
ENV['PREFIX'] and bin_dir = "#{ENV['PREFIX']}/bin" or bin_dir = "#{RedisRunner.prefix}bin"
|
20
|
+
|
21
|
+
mk_bin_dir(bin_dir)
|
22
|
+
|
23
|
+
Dir.chdir('/tmp/dtach-0.8/')
|
24
|
+
system 'cd /tmp/dtach-0.8/ && ./configure && make'
|
25
|
+
system "cp /tmp/dtach-0.8/dtach #{bin_dir}"
|
26
|
+
|
27
|
+
puts "Dtach successfully installed to #{bin_dir}"
|
28
|
+
end #unless
|
29
|
+
end #dtach_install
|
30
|
+
end #do
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "redis-download", "Download redis package"
|
3
|
+
def redis_download
|
4
|
+
if windows?
|
5
|
+
require 'net/http'
|
6
|
+
require 'zip/zip'
|
7
|
+
puts "Installing redis to #{redis_home}."
|
8
|
+
|
9
|
+
Net::HTTP.start("cloud.github.com") do |http|
|
10
|
+
resp = http.get("/downloads/dmajkic/redis/#{$redis_ver}-win32-win64.zip")
|
11
|
+
open($redis_zip, "wb") do |file|
|
12
|
+
file.write(resp.body)
|
13
|
+
end #do
|
14
|
+
end #do
|
15
|
+
|
16
|
+
Zip::ZipFile.open($redis_zip) do |zip_file|
|
17
|
+
zip_file.each do |f|
|
18
|
+
f_path = File.join(redis_home, f.name)
|
19
|
+
FileUtils.mkdir_p(File.dirname(f_path))
|
20
|
+
zip_file.extract(f, f_path) { true }
|
21
|
+
end #do
|
22
|
+
end #do
|
23
|
+
|
24
|
+
FileUtils.mv Dir.glob(File.join(redis_home,'32bit','*')), redis_home
|
25
|
+
FileUtils.rm_rf File.join(redis_home, '64bit')
|
26
|
+
FileUtils.rm_f $redis_zip
|
27
|
+
else
|
28
|
+
sh 'rm -rf /tmp/redis/' if File.exists?("#{RedisRunner.redisdir}")
|
29
|
+
sh 'git clone git://github.com/antirez/redis.git /tmp/redis -n'
|
30
|
+
sh "cd #{RedisRunner.redisdir} && git reset --hard && git checkout #{REDIS_RELEASE}"
|
31
|
+
end #if
|
32
|
+
end #redis_download
|
33
|
+
end #do
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "redis-install", 'Install the latest verison of Redis from Github (requires git, duh)'
|
3
|
+
def redis_install
|
4
|
+
invoke :redis_about
|
5
|
+
invoke :redis_download
|
6
|
+
invoke :redis_make
|
7
|
+
unless windows?
|
8
|
+
ENV['PREFIX'] and bin_dir = "#{ENV['PREFIX']}/bin" or bin_dir = "#{RedisRunner.prefix}bin"
|
9
|
+
|
10
|
+
mk_bin_dir(bin_dir)
|
11
|
+
|
12
|
+
%w(redis-benchmark redis-cli redis-server).each do |bin|
|
13
|
+
sh "cp /tmp/redis/src/#{bin} #{bin_dir}"
|
14
|
+
end #do
|
15
|
+
|
16
|
+
puts "Installed redis-benchmark, redis-cli and redis-server to #{bin_dir}"
|
17
|
+
|
18
|
+
ENV['PREFIX'] and conf_dir = "#{ENV['PREFIX']}/etc" or conf_dir = "#{RedisRunner.prefix}etc"
|
19
|
+
unless File.exists?("#{conf_dir}/redis.conf")
|
20
|
+
sh "mkdir #{conf_dir}" unless File.exists?("#{conf_dir}")
|
21
|
+
sh "cp /tmp/redis/redis.conf #{conf_dir}/redis.conf"
|
22
|
+
puts "Installed redis.conf to #{conf_dir} \n You should look at this file!"
|
23
|
+
end #unless
|
24
|
+
end #unless
|
25
|
+
end #redis_install
|
26
|
+
end #do
|
@@ -0,0 +1,67 @@
|
|
1
|
+
REDIS_RELEASE = "2.4.10"
|
2
|
+
|
3
|
+
class RedisRunner
|
4
|
+
|
5
|
+
def self.prefix
|
6
|
+
"/usr/local/"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.redisdir
|
10
|
+
"/tmp/redis/"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.redisconfdir
|
14
|
+
server_dir = File.dirname(`which redis-server`)
|
15
|
+
conf_file = "#{RedisRunner.prefix}etc/redis.conf"
|
16
|
+
unless File.exists? conf_file
|
17
|
+
conf_file = "#{server_dir}/redis.conf"
|
18
|
+
end
|
19
|
+
conf_file
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.dtach_socket
|
23
|
+
'/tmp/redis.dtach'
|
24
|
+
end
|
25
|
+
|
26
|
+
# Just check for existance of dtach socket
|
27
|
+
def self.running?
|
28
|
+
File.exists? dtach_socket
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.start
|
32
|
+
if windows?
|
33
|
+
puts "Starting redis in a new window..."
|
34
|
+
sh "start #{File.join(redis_home,'redis-server')} #{File.join(redis_home,'redis.conf')}" rescue
|
35
|
+
"redis-server not installed on your path, please run 'rhoconnect redis-install' first."
|
36
|
+
elsif defined?(JRUBY_VERSION)
|
37
|
+
puts "Starting redis ..."
|
38
|
+
sh "redis-server #{redisconfdir}"
|
39
|
+
else
|
40
|
+
puts 'Detach with Ctrl+\ Re-attach with rhoconnect redis-attach'
|
41
|
+
sleep 1
|
42
|
+
command = "dtach -A #{dtach_socket} redis-server #{redisconfdir}"
|
43
|
+
sh command
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# this function is used with Rhostudio where there is no terminal
|
48
|
+
def self.startbg
|
49
|
+
if windows?
|
50
|
+
puts "Starting redis in a new window..."
|
51
|
+
sh "start #{File.join(redis_home,'redis-server')} #{File.join(redis_home,'redis.conf')}" rescue
|
52
|
+
"redis-server not installed on your path, please run 'rhoconnect redis-install' first."
|
53
|
+
else
|
54
|
+
puts "Starting redis ..."
|
55
|
+
system("redis-server #{redisconfdir} &")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.attach
|
60
|
+
exec "dtach -a #{dtach_socket}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.stop
|
64
|
+
Redis.new.shutdown rescue nil
|
65
|
+
end
|
66
|
+
|
67
|
+
end #RedisRunner
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "config", "Config", :hide => true
|
3
|
+
def config
|
4
|
+
$settings = load_settings(File.join('settings','settings.yml'))
|
5
|
+
$env = (ENV['RHO_ENV'] || ENV['RACK_ENV'] || :development).to_sym
|
6
|
+
uri = URI.parse($settings[$env][:syncserver])
|
7
|
+
$url = "#{uri.scheme}://#{uri.host}"
|
8
|
+
$url = "#{$url}:#{uri.port}" if uri.port && uri.port != 80
|
9
|
+
$host = uri.host
|
10
|
+
$port = uri.port
|
11
|
+
$appname = $settings[$env][:syncserver].split('/').last
|
12
|
+
$token_file = File.join(ENV['HOME'],'.rhoconnect_token')
|
13
|
+
$token = File.read($token_file) if File.exist?($token_file)
|
14
|
+
end #config
|
15
|
+
end #do
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "console [environment]", "run rhoconnect console"
|
3
|
+
def console(environment=nil)
|
4
|
+
if RedisRunner.running?
|
5
|
+
application_file = ruby19? ? './application' : 'application'
|
6
|
+
#load development environment by default
|
7
|
+
ENV['RACK_ENV'] = environment || 'development'
|
8
|
+
system "irb -rubygems -r #{File.join(File.dirname(__FILE__),'console_helper')} " +
|
9
|
+
"-r #{File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'rhoconnect') } " +
|
10
|
+
"-r #{application_file}"
|
11
|
+
else
|
12
|
+
puts "Redis is not running. Please start it by running 'rhoconnect redis-start' command."
|
13
|
+
end #if
|
14
|
+
end #console
|
15
|
+
end #do
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "create-user", "Creates and subscribes user for application in rhoconnect"
|
3
|
+
def create_user
|
4
|
+
invoke :config
|
5
|
+
password = ''
|
6
|
+
login = ask "new user login: "
|
7
|
+
begin
|
8
|
+
system "stty -echo"
|
9
|
+
password = ask "\nnew user password: "
|
10
|
+
system "stty echo"
|
11
|
+
rescue NoMethodError, Interrupt
|
12
|
+
system "stty echo"
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
puts ''
|
16
|
+
RhoconnectApi.create_user($url,$token,login,password)
|
17
|
+
end #create_user
|
18
|
+
end #do
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "delete-device", "Deletes a device from rhoconnect"
|
3
|
+
def delete_device
|
4
|
+
invoke :config
|
5
|
+
user_id = ask "device's user_id: "
|
6
|
+
device_id = ask "device to delete: "
|
7
|
+
RhoconnectApi.delete_client($url,$token,user_id,device_id)
|
8
|
+
end #delete_device
|
9
|
+
end #do
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "flushdb", "Flush data store - WARNING: THIS REMOVES ALL DATA IN RHOCONNECT"
|
3
|
+
def flushdb
|
4
|
+
invoke :config
|
5
|
+
puts "*** WARNING: THIS WILL REMOVE ALL DATA FROM YOUR REDIS STORE ***"
|
6
|
+
confirm = ask "Are you sure (please answer yes/no)? "
|
7
|
+
if confirm == 'yes'
|
8
|
+
Redis.new.flushdb
|
9
|
+
puts "Database flushed..."
|
10
|
+
else
|
11
|
+
puts "Aborted..."
|
12
|
+
end #if
|
13
|
+
end #flushdb
|
14
|
+
end #do
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "get-token", "Fetches current api token from rhoconnect"
|
3
|
+
def get_token
|
4
|
+
invoke :config
|
5
|
+
password = ''
|
6
|
+
login = ask "admin login: "
|
7
|
+
begin
|
8
|
+
system "stty -echo"
|
9
|
+
password = ask "\nadmin password: "
|
10
|
+
system "stty echo"
|
11
|
+
rescue NoMethodError, Interrupt
|
12
|
+
system "stty echo"
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
puts ''
|
16
|
+
begin
|
17
|
+
$token = RhoconnectApi.get_token($url,login,password)
|
18
|
+
rescue
|
19
|
+
puts "Login failed."
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
File.open($token_file,'w') {|f| f.write $token}
|
23
|
+
puts "Token is saved in: #{$token_file}"
|
24
|
+
end #get_token
|
25
|
+
end #do
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "reset", "Reset the rhoconnect database (you will need to run rhoconnect:get_token afterwards)"
|
3
|
+
def reset
|
4
|
+
invoke :config
|
5
|
+
confirm = ask " Are you sure? Resetting will remove all data!\n" +
|
6
|
+
" It will also return an error code to all\n" +
|
7
|
+
" existing devices when they connect! (yes/no):"
|
8
|
+
|
9
|
+
if confirm == 'yes'
|
10
|
+
RhoconnectApi.reset($url,$token)
|
11
|
+
puts "Database reset."
|
12
|
+
else
|
13
|
+
puts "Cancelling."
|
14
|
+
end #if
|
15
|
+
end #reset
|
16
|
+
end #do
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "reset-refresh", "Reset source refresh time"
|
3
|
+
def reset_refresh
|
4
|
+
invoke :config
|
5
|
+
user = ask "user: "
|
6
|
+
source_name = ask "source name: "
|
7
|
+
RestClient.post("#{$url}/api/source/set_refresh_time", { :api_token => $token,
|
8
|
+
:user_name => user,
|
9
|
+
:source_name => source_name })
|
10
|
+
end #reset_refresh
|
11
|
+
end #do
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "secret", "Generate a cryptographically secure secret session key"
|
3
|
+
def secret
|
4
|
+
begin
|
5
|
+
require 'securerandom'
|
6
|
+
puts SecureRandom.hex(64)
|
7
|
+
rescue LoadError
|
8
|
+
puts "Missing secure random generator. Try running `rhoconnect secret` in a rails application instead."
|
9
|
+
end #begin
|
10
|
+
end #secret
|
11
|
+
end #do
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Execute.define_task do
|
2
|
+
desc "set-admin-password", "Sets the admin password"
|
3
|
+
def set_admin_password
|
4
|
+
invoke :get_token
|
5
|
+
new_pass,new_pass_confirm = '',''
|
6
|
+
begin
|
7
|
+
system "stty -echo"
|
8
|
+
new_pass = ask "\nnew admin password: "
|
9
|
+
new_pass_confirm = ask "\nconfirm new admin password: "
|
10
|
+
system "stty echo"
|
11
|
+
rescue NoMethodError, Interrupt
|
12
|
+
system "stty echo"
|
13
|
+
exit
|
14
|
+
end #begin
|
15
|
+
if new_pass == ''
|
16
|
+
puts "\nNew password can't be empty."
|
17
|
+
elsif new_pass == new_pass_confirm
|
18
|
+
puts ""
|
19
|
+
RestClient.post("#{$url}/api/user/update_user", { :app_name => $appname,
|
20
|
+
:api_token => $token,
|
21
|
+
:attributes => { :new_password => new_pass } })
|
22
|
+
else
|
23
|
+
puts "\nNew password and confirmation must match."
|
24
|
+
end #if
|
25
|
+
end #set_admin_password
|
26
|
+
end #do
|