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
@@ -0,0 +1,225 @@
|
|
1
|
+
module GraphHelper
|
2
|
+
|
3
|
+
def source_timing(params)
|
4
|
+
#name,data,options
|
5
|
+
puts "display is #{params}"
|
6
|
+
@displayname = params['display_name']
|
7
|
+
names = []
|
8
|
+
begin
|
9
|
+
names = get_sources('all') #RhoconnectApi::list_sources(session[:server],session[:token],:all)
|
10
|
+
rescue Exception => e
|
11
|
+
puts "errror #{e.message}"
|
12
|
+
end
|
13
|
+
@sources = []
|
14
|
+
|
15
|
+
names.each do |name|
|
16
|
+
s = {}
|
17
|
+
data = []
|
18
|
+
series = []
|
19
|
+
options = { :legend => { :show => true }, :title => name }
|
20
|
+
s['name'] = name
|
21
|
+
|
22
|
+
keys = get_user_count("source:*:#{name}") #RhoconnectApi::stats(session[:server],session[:token], :names => "source:*:#{name}")
|
23
|
+
|
24
|
+
xmin = 9999999999999999
|
25
|
+
xmax = -1
|
26
|
+
ymin = 9999999999999999
|
27
|
+
ymax = -1
|
28
|
+
keys.each do |key|
|
29
|
+
method = key.gsub(/source:/,"").gsub(/:.*/,"")
|
30
|
+
series << {:showLabel => true, :label => method }
|
31
|
+
|
32
|
+
range = get_user_count(nil,key,0,-1) #RhoconnectApi::stats(session[:server],session[:token], {:metric => key, :start => 0, :finish => -1})
|
33
|
+
thisdata = []
|
34
|
+
range.each do |value|
|
35
|
+
count = value.split(',')[0]
|
36
|
+
value.gsub!(/.*,/,"")
|
37
|
+
thisdata << value.split(":").reverse
|
38
|
+
thisdata[-1][0] = thisdata[-1][0].to_i * 1000
|
39
|
+
thisdata[-1][1] = thisdata[-1][1].to_f
|
40
|
+
thisdata[-1][1] /= count.to_f
|
41
|
+
|
42
|
+
ymin = thisdata[-1][1].to_f if thisdata[-1][1] && thisdata[-1][1].to_f < ymin
|
43
|
+
ymax = thisdata[-1][1].to_f if thisdata[-1][1] && thisdata[-1][1].to_f > ymax
|
44
|
+
|
45
|
+
end
|
46
|
+
data << thisdata
|
47
|
+
xmin = thisdata[0][0].to_i if thisdata[0] && thisdata[0][0].to_i < xmin
|
48
|
+
xmax = thisdata[-1][0].to_i if thisdata[-1] && thisdata[-1][0].to_i > xmax
|
49
|
+
end
|
50
|
+
|
51
|
+
options[:axes] = {
|
52
|
+
:yaxis => { :tickOptions => { :formatString =>'%.3f'}, :autoscale => true, :min => 0, :max => ymax + (ymax * 0.05), :label => 'Seconds', :labelRenderer => '$.jqplot.CanvasAxisLabelRenderer' },
|
53
|
+
:xaxis => { :autoscale => true, :renderer=>'$.jqplot.DateAxisRenderer',
|
54
|
+
:tickOptions => {:formatString => '%m/%d/%y'}}
|
55
|
+
}
|
56
|
+
|
57
|
+
s['data'] = data
|
58
|
+
options[:series] = series
|
59
|
+
options[:cursor] = {:zoom => true, :showTooltip => true}
|
60
|
+
|
61
|
+
s['options'] = options
|
62
|
+
|
63
|
+
@sources << s
|
64
|
+
end
|
65
|
+
@graph_t = 'source'
|
66
|
+
@data = [[[1,2],[3,4],[5,6]]].to_json
|
67
|
+
erb :jqplot, :layout => false
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
def http_timing(params)
|
72
|
+
@uri = 'timing/httptiming'
|
73
|
+
|
74
|
+
#name,data,options
|
75
|
+
@displayname = params['display_name']
|
76
|
+
names = ["GET","POST"]
|
77
|
+
begin
|
78
|
+
names = get_sources('all') #RhoconnectApi::list_sources(session[:server],session[:token],:all)
|
79
|
+
rescue Exception => e
|
80
|
+
puts "errror #{e.message}"
|
81
|
+
end
|
82
|
+
names << "ALL"
|
83
|
+
@sources = []
|
84
|
+
|
85
|
+
names.each do |name|
|
86
|
+
s = {}
|
87
|
+
data = []
|
88
|
+
series = []
|
89
|
+
options = { :legend => { :show => true }, :title => name }
|
90
|
+
s['name'] = name
|
91
|
+
|
92
|
+
name = "*" if name == "ALL"
|
93
|
+
keys = get_user_count("http:*:#{name}") #RhoconnectApi::stats(session[:server],session[:token], :names => "http:*:#{name}")
|
94
|
+
|
95
|
+
xmin = 9999999999999999
|
96
|
+
xmax = -1
|
97
|
+
ymin = 9999999999999999
|
98
|
+
ymax = -1
|
99
|
+
keys.each do |key|
|
100
|
+
method = key.gsub(/http:.*?:/,"")
|
101
|
+
method.gsub!(/:.*/,"") unless name == "*"
|
102
|
+
series << {:showLabel => true, :label => method }
|
103
|
+
|
104
|
+
range = get_user_count(nil,key,0,-1) #RhoconnectApi::stats(session[:server],session[:token], {:metric => key, :start => 0, :finish => -1})
|
105
|
+
thisdata = []
|
106
|
+
range.each do |value|
|
107
|
+
count = value.split(',')[0]
|
108
|
+
value.gsub!(/.*,/,"")
|
109
|
+
thisdata << value.split(":").reverse
|
110
|
+
thisdata[-1][0] = thisdata[-1][0].to_i * 1000
|
111
|
+
thisdata[-1][1] = thisdata[-1][1].to_f
|
112
|
+
thisdata[-1][1] /= count.to_f
|
113
|
+
|
114
|
+
ymin = thisdata[-1][1].to_f if thisdata[-1][1] && thisdata[-1][1].to_f < ymin
|
115
|
+
ymax = thisdata[-1][1].to_f if thisdata[-1][1] && thisdata[-1][1].to_f > ymax
|
116
|
+
|
117
|
+
end
|
118
|
+
data << thisdata
|
119
|
+
xmin = thisdata[0][0].to_i if thisdata[0] && thisdata[0][0].to_i < xmin
|
120
|
+
xmax = thisdata[-1][0].to_i if thisdata[-1] && thisdata[-1][0].to_i > xmax
|
121
|
+
end
|
122
|
+
|
123
|
+
options[:axes] = {
|
124
|
+
:yaxis => { :tickOptions => { :formatString =>'%.3f'}, :autoscale => true, :min => 0, :max => ymax + (ymax * 0.05), :label => 'Seconds', :labelRenderer => '$.jqplot.CanvasAxisLabelRenderer' },
|
125
|
+
:xaxis => { :autoscale => true, :renderer=>'$.jqplot.DateAxisRenderer',
|
126
|
+
:tickOptions => {:formatString => '%m/%d/%y'}}
|
127
|
+
}
|
128
|
+
|
129
|
+
s['data'] = data
|
130
|
+
options[:series] = series
|
131
|
+
options[:cursor] = {:zoom => true, :showTooltip => true}
|
132
|
+
|
133
|
+
s['options'] = options
|
134
|
+
|
135
|
+
@sources << s
|
136
|
+
end
|
137
|
+
@graph_t = 'http'
|
138
|
+
@data = [[[1,2],[3,4],[5,6]]].to_json
|
139
|
+
erb :jqplot, :layout => false
|
140
|
+
end
|
141
|
+
|
142
|
+
def count_graph(uri,title,name,metric)
|
143
|
+
start = 0
|
144
|
+
finish = -1
|
145
|
+
now = Time.now.to_i
|
146
|
+
format = "%m/%d/%y"
|
147
|
+
|
148
|
+
thisdata = []
|
149
|
+
series = []
|
150
|
+
series <<
|
151
|
+
options = { :legend => { :show => false }, :title => title }
|
152
|
+
@sources = []
|
153
|
+
|
154
|
+
s = {}
|
155
|
+
usercount = []
|
156
|
+
|
157
|
+
usercount = get_user_count(nil,metric,start,finish)
|
158
|
+
|
159
|
+
usercount.each do |count|
|
160
|
+
user,timestamp = count.split(':')
|
161
|
+
user = user.to_i
|
162
|
+
timestamp = timestamp.to_i * 1000
|
163
|
+
thisdata << [timestamp,user]
|
164
|
+
end
|
165
|
+
|
166
|
+
options[:axes] = {
|
167
|
+
:xaxis => { :autoscale => true, :renderer=>'$.jqplot.DateAxisRenderer',
|
168
|
+
:tickOptions => {:formatString => format}},
|
169
|
+
:yaxis => {:label => name, :labelRenderer => '$.jqplot.CanvasAxisLabelRenderer'}
|
170
|
+
}
|
171
|
+
|
172
|
+
options[:cursor] = {:zoom => true, :showTooltip => true}
|
173
|
+
s['name'] = name
|
174
|
+
s['data'] = [thisdata]
|
175
|
+
s['options'] = options
|
176
|
+
@sources << s
|
177
|
+
erb :jqplot, :layout => false
|
178
|
+
end
|
179
|
+
|
180
|
+
def get_user_count(name=nil,metric_p=nil,start=nil,finish=nil)
|
181
|
+
begin
|
182
|
+
if Rhoconnect.stats == true
|
183
|
+
names = name
|
184
|
+
if names
|
185
|
+
Rhoconnect::Stats::Record.keys(names)
|
186
|
+
else
|
187
|
+
metric = metric_p
|
188
|
+
rtype = Rhoconnect::Stats::Record.rtype(metric)
|
189
|
+
if rtype == 'zset'
|
190
|
+
# returns [] if no results
|
191
|
+
Rhoconnect::Stats::Record.range(metric,start,finish)
|
192
|
+
elsif rtype == 'string'
|
193
|
+
Rhoconnect::Stats::Record.get_value(metric) || ''
|
194
|
+
else
|
195
|
+
raise ApiException.new(404, "Unknown metric")
|
196
|
+
end
|
197
|
+
end
|
198
|
+
else
|
199
|
+
raise ApiException.new(500, "Stats not enabled")
|
200
|
+
end
|
201
|
+
rescue Exception => e
|
202
|
+
puts "error #{e.message} -- #{metric}"
|
203
|
+
usercount = ["0:#{Time.now.to_i}"]
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def get_sources(partition_type)
|
208
|
+
sources = App.load(APP_NAME).sources
|
209
|
+
puts "sources is -- #{sources}"
|
210
|
+
if partition_type.nil? or partition_type == 'all'
|
211
|
+
sources
|
212
|
+
else
|
213
|
+
res = []
|
214
|
+
sources.each do |name|
|
215
|
+
s = Source.load(name,{:app_id => APP_NAME,:user_id => '*'})
|
216
|
+
if s.partition_type and s.partition_type == partition_type.to_sym
|
217
|
+
res << name
|
218
|
+
end
|
219
|
+
end
|
220
|
+
res
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
@@ -20,19 +20,39 @@ module Rhoconnect
|
|
20
20
|
create_hsql_data_file(bulk_data,ts) if Rhoconnect.blackberry_bulk_sync
|
21
21
|
lap_timer('create_hsql_data_file',timer)
|
22
22
|
log "finished bulk data process"
|
23
|
+
#bulk_data.state = :completed
|
24
|
+
#bulk_data.refresh_time = Time.now.to_i + Rhoconnect.bulk_sync_poll_interval
|
25
|
+
else
|
26
|
+
raise Exception.new("No bulk data found for #{params["data_name"]}")
|
27
|
+
end
|
28
|
+
rescue Exception => e
|
29
|
+
bulk_data.delete if bulk_data
|
30
|
+
log "Bulk data job raised: #{e.message}"
|
31
|
+
log e.backtrace.join("\n")
|
32
|
+
raise e
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.after_perform_x(*args)
|
37
|
+
log "BulkDataJob.after_perform_x hook called ..."
|
38
|
+
params = args[0] # 1st parameter is bulk data
|
39
|
+
begin
|
40
|
+
bulk_data = BulkData.load(params["data_name"]) if BulkData.is_exist?(params["data_name"])
|
41
|
+
if bulk_data
|
23
42
|
bulk_data.state = :completed
|
24
43
|
bulk_data.refresh_time = Time.now.to_i + Rhoconnect.bulk_sync_poll_interval
|
44
|
+
log "BulkDataJob.after_perform_x hook set data state to complete."
|
25
45
|
else
|
26
46
|
raise Exception.new("No bulk data found for #{params["data_name"]}")
|
27
47
|
end
|
28
48
|
rescue Exception => e
|
29
49
|
bulk_data.delete if bulk_data
|
30
|
-
log "Bulk data
|
50
|
+
log "Bulk data after_perform_x raised: #{e.message}"
|
31
51
|
log e.backtrace.join("\n")
|
32
52
|
raise e
|
33
53
|
end
|
34
54
|
end
|
35
|
-
|
55
|
+
|
36
56
|
def self.import_data_to_object_values(db,source)
|
37
57
|
data = source.get_data(:md)
|
38
58
|
counter = {}
|
@@ -129,6 +149,8 @@ module Rhoconnect
|
|
129
149
|
sources_refs = {}
|
130
150
|
schema,index,bulk_data.dbfile = get_file_args(bulk_data.name,ts)
|
131
151
|
FileUtils.mkdir_p(File.dirname(bulk_data.dbfile))
|
152
|
+
# TODO: remove old bulk files!
|
153
|
+
# FileUtils.rm Dir.glob(File.join(Rhoconnect.data_directory, "#{bulk_data.name}*"))
|
132
154
|
|
133
155
|
db = DBAdapter.instance.get_connection(bulk_data.dbfile)
|
134
156
|
db.execute_batch(File.open(schema,'r').read)
|
data/lib/rhoconnect/server.rb
CHANGED
@@ -3,7 +3,6 @@ require 'sinatra/base'
|
|
3
3
|
require 'erb'
|
4
4
|
require 'json'
|
5
5
|
require 'fileutils'
|
6
|
-
#require 'rack/contrib'
|
7
6
|
require 'rhoconnect'
|
8
7
|
require 'rhoconnect/x_domain_session_wrapper'
|
9
8
|
require 'rhoconnect/body_content_type_parser'
|
@@ -20,9 +19,6 @@ module Rhoconnect
|
|
20
19
|
end
|
21
20
|
|
22
21
|
class Server < Sinatra::Base
|
23
|
-
libdir = File.dirname(File.expand_path(__FILE__))
|
24
|
-
set :views, "#{libdir}/server/views"
|
25
|
-
set :public_folder, "#{libdir}/server/public"
|
26
22
|
set :static, true
|
27
23
|
set :stats, false
|
28
24
|
# default secret
|
@@ -200,7 +196,30 @@ module Rhoconnect
|
|
200
196
|
end
|
201
197
|
end
|
202
198
|
|
199
|
+
private
|
200
|
+
def self._use_async_framework
|
201
|
+
return false if settings.respond_to?(:use_async_model) and settings.use_async_model == false
|
202
|
+
return false if @dispatch_framework_initialized
|
203
|
+
|
204
|
+
@dispatch_framework_initialized ||=true
|
205
|
+
if RUBY_VERSION =~ /1.9/ and not defined?(JRUBY_VERSION)
|
206
|
+
require 'rhoconnect/async'
|
207
|
+
register Rhoconnect::Synchrony
|
208
|
+
helpers Rhoconnect::AsyncHelpers
|
209
|
+
else
|
210
|
+
settings.use_async_model = false
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
203
214
|
def self.new
|
215
|
+
# by default, enable this feature
|
216
|
+
if not settings.respond_to?(:use_async_model) or settings.use_async_model != false
|
217
|
+
set :use_async_model, true
|
218
|
+
end
|
219
|
+
# this must be called first - because
|
220
|
+
# it redefines some of the middleware
|
221
|
+
Rhoconnect::Server._use_async_framework
|
222
|
+
|
204
223
|
if settings.respond_to?(:stats) and settings.send(:stats) == true
|
205
224
|
Rhoconnect.stats = true
|
206
225
|
else
|
@@ -208,6 +227,7 @@ module Rhoconnect
|
|
208
227
|
Rhoconnect.stats = false
|
209
228
|
end
|
210
229
|
settings.use_middleware
|
230
|
+
|
211
231
|
super
|
212
232
|
end
|
213
233
|
|
@@ -222,12 +242,16 @@ module Rhoconnect
|
|
222
242
|
before do
|
223
243
|
cache_control :no_cache
|
224
244
|
headers({'pragma'=>'no-cache'})
|
225
|
-
|
245
|
+
|
226
246
|
if params[:version] and params[:version].to_i < 3
|
227
247
|
throw :halt, [404, "Server supports version 3 or higher of the protocol."]
|
228
248
|
end
|
229
249
|
end
|
230
|
-
|
250
|
+
|
251
|
+
get '/' do
|
252
|
+
redirect "/console/"
|
253
|
+
end
|
254
|
+
|
231
255
|
%w[get post].each do |verb|
|
232
256
|
send(verb, "/*application*") do
|
233
257
|
unless request_action == 'clientlogin'
|
@@ -236,11 +260,7 @@ module Rhoconnect
|
|
236
260
|
pass
|
237
261
|
end
|
238
262
|
end
|
239
|
-
|
240
|
-
get '/' do
|
241
|
-
erb :index
|
242
|
-
end
|
243
|
-
|
263
|
+
|
244
264
|
# old routes
|
245
265
|
post '/login' do
|
246
266
|
mark_deprecated_call_and_reroute(:login, :admin, self, params)
|
data/lib/rhoconnect/source.rb
CHANGED
@@ -68,6 +68,13 @@ module Rhoconnect
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
def update_fields(fields)
|
72
|
+
fields.each do |name,value|
|
73
|
+
arg = "#{name}=".to_sym
|
74
|
+
self.send(arg, value)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
71
78
|
def to_array
|
72
79
|
res = []
|
73
80
|
@@string_fields.each do |field|
|
@@ -90,14 +97,11 @@ module Rhoconnect
|
|
90
97
|
|
91
98
|
# source fields
|
92
99
|
define_fields([:id, :rho__id, :name, :url, :login, :password, :callback_url, :partition_type, :sync_type,
|
93
|
-
:queue, :query_queue, :cud_queue, :belongs_to, :has_many, :pass_through], [:source_id, :priority, :retry_limit])
|
100
|
+
:queue, :query_queue, :cud_queue, :belongs_to, :has_many, :pass_through], [:source_id, :priority, :retry_limit, :simulate_time])
|
94
101
|
|
95
102
|
def initialize(fields)
|
96
103
|
self.name = fields['name'] || fields[:name]
|
97
|
-
fields
|
98
|
-
arg = "#{name}=".to_sym
|
99
|
-
self.send(arg, value) if self.respond_to?(arg)
|
100
|
-
end
|
104
|
+
update_fields(fields)
|
101
105
|
end
|
102
106
|
|
103
107
|
def self.set_defaults(fields)
|
@@ -113,6 +117,7 @@ module Rhoconnect
|
|
113
117
|
fields[:belongs_to] = fields[:belongs_to].to_json if fields[:belongs_to]
|
114
118
|
fields[:schema] = fields[:schema].to_json if fields[:schema]
|
115
119
|
fields[:retry_limit] = fields[:retry_limit] ? fields[:retry_limit] : 0
|
120
|
+
fields[:simulate_time] = fields[:simulate_time] ? fields[:simulate_time] : 0
|
116
121
|
end
|
117
122
|
|
118
123
|
def self.create(fields,params)
|
@@ -111,6 +111,29 @@ module Rhoconnect
|
|
111
111
|
@source.app_id,@source.user_id,params)
|
112
112
|
end
|
113
113
|
|
114
|
+
def fast_insert(new_objs, timeout=10,raise_on_expire=false)
|
115
|
+
@source.lock(:md,timeout,raise_on_expire) do |s|
|
116
|
+
diff_count = new_objs.size
|
117
|
+
@source.put_data(:md, new_objs, true)
|
118
|
+
@source.update_count(:md_size,diff_count)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def fast_update(orig_hash, new_hash, timeout=10,raise_on_expire=false)
|
123
|
+
@source.lock(:md,timeout,raise_on_expire) do |s|
|
124
|
+
@source.delete_data(:md, orig_hash)
|
125
|
+
@source.put_data(:md, new_hash, true)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def fast_delete(delete_objs, timeout=10,raise_on_expire=false)
|
130
|
+
@source.lock(:md,timeout,raise_on_expire) do |s|
|
131
|
+
diff_count = -delete_objs.size
|
132
|
+
@source.delete_data(:md, delete_objs)
|
133
|
+
@source.update_count(:md_size,diff_count)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
114
137
|
def push_objects(objects,timeout=10,raise_on_expire=false,rebuild_md=true)
|
115
138
|
@source.lock(:md,timeout,raise_on_expire) do |s|
|
116
139
|
diff_count = 0
|
@@ -360,10 +383,17 @@ module Rhoconnect
|
|
360
383
|
# Metadata Operation; source adapter returns json
|
361
384
|
def _get_data(method)
|
362
385
|
if @adapter.respond_to?(method)
|
363
|
-
data = @adapter.send(method)
|
386
|
+
data = @adapter.send(method)
|
364
387
|
if data
|
365
388
|
@source.put_value(method,data)
|
366
|
-
|
389
|
+
if method == :schema
|
390
|
+
parsed = JSON.parse(data)
|
391
|
+
schema_version = parsed['version']
|
392
|
+
raise "Mandatory version key is not defined in source adapter schema method" if schema_version.nil?
|
393
|
+
@source.put_value("#{method}_sha1",Digest::SHA1.hexdigest(schema_version))
|
394
|
+
else
|
395
|
+
@source.put_value("#{method}_sha1",Digest::SHA1.hexdigest(data))
|
396
|
+
end
|
367
397
|
end
|
368
398
|
end
|
369
399
|
end
|
data/lib/rhoconnect/tasks.rb
CHANGED
@@ -1,111 +1,19 @@
|
|
1
|
-
require 'json'
|
2
1
|
require 'zip/zip'
|
3
2
|
require 'uri'
|
4
|
-
|
3
|
+
$:.unshift File.dirname(__FILE__)
|
4
|
+
require 'console/rhoconnect_api'
|
5
|
+
require 'utilities'
|
5
6
|
|
7
|
+
DEPRECATION_MSG = "\n" +
|
8
|
+
"*** Warning: As of version 4.0 of rhoconnect, the rake command will be deprecated. ***\n" +
|
9
|
+
"*** Use the corresponding rhoconnect commands instead. ***\n" +
|
10
|
+
"*** Type 'rhoconnect help' for more information on these commands. ***\n" +
|
11
|
+
"\n"
|
6
12
|
|
7
|
-
|
8
|
-
module TaskHelper
|
9
|
-
def post(path,params)
|
10
|
-
req = Net::HTTP.new($host,$port)
|
11
|
-
resp = req.post(path, params.to_json, 'Content-Type' => 'application/json')
|
12
|
-
print_resp(resp, resp.is_a?(Net::HTTPSuccess) ? true : false)
|
13
|
-
end
|
14
|
-
|
15
|
-
def print_resp(resp,success=true)
|
16
|
-
if success
|
17
|
-
puts "=> OK"
|
18
|
-
else
|
19
|
-
puts "=> FAILED"
|
20
|
-
end
|
21
|
-
puts "=> " + resp.body if resp and resp.body and resp.body.length > 0
|
22
|
-
end
|
23
|
-
|
24
|
-
def archive(path)
|
25
|
-
File.join(path,File.basename(path))+'.zip'
|
26
|
-
end
|
27
|
-
|
28
|
-
def ask(msg)
|
29
|
-
print msg
|
30
|
-
STDIN.gets.chomp
|
31
|
-
end
|
32
|
-
|
33
|
-
def load_settings(file)
|
34
|
-
begin
|
35
|
-
$settings = YAML.load_file(file)
|
36
|
-
rescue Exception => e
|
37
|
-
puts "Error opening settings file #{file}: #{e}."
|
38
|
-
puts e.backtrace.join("\n")
|
39
|
-
raise e
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def rhoconnect_socket
|
44
|
-
'/tmp/rhoconnect.dtach'
|
45
|
-
end
|
46
|
-
|
47
|
-
def rhoconnect_pid
|
48
|
-
if windows?
|
49
|
-
Dir.mkdir 'C:/TMP' unless File.directory? 'C:/TMP'
|
50
|
-
'C:/TMP/rhoconnect.pid'
|
51
|
-
else
|
52
|
-
'/tmp/rhoconnect.pid'
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def windows?
|
57
|
-
RUBY_PLATFORM =~ /(win|w)32$/
|
58
|
-
end
|
59
|
-
|
60
|
-
def ruby19?
|
61
|
-
RUBY_VERSION =~ /1.9/
|
62
|
-
end
|
63
|
-
|
64
|
-
def jruby?
|
65
|
-
defined?(JRUBY_VERSION)
|
66
|
-
end
|
67
|
-
|
68
|
-
def thin?
|
69
|
-
begin
|
70
|
-
require 'thin'
|
71
|
-
'rackup -s thin'
|
72
|
-
rescue LoadError
|
73
|
-
nil
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def mongrel?
|
78
|
-
begin
|
79
|
-
require 'mongrel'
|
80
|
-
'rackup -s mongrel'
|
81
|
-
rescue LoadError
|
82
|
-
nil
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def report_missing_server
|
87
|
-
msg =<<-EOF
|
88
|
-
Could not find 'thin' or 'mongrel' on your system. Please install one:
|
89
|
-
gem install thin
|
90
|
-
or
|
91
|
-
gem install mongrel
|
92
|
-
EOF
|
93
|
-
puts msg
|
94
|
-
exit 1
|
95
|
-
end
|
96
|
-
|
97
|
-
# def jetty_rackup?
|
98
|
-
# 'jruby -S jetty-rackup'
|
99
|
-
# end
|
100
|
-
|
101
|
-
def trinidad?
|
102
|
-
'jruby -S trinidad -p 9292 -r config.ru'
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
13
|
+
puts DEPRECATION_MSG if $0.include? 'rake'
|
106
14
|
|
107
15
|
namespace :rhoconnect do
|
108
|
-
include
|
16
|
+
include Utilities
|
109
17
|
include RhoconnectApi
|
110
18
|
|
111
19
|
task :config do
|
@@ -256,7 +164,7 @@ namespace :rhoconnect do
|
|
256
164
|
else
|
257
165
|
puts 'Detach with Ctrl+\ Re-attach with rake rhoconnect:attach'
|
258
166
|
sleep 2
|
259
|
-
|
167
|
+
system "dtach -A #{rhoconnect_socket} #{cmd} config.ru -P #{rhoconnect_pid}"
|
260
168
|
end
|
261
169
|
end
|
262
170
|
|
@@ -305,10 +213,13 @@ namespace :rhoconnect do
|
|
305
213
|
|
306
214
|
desc "run rhoconnect console"
|
307
215
|
task :console, :environment do |t, args|
|
308
|
-
if RedisRunner.running?
|
216
|
+
if RedisRunner.running?
|
217
|
+
application_file = ruby19? ? './application' : 'application'
|
309
218
|
#load development environment by default
|
310
219
|
ENV['RACK_ENV'] = args[:environment] || 'development'
|
311
|
-
|
220
|
+
system "irb -rubygems -r #{File.join(File.dirname(__FILE__),'console')} " +
|
221
|
+
"-r #{File.dirname(__FILE__)} " +
|
222
|
+
"-r #{application_file}"
|
312
223
|
else
|
313
224
|
puts "Redis is not running. Please start it by running 'rake redis:start' command."
|
314
225
|
end
|
@@ -319,13 +230,13 @@ namespace :rhoconnect do
|
|
319
230
|
if windows?
|
320
231
|
File.delete "#{rhoconnect_pid}" if system("FOR /F %A in (#{rhoconnect_pid}) do taskkill /F /PID %A")
|
321
232
|
else
|
322
|
-
|
233
|
+
system "cat #{rhoconnect_pid} | xargs kill -3"
|
323
234
|
end
|
324
235
|
end
|
325
236
|
|
326
237
|
desc "Attach to rhoconnect console"
|
327
238
|
task :attach => :dtach_installed do
|
328
|
-
|
239
|
+
system "dtach -a #{rhoconnect_socket}" unless windows?
|
329
240
|
end
|
330
241
|
|
331
242
|
desc "Launch the web console in a browser - uses :syncserver: in settings.yml"
|
@@ -380,7 +291,7 @@ namespace :rhoconnect do
|
|
380
291
|
end
|
381
292
|
# build the executable WAR using the config/warble.rb file
|
382
293
|
ENV['BUNDLE_WITHOUT'] = ['development','test'].join(':')
|
383
|
-
|
294
|
+
system 'warble executable war'
|
384
295
|
else
|
385
296
|
puts "Cannot build WAR files outside of JRuby environment!"
|
386
297
|
end
|
@@ -45,6 +45,26 @@ module Rhoconnect
|
|
45
45
|
return @s.is_pass_through? ? res : md
|
46
46
|
end
|
47
47
|
|
48
|
+
# Executes the adapter's search method based on search_params
|
49
|
+
# and returns a hash of hashes.
|
50
|
+
# For example, if master document was
|
51
|
+
# {
|
52
|
+
# "1"=>{"name"=>"Acme", "industry"=>"Electronics"},
|
53
|
+
# "2"=>{"name"=>"Best", "industry"=>"Software"}
|
54
|
+
# }
|
55
|
+
#
|
56
|
+
# Then call test_search("name"=>"Acme") would return
|
57
|
+
# {
|
58
|
+
# "1"=>{"name"=>"Acme", "industry"=>"Electronics"},
|
59
|
+
# }
|
60
|
+
def test_search(search_params)
|
61
|
+
pass_through = @s.pass_through
|
62
|
+
@s.pass_through = 'true'
|
63
|
+
res = @ss.search(@c.id, search_params)
|
64
|
+
@s.pass_through = pass_through
|
65
|
+
res
|
66
|
+
end
|
67
|
+
|
48
68
|
# Executes the adapter's query method and returns
|
49
69
|
# the metadata stored in redis
|
50
70
|
# For example, if your source adapter metadata method was:
|