rhoconnect 4.0.4 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +5 -13
  2. data/CHANGELOG.md +54 -5
  3. data/CREDITS +219 -219
  4. data/Gemfile +2 -2
  5. data/Gemfile.lock +68 -79
  6. data/Rakefile +1 -2
  7. data/bench/benchapp/spec/models/ruby/mock_adapter_spec.rb +17 -17
  8. data/bench/benchapp/spec/models/ruby/queue_mock_adapter_spec.rb +17 -17
  9. data/bench/benchapp/spec/spec_helper.rb +3 -3
  10. data/bench/blobapp/spec/models/ruby/blob_adapter_spec.rb +17 -17
  11. data/bench/blobapp/spec/spec_helper.rb +3 -3
  12. data/bench/lib/bench/runner.rb +1 -69
  13. data/bench/lib/bench.rb +18 -18
  14. data/bench/spec/mock_adapter_spec.rb +54 -55
  15. data/bench/spec/mock_client_spec.rb +47 -48
  16. data/bench/spec/result_spec.rb +41 -44
  17. data/bench/spec/utils_spec.rb +24 -25
  18. data/commands/generators/app.rb +7 -5
  19. data/commands/generators/controller.rb +7 -5
  20. data/commands/generators/model.rb +7 -5
  21. data/commands/generators/source.rb +7 -5
  22. data/commands/parser.rb +1 -1
  23. data/commands/redis/redis_download.rb +1 -1
  24. data/doc/async-jobs.txt +9 -9
  25. data/doc/supported-platforms.txt +0 -2
  26. data/generators/rhoconnect.rb +92 -212
  27. data/generators/templates/application/rcgemfile +3 -3
  28. data/generators/templates/application/spec/application_controller_spec.rb +14 -16
  29. data/generators/templates/application/spec/js_spec.rb +20 -20
  30. data/generators/templates/application/spec/spec_helper.rb +1 -1
  31. data/generators/templates/source/controllers/ruby/controller_spec.rb +18 -19
  32. data/generators/templates/source/models/ruby/model_spec.rb +17 -17
  33. data/install.sh +10 -21
  34. data/installer/unix-like/rho_connect_install_constants.rb +5 -5
  35. data/installer/unix-like/rho_connect_install_installers.rb +4 -4
  36. data/installer/utils/constants.rb +6 -6
  37. data/installer/utils/nix_install_test.rb +29 -29
  38. data/installer/utils/package_upload/repos.rake +16 -26
  39. data/js-adapters/node.rb +4 -4
  40. data/js-adapters/node_channel.rb +4 -8
  41. data/lib/rhoconnect/db_adapter.rb +13 -13
  42. data/lib/rhoconnect/handler/changes/engine.rb +1 -1
  43. data/lib/rhoconnect/jobs/bulk_data_job.rb +29 -29
  44. data/lib/rhoconnect/license.rb +7 -7
  45. data/lib/rhoconnect/model/helpers/find_duplicates_on_update.rb +13 -13
  46. data/lib/rhoconnect/ping/apple.rb +4 -4
  47. data/lib/rhoconnect/server.rb +2 -2
  48. data/lib/rhoconnect/source.rb +2 -2
  49. data/lib/rhoconnect/store.rb +12 -6
  50. data/lib/rhoconnect/utilities.rb +2 -2
  51. data/lib/rhoconnect/version.rb +1 -1
  52. data/lib/rhoconnect.rb +6 -4
  53. data/rhoconnect.gemspec +5 -6
  54. data/spec/api/api_helper.rb +1 -1
  55. data/spec/api/app/fast_delete_spec.rb +22 -22
  56. data/spec/api/app/fast_insert_spec.rb +23 -23
  57. data/spec/api/app/fast_update_spec.rb +63 -63
  58. data/spec/api/app/push_deletes_spec.rb +11 -13
  59. data/spec/api/app/push_objects_spec.rb +39 -39
  60. data/spec/api/client/client_get_db_doc_spec.rb +29 -29
  61. data/spec/api/client/client_set_db_doc_spec.rb +11 -11
  62. data/spec/api/client/get_client_params_spec.rb +29 -29
  63. data/spec/api/client/list_client_docs_spec.rb +32 -34
  64. data/spec/api/client/reset_spec.rb +30 -30
  65. data/spec/api/readstate/set_refresh_time_spec.rb +43 -43
  66. data/spec/api/source/get_source_params_spec.rb +32 -34
  67. data/spec/api/source/list_sources_spec.rb +13 -13
  68. data/spec/api/source/update_source_params_spec.rb +19 -19
  69. data/spec/api/store/get_db_doc_spec.rb +27 -27
  70. data/spec/api/store/set_db_doc_spec.rb +38 -38
  71. data/spec/api/system/adapter_spec.rb +27 -29
  72. data/spec/api/system/get_license_info_spec.rb +11 -11
  73. data/spec/api/system/login_spec.rb +37 -37
  74. data/spec/api/system/reset_spec.rb +15 -15
  75. data/spec/api/system/stats_spec.rb +70 -71
  76. data/spec/api/user/create_user_spec.rb +37 -37
  77. data/spec/api/user/delete_client_spec.rb +7 -7
  78. data/spec/api/user/delete_user_spec.rb +62 -62
  79. data/spec/api/user/list_clients_spec.rb +24 -24
  80. data/spec/api/user/list_source_docs_spec.rb +29 -29
  81. data/spec/api/user/list_users_spec.rb +22 -22
  82. data/spec/api/user/ping_spec.rb +18 -18
  83. data/spec/api/user/show_user_spec.rb +10 -10
  84. data/spec/api/user/update_user_spec.rb +43 -43
  85. data/spec/api/user/user_get_db_doc_spec.rb +12 -12
  86. data/spec/api/user/user_set_db_doc_spec.rb +37 -37
  87. data/spec/api_token_spec.rb +8 -8
  88. data/spec/app_spec.rb +18 -17
  89. data/spec/apps/jstestapp/settings/settings.yml +2 -0
  90. data/spec/async_spec.rb +9 -11
  91. data/spec/bulk_data/bulk_data_spec.rb +120 -120
  92. data/spec/cli/cli_spec.rb +50 -53
  93. data/spec/client_spec.rb +105 -105
  94. data/spec/client_sync_spec.rb +529 -528
  95. data/spec/controllers/js_base_spec.rb +147 -141
  96. data/spec/doc/doc_spec.rb +51 -52
  97. data/spec/document_spec.rb +58 -58
  98. data/spec/dynamic_adapter_spec.rb +33 -36
  99. data/spec/generator/generator_spec.rb +76 -42
  100. data/spec/jobs/bulk_data_job_spec.rb +101 -102
  101. data/spec/jobs/ping_job_spec.rb +176 -177
  102. data/spec/jobs/source_job_spec.rb +24 -25
  103. data/spec/license_spec.rb +54 -55
  104. data/spec/models/js_base_spec.rb +121 -120
  105. data/spec/perf/bulk_data_perf_spec.rb +23 -24
  106. data/spec/perf/perf_spec_helper.rb +7 -7
  107. data/spec/perf/store_perf_spec.rb +139 -140
  108. data/spec/ping/apple_spec.rb +65 -65
  109. data/spec/ping/gcm_spec.rb +83 -84
  110. data/spec/ping/rhoconnect_push_spec.rb +52 -53
  111. data/spec/predefined_adapters/rho_internal_bench_adapter_controller_js_spec.rb +100 -101
  112. data/spec/predefined_adapters/rho_internal_js_bench_adapter_js_spec.rb +29 -31
  113. data/spec/read_state_spec.rb +24 -25
  114. data/spec/rhoconnect_spec.rb +7 -7
  115. data/spec/server/server_spec.rb +664 -662
  116. data/spec/server/stats_spec.rb +12 -12
  117. data/spec/source_adapter_spec.rb +124 -125
  118. data/spec/source_spec.rb +148 -149
  119. data/spec/source_sync_spec.rb +736 -736
  120. data/spec/spec_helper.rb +4 -5
  121. data/spec/stats/record_spec.rb +22 -21
  122. data/spec/store_orm_spec.rb +48 -48
  123. data/spec/store_spec.rb +428 -426
  124. data/spec/support/shared_examples.rb +5 -7
  125. data/spec/sync_states_spec.rb +67 -67
  126. data/spec/test_methods_spec.rb +121 -123
  127. data/spec/testdata/10000-data.txt +0 -0
  128. data/spec/testdata/5000-data.txt +0 -0
  129. data/spec/user_spec.rb +102 -102
  130. data/tasks/redis.rake +3 -3
  131. metadata +154 -195
  132. data/bench/benchapp/tmp/pids/passenger.9292.pid.lock +0 -0
  133. data/bench/benchapp/tmp/restart.txt +0 -0
  134. data/bench/blobapp/settings/license.key.bak +0 -2
  135. data/bench/blobapp/tmp/restart.txt +0 -0
  136. data/bench/lib/testdata/1-data.txt +0 -0
  137. data/bench/lib/testdata/10-data.txt +0 -0
  138. data/bench/lib/testdata/2-data.txt +0 -0
  139. data/bench/lib/testdata/250-data.txt +0 -0
  140. data/bench/lib/testdata/5-blob_data.txt +0 -0
  141. data/bench/lib/testdata/5-data.txt +0 -0
  142. data/bench/lib/testdata/50-data.txt +0 -0
  143. data/bench/lib/testdata/500-data.txt +0 -0
  144. data/doc/protocol.html +0 -1993
  145. data/spec/coverage/rcov/assets/0.2.3/jquery-1.3.2.min.js +0 -19
  146. data/spec/coverage/rcov/assets/0.2.3/jquery.tablesorter.min.js +0 -15
  147. data/spec/coverage/rcov/assets/0.2.3/print.css +0 -12
  148. data/spec/coverage/rcov/assets/0.2.3/rcov.js +0 -42
  149. data/spec/coverage/rcov/assets/0.2.3/screen.css +0 -270
  150. data/spec/coverage/rcov/index.html +0 -88
  151. data/spec/generator/generator_spec_helper.rb +0 -9
