rhoconnect 3.0.2 → 3.0.3
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.md +6 -0
- data/Gemfile.lock +7 -7
- data/LICENSE +4 -4
- data/Rakefile +1 -1
- data/doc/client-objc.txt +736 -0
- data/doc/client.txt +10 -0
- data/doc/deploying.txt +111 -0
- data/doc/heroku-addon.txt +13 -12
- data/doc/install.txt +3 -3
- data/doc/net-plugin.txt +3 -3
- data/doc/rails-plugin.txt +18 -7
- data/doc/web-console.txt +1 -1
- data/installer/utils/constants.rb +2 -3
- data/installer/utils/nix_install_test.rb +42 -42
- data/installer/utils/nix_installation.rake +1 -1
- data/lib/rhoconnect/client_sync.rb +9 -3
- data/lib/rhoconnect/read_state.rb +2 -0
- data/lib/rhoconnect/source.rb +37 -1
- data/lib/rhoconnect/source_sync.rb +8 -4
- data/lib/rhoconnect/store.rb +36 -15
- data/lib/rhoconnect/version.rb +1 -1
- data/rhoconnect.gemspec +1 -1
- data/spec/source_sync_spec.rb +78 -5
- data/spec/store_spec.rb +23 -0
- metadata +92 -153
- data/examples/simple/dump.rdb +0 -0
data/doc/client.txt
CHANGED
@@ -121,6 +121,9 @@ Rhoconnect Client is a library to add sync data capability to your applications.
|
|
121
121
|
//find all objects by set of properties
|
122
122
|
- (NSMutableArray *) find_all: (NSDictionary *)cond;
|
123
123
|
|
124
|
+
//run sql query - result is array of hashes (string)
|
125
|
+
- (NSMutableArray *) find_bysql: (NSString*)sql args: (NSArray*) sql_args;
|
126
|
+
|
124
127
|
//save object represents by data to database
|
125
128
|
- (void) save: (NSDictionary *)data;
|
126
129
|
|
@@ -238,6 +241,13 @@ To create schema model tables edit database schema file:
|
|
238
241
|
|
239
242
|
[sclient addObjectNotify: [[item objectForKey:@"source_id"] intValue] szObject:[item valueForKey:@"object"] ];
|
240
243
|
|
244
|
+
#### Run SQL query on Schema model
|
245
|
+
|
246
|
+
:::cplusplus
|
247
|
+
NSArray* params = [NSArray arrayWithObjects: @"Apple", nil];
|
248
|
+
NSMutableArray* items2 = [product find_bysql:@"SELECT * FROM Product_s WHERE name=?" args: params];
|
249
|
+
//items2 is an Array of NSDictionary* (NSString* to NSString*)
|
250
|
+
|
241
251
|
## Android Java Client
|
242
252
|
|
243
253
|
### Getting started
|
data/doc/deploying.txt
CHANGED
@@ -80,3 +80,114 @@ Deploying the WAR container varies per J2EE App Server, for JBoss it is necessar
|
|
80
80
|
to place the WAR file into the server's deploy directory.
|
81
81
|
|
82
82
|
We recommend using the [phusion passenger](http://modrails.com/index.html) stack for deploying an on-premise RhoConnect application. Please refer to the [section on rack applications](http://modrails.com/documentation/Users%20guide%20Apache.html#_deploying_a_rack_based_ruby_application) for information on deploying a RhoConnect sinatra application.
|
83
|
+
|
84
|
+
## Deploying packaged RhoConnect software on Linux servers
|
85
|
+
|
86
|
+
You can create RhoConnect production environment on Linux servers by installing software packages
|
87
|
+
for Ubuntu and Cent OS respectively. At this moment supported formats are Debian (deb) and Red Hat (rpm) packages.
|
88
|
+
|
89
|
+
Every package provides the following components:
|
90
|
+
|
91
|
+
* Ruby 1.8.7, Ruby Enterprise Edition 2011.03
|
92
|
+
|
93
|
+
* Nginx HTTP server (v. 1.0.6)
|
94
|
+
|
95
|
+
* Passenger (v. 3.0.9)
|
96
|
+
|
97
|
+
* Redis data store (v. 2.2.14)
|
98
|
+
|
99
|
+
* Rhoconnect gem with all required dependencies
|
100
|
+
|
101
|
+
In addition, RPM package provides latest Sqlite3 headers and binaries, because standard Cent OS (5.x) libraries for Sqlite3 outdated.
|
102
|
+
|
103
|
+
To create Debian package you need to have development version of RhoConnect software on Ubuntu (server, desktop. virtual machine) and execute the following rake task:
|
104
|
+
<pre>
|
105
|
+
rake build:deb
|
106
|
+
</pre>
|
107
|
+
|
108
|
+
To create RPM package you need to have development version of RhoConnect software on Cent OS and execute the following rake task:
|
109
|
+
<pre>
|
110
|
+
rake build:rpm
|
111
|
+
</pre>
|
112
|
+
|
113
|
+
After task is compete, either rhoconnect-x.y.z_all.deb or rhoconnect-x.y.z.noarch.rpm package will be created in the pkg/ directory. In the future, pre-built packages for latest RhoConnect software will be available for direct download.
|
114
|
+
|
115
|
+
To install Deb package on Ununtu server (Ubuntu 11.4 server, Amazon EC2 Ubuntu server), you should run the following command:
|
116
|
+
<pre>
|
117
|
+
dpkg -i rhoconnect-x.y.z_all.deb
|
118
|
+
</pre>
|
119
|
+
|
120
|
+
To install RPM package on Cent OS server (tested for 5.x, 6.x, and basic 64-bit Amazon Linux AMI 2011.09):
|
121
|
+
<pre>
|
122
|
+
rpm -i rhoconnect-x.y.z.noarch.rpm
|
123
|
+
</pre>
|
124
|
+
|
125
|
+
In process of installation many of above components will be downloaded, configured and compiled on target platform.
|
126
|
+
For practical usage, you should be familiar with and understand some of the provided settings.
|
127
|
+
|
128
|
+
### Ruby Enterprise Edition
|
129
|
+
By defaut all ruby binaries, libraries, and gems are installed into <b>/opt/rhoconnect</b> directory.
|
130
|
+
You may wish to have access to these items by adding to bash configuration files this command:
|
131
|
+
<pre>
|
132
|
+
export PATH=/opt/rhoconnect/bin:$PATH
|
133
|
+
</pre>
|
134
|
+
|
135
|
+
### Redis
|
136
|
+
Rhoconnect installer configured redis server with the following settings:
|
137
|
+
|
138
|
+
* Redis configuration file <b>/opt/rhoconnect/etc/redis.conf</b> has the following properties:
|
139
|
+
<pre>
|
140
|
+
daemonize yes
|
141
|
+
pidfile /var/run/redis.pid
|
142
|
+
logfile /var/log/redis.log
|
143
|
+
</pre>
|
144
|
+
|
145
|
+
* Redis logrotate settings for <b>/var/log/redis.log</b> files defined in <b>/etc/logrotate.d/redis</b> as:
|
146
|
+
<pre>
|
147
|
+
/var/log/redis.log {
|
148
|
+
rotate 3
|
149
|
+
missingok
|
150
|
+
notifempty
|
151
|
+
size 250k
|
152
|
+
create 0644 root root
|
153
|
+
compress
|
154
|
+
}
|
155
|
+
</pre>
|
156
|
+
|
157
|
+
* Redis start-up script <b>/etc/init.d/redis</b>. You can start/stop redis server by running the following commands:
|
158
|
+
<pre>
|
159
|
+
/etc/init.d/redis {start|stop}
|
160
|
+
</pre>
|
161
|
+
|
162
|
+
### Nginx
|
163
|
+
Installer compiled Nginx web server (to <b>/opt/nginx</b> directory) with the following configuration files:
|
164
|
+
|
165
|
+
* Nginx start-up script (<b>/etc/init.d/nginx</b>)
|
166
|
+
|
167
|
+
* Nginx logrotate settings (<b>/etc/logrotate.d/nginx</b>)
|
168
|
+
|
169
|
+
* Nginx configuration file (<b>/opt/nginx/conf/nginx.conf</b>)
|
170
|
+
|
171
|
+
* Passenger configuration file and virtual host template for RhoConnect application
|
172
|
+
(<b>/opt/nginx/conf/conf.d/passenger.conf</b> and <b>/opt/nginx/conf/conf.d/rhoconnect.conf</b>)
|
173
|
+
|
174
|
+
* user <b>nginx</b> added to system users list
|
175
|
+
|
176
|
+
|
177
|
+
### As a bonus :-)
|
178
|
+
Installer also created and configured RhoConnect <b>rhoapp</b> application in <b>/opt/nginx/html</b> directory.
|
179
|
+
To test it you need to as a root user start redis and nginx servers:
|
180
|
+
<pre>
|
181
|
+
/etc/init.d/redis start
|
182
|
+
/etc/init.d/nginx start
|
183
|
+
</pre>
|
184
|
+
|
185
|
+
And verify that it's up and running by visiting application web console in your browser:
|
186
|
+
<pre>
|
187
|
+
http://server_ip_address/console/
|
188
|
+
</pre>
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
data/doc/heroku-addon.txt
CHANGED
@@ -4,7 +4,6 @@ Heroku Addon
|
|
4
4
|
RhoConnect is now available for those using <a href='http://heroku.com' target='_blank'>Heroku</a> as an addon.
|
5
5
|
|
6
6
|
|
7
|
-
|
8
7
|
Adding RhoConnect from Heroku
|
9
8
|
-----------------------
|
10
9
|
To use RhoConnect from Heroku, install the RhoConnect add-on:
|
@@ -12,14 +11,14 @@ To use RhoConnect from Heroku, install the RhoConnect add-on:
|
|
12
11
|
:::term
|
13
12
|
$ heroku addons:add rhoconnect
|
14
13
|
|
15
|
-
|
14
|
+
##Setup
|
16
15
|
|
17
16
|
From inside your heroku account, setup the url to your backend service that RhoConnect will connect to.
|
18
17
|
|
19
18
|
First, click the addons drop down and select rhoconnect.
|
20
19
|
<p><img src='https://s3.amazonaws.com/rhodocs/rhoconnect-service/addon_rhoconnect.png' width="479" height="319"/></p>
|
21
20
|
|
22
|
-
You will be redirected to the admin console of your RhoConnect instance where you can set the backend app url. Select Backend App
|
21
|
+
You will be redirected to the admin console of your RhoConnect instance where you can set the backend app url. Select Backend App URL from the right menu.
|
23
22
|
<p><img src='https://s3.amazonaws.com/rhodocs/rhoconnect-service/console.png' width="800" height="280"/></p>
|
24
23
|
|
25
24
|
|
@@ -31,24 +30,26 @@ Connecting a simple rhodes app
|
|
31
30
|
-------------------------------
|
32
31
|
To view a full tutorial about creating a rhodes application and the features of rhodes see [Rhodes framework](http://docs.rhomobile.com/rhodes/tutorial).
|
33
32
|
|
34
|
-
|
33
|
+
##Gem installation:
|
35
34
|
|
36
|
-
:::
|
37
|
-
[sudo] gem install rhodes
|
35
|
+
:::term
|
36
|
+
$ [sudo] gem install rhodes
|
38
37
|
|
39
38
|
Next using the rhodes gem you can create a rhodes app.
|
40
39
|
|
41
|
-
:::
|
42
|
-
rhodes app sample_app url_of_rhoconnect_instance
|
40
|
+
:::term
|
41
|
+
$ rhodes app sample_app url_of_rhoconnect_instance
|
43
42
|
|
44
43
|
To get the value for the url_of_rhoconnect_instance argument, go to the RhoConnect console and click on the right Backend App URL link. From there you can copy the syncserver url.
|
45
44
|
|
46
45
|
<p><img src='https://s3.amazonaws.com/rhodocs/rhoconnect-service/console.png' width="800" height="280"/></p>
|
47
46
|
|
48
47
|
|
49
|
-
|
50
|
-
[RhoConnect Introduction](http://docs.rhomobile.com/
|
48
|
+
##Other Resources
|
49
|
+
[RhoConnect Introduction](http://docs.rhomobile.com/rhoconnect/introduction)
|
50
|
+
|
51
|
+
[RhoConnect Installation](http://docs.rhomobile.com/rhoconnect/install)
|
51
52
|
|
52
|
-
[RhoConnect
|
53
|
+
[RhoConnect Tutorial](http://docs.rhomobile.com/rhoconnect/tutorial)
|
53
54
|
|
54
|
-
[RhoConnect
|
55
|
+
[Using RhoConnect from Rails/Sinatra](http://docs.rhomobile.com/rhoconnect/rails-plugin)
|
data/doc/install.txt
CHANGED
@@ -3,9 +3,9 @@ Installing RhoConnect
|
|
3
3
|
|
4
4
|
## Windows
|
5
5
|
|
6
|
-
If you're running Windows, download the latest [
|
6
|
+
If you're running Windows, download the latest [RhoStudio for Windows](http://rhomobile.com/rhostudio-windows). This installs the [Ruby stack](http://www.ruby-lang.org/en/), [Redis](http://redis.io/), [RhoConnect](/rhoconnect/introduction) and [Rhodes](/rhodes/introduction).
|
7
7
|
|
8
|
-
|
8
|
+
You can now skip to the [generating a new application instructions](/rhoconnect/command-line#generate-an-application) in the next section.
|
9
9
|
|
10
10
|
## Mac OS / Linux
|
11
11
|
|
@@ -17,7 +17,7 @@ Your RhoConnect application folder will be located in C:\RhoConnect\rhoconnect b
|
|
17
17
|
|
18
18
|
3. Ruby Web Server - We test with [thin](http://code.macournoyer.com/thin/), and [passenger](http://www.modrails.com/). WEBrick, the web server that ships with ruby, is known to cause issues with HTTP headers/cookies and is ***not*** recommended.
|
19
19
|
|
20
|
-
4. [Redis 2.2.14+](http://redis.io/) - RhoConnect includes a simple [rake task](/rhoconnect/command-line#rake-tasks) `redis:install` to install redis, covered in the [Rake Tasks section](rhoconnect/command-line#rake-tasks). Alternatively, you can [install redis directly](http://redis.io/download).
|
20
|
+
4. [Redis 2.2.14+](http://redis.io/) - RhoConnect includes a simple [rake task](/rhoconnect/command-line#rake-tasks) `redis:install` to install redis, covered in the [Rake Tasks section](/rhoconnect/command-line#rake-tasks). Alternatively, you can [install redis directly](http://redis.io/download).
|
21
21
|
|
22
22
|
### Installing RhoConnect Gem
|
23
23
|
|
data/doc/net-plugin.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
rhoconnect.NET
|
2
2
|
===
|
3
3
|
|
4
|
-
A .NET 4 framework library for the [Rhoconnect](http://rhomobile.com/products/
|
4
|
+
A .NET 4 framework library for the [Rhoconnect](http://rhomobile.com/products/rhoconnect) App Integration Server.
|
5
5
|
|
6
|
-
Using rhoconnect.NET, your [ASP.NET MVC3](http://www.asp.net/mvc/mvc3) application's data will transparently synchronize with a mobile application built on the [Rhodes framework](http://rhomobile.com/products/rhodes), or any of the available [Rhoconnect clients](http://rhomobile.com/products/
|
6
|
+
Using rhoconnect.NET, your [ASP.NET MVC3](http://www.asp.net/mvc/mvc3) application's data will transparently synchronize with a mobile application built on the [Rhodes framework](http://rhomobile.com/products/rhodes), or any of the available [Rhoconnect clients](http://rhomobile.com/products/rhoconnect/).
|
7
7
|
|
8
8
|
## Getting started
|
9
9
|
|
@@ -183,7 +183,7 @@ Each of the above methods have a partition key supplied with the CRUD request. T
|
|
183
183
|
For example, the `Product` model above might have a relationship to the User model. This provides us a simple way to organize the `Product` dataset for rhoconnect by reusing this relationship.
|
184
184
|
In this case, your implementation might filter out data on a per user basis.
|
185
185
|
|
186
|
-
For more information about Rhoconnect partitions, please refer to the [Rhoconnect docs](http://docs.rhomobile.com/
|
186
|
+
For more information about Rhoconnect partitions, please refer to the [Rhoconnect docs](http://docs.rhomobile.com/rhoconnect/source-adapters#data-partitioning).
|
187
187
|
|
188
188
|
## Implementing MVC callbacks
|
189
189
|
All of the above methods are necessary to establish the communication from the Rhoconnect instance to your ASP.NET MVC application.
|
data/doc/rails-plugin.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
rhoconnect-rb
|
2
2
|
===
|
3
3
|
|
4
|
-
A ruby library for the [Rhoconnect](http://rhomobile.com/products/
|
4
|
+
A ruby library for the [Rhoconnect](http://rhomobile.com/products/rhoconnect) App Integration Server.
|
5
5
|
|
6
|
-
Using rhoconnect-rb, your application's model data will transparently synchronize with a mobile application built on the [Rhodes framework](http://rhomobile.com/products/rhodes), or any of the available [Rhoconnect clients](http://rhomobile.com/products/
|
6
|
+
Using rhoconnect-rb, your application's model data will transparently synchronize with a mobile application built on the [Rhodes framework](http://rhomobile.com/products/rhodes), or any of the available [Rhoconnect clients](http://rhomobile.com/products/rhoconnect/). This client includes built-in support for [ActiveRecord](http://ar.rubyonrails.org/) and [DataMapper](http://datamapper.org/) models.
|
7
7
|
|
8
8
|
## Getting started
|
9
9
|
|
@@ -13,7 +13,7 @@ Load the `rhoconnect-rb` library:
|
|
13
13
|
|
14
14
|
Note, if you are using datamapper, install the `dm-serializer` library and require it in your application. `rhoconnect-rb` depends on this utility to interact with Rhoconnect applications using JSON.
|
15
15
|
|
16
|
-
##
|
16
|
+
## Setup the Model
|
17
17
|
Now include Rhoconnect::Resource in a model that you want to synchronize with your mobile application:
|
18
18
|
|
19
19
|
class Product < ActiveRecord::Base
|
@@ -27,7 +27,7 @@ Or, if you are using DataMapper:
|
|
27
27
|
include Rhoconnect::Resource
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
## Partitioning Datasets
|
31
31
|
|
32
32
|
Next, your models will need to declare a partition key for `rhoconnect-rb`. This partition key is used by `rhoconnect-rb` to uniquely identify the model dataset when it is stored in a rhoconnect instance. It is typically an attribute on the model or related model. `rhoconnect-rb` supports two types of partitions:
|
33
33
|
|
@@ -52,9 +52,9 @@ Now all of the `Product` data synchronized by rhoconnect will organized by `self
|
|
52
52
|
:app
|
53
53
|
end
|
54
54
|
|
55
|
-
For more information about Rhoconnect partitions, please refer to the [Rhoconnect docs](http://docs.rhomobile.com/
|
55
|
+
For more information about Rhoconnect partitions, please refer to the [Rhoconnect docs](http://docs.rhomobile.com/rhoconnect/source-adapters#data-partitioning).
|
56
56
|
|
57
|
-
|
57
|
+
## Querying Datasets
|
58
58
|
|
59
59
|
`rhoconnect-rb` installs a `/rhoconnect/query` route in your application which the Rhoconnect instance invokes to query the dataset for the dataset you want to synchronize. This route is mapped to a `rhoconnect_query` method in your model. This method should return a collection of objects:
|
60
60
|
|
@@ -74,7 +74,7 @@ For more information about Rhoconnect partitions, please refer to the [Rhoconnec
|
|
74
74
|
|
75
75
|
In this example, `self.rhoconnect_query` returns a list of products where the partition string (provided by the rhoconnect instance) matches the `user_id` field in the products table.
|
76
76
|
|
77
|
-
|
77
|
+
## Configuration and Authentication
|
78
78
|
|
79
79
|
Configure Rhoconnect in an initializer like `config/initializers/rhoconnect.rb` (for Rails), or directly in your application (i.e. Sinatra). Here you will setup the rhoconnect uri (the location of your rhoconnect instance), and app\_endpoint (the location of your ruby app):
|
80
80
|
|
@@ -109,6 +109,17 @@ Example with authentication:
|
|
109
109
|
}
|
110
110
|
end
|
111
111
|
|
112
|
+
Example using the [RhoConnect Heroku Addon](/rhoconnect/heroku-addon):
|
113
|
+
|
114
|
+
If you're using the [RhoConnect Heroku Addon](/rhoconnect/heroku-addon), then you can omit the config.uri (it is added for you):
|
115
|
+
|
116
|
+
Rhoconnect.configure do |config|
|
117
|
+
config.token = "secrettoken"
|
118
|
+
config.authenticate = lambda { |credentials|
|
119
|
+
User.authenticate(credentials[:login], credentials[:password])
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
112
123
|
|
113
124
|
## Meta
|
114
125
|
Created and maintained by Lucas Campbell-Rossen, Vladimir Tarasov and Lars Burgess.
|
data/doc/web-console.txt
CHANGED
@@ -32,4 +32,4 @@ If you want to disable this web interface, you can do so by editing the rackup f
|
|
32
32
|
|
33
33
|
Here is a screenshot of the web console:
|
34
34
|
|
35
|
-
<img src="https://img.skitch.com/
|
35
|
+
<img src="https://img.skitch.com/20111007-c7agn6jqxnq2nne5srq1ijxk4g.png"/>
|
@@ -11,7 +11,6 @@ module Constants
|
|
11
11
|
REMOTE_HOME = '/home/ubuntu'
|
12
12
|
PEM_FILE = 'alexdevkey.pem'
|
13
13
|
SSH_KEY = "#{HOME_DIR}/.ssh/#{PEM_FILE}"
|
14
|
-
SCP_KEY = "#{HOME_DIR}/.scp/#{PEM_FILE}"
|
15
14
|
ACCESS_KEY_FILE = "#{HOME_DIR}/.ec2/credentials"
|
16
15
|
UBUNTU_STACK = { :image_id => 'ami-3d491a78',
|
17
16
|
:flavor_id => 'm1.small',
|
@@ -25,8 +24,8 @@ module Constants
|
|
25
24
|
:groups => 'load-test',
|
26
25
|
:user => 'root'}
|
27
26
|
|
28
|
-
STACKS = [ UBUNTU_STACK
|
29
|
-
|
27
|
+
STACKS = [ UBUNTU_STACK,
|
28
|
+
CENTOS_STACK ]
|
30
29
|
|
31
30
|
DEB_DEPS = [ "build-essential",
|
32
31
|
"zlib1g-dev",
|
@@ -32,21 +32,23 @@ def compile_stack_info
|
|
32
32
|
@stack.delete :user
|
33
33
|
|
34
34
|
# This part of the package name will always be the same
|
35
|
-
local_file = "#{`pwd`.strip}
|
35
|
+
local_file = "#{`pwd`.strip}/pkg/"
|
36
36
|
|
37
37
|
# Append the rest of the file name according to distribution
|
38
38
|
if @user == 'ubuntu'
|
39
|
-
@dist = { :package
|
40
|
-
:local_file
|
41
|
-
:pkg_mgr
|
42
|
-
:
|
43
|
-
:
|
39
|
+
@dist = { :package => "rhoconnect_#{Constants::RC_VERSION}_all.deb",
|
40
|
+
:local_file => "#{local_file}rhoconnect_#{Constants::RC_VERSION}_all.deb",
|
41
|
+
:pkg_mgr => 'dpkg',
|
42
|
+
:pkg_type => 'DEB',
|
43
|
+
:pkg_repo => 'apt-get -y',
|
44
|
+
:deps => Constants::DEB_DEPS }
|
44
45
|
elsif @user == 'root'
|
45
|
-
@dist = { :package
|
46
|
-
:local_file
|
47
|
-
:pkg_mgr
|
48
|
-
:
|
49
|
-
:
|
46
|
+
@dist = { :package => "rhoconnect-#{Constants::RC_VERSION}.noarch.rpm",
|
47
|
+
:local_file => "#{local_file}rhoconnect-#{Constants::RC_VERSION}.noarch.rpm",
|
48
|
+
:pkg_mgr => 'rpm',
|
49
|
+
:pkg_type => 'RPM',
|
50
|
+
:pkg_repo => 'yes | yum',
|
51
|
+
:deps => Constants::RPM_DEPS }
|
50
52
|
else
|
51
53
|
puts "Incorrect user name"
|
52
54
|
exit
|
@@ -122,7 +124,8 @@ end #create_scp_connection
|
|
122
124
|
# transfer
|
123
125
|
# transfers given data to remote machine via scp
|
124
126
|
def transfer(local_data, remote_data)
|
125
|
-
puts "Attempting
|
127
|
+
puts "Attempting file transfer via SCP"
|
128
|
+
puts "Transferring #{local_data} to #{remote_data}..."
|
126
129
|
@scp.upload( local_data, remote_data ) do |cd, name, sent, total|
|
127
130
|
print "\r#{name}: #{(sent.to_f * 100 / total.to_f).to_i}%"
|
128
131
|
end #do
|
@@ -132,7 +135,7 @@ end #establish_scp_connection
|
|
132
135
|
# transfer_rhoconnect
|
133
136
|
# Transfers the rhoconnect package over SCP
|
134
137
|
def transfer_rhoconnect
|
135
|
-
transfer @dist[:local_file],
|
138
|
+
transfer @dist[:local_file], @dist[:remote_home]
|
136
139
|
end #transfer_rhoconnect
|
137
140
|
|
138
141
|
# destroy_ec2_instance
|
@@ -163,8 +166,20 @@ def install_package
|
|
163
166
|
end #install_package
|
164
167
|
|
165
168
|
def start_servers
|
166
|
-
|
167
|
-
|
169
|
+
attempts = 0
|
170
|
+
while @ssh.run("pgrep redis")[0].stdout.strip == ""
|
171
|
+
ssh_cmd "sudo /etc/init.d/redis start"
|
172
|
+
attempts += 0
|
173
|
+
end #while
|
174
|
+
puts "Redis start took #{attempts} attempts"
|
175
|
+
puts
|
176
|
+
attempts = 0
|
177
|
+
while @ssh.run("pgrep nginx")[0].stdout.strip == ""
|
178
|
+
ssh_cmd "sudo /etc/init.d/nginx start"
|
179
|
+
attempts += 0
|
180
|
+
end #while
|
181
|
+
puts "Nginx start took #{attempts} attempts."
|
182
|
+
puts
|
168
183
|
puts "Waiting #{Constants::SLEEP} seconds for servers to initialize"
|
169
184
|
Constants::SLEEP.times do
|
170
185
|
sleep 1
|
@@ -198,51 +213,35 @@ def compute_time(start_time, end_time)
|
|
198
213
|
time_units = 'seconds'
|
199
214
|
end #if
|
200
215
|
|
201
|
-
"
|
216
|
+
"\nTest completed in #{time_delta} #{time_units}\n"
|
202
217
|
end #compute_time
|
203
218
|
|
204
219
|
# SCRIPT
|
205
220
|
|
206
|
-
### This part has been set as a dependency in the :test rake task
|
207
|
-
# Create Packages
|
208
|
-
|
209
|
-
# Creating debian package
|
210
|
-
#cmd "sudo rake build:deb"
|
211
|
-
# Make sure package was created successfully
|
212
|
-
#if $? != 0
|
213
|
-
# puts "Debian package was not created successfully" +
|
214
|
-
# "Exiting..."
|
215
|
-
# exit 1
|
216
|
-
#end #if
|
217
|
-
|
218
|
-
# Keep commented until running on a machine with rpm
|
219
|
-
# Creating RPM package
|
220
|
-
#cmd "sudo rake build:rpm"
|
221
|
-
# Make sure package was created successfully
|
222
|
-
#if $? != 0
|
223
|
-
# puts "RPM package was not created successfully" +
|
224
|
-
# "Exiting..."
|
225
|
-
# exit 1
|
226
|
-
#end #if
|
227
|
-
|
228
221
|
# Test Package installations
|
229
|
-
start_time = Time.now
|
230
222
|
Constants::STACKS.each do |stack|
|
223
|
+
start_time = Time.now
|
231
224
|
begin
|
232
225
|
@stack = stack
|
233
226
|
compile_stack_info
|
227
|
+
puts
|
228
|
+
puts "================================================"
|
229
|
+
puts "Now starting test of #{@dist[:pkg_type]} package"
|
230
|
+
puts "================================================"
|
231
|
+
puts
|
234
232
|
|
235
233
|
create_ec2_instance
|
236
234
|
|
237
235
|
# Establish connections
|
238
236
|
establish_ssh_connection
|
237
|
+
@dist[:remote_home] = @ssh.run("echo ~")[0].stdout.strip
|
239
238
|
establish_scp_connection
|
240
239
|
|
241
240
|
# Transfer the Rhoconnect package to the remote machine
|
242
241
|
transfer_rhoconnect
|
243
242
|
|
244
243
|
puts "Installing rhoconnect package.\n" +
|
245
|
-
"This may take a while
|
244
|
+
"This may take a while...\n\n"
|
246
245
|
install_package
|
247
246
|
|
248
247
|
# Start the redis and nginx servers on the remote machine
|
@@ -250,6 +249,9 @@ Constants::STACKS.each do |stack|
|
|
250
249
|
|
251
250
|
# Check the status of the rhoconnect service
|
252
251
|
check_rc_service
|
252
|
+
|
253
|
+
end_time = Time.now
|
254
|
+
puts compute_time(start_time, end_time)
|
253
255
|
rescue => e
|
254
256
|
puts "OH NOEZ, Exception!!"
|
255
257
|
puts e.inspect
|
@@ -260,5 +262,3 @@ Constants::STACKS.each do |stack|
|
|
260
262
|
end #if
|
261
263
|
end #begin
|
262
264
|
end #do
|
263
|
-
end_time = Time.now
|
264
|
-
puts compute_time(start_time, end_time)
|
@@ -2,6 +2,6 @@ namespace :rc_pkg do
|
|
2
2
|
desc 'Test creation and installation of both DEB and RPM rhoconnect packages.'
|
3
3
|
task :test => ['build:deb', 'build:rpm'] do
|
4
4
|
# Run installation test
|
5
|
-
|
5
|
+
ruby "installer/utils/nix_install_test.rb"
|
6
6
|
end #:test
|
7
7
|
end #:rc_pkg
|
@@ -49,7 +49,7 @@ module Rhoconnect
|
|
49
49
|
return _resend_search_result if params[:token] and params[:resend]
|
50
50
|
if params[:token] and !_ack_search(params[:token])
|
51
51
|
formatted_result = _format_search_result
|
52
|
-
|
52
|
+
_delete_search
|
53
53
|
return formatted_result
|
54
54
|
end
|
55
55
|
end
|
@@ -304,7 +304,7 @@ module Rhoconnect
|
|
304
304
|
|
305
305
|
def _ack_search(search_token)
|
306
306
|
if @client.get_value(:search_token) != search_token
|
307
|
-
|
307
|
+
_delete_search
|
308
308
|
@client.put_data(:search_errors,
|
309
309
|
{'search-error'=>{'message'=>'Search error - invalid token'}}
|
310
310
|
)
|
@@ -313,13 +313,19 @@ module Rhoconnect
|
|
313
313
|
true
|
314
314
|
end
|
315
315
|
|
316
|
+
def _delete_search
|
317
|
+
[:search, :search_page, :search_token, :search_errors].each do |search_doc|
|
318
|
+
@client.flash_data(search_doc)
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
316
322
|
def _do_search(params={})
|
317
323
|
# call source adapter search unless client is sending token for ack
|
318
324
|
search_params = params[:search] if params
|
319
325
|
res = @source_sync.search(@client.id,search_params) if params.nil? or !params[:token]
|
320
326
|
res,diffsize = @source.is_pass_through? ? [res,res.size] : compute_search
|
321
327
|
formatted_res = _format_search_result(res,diffsize)
|
322
|
-
|
328
|
+
_delete_search if diffsize == 0
|
323
329
|
formatted_res
|
324
330
|
end
|
325
331
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Rhoconnect
|
2
2
|
class ReadState < Model
|
3
3
|
field :refresh_time, :integer
|
4
|
+
field :prev_refresh_time, :integer
|
4
5
|
field :retry_counter, :integer
|
5
6
|
|
6
7
|
def self.create(fields)
|
@@ -9,6 +10,7 @@ module Rhoconnect
|
|
9
10
|
fields.delete(:user_id)
|
10
11
|
fields.delete(:source_name)
|
11
12
|
fields[:refresh_time] ||= Time.now.to_i
|
13
|
+
fields[:prev_refresh_time] ||= Time.now.to_i
|
12
14
|
fields[:retry_counter] ||= 0
|
13
15
|
super(fields,{})
|
14
16
|
end
|
data/lib/rhoconnect/source.rb
CHANGED
@@ -266,11 +266,47 @@ module Rhoconnect
|
|
266
266
|
def if_need_refresh(client_id=nil,params=nil)
|
267
267
|
need_refresh = lock(:md) do |s|
|
268
268
|
check = check_refresh_time
|
269
|
-
|
269
|
+
self.read_state.prev_refresh_time = self.read_state.refresh_time if check
|
270
|
+
self.read_state.refresh_time = Time.now.to_i + self.poll_interval if check
|
270
271
|
check
|
271
272
|
end
|
272
273
|
yield client_id,params if need_refresh
|
273
274
|
end
|
275
|
+
|
276
|
+
def rewind_refresh_time(query_failure)
|
277
|
+
return if self.poll_interval == 0
|
278
|
+
lock(:md) do |s|
|
279
|
+
rewind_time = false
|
280
|
+
# reset number of retries
|
281
|
+
# and prev_refresh_time on succesfull query
|
282
|
+
# or if last refresh was more than 'poll_interval' time ago
|
283
|
+
if not query_failure or ((Time.now.to_i - self.read_state.prev_refresh_time) >= self.poll_interval)
|
284
|
+
# we need to reset the prev_refresh_time here
|
285
|
+
# otherwise in case of expired poll interval
|
286
|
+
# and repeating failures - it will reset the counter
|
287
|
+
# on every error
|
288
|
+
self.read_state.prev_refresh_time = Time.now.to_i
|
289
|
+
self.read_state.retry_counter = 0
|
290
|
+
end
|
291
|
+
|
292
|
+
# rewind the refresh time on failure
|
293
|
+
# if retry limit is not reached
|
294
|
+
if query_failure
|
295
|
+
if self.read_state.retry_counter < self.retry_limit
|
296
|
+
self.read_state.increment!(:retry_counter)
|
297
|
+
rewind_time = true
|
298
|
+
# we have reached the limit - do not rewind the refresh time
|
299
|
+
# and reset the counter
|
300
|
+
else
|
301
|
+
self.read_state.retry_counter = 0
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
if rewind_time
|
306
|
+
self.read_state.refresh_time = self.read_state.prev_refresh_time
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
274
310
|
|
275
311
|
def is_pass_through?
|
276
312
|
self.pass_through and self.pass_through == 'true'
|
@@ -92,10 +92,14 @@ module Rhoconnect
|
|
92
92
|
result = nil
|
93
93
|
@source.if_need_refresh do
|
94
94
|
Stats::Record.update("source:query:#{@source.name}") do
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
95
|
+
if _auth_op('login')
|
96
|
+
result = self.read(nil,params)
|
97
|
+
_auth_op('logoff')
|
98
|
+
end
|
99
|
+
# re-wind refresh time in case of error
|
100
|
+
query_failure = Store.exists?(@source.docname(:errors))
|
101
|
+
@source.rewind_refresh_time(query_failure)
|
102
|
+
end
|
99
103
|
end
|
100
104
|
result
|
101
105
|
end
|