rhoconnect 3.0.0.rc1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/{CHANGELOG → CHANGELOG.md} +8 -1
- data/CREDITS +6 -1
- data/Gemfile.lock +19 -1
- data/Rakefile +12 -13
- data/bench/blobapp/settings/license.key +1 -1
- data/doc/authentication.txt +1 -1
- data/doc/install.txt +1 -1
- data/doc/rest-api.txt +11 -0
- data/doc/settings.txt +0 -22
- data/generators/templates/application/Gemfile +2 -0
- data/generators/templates/application/config.ru +5 -0
- data/install.sh +17 -6
- data/installer/{utils → unix-like}/create_texts.rb +2 -2
- data/installer/unix-like/rho_connect_install_checkers.rb +2 -3
- data/installer/unix-like/rho_connect_install_constants.rb +22 -29
- data/installer/unix-like/rho_connect_install_installers.rb +18 -43
- data/installer/unix-like/rho_connect_install_utilities.rb +1 -0
- data/installer/unix-like/rhoinstaller.rb +12 -5
- data/installer/utils/constants.rb +45 -0
- data/installer/utils/nix_installation.rake +0 -0
- data/installer/utils/unix_install_test.rb +258 -0
- data/lib/rhoconnect/api/source/push_deletes.rb +4 -1
- data/lib/rhoconnect/api/source/push_objects.rb +4 -1
- data/lib/rhoconnect/document.rb +8 -0
- data/lib/rhoconnect/source.rb +7 -33
- data/lib/rhoconnect/source_adapter.rb +9 -5
- data/lib/rhoconnect/source_sync.rb +49 -29
- data/lib/rhoconnect/store.rb +51 -0
- data/lib/rhoconnect/tasks.rb +20 -1
- data/lib/rhoconnect/version.rb +1 -1
- data/rhoconnect.gemspec +1 -1
- data/spec/source_sync_spec.rb +0 -50
- data/spec/store_spec.rb +36 -1
- data/tasks/redis.rake +17 -0
- metadata +9 -9
- data/installer/utils/install_test.rb +0 -152
@@ -0,0 +1,258 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require 'constants'
|
5
|
+
require 'rubygems'
|
6
|
+
require 'fog'
|
7
|
+
require 'readline'
|
8
|
+
|
9
|
+
# METHODS
|
10
|
+
|
11
|
+
# cmd
|
12
|
+
# easily issue system commands in a clear way
|
13
|
+
def cmd(cmd)
|
14
|
+
puts cmd
|
15
|
+
system(cmd)
|
16
|
+
end #cmd
|
17
|
+
|
18
|
+
# ssh_cmd
|
19
|
+
# More easily issue commands over the ssh connection.
|
20
|
+
def ssh_cmd(cmd)
|
21
|
+
puts cmd
|
22
|
+
puts @ssh.run(cmd)[0].stdout
|
23
|
+
end #ssh_cmd
|
24
|
+
|
25
|
+
# compile_stack_info
|
26
|
+
# Fills in all necessary information which is stack specific
|
27
|
+
def compile_stack_info
|
28
|
+
# User is stack specific but not to
|
29
|
+
# be included in the fog creation hash
|
30
|
+
@user = @stack[:user]
|
31
|
+
@stack.delete :user
|
32
|
+
|
33
|
+
# This part of the package name will always be the same
|
34
|
+
local_file = "#{`pwd`.strip}/../../pkg/"
|
35
|
+
|
36
|
+
# Append the rest of the file name according to distribution
|
37
|
+
if @user == 'ubuntu'
|
38
|
+
@dist = { :package => "rhoconnect_#{Constants::RC_VERSION}_all.deb",
|
39
|
+
:local_file => "#{local_file}rhoconnect_#{Constants::RC_VERSION}_all.deb",
|
40
|
+
:pkg_mgr => 'dpkg',
|
41
|
+
:pkg_repo => 'apt-get -y',
|
42
|
+
:deps => Constants::DEB_DEPS }
|
43
|
+
elsif @user == 'root'
|
44
|
+
@dist = { :package => "rhoconnect_#{Constants::RC_VERSION}_noarch.rpm",
|
45
|
+
:local_file => "#{local_file}rhoconnect_#{Constants::RC_VERSION}_noarch.rpm",
|
46
|
+
:pkg_mgr => 'rpm',
|
47
|
+
:pkg_repo => 'yes | yum',
|
48
|
+
:deps => Constants::RPM_DEPS }
|
49
|
+
else
|
50
|
+
puts "Incorrect user name"
|
51
|
+
exit
|
52
|
+
end #i
|
53
|
+
end #compile_stack_info
|
54
|
+
|
55
|
+
# create_ec2_instance
|
56
|
+
# Generates the Fog object and creates a new ec2 instance.
|
57
|
+
def create_ec2_instance
|
58
|
+
make_fog
|
59
|
+
start_new_instance
|
60
|
+
end #create_ec2_instance
|
61
|
+
|
62
|
+
# get_access_keys
|
63
|
+
# Retrieves the access key and secret access key from the above specified file.
|
64
|
+
def get_access_keys
|
65
|
+
lines = IO.readlines Constants::ACCESS_KEY_FILE
|
66
|
+
@access_key = lines.first.strip
|
67
|
+
@secret_access_key = lines.last.strip
|
68
|
+
end #get_access_keys
|
69
|
+
|
70
|
+
# make_fog
|
71
|
+
# Generates the Fog object used to create the new ec2 instance.
|
72
|
+
def make_fog
|
73
|
+
get_access_keys
|
74
|
+
@fog = Fog::Compute.new(
|
75
|
+
:provider => 'AWS',
|
76
|
+
:region => Constants::REGION,
|
77
|
+
:aws_access_key_id => @access_key,
|
78
|
+
:aws_secret_access_key => @secret_access_key
|
79
|
+
)
|
80
|
+
end #make_fog
|
81
|
+
|
82
|
+
# start_new_instance
|
83
|
+
# Creates a new ec2 instance as per the given stack.
|
84
|
+
def start_new_instance
|
85
|
+
puts "Creating new instance..."
|
86
|
+
|
87
|
+
@server = @fog.servers.create(@stack)
|
88
|
+
@server.wait_for { print "."; STDOUT.flush; ready? }
|
89
|
+
puts
|
90
|
+
if @server.ready?
|
91
|
+
# wait for all services to start on remote VM
|
92
|
+
puts "Waiting #{Constants::SLEEP} seconds for services to start on remote VM..."
|
93
|
+
Constants::SLEEP.times do
|
94
|
+
sleep( 1 )
|
95
|
+
print "."
|
96
|
+
STDOUT.flush
|
97
|
+
end #do
|
98
|
+
puts
|
99
|
+
|
100
|
+
# save important instance information
|
101
|
+
@host = @server.dns_name
|
102
|
+
@server_id = @server.id
|
103
|
+
else
|
104
|
+
puts "Server timed out."
|
105
|
+
exit
|
106
|
+
end #if
|
107
|
+
end #start_new_instance
|
108
|
+
|
109
|
+
# establish_ssh_connection
|
110
|
+
# Establishes the ssh connection needed to issue commands to the remote machine.
|
111
|
+
def establish_ssh_connection
|
112
|
+
@ssh = Fog::SSH.new( @host, @user, :keys => Constants::SSH_KEY )
|
113
|
+
end #establish_ssh_connection
|
114
|
+
|
115
|
+
# establish_scp_connection
|
116
|
+
# Establishes a gateway through which to transfer data
|
117
|
+
def establish_scp_connection
|
118
|
+
@scp = Fog::SCP.new( @host, @user, :keys => Constants::SSH_KEY )
|
119
|
+
end #create_scp_connection
|
120
|
+
|
121
|
+
# transfer
|
122
|
+
# transfers given data to remote machine via scp
|
123
|
+
def transfer(local_data, remote_data)
|
124
|
+
puts "Attempting to establish SCP connection..."
|
125
|
+
@scp.upload( local_data, remote_data ) do |cd, name, sent, total|
|
126
|
+
print "\r#{name}: #{(sent.to_f * 100 / total.to_f).to_i}%"
|
127
|
+
end #do
|
128
|
+
puts
|
129
|
+
end #establish_scp_connection
|
130
|
+
|
131
|
+
# transfer_rhoconnect
|
132
|
+
# Transfers the rhoconnect package over SCP
|
133
|
+
def transfer_rhoconnect
|
134
|
+
transfer @dist[:local_file], Constants::REMOTE_HOME
|
135
|
+
end #transfer_rhoconnect
|
136
|
+
|
137
|
+
# destroy_ec2_instance
|
138
|
+
# Terminates the current ec2 instance
|
139
|
+
def destroy_ec2_instance
|
140
|
+
@server.destroy
|
141
|
+
puts "Terminating Instance."
|
142
|
+
end #destroy_ec2_instance
|
143
|
+
|
144
|
+
# install_dependencies
|
145
|
+
# Installs all dependant packages on the remove machine
|
146
|
+
def install_dependencies
|
147
|
+
dep_install_string = "sudo #{@dist[:pkg_repo]} install"
|
148
|
+
@dist[:deps].each do |dep|
|
149
|
+
dep_install_string << " #{dep}"
|
150
|
+
end #do
|
151
|
+
ssh_cmd "sudo #{@dist[:pkg_repo]} update"
|
152
|
+
ssh_cmd dep_install_string
|
153
|
+
puts
|
154
|
+
end #install_dependencies
|
155
|
+
|
156
|
+
# install_package
|
157
|
+
# Issues commands to the remote machine to start the installation
|
158
|
+
def install_package
|
159
|
+
install_dependencies
|
160
|
+
ssh_cmd "sudo #{@dist[:pkg_mgr]} -i #{@dist[:package]}"
|
161
|
+
puts
|
162
|
+
end #install_package
|
163
|
+
|
164
|
+
def start_servers
|
165
|
+
puts "Starting Redis server"
|
166
|
+
ssh_cmd "sudo /etc/init.d/redis start"
|
167
|
+
puts "Starting nginx server"
|
168
|
+
ssh_cmd "sudo /etc/init.d/nginx start"
|
169
|
+
puts
|
170
|
+
end # start_servers
|
171
|
+
|
172
|
+
def check_rc_service
|
173
|
+
request = Net::HTTP.get_response(@host, '/console')
|
174
|
+
puts "Host: #{@host}"
|
175
|
+
puts "Code: #{request.code} Message: #{request.message}"
|
176
|
+
if request.code == '200'
|
177
|
+
puts "Rhoconnect service up!"
|
178
|
+
else
|
179
|
+
puts "Rhoconnect service down :("
|
180
|
+
end #if
|
181
|
+
end #check_rc_service
|
182
|
+
|
183
|
+
def compute_time(start_time, end_time)
|
184
|
+
time_delta = (end_time - start_time)
|
185
|
+
|
186
|
+
if time_delta >= 60
|
187
|
+
time_delta /= 60
|
188
|
+
time_units = 'minute'
|
189
|
+
if time_delta > 1
|
190
|
+
time_units << 's'
|
191
|
+
end #if
|
192
|
+
else
|
193
|
+
time_units = 'seconds'
|
194
|
+
end #if
|
195
|
+
|
196
|
+
"Test completed in #{time_delta} #{time_units}"
|
197
|
+
end #compute_time
|
198
|
+
|
199
|
+
# SCRIPT
|
200
|
+
|
201
|
+
# Create Packages
|
202
|
+
|
203
|
+
# Creating debian package
|
204
|
+
cmd "sudo rake build:deb"
|
205
|
+
# Make sure package was created successfully
|
206
|
+
if $? != 0
|
207
|
+
puts "Debian package was not created successfully" +
|
208
|
+
"Exiting..."
|
209
|
+
exit 1
|
210
|
+
end #if
|
211
|
+
|
212
|
+
# Keep commented until running on a machine with rpm
|
213
|
+
# Creating RPM package
|
214
|
+
#cmd "sudo rake build:rpm"
|
215
|
+
# Make sure package was created successfully
|
216
|
+
#if $? != 0
|
217
|
+
# puts "RPM package was not created successfully" +
|
218
|
+
# "Exiting..."
|
219
|
+
# exit 1
|
220
|
+
#end #if
|
221
|
+
|
222
|
+
# Test Package installations
|
223
|
+
start_time = Time.now
|
224
|
+
Constants::STACKS.each do |stack|
|
225
|
+
begin
|
226
|
+
@stack = stack
|
227
|
+
compile_stack_info
|
228
|
+
|
229
|
+
create_ec2_instance
|
230
|
+
|
231
|
+
# Establish connections
|
232
|
+
establish_ssh_connection
|
233
|
+
establish_scp_connection
|
234
|
+
|
235
|
+
# Transfer the Rhoconnect package to the remote machine
|
236
|
+
transfer_rhoconnect
|
237
|
+
|
238
|
+
puts "Installing rhoconnect package.\n" +
|
239
|
+
"This may take a while..."
|
240
|
+
install_package
|
241
|
+
|
242
|
+
# Start the redis and nginx servers on the remote machine
|
243
|
+
start_servers
|
244
|
+
|
245
|
+
# Check the status of the rhoconnect service
|
246
|
+
check_rc_service
|
247
|
+
rescue => e
|
248
|
+
puts "OH NOEZ, Exception!!"
|
249
|
+
puts e.inspect
|
250
|
+
puts e.backtrace
|
251
|
+
ensure
|
252
|
+
if @server != nil
|
253
|
+
destroy_ec2_instance
|
254
|
+
end #if
|
255
|
+
end #begin
|
256
|
+
end #do
|
257
|
+
end_time = Time.now
|
258
|
+
puts compute_time start_time end_time
|
@@ -3,6 +3,9 @@ Server.api :push_deletes, :source do |params,user|
|
|
3
3
|
# if source does not exist create one for dynamic adapter
|
4
4
|
source = Source.create({:name => params[:source_id]},{:app_id => APP_NAME,:user_id=>params[:user_id]}) unless source
|
5
5
|
source_sync = SourceSync.new(source)
|
6
|
-
|
6
|
+
timeout = params[:timeout] || 10
|
7
|
+
raise_on_expire = params[:raise_on_expire] || false
|
8
|
+
rebuild_md = params[:rebuild_md].nil? ? true : params[:rebuild_md]
|
9
|
+
source_sync.push_deletes(params[:objects],timeout,raise_on_expire,rebuild_md)
|
7
10
|
'done'
|
8
11
|
end
|
@@ -3,6 +3,9 @@ Server.api :push_objects, :source do |params,user|
|
|
3
3
|
# if source does not exist create one for dynamic adapter
|
4
4
|
source = Source.create({:name => params[:source_id]},{:app_id => APP_NAME,:user_id=>params[:user_id]}) unless source
|
5
5
|
source_sync = SourceSync.new(source)
|
6
|
-
|
6
|
+
timeout = params[:timeout] || 10
|
7
|
+
raise_on_expire = params[:raise_on_expire] || false
|
8
|
+
rebuild_md = params[:rebuild_md].nil? ? true : params[:rebuild_md]
|
9
|
+
source_sync.push_objects(params[:objects],timeout,raise_on_expire,rebuild_md)
|
7
10
|
'done'
|
8
11
|
end
|
data/lib/rhoconnect/document.rb
CHANGED
@@ -13,6 +13,14 @@ module Document
|
|
13
13
|
Store.put_data(docname(doctype),data,append)
|
14
14
|
end
|
15
15
|
|
16
|
+
def update_objects(doctype,updates)
|
17
|
+
Store.update_objects(docname(doctype),updates)
|
18
|
+
end
|
19
|
+
|
20
|
+
def remove_objects(doctype,deletes)
|
21
|
+
Store.delete_objects(docname(doctype),deletes)
|
22
|
+
end
|
23
|
+
|
16
24
|
def put_value(doctype,data)
|
17
25
|
Store.put_value(docname(doctype),data)
|
18
26
|
end
|
data/lib/rhoconnect/source.rb
CHANGED
@@ -262,42 +262,16 @@ module Rhoconnect
|
|
262
262
|
self.poll_interval == 0 or
|
263
263
|
(self.poll_interval != -1 and self.read_state.refresh_time <= Time.now.to_i)
|
264
264
|
end
|
265
|
-
|
266
|
-
def if_need_refresh(client_id=nil,params=nil)
|
267
|
-
need_refresh = check_refresh_time
|
268
|
-
yield client_id,params if need_refresh
|
269
|
-
end
|
270
265
|
|
271
|
-
def
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
allowed_update = true
|
278
|
-
# reset number of retries on succesfull query
|
279
|
-
# or if last refresh was more than 'poll_interval' time ago
|
280
|
-
if not query_failure or (Time.now.to_i - self.read_state.refresh_time >= self.poll_interval)
|
281
|
-
self.read_state.retry_counter = 0
|
282
|
-
end
|
283
|
-
|
284
|
-
# do not reset the refresh time on failure
|
285
|
-
# if retry limit is not reached
|
286
|
-
if query_failure
|
287
|
-
if self.read_state.retry_counter < self.retry_limit
|
288
|
-
allowed_update = false
|
289
|
-
self.read_state.increment!(:retry_counter)
|
290
|
-
# we have reached the limit - update the refresh time
|
291
|
-
# and reset the counter
|
292
|
-
else
|
293
|
-
self.read_state.retry_counter = 0
|
294
|
-
end
|
295
|
-
end
|
296
|
-
if allowed_update
|
297
|
-
self.read_state.refresh_time = Time.now.to_i + self.poll_interval
|
266
|
+
def if_need_refresh(client_id=nil,params=nil)
|
267
|
+
need_refresh = lock(:md) do |s|
|
268
|
+
check = check_refresh_time
|
269
|
+
s.read_state.refresh_time = Time.now.to_i + s.poll_interval if check
|
270
|
+
check
|
298
271
|
end
|
272
|
+
yield client_id,params if need_refresh
|
299
273
|
end
|
300
|
-
|
274
|
+
|
301
275
|
def is_pass_through?
|
302
276
|
self.pass_through and self.pass_through == 'true'
|
303
277
|
end
|
@@ -55,16 +55,20 @@ module Rhoconnect
|
|
55
55
|
|
56
56
|
def sync
|
57
57
|
if @result and @result.empty?
|
58
|
-
@source.
|
59
|
-
|
58
|
+
@source.lock(:md) do |s|
|
59
|
+
s.flash_data(:md)
|
60
|
+
s.put_value(:md_size,0)
|
61
|
+
end
|
60
62
|
else
|
61
63
|
if @result
|
62
64
|
Store.put_data(@tmp_docname,@result)
|
63
65
|
@stash_size += @result.size
|
64
66
|
end
|
65
|
-
@source.
|
66
|
-
|
67
|
-
|
67
|
+
@source.lock(:md) do |s|
|
68
|
+
s.flash_data(:md)
|
69
|
+
Store.rename(@tmp_docname,s.docname(:md))
|
70
|
+
s.put_value(:md_size,@stash_size)
|
71
|
+
end
|
68
72
|
end
|
69
73
|
end
|
70
74
|
|
@@ -90,17 +90,11 @@ module Rhoconnect
|
|
90
90
|
|
91
91
|
def do_query(params=nil)
|
92
92
|
result = nil
|
93
|
-
@source.
|
94
|
-
@source.
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
_auth_op('logoff')
|
99
|
-
end
|
100
|
-
# update refresh time
|
101
|
-
query_failure = Store.get_keys(@source.docname(:errors)).size > 0
|
102
|
-
@source.update_refresh_time(query_failure)
|
103
|
-
end
|
93
|
+
@source.if_need_refresh do
|
94
|
+
Stats::Record.update("source:query:#{@source.name}") do
|
95
|
+
return if _auth_op('login') == false
|
96
|
+
result = self.read(nil,params)
|
97
|
+
_auth_op('logoff')
|
104
98
|
end
|
105
99
|
end
|
106
100
|
result
|
@@ -113,31 +107,57 @@ module Rhoconnect
|
|
113
107
|
@source.app_id,@source.user_id,client_id,params)
|
114
108
|
end
|
115
109
|
|
116
|
-
def push_objects(objects,timeout=10,raise_on_expire=false)
|
110
|
+
def push_objects(objects,timeout=10,raise_on_expire=false,rebuild_md=true)
|
117
111
|
@source.lock(:md,timeout,raise_on_expire) do |s|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
112
|
+
diff_count = 0
|
113
|
+
# in case of rebuild_md
|
114
|
+
# we clean-up and rebuild the whole :md doc
|
115
|
+
# on every request
|
116
|
+
if(rebuild_md)
|
117
|
+
doc = @source.get_data(:md)
|
118
|
+
orig_doc_size = doc.size
|
119
|
+
objects.each do |id,obj|
|
120
|
+
doc[id] ||= {}
|
121
|
+
doc[id].merge!(obj)
|
122
|
+
end
|
123
|
+
diff_count = doc.size - orig_doc_size
|
124
|
+
@source.put_data(:md,doc)
|
125
|
+
else
|
126
|
+
# if rebuild_md == false
|
127
|
+
# we only operate on specific set values
|
128
|
+
# which brings a big optimization
|
129
|
+
# in case of small transactions
|
130
|
+
diff_count = @source.update_objects(:md, objects)
|
131
|
+
end
|
132
|
+
|
126
133
|
@source.update_count(:md_size,diff_count)
|
127
134
|
end
|
128
135
|
end
|
129
136
|
|
130
|
-
def push_deletes(objects,timeout=10,raise_on_expire=false)
|
137
|
+
def push_deletes(objects,timeout=10,raise_on_expire=false,rebuild_md=true)
|
131
138
|
@source.lock(:md,timeout,raise_on_expire) do |s|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
doc
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
+
diff_count = 0
|
140
|
+
if(rebuild_md)
|
141
|
+
# in case of rebuild_md
|
142
|
+
# we clean-up and rebuild the whole :md doc
|
143
|
+
# on every request
|
144
|
+
doc = @source.get_data(:md)
|
145
|
+
orig_doc_size = doc.size
|
146
|
+
objects.each do |id|
|
147
|
+
doc.delete(id)
|
148
|
+
end
|
149
|
+
diff_count = doc.size - orig_doc_size
|
150
|
+
@source.put_data(:md,doc)
|
151
|
+
else
|
152
|
+
# if rebuild_md == false
|
153
|
+
# we only operate on specific set values
|
154
|
+
# which brings a big optimization
|
155
|
+
# in case of small transactions
|
156
|
+
diff_count = -@source.remove_objects(:md, objects)
|
157
|
+
end
|
158
|
+
|
139
159
|
@source.update_count(:md_size,diff_count)
|
140
|
-
end
|
160
|
+
end
|
141
161
|
end
|
142
162
|
|
143
163
|
private
|
data/lib/rhoconnect/store.rb
CHANGED
@@ -47,6 +47,57 @@ module Rhoconnect
|
|
47
47
|
end
|
48
48
|
true
|
49
49
|
end
|
50
|
+
|
51
|
+
# updates objects for a given doctype, source, user
|
52
|
+
# create new objects if necessary
|
53
|
+
def update_objects(dockey, data={})
|
54
|
+
return 0 unless dockey and data
|
55
|
+
|
56
|
+
new_object_count = 0
|
57
|
+
doc = get_data(dockey)
|
58
|
+
@@db.pipelined do
|
59
|
+
data.each do |key,value|
|
60
|
+
is_create = doc[key].nil?
|
61
|
+
new_object_count += 1 if is_create
|
62
|
+
value.each do |attrib,value|
|
63
|
+
next if _is_reserved?(attrib, value)
|
64
|
+
|
65
|
+
new_element = setelement(key,attrib,value)
|
66
|
+
element_exists = is_create ? false : doc[key].has_key?(attrib)
|
67
|
+
if element_exists
|
68
|
+
existing_element = setelement(key,attrib,doc[key][attrib])
|
69
|
+
if existing_element != new_element
|
70
|
+
@@db.srem(dockey, existing_element)
|
71
|
+
@@db.sadd(dockey, new_element)
|
72
|
+
end
|
73
|
+
else
|
74
|
+
@@db.sadd(dockey, new_element)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
new_object_count
|
80
|
+
end
|
81
|
+
|
82
|
+
# Removes objects from a given doctype,source,user
|
83
|
+
def delete_objects(dockey,data=[])
|
84
|
+
return 0 unless dockey and data
|
85
|
+
|
86
|
+
deleted_object_count = 0
|
87
|
+
doc = get_data(dockey)
|
88
|
+
@@db.pipelined do
|
89
|
+
data.each do |id|
|
90
|
+
if doc[id]
|
91
|
+
doc[id].each do |name,value|
|
92
|
+
@@db.srem(dockey, setelement(id,name,value))
|
93
|
+
end
|
94
|
+
deleted_object_count += 1
|
95
|
+
end
|
96
|
+
doc.delete(id)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
deleted_object_count
|
100
|
+
end
|
50
101
|
|
51
102
|
# Adds a simple key/value pair
|
52
103
|
def put_value(dockey,value)
|
data/lib/rhoconnect/tasks.rb
CHANGED
@@ -270,7 +270,7 @@ namespace :rhoconnect do
|
|
270
270
|
end
|
271
271
|
end
|
272
272
|
|
273
|
-
desc "Start rhoconnect server in bg mode (Rhostudio)"
|
273
|
+
# desc "Start rhoconnect server in bg mode (Rhostudio) - this is an internal command"
|
274
274
|
task :startbg do
|
275
275
|
cmd = (jruby?) ? trinidad? : (thin? || mongrel? || report_missing_server)
|
276
276
|
Thread.new {
|
@@ -288,6 +288,25 @@ namespace :rhoconnect do
|
|
288
288
|
exit
|
289
289
|
end
|
290
290
|
|
291
|
+
# desc "Start rhoconnect server in debug mode (Rhostudio) - this is an internal command"
|
292
|
+
task :startdebug do
|
293
|
+
cmd = (jruby?) ? trinidad? : (thin? || mongrel? || report_missing_server)
|
294
|
+
ENV['DEBUG'] = 'yes'
|
295
|
+
Thread.new {
|
296
|
+
if windows?
|
297
|
+
puts 'Starting rhoconnect...'
|
298
|
+
system("#{cmd} config.ru -P #{rhoconnect_pid}")
|
299
|
+
elsif jruby?
|
300
|
+
puts 'Starting rhoconnect in jruby environment...'
|
301
|
+
system("#{cmd}")
|
302
|
+
else
|
303
|
+
system("#{cmd} config.ru -P #{rhoconnect_pid}")
|
304
|
+
end
|
305
|
+
}
|
306
|
+
|
307
|
+
exit
|
308
|
+
end
|
309
|
+
|
291
310
|
desc "run rhoconnect console"
|
292
311
|
task :console, :environment do |t, args|
|
293
312
|
if RedisRunner.running?
|
data/lib/rhoconnect/version.rb
CHANGED
data/rhoconnect.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.rubyforge_project = nil
|
17
17
|
|
18
18
|
s.files = %w(
|
19
|
-
CHANGELOG CREDITS Gemfile Gemfile.lock install.sh README.md Rakefile LICENSE Rakefile rhoconnect.gemspec
|
19
|
+
CHANGELOG.md CREDITS Gemfile Gemfile.lock install.sh README.md Rakefile LICENSE Rakefile rhoconnect.gemspec
|
20
20
|
)
|
21
21
|
s.files += Dir.glob("bench/**/*")
|
22
22
|
s.files += Dir.glob("doc/**/*")
|
data/spec/source_sync_spec.rb
CHANGED
@@ -231,55 +231,6 @@ describe "SourceSync" do
|
|
231
231
|
verify_read_operation_with_error('query')
|
232
232
|
end
|
233
233
|
|
234
|
-
it "should do query with exception raised and update refresh time only after retries limit is exceeded" do
|
235
|
-
@s.retry_limit = 1
|
236
|
-
msg = "Error during query"
|
237
|
-
@ss.should_receive(:log).with("SourceAdapter raised query exception: #{msg}")
|
238
|
-
@ss.should_receive(:log).with(anything)
|
239
|
-
set_test_data('test_db_storage',{},msg,"query error")
|
240
|
-
res = @ss.do_query
|
241
|
-
verify_result(@s.docname(:md) => {},
|
242
|
-
@s.docname(:errors) => {'query-error'=>{'message'=>msg}})
|
243
|
-
# 1) if retry_limit is set to N - then, first N retries should not update refresh_time
|
244
|
-
@s.read_state.retry_counter.should == 1
|
245
|
-
@s.read_state.refresh_time.should <= Time.now.to_i
|
246
|
-
|
247
|
-
# try once more and fail again
|
248
|
-
@ss.should_receive(:log).with("SourceAdapter raised query exception: #{msg}")
|
249
|
-
@ss.should_receive(:log).with(anything)
|
250
|
-
set_test_data('test_db_storage',{},msg,"query error")
|
251
|
-
res = @ss.do_query
|
252
|
-
verify_result(@s.docname(:md) => {},
|
253
|
-
@s.docname(:errors) => {'query-error'=>{'message'=>msg}})
|
254
|
-
|
255
|
-
# 2) if retry_limit is set to N and number of retries exceeded it - update refresh_time
|
256
|
-
@s.read_state.retry_counter.should == 0
|
257
|
-
@s.read_state.refresh_time.should > Time.now.to_i
|
258
|
-
end
|
259
|
-
|
260
|
-
it "should do query with exception raised and restore state with succesfull retry" do
|
261
|
-
@s.retry_limit = 1
|
262
|
-
msg = "Error during query"
|
263
|
-
@ss.should_receive(:log).with("SourceAdapter raised query exception: #{msg}")
|
264
|
-
@ss.should_receive(:log).with(anything)
|
265
|
-
set_test_data('test_db_storage',{},msg,"query error")
|
266
|
-
res = @ss.do_query
|
267
|
-
verify_result(@s.docname(:md) => {},
|
268
|
-
@s.docname(:errors) => {'query-error'=>{'message'=>msg}})
|
269
|
-
# 1) if retry_limit is set to N - then, first N retries should not update refresh_time
|
270
|
-
@s.read_state.retry_counter.should == 1
|
271
|
-
@s.read_state.refresh_time.should <= Time.now.to_i
|
272
|
-
|
273
|
-
# try once more (with success)
|
274
|
-
expected = {'1'=>@product1,'2'=>@product2}
|
275
|
-
set_test_data('test_db_storage',expected)
|
276
|
-
@ss.do_query
|
277
|
-
verify_result(@s.docname(:md) => expected,
|
278
|
-
@s.docname(:errors) => {})
|
279
|
-
@s.read_state.retry_counter.should == 0
|
280
|
-
@s.read_state.refresh_time.should > Time.now.to_i
|
281
|
-
end
|
282
|
-
|
283
234
|
it "should do query with exception raised and update refresh time if retry_limit is 0" do
|
284
235
|
@s.retry_limit = 0
|
285
236
|
msg = "Error during query"
|
@@ -289,7 +240,6 @@ describe "SourceSync" do
|
|
289
240
|
res = @ss.do_query
|
290
241
|
verify_result(@s.docname(:md) => {},
|
291
242
|
@s.docname(:errors) => {'query-error'=>{'message'=>msg}})
|
292
|
-
# if poll_interval is set to 0 - refresh time should be updated
|
293
243
|
@s.read_state.retry_counter.should == 0
|
294
244
|
@s.read_state.refresh_time.should > Time.now.to_i
|
295
245
|
end
|