@@ -19,18 +19,18 @@ module Installers
19
19
  end
20
20
  raise "Nginx installation failed." if $? != 0
21
21
  end
22
-
22
+
23
23
  def install_all_gems
24
24
  @gem_path = "#{@options[:prefix]}/bin/gem"
25
25
  # Update the RubyGems system software
26
26
  # FIXME: => v.2.0.0
27
- cmd "#{@gem_path} update --system 1.8.25"
27
+ # cmd "#{@gem_path} update --system 1.8.25"
28
28
  GEMS.each do |gem|
29
29
  install_gem(gem)
30
30
  end
31
31
  end
32
32
 
33
- def install_gem(gem, options = "--no-ri --no-rdoc")
33
+ def install_gem(gem, options = "--no-document")
34
34
  print_header "Installing #{gem} ..."
35
35
  cmd "#{@gem_path} install #{gem} #{options}"
36
36
  raise "#{gem} installation failed." if $? != 0
@@ -76,7 +76,7 @@ module Installers
76
76
 
77
77
  cmd "#{@options[:prefix]}/bin/bundle config build.sqlite3 " +
78
78
  "--with-sqlite3-include=#{@options[:prefix]}/include " +
79
- "--with-sqlite3-lib=#{@options[:prefix]}/lib"
79
+ "--with-sqlite3-lib=#{@options[:prefix]}/lib"
80
80
  gem_name = (Dir.glob "rhoconnect-*.gem")[0]
81
81
  if gem_name && File.exists?(gem_name)
82
82
  install_gem(gem_name)
@@ -11,20 +11,20 @@ module Constants
11
11
  PEM_FILE = 'jenkinskey.pem'
12
12
  SSH_KEY = "#{HOME_DIR}/.ssh/#{PEM_FILE}"
13
13
  ACCESS_KEY_FILE = "#{HOME_DIR}/.ec2"
14
- UBUNTU_STACK = { :image_id => 'ami-02d7f547', # jenkins-ubuntu-12.04-test-image
15
- :tags => {'Name' => 'Ubuntu-12.04'},
14
+ UBUNTU_STACK = { :image_id => 'ami-e0b882a5', # jenkins-ubuntu-14.04-test-image
15
+ :tags => {'Name' => 'Ubuntu-14.04'},
16
16
  :flavor_id => 'c1.xlarge',
17
17
  :key_name => 'jenkinskey',
18
18
  :groups => 'load-test',
19
19
  :user => 'ubuntu'}
20
- CENTOS5_STACK = { :image_id => 'ami-1a7d4d5f', # jenkins-centos-5.9-test-image
21
- :tags => {'Name' => 'CentOS-5.9'},
20
+ CENTOS5_STACK = { :image_id => 'ami-079b9d42', # jenkins-centos-5.10-test-image
21
+ :tags => {'Name' => 'CentOS-5.10'},
22
22
  :flavor_id => 'c1.xlarge',
23
23
  :key_name => 'jenkinskey',
24
24
  :groups => 'load-test',
25
25
  :user => 'root'}
26
- CENTOS6_STACK = { :image_id => 'ami-02ae8c47', # jenkins-centos-6.3-test-image
27
- :tags => {'Name' => 'CentOS-6.3'},
26
+ CENTOS6_STACK = { :image_id => 'ami-19283b5c', # jenkins-centos-6.6-test-image
27
+ :tags => {'Name' => 'CentOS-6.6'},
28
28
  :flavor_id => 'c1.xlarge',
29
29
  :key_name => 'jenkinskey',
30
30
  :groups => 'load-test',
@@ -16,7 +16,7 @@ def run_on_server(server, cmds)
16
16
  result = server.ssh(cmds)
17
17
  result.each do |r|
18
18
  raise "Command #{r.command} failed.\nStdout: #{r.stdout}\nStderr: #{r.stderr}" if r.status != 0
19
- puts "$ #{r.command}"
19
+ puts "$ #{r.command}"
20
20
  puts r.stdout
21
21
  end
22
22
  end
@@ -51,7 +51,7 @@ def compile_stack_info(stack)
51
51
  :local_file => "#{local_file}rhoconnect_#{Constants::RC_VERSION}_all.deb",
52
52
  :pkg_mgr => 'dpkg',
53
53
  :pkg_type => 'DEB',
54
- :pkg_cmd => 'apt-get',
54
+ :pkg_cmd => 'apt-get --force-yes -y',
55
55
  :deps => Constants::DEB_DEPS,
56
56
  :repo_src_file => '/etc/apt/sources.list',
57
57
  :repo_str => '\n' +
@@ -81,22 +81,22 @@ def connect_to_amazon
81
81
  lines = IO.readlines Constants::ACCESS_KEY_FILE
82
82
  access_key = lines.first.strip.split("=")[1]
83
83
  secret_access_key = lines.last.strip.split("=")[1]
84
-
84
+
85
85
  Fog::Compute.new(:provider => 'AWS', :region => Constants::REGION,
86
- :aws_access_key_id => access_key,
87
- :aws_secret_access_key => secret_access_key)
86
+ :aws_access_key_id => access_key,
87
+ :aws_secret_access_key => secret_access_key)
88
88
  end
89
89
 
90
90
  # Creates a new ec2 instance as per the given stack.
91
91
  def start_new_instance(connection, params)
92
92
  puts "Creating new instance..."
93
93
 
94
- server = connection.servers.create(params)
94
+ server = connection.servers.create(params)
95
95
  # Wait for machine to be booted
96
96
  server.wait_for { ready? }
97
97
  # Wait for machine to get an ip-address
98
- server.wait_for { !public_ip_address.nil? }
99
-
98
+ server.wait_for { !public_ip_address.nil? }
99
+
100
100
  if server.ready?
101
101
  # wait for all services to start on remote VM
102
102
  puts "Waiting #{Constants::SLEEP} seconds for services to start on remote VM..."
@@ -122,18 +122,18 @@ def install_package(server, distro_params)
122
122
  # Get current permissions of file
123
123
  perms = server.ssh("stat --format=%a #{filename}")[0].stdout.strip
124
124
  # Change permissions so that it can be edited by "others"
125
- cmds = ["sudo chmod 0666 #{filename}",
126
- "echo -e \"#{src_str}\" >> #{filename}",
125
+ cmds = ["sudo chmod 0666 #{filename}",
126
+ "echo -e \"#{src_str}\" >> #{filename}",
127
127
  "sudo chmod 0#{perms} #{filename}"]
128
- cmds << "sudo #{distro_params[:pkg_cmd]} update" unless distro_params[:flavor] == "centos"
129
- run_on_server(server, cmds)
128
+ cmds << "sudo #{distro_params[:pkg_cmd]} update" unless distro_params[:flavor] == "centos"
129
+ run_on_server(server, cmds)
130
130
 
131
131
  puts "Installing rhoconnect package.\nThis may take a while...\n\n"
132
- run_on_server(server, "yes | sudo #{distro_params[:pkg_cmd]} install rhoconnect")
132
+ run_on_server(server, "sudo #{distro_params[:pkg_cmd]} install rhoconnect")
133
133
  end
134
134
 
135
135
  def start_services(server)
136
- puts
136
+ puts
137
137
  ['redis', 'thin', 'nginx'].each do |program|
138
138
  status = -1
139
139
  3.times do
@@ -183,7 +183,7 @@ def ping_remote_host(server)
183
183
  begin
184
184
  res = server.ssh(['uptime'])
185
185
  status = res[0].status
186
- break if status == 0
186
+ break if status == 0
187
187
  rescue Exception => e
188
188
  sleep 6
189
189
  end
@@ -194,23 +194,23 @@ end
194
194
  def test_package(connection, stack)
195
195
  start_time = Time.now
196
196
 
197
- user, distro_params = compile_stack_info(stack)
198
- server = start_new_instance(connection, stack)
197
+ user, distro_params = compile_stack_info(stack)
198
+ server = start_new_instance(connection, stack)
199
199
  host = server.dns_name
200
200
  puts "Remote host #{host} is up and running ..."
201
-
201
+
202
202
  server.username = user
203
- server.private_key_path = Constants::SSH_KEY
203
+ server.private_key_path = Constants::SSH_KEY
204
204
  puts "Establish ssh connection for \"#{user}@#{host}\" ..."
205
- # For a minute trying to reach remote host
206
- raise "Cannot establish ssh connection with #{stack[:tags]['Name']} instance." if ping_remote_host(server) != 0
205
+ # For a minute trying to reach remote host
206
+ raise "Cannot establish ssh connection with #{stack[:tags]['Name']} instance." if ping_remote_host(server) != 0
207
207
  puts "SSH connection establised!"
208
208
 
209
209
  install_package(server, distro_params)
210
210
  # Start the redis and nginx servers on the remote machine
211
211
  start_services(server)
212
212
  # Check the status of the rhoconnect service
213
- check_rhoconnect_status(server)
213
+ check_rhoconnect_status(server)
214
214
 
215
215
  elapsed_time = (Time.now - start_time).to_i
216
216
  puts "Test for #{stack[:tags]['Name']} completed in #{elapsed_time/60} min. #{elapsed_time - ((elapsed_time/60)*60)} sec."
@@ -220,7 +220,7 @@ rescue => e
220
220
  puts e.backtrace
221
221
  -1
222
222
  ensure
223
- if server
223
+ if server
224
224
  puts "Terminating #{stack[:tags]['Name']} instance ..."
225
225
  server.destroy
226
226
  end
@@ -230,7 +230,7 @@ module ThreadOut
230
230
  # Writes to Thread.current[:stdout] instead of STDOUT if the thread local is set.
231
231
  def self.write(stuff)
232
232
  if Thread.current[:stdout] then
233
- Thread.current[:stdout].write stuff
233
+ Thread.current[:stdout].write stuff
234
234
  else
235
235
  STDOUT.write stuff
236
236
  end
@@ -252,7 +252,7 @@ STACK_SIZE.times do |i|
252
252
  threads << Thread.new(i) do |idx|
253
253
  puts "Starting test for #{STACKS[idx][:tags]['Name']} ... "
254
254
  Thread.current[:stdout] = logs[idx]
255
- test_package(connection, STACKS[idx])
255
+ test_package(connection, STACKS[idx])
256
256
  end
257
257
  end
258
258
  # Wait till threads re finished
@@ -260,15 +260,15 @@ threads.each { |thread| thread.join }
260
260
 
261
261
  # Output logs and check resluts
262
262
  threads.each_with_index do |thread, i|
263
- puts "\n#{STACKS[i][:tags]['Name']} installation log:"
264
- puts logs[i].string
263
+ puts "\n#{STACKS[i][:tags]['Name']} installation log:"
264
+ puts logs[i].string
265
265
  end
266
266
  exit_code = 0
267
267
  threads.each_with_index do |thread, i|
268
268
  if thread.value != 0
269
- puts "Package for #{STACKS[i][:tags]['Name']} failed to pass test!"
269
+ puts "Package for #{STACKS[i][:tags]['Name']} failed to pass test!"
270
270
  exit_code = -1
271
- end
271
+ end
272
272
  end
273
273
 
274
274
  elapsed_time = (Time.now - start_at).to_i
@@ -12,33 +12,23 @@ task "build:repos", :build_type, :build_number do |t, args|
12
12
  args.with_defaults :build_type => 'nightly'
13
13
  args.with_defaults :build_number => ''
14
14
  puts args
15
-
15
+
16
16
  build_type = args[:build_type]
17
17
  build_number = args[:build_number]
18
18
 
19
- # CONSTANTS
20
-
21
19
  RHOCONNECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..'))
22
-
23
- PKG_DIR = case build_type
24
- when 'release'
25
- '/packages'
26
- when 'test'
27
- '/test-packages'
28
- when 'beta'
29
- '/beta-packages'
30
- else 'nightly'
31
- '/nightly-packages'
32
- end #case
33
-
34
- BUCKET = 'rhoconnect'
20
+ PKG_DIR = case build_type
21
+ when 'release' then '/packages'
22
+ when 'test' then '/test-packages'
23
+ when 'beta' then '/beta-packages'
24
+ else '/nightly-packages'
25
+ end
26
+ BUCKET = 'rhoconnect'
35
27
 
36
28
  def cmd(cmd)
37
29
  puts cmd
38
30
  puts `#{cmd}`
39
- end #cmd
40
-
41
- # METHODS
31
+ end
42
32
 
43
33
  def prepare_destination
44
34
  # Prompt to remove the /deb directory if it exists
@@ -61,7 +51,7 @@ task "build:repos", :build_type, :build_number do |t, args|
61
51
  cmd "sudo touch #{filename}/distributions"
62
52
  cmd "sudo chmod -R 777 #{PKG_DIR}"
63
53
 
64
- # Write distributions string to corresponding file
54
+ # Write distributions string to corresponding file
65
55
  dist_file = File.new("#{filename}/distributions", "w")
66
56
  dist_file.write(distributions)
67
57
  dist_file.close
@@ -71,7 +61,7 @@ task "build:repos", :build_type, :build_number do |t, args|
71
61
 
72
62
  end #prepare_destination
73
63
 
74
-
64
+
75
65
  def copy_files
76
66
  # Move back into rhoconnect repo root first
77
67
  Dir.chdir RHOCONNECT_ROOT
@@ -96,13 +86,13 @@ task "build:repos", :build_type, :build_number do |t, args|
96
86
  prepare_destination
97
87
 
98
88
  copy_files
99
-
89
+
100
90
  if !build_number.empty?
101
91
  # Change name of packages to include build number
102
92
  ['deb', 'rpm'].each do |arch|
103
93
  Find.find("#{PKG_DIR}") do |file|
104
94
  if !File.directory?(file) and file =~ /#{arch}$/
105
- file_to_rename = File.open(file, 'r')
95
+ #file_to_rename = File.open(file, 'r')
106
96
  old_name = File.expand_path(file)
107
97
  new_name = old_name.gsub(/(#{arch})$/, "#{build_number}.\\1" )
108
98
  #File.rename(old_name, new_name)
@@ -117,14 +107,14 @@ task "build:repos", :build_type, :build_number do |t, args|
117
107
  # REPOIFY!
118
108
  cmd "sudo reprepro -b #{PKG_DIR}/deb includedeb rhoconnect #{PKG_DIR}/deb/#{@deb_pkg}"
119
109
  cmd "sudo createrepo #{PKG_DIR}/rpm"
120
-
110
+
121
111
  # Create SHA1 checksum of repo dirs
122
- checksum_dest = "#{PKG_DIR}/SHA1/"
112
+ # checksum_dest = "#{PKG_DIR}/SHA1/"
123
113
  cmd "sudo ./installer/utils/create_sha1.rb #{PKG_DIR} #{PKG_DIR}/SHA1"
124
114
 
125
115
  # Call s3_upload.rb
126
116
  ['deb', 'rpm'].each do |dir|
127
- cmd "sudo ruby ./installer/utils/package_upload/s3_upload.rb #{PKG_DIR}/#{dir} #{BUCKET}"
117
+ cmd "sudo ruby ./installer/utils/package_upload/s3_upload.rb #{PKG_DIR}/#{dir} #{BUCKET}"
128
118
  end #do
129
119
  cmd "sudo ruby ./installer/utils/package_upload/s3_upload.rb #{PKG_DIR}/SHA1 #{BUCKET}"
130
120
  end #build:repos
data/js-adapters/node.rb CHANGED
@@ -24,13 +24,13 @@ module Rhoconnect
24
24
  dir = File.expand_path(File.dirname(__FILE__))
25
25
  pwd = Dir.pwd
26
26
  node_modules = File.join(pwd,'node_modules')
27
- sub_env = {
28
- "NODE_PATH" => "#{node_modules}#{File::PATH_SEPARATOR}#{pwd}#{File::PATH_SEPARATOR}#{dir}",
29
- "REDIS_URL" => Rhoconnect.redis_url
27
+ sub_env = {
28
+ "NODE_PATH" => "#{node_modules}#{File::PATH_SEPARATOR}#{pwd}#{File::PATH_SEPARATOR}#{dir}",
29
+ "REDIS_URL" => Rhoconnect.redis_url
30
30
  }
31
31
  file = File.join(dir,"server.js")
32
32
  args = [
33
- sub_env, "node", file, Rhoconnect::NodeChannel::PUBSUB_IDENTIFIER,
33
+ sub_env, "node", file, Rhoconnect::NodeChannel::PUBSUB_IDENTIFIER,
34
34
  Rhoconnect.environment.to_s, Rhoconnect.base_directory
35
35
  ]
36
36
  @pipe = IO.popen(args, "w")
@@ -10,18 +10,13 @@ module Rhoconnect
10
10
  end
11
11
 
12
12
  RESULT_HASH = {}
13
- TIMEOUT = 30 # seconds
14
13
  PUBSUB_IDENTIFIER = "#{$$}-#{SecureRandom.hex}"
15
14
  PUB_CHANNEL = "#{PUBSUB_IDENTIFIER}-RedisSUB" # pub channel must link to redis sub channel
16
15
  SUB_CHANNEL = "#{PUBSUB_IDENTIFIER}-RedisPUB" # sub channel must link to redis pub channel
17
16
  @message_thread,@redis_subscriber,@redis_publisher = nil
18
17
 
19
18
  class << self
20
- attr_accessor :thrd, :register_semaphore, :register_condition
21
-
22
- def get_timeout
23
- TIMEOUT
24
- end
19
+ attr_accessor :thrd, :register_semaphore, :register_condition, :timeout
25
20
 
26
21
  def redis_subscriber
27
22
  url = Rhoconnect.redis.is_a?(Array) ? Rhoconnect.redis[0] : Rhoconnect.redis
@@ -41,7 +36,7 @@ module Rhoconnect
41
36
  NodeChannel.redis_publisher.publish(PUB_CHANNEL,{:route => 'deregister'}.to_json)
42
37
  end
43
38
 
44
- def bootstrap
39
+ def bootstrap(timeout)
45
40
  @register_semaphore ||= Mutex.new
46
41
  @register_condition ||= ConditionVariable.new
47
42
  # Run in the main thread, we setup node thread and wait for it to
@@ -54,6 +49,7 @@ module Rhoconnect
54
49
  @message_thread = Thread.new{check_channel}
55
50
  @register_condition.wait(@register_semaphore)
56
51
  end
52
+ @timeout = timeout
57
53
  end
58
54
 
59
55
  def publish_channel_and_wait(msg,curr_model)
@@ -97,7 +93,7 @@ module Rhoconnect
97
93
 
98
94
  def wait_for_result(key,curr_model)
99
95
  begin
100
- Timeout::timeout(TIMEOUT) do
96
+ Timeout::timeout(@timeout) do
101
97
  while(RESULT_HASH[key][:status] == 'waiting') do
102
98
  if RESULT_HASH[key][:pending_js_requests] and result_id = RESULT_HASH[key][:pending_js_requests][0]
103
99
  #do some logic and return data with memory
@@ -1,11 +1,11 @@
1
1
  require 'singleton'
2
2
 
3
- class DBAdapter
3
+ class DBAdapter
4
4
  include Singleton
5
5
 
6
6
  # Return the database connection...
7
- # For JRuby platform returned connection has extra missing singleton methods ('execute_batch' and 'close'),
8
- # and redefined 'transaction' method (to manage DBI auto-commit behavior)
7
+ # For JRuby platform returned connection has extra missing singleton methods ('execute_batch' and 'close'),
8
+ # and redefined 'transaction' method (to manage DBI auto-commit behavior)
9
9
  def get_connection(dbfile)
10
10
  if defined?(JRUBY_VERSION) # JRuby
11
11
  require 'dbi'
@@ -18,25 +18,25 @@ class DBAdapter
18
18
  self.do(sth.strip)
19
19
  end
20
20
  end
21
-
21
+
22
22
  # jdbc/sqlite3 instead of 'close' uses 'disconnect' method
23
23
  def close
24
24
  self.disconnect
25
25
  end
26
26
 
27
27
  alias_method :do_transaction, :transaction
28
- # Disable auto-commit, perform transaction and restore default DBI auto-commit behavior
29
- def transaction &block
28
+ # Disable auto-commit, perform transaction and restore default DBI auto-commit behavior
29
+ def transaction(&block)
30
30
  self['AutoCommit'] = false
31
- self.do_transaction &block
32
- self['AutoCommit'] = true
33
- end
34
- end
35
- else # Ruby 1.9
31
+ self.do_transaction(&block)
32
+ self['AutoCommit'] = true
33
+ end
34
+ end
35
+ else # MRI Ruby
36
36
  require 'sqlite3'
37
37
  db = SQLite3::Database.new(dbfile)
38
38
  end
39
39
 
40
- db
41
- end
40
+ db
41
+ end
42
42
  end
@@ -236,7 +236,7 @@ module Rhoconnect
236
236
  # call logoff
237
237
  auth_method('logoff')
238
238
  end
239
-
239
+
240
240
  { "delete_page" => deletes,
241
241
  "#{operation}_links" => links,
242
242
  "#{operation}_errors" => errors }.each do |doctype,client_docs|
@@ -1,10 +1,10 @@
1
- require 'zip/zip'
1
+ require 'zip'
2
2
  require 'zlib'
3
3
 
4
4
  module Rhoconnect
5
5
  module BulkDataJob
6
6
  @queue = :bulk_data
7
-
7
+
8
8
  def self.perform(params)
9
9
  do_bulk_job(params) do |bulk_data|
10
10
  timer = start_timer('starting bulk data process')
@@ -50,7 +50,7 @@ module Rhoconnect
50
50
  data = source.get_data(:md) if is_selected
51
51
  counter = {}
52
52
  db.transaction do |database|
53
- database.prepare("insert into object_values
53
+ database.prepare("insert into object_values
54
54
  (source_id,attrib,object,value) values (?,?,?,?)") do |stmt|
55
55
  data.each do |object_id,object|
56
56
  object.each do |attrib,value|
@@ -62,20 +62,20 @@ module Rhoconnect
62
62
  end
63
63
  counter
64
64
  end
65
-
65
+
66
66
  # Loads data into fixed schema table based on source settings
67
67
  def self.import_data_to_fixed_schema(db,source,is_selected=true)
68
68
  data = {}
69
69
  data = source.get_data(:md) if is_selected
70
- counter = {}
70
+ # counter = {}
71
71
  columns,qm = [],[]
72
72
  create_table = ["\"object\" varchar(255) PRIMARY KEY"]
73
73
  schema = JSON.parse(source.schema)
74
-
74
+
75
75
  db.transaction do |database|
76
76
  # Create a table with columns specified by 'property' array in settings
77
77
  schema['property'].each do |key,value|
78
- create_table << "\"#{key}\" varchar default NULL"
78
+ create_table << "\"#{key}\" varchar default NULL"
79
79
  columns << key
80
80
  qm << '?'
81
81
  end
@@ -86,11 +86,11 @@ module Rhoconnect
86
86
  args = [obj]
87
87
  columns.each { |col| args << row[col] }
88
88
  # The * is used to expand an array into individual arguments for 'execute' method.
89
- # JRuby (1.6.0) won't work without asterisk, but other rubies doing well!
90
- stmt.execute(*args)
89
+ # JRuby (1.6.0) won't work without asterisk, but other rubies doing well!
90
+ stmt.execute(*args)
91
91
  end
92
92
  end
93
-
93
+
94
94
  # Create indexes for specified columns in settings 'index'
95
95
  schema['index'].each do |key,value|
96
96
  val2 = ""
@@ -98,10 +98,10 @@ module Rhoconnect
98
98
  val2 += ',' if val2.length > 0
99
99
  val2 += "\"#{col}\""
100
100
  end
101
-
101
+
102
102
  database.execute("CREATE INDEX #{key} on #{source.name} (#{val2});")
103
103
  end if schema['index']
104
-
104
+
105
105
  # Create unique indexes for specified columns in settings 'unique_index'
106
106
  schema['unique_index'].each do |key,value|
107
107
  val2 = ""
@@ -109,14 +109,14 @@ module Rhoconnect
109
109
  val2 += ',' if val2.length > 0
110
110
  val2 += "\"#{col}\""
111
111
  end
112
-
112
+
113
113
  database.execute("CREATE UNIQUE INDEX #{key} on #{source.name} (#{val2});")
114
114
  end if schema['unique_index']
115
115
  end
116
-
116
+
117
117
  return {}
118
118
  end
119
-
119
+
120
120
  def self.refs_to_s(refs)
121
121
  str = ''
122
122
  refs.sort.each do |name,value|
@@ -124,15 +124,15 @@ module Rhoconnect
124
124
  end
125
125
  str[0..-2]
126
126
  end
127
-
127
+
128
128
  # #2354: Bulk sync not updating sources table
129
129
  # last_inserted_size +
130
130
  # last_deleted_size
131
131
  # backend_refresh_time +
132
- def self.populate_sources_table(db,sources_refs)
132
+ def self.populate_sources_table(db,sources_refs)
133
133
  db.transaction do |database|
134
134
  database.prepare("insert into sources
135
- (source_id,name,sync_priority,partition,sync_type,source_attribs,metadata,schema,blob_attribs,associations,last_inserted_size,backend_refresh_time)
135
+ (source_id,name,sync_priority,partition,sync_type,source_attribs,metadata,schema,blob_attribs,associations,last_inserted_size,backend_refresh_time)
136
136
  values (?,?,?,?,?,?,?,?,?,?,?,?)") do |stmt|
137
137
  sources_refs.each do |source_name,ref|
138
138
  s = ref[:source]
@@ -144,7 +144,7 @@ module Rhoconnect
144
144
  end
145
145
  end
146
146
  end
147
-
147
+
148
148
  def self.create_sqlite_data_file(bulk_data,ts)
149
149
  sources_refs = {}
150
150
  schema,index,bulk_data.dbfile = get_file_args(bulk_data.name,ts)
@@ -152,9 +152,9 @@ module Rhoconnect
152
152
  # TODO: remove old bulk files!
153
153
  # FileUtils.rm Dir.glob(File.join(Rhoconnect.data_directory, "#{bulk_data.name}*"))
154
154
 
155
- db = DBAdapter.instance.get_connection(bulk_data.dbfile)
155
+ db = DBAdapter.instance.get_connection(bulk_data.dbfile)
156
156
  db.execute_batch(File.open(schema,'r').read)
157
-
157
+
158
158
  src_counter = 1
159
159
  selected_sources = {}
160
160
  bulk_data.sources[0, -1].each do |source|
@@ -173,33 +173,33 @@ module Rhoconnect
173
173
  else
174
174
  source_attrib_refs = import_data_to_object_values(db,source,is_selected_source)
175
175
  end
176
- sources_refs[source_name] =
176
+ sources_refs[source_name] =
177
177
  {:source => source, :refs => source_attrib_refs, :skip_source => !is_selected_source}
178
178
  lap_timer("finished importing sqlite data for #{source_name}",timer)
179
179
  end
180
180
  populate_sources_table(db,sources_refs)
181
-
181
+
182
182
  db.execute_batch(File.open(index,'r').read)
183
183
  db.execute_batch("VACUUM;");
184
184
  db.close
185
-
185
+
186
186
  compress("#{bulk_data.dbfile}.rzip",bulk_data.dbfile)
187
187
  gzip_compress("#{bulk_data.dbfile}.gzip",bulk_data.dbfile)
188
188
  end
189
-
189
+
190
190
  def self.get_file_args(bulk_data_name,ts)
191
191
  schema = BulkData.schema_file
192
192
  index = BulkData.index_file
193
193
  dbfile = File.join(Rhoconnect.data_directory,bulk_data_name+'_'+ts+'.data')
194
194
  [schema,index,dbfile]
195
195
  end
196
-
196
+
197
197
  def self.compress(archive,file)
198
- Zip::ZipFile.open(archive, 'w') do |zipfile|
198
+ Zip::File.open(archive, 'w') do |zipfile|
199
199
  zipfile.add(URI.escape(File.basename(file)),file)
200
200
  end
201
201
  end
202
-
202
+
203
203
  def self.gzip_compress(archive,file)
204
204
  data = File.new(file, "rb")
205
205
  File.open(archive, 'wb') do |f|
@@ -209,6 +209,6 @@ module Rhoconnect
209
209
  end
210
210
  data.close
211
211
  end
212
-
212
+
213
213
  end
214
214
  end
@@ -4,7 +4,7 @@ require 'pathname'
4
4
  module Rhoconnect
5
5
  class LicenseException < RuntimeError; end
6
6
  class LicenseSeatsExceededException < LicenseException; end
7
-
7
+
8
8
  class License
9
9
  attr_reader :rhoconnect_version, :licensee, :seats, :issued
10
10
  attr_accessor :license
@@ -20,9 +20,9 @@ module Rhoconnect
20
20
  elsif ENV['RHOSYNC_LICENSE']
21
21
  @license = ENV['RHOSYNC_LICENSE']
22
22
  else
23
- app_config = Rhoconnect.get_config(Rhoconnect.base_directory)
23
+ # app_config = Rhoconnect.get_config(Rhoconnect.base_directory)
24
24
  settings = Rhoconnect.get_config(Rhoconnect.base_directory)[Rhoconnect.environment]
25
- licensefile = settings[:licensefile]
25
+ licensefile = settings[:licensefile]
26
26
  if licensefile
27
27
  path_to_license = (Pathname.new(licensefile).absolute?) ? licensefile : File.join(Rhoconnect.base_directory, licensefile)
28
28
  else
@@ -37,7 +37,7 @@ module Rhoconnect
37
37
  raise LicenseException.new("Error verifying license.")
38
38
  end
39
39
  end
40
-
40
+
41
41
  def check_and_use_seat
42
42
  incr = false
43
43
  Store.lock(CLIENT_DOCKEY) do
@@ -53,7 +53,7 @@ module Rhoconnect
53
53
  log msg; raise LicenseSeatsExceededException.new(msg)
54
54
  end
55
55
  end
56
-
56
+
57
57
  def free_seat
58
58
  Store.lock(CLIENT_DOCKEY) do
59
59
  current = Store.get_value(CLIENT_DOCKEY)
@@ -63,14 +63,14 @@ module Rhoconnect
63
63
  end
64
64
  end
65
65
  end
66
-
66
+
67
67
  def available
68
68
  current = Store.get_value(CLIENT_DOCKEY)
69
69
  current = current ? current.to_i : 0
70
70
  available = self.seats - current
71
71
  available > 0 ? available : 0
72
72
  end
73
-
73
+
74
74
  private
75
75
 
76
76
  def _decrypt