rhoconnect 3.0.6 → 3.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/CHANGELOG.md +9 -0
  2. data/Gemfile +3 -3
  3. data/Gemfile.lock +38 -17
  4. data/Rakefile +0 -10
  5. data/bench/benchapp/Gemfile.lock +1 -0
  6. data/bench/distr_bench/distr_bench_main +94 -27
  7. data/bench/distr_bench/run_test_query_script.sh +22 -18
  8. data/bench/lib/bench/aws_utils.rb +326 -0
  9. data/bench/lib/bench/bench_result_processor.rb +268 -75
  10. data/bench/lib/bench/cli.rb +1 -0
  11. data/bench/lib/bench/distr_runner.rb +102 -0
  12. data/bench/lib/bench/utils.rb +127 -0
  13. data/bench/lib/bench.rb +16 -15
  14. data/bench/prepare_bench +3 -11
  15. data/bench/scripts/test_query_script.rb +6 -7
  16. data/bin/rhoconnect-benchmark +257 -5
  17. data/doc/benchmarks-running.txt +140 -0
  18. data/doc/client-java.txt +236 -0
  19. data/doc/client-objc.txt +41 -1
  20. data/doc/client.txt +12 -0
  21. data/doc/command-line.txt +12 -3
  22. data/doc/cud-conflicts.txt +68 -0
  23. data/doc/deploying.txt +1 -70
  24. data/doc/hosting-rhohub.txt +3 -0
  25. data/doc/install.txt +50 -13
  26. data/doc/java-plugin.txt +217 -177
  27. data/doc/net-plugin.txt +97 -64
  28. data/doc/plugin-intro.txt +4 -2
  29. data/doc/preparing-production.txt +63 -0
  30. data/doc/rhoconnect-redis-stack.txt +252 -0
  31. data/doc/source-adapters.txt +3 -1
  32. data/doc/tutorial.txt +111 -49
  33. data/examples/simple/dump.rdb +0 -0
  34. data/installer/unix-like/rho_connect_install_constants.rb +6 -5
  35. data/installer/unix-like/rho_connect_install_installers.rb +6 -2
  36. data/installer/utils/nix_install_test.rb +2 -0
  37. data/installer/utils/package_upload/auto-repo.rb +136 -0
  38. data/installer/utils/package_upload/repos.rake +6 -3
  39. data/installer/utils/package_upload/s3_upload.rb +11 -6
  40. data/installer/windows/rhosync.nsi +5 -5
  41. data/lib/rhoconnect/client_sync.rb +2 -2
  42. data/lib/rhoconnect/document.rb +12 -0
  43. data/lib/rhoconnect/jobs/source_job.rb +2 -2
  44. data/lib/rhoconnect/predefined_adapters/bench_adapter.rb +61 -0
  45. data/lib/rhoconnect/source.rb +5 -0
  46. data/lib/rhoconnect/source_adapter.rb +10 -1
  47. data/lib/rhoconnect/source_sync.rb +161 -88
  48. data/lib/rhoconnect/store.rb +48 -0
  49. data/lib/rhoconnect/test_methods.rb +6 -6
  50. data/lib/rhoconnect/version.rb +1 -1
  51. data/lib/rhoconnect.rb +25 -2
  52. data/spec/apps/rhotestapp/sources/sample_adapter.rb +29 -0
  53. data/spec/jobs/source_job_spec.rb +5 -5
  54. data/spec/source_adapter_spec.rb +10 -0
  55. data/spec/source_sync_spec.rb +114 -33
  56. data/spec/spec_helper.rb +21 -2
  57. data/spec/store_spec.rb +29 -0
  58. data/spec/support/shared_examples.rb +1 -1
  59. data/spec/test_methods_spec.rb +4 -4
  60. data/tasks/redis.rake +2 -2
  61. metadata +59 -59
  62. data/bench/benchapp/log/passenger.3000.log +0 -1
  63. data/bench/benchapp/log/passenger.9292.log +0 -59
  64. data/bench/benchapp/tmp/pids/passenger.3000.pid.lock +0 -0
  65. data/bench/benchapp/tmp/pids/passenger.9292.pid.lock +0 -0
  66. data/bench/lib/testdata/0-data.txt +0 -0
  67. data/bench/lib/testdata/1-data.txt +0 -0
  68. data/bench/lib/testdata/10-data.txt +0 -15
  69. data/bench/lib/testdata/2-data.txt +0 -3
  70. data/bench/lib/testdata/25-data.txt +0 -39
  71. data/bench/lib/testdata/250-data.txt +0 -353
  72. data/bench/lib/testdata/3-data.txt +0 -4
  73. data/bench/lib/testdata/50-data.txt +0 -70
  74. data/bench/lib/testdata/500-data.txt +0 -711
data/doc/tutorial.txt CHANGED
@@ -1,25 +1,40 @@
1
- RhoConnect Tutorial
2
- ===
1
+ # RhoConnect Tutorial
3
2
 
4
- Adding Synchronized Data to Your App with RhoConnect
5
- ---
3
+ ## Adding Synchronized Data to Your Backend Application with RhoConnect
6
4
 
7
- RhoConnect is a synchronization framework consisting of a client component on the device and a server component that runs on any server capable of running Ruby. RhoConnect requires that you write a small amount of Ruby code for the query, create, update and delete operations of your particular enterprise backend. The collection of the Ruby code for these operations we refer to as a "source" or "source adapter". Full documentation of all capabilities of RhoConnect is in the [RhoConnect Developer Reference](/rhoconnect/introduction).
5
+ RhoConnect is a synchronization framework consisting of a backend application (a client component on the mobile device) and a server component (a RhoConnect application) that runs on any server capable of running Ruby. The backend application can be a Rhodes application, or another mobile application written without the use of Rhodes (such as an iOS/Objective C or Android/Java application).
8
6
 
9
- Install the RhoConnect Dependencies
10
- ---
7
+ RhoConnect requires that you write a small amount of code for the query, create, update and delete operations of your particular enterprise backend. You can write this code in Ruby as a RhoConnect source adapter, or you can write this code as a RhoConnect plugin application written in Java, .NET, or Ruby on Rails.
8
+
9
+ Full documentation of all capabilities of RhoConnect is in the [RhoConnect Developer Reference](/rhoconnect/introduction).
10
+
11
+ ## Installing the RhoConnect Dependencies
11
12
 
12
13
  * Install RhoConnect as described [here](/rhoconnect/install).
13
14
 
14
- * If you have a RhoConnect license that has been sent to you you can replace the settings/license.yml file as described [here](/rhoconnect/licensing).
15
+ * If you have a RhoConnect license that has been sent to you, you can replace the settings/license.yml file as described [here](/rhoconnect/licensing).
16
+
17
+ Now you are ready to write your RhoConnect app. You can generate an app with RhoStudio, or with the RhoConnect app command.
18
+
19
+ ### Generating a RhoConnect App with RhoStudio
20
+
21
+ In RhoStudio, select File->New->Project...
15
22
 
16
- Now you are ready to write your RhoConnect app. You can generate an app with the RhoConnect app command.
23
+ The New Project window opens. Select the RhoConnect application wizard and click the Next button.
24
+
25
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/new-project-rhoconnect.png"/>
26
+
27
+ Enter the name for your RhoConnect application in Project name; in this case, "storeserver". You may specify a specific folder for your destination where your project is stored, by default, the destination is your RhoStudio workspace folder. Then press the Finish button.
28
+
29
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/rhoconnect-application-wizard.png"/>
30
+
31
+ ### Generating a RhoConnect App from the Command Line
17
32
 
18
33
  :::term
19
- $ rhoconnect app storemanager-server
20
- $ cd storemanager-server/
34
+ $ rhoconnect app storeserver
35
+ $ cd storeserver
21
36
 
22
- Next, install the application's dependencies. RhoConnect applications use [bundler](http://gembundler.com/) to manage dependencies, so you can install them with:
37
+ Next, install the application's dependencies. RhoConnect applications use [bundler](http://gembundler.com/) to manage dependencies, so you can install them with:
23
38
 
24
39
  :::term
25
40
  $ [sudo] bundle install
@@ -29,8 +44,6 @@ Next, install the application's dependencies. RhoConnect applications use [bund
29
44
  :::term
30
45
  $ [sudo] rake dtach:install
31
46
 
32
- ### Verify Installation
33
-
34
47
  Now you can run redis and your RhoConnect app:
35
48
 
36
49
  :::term
@@ -41,12 +54,36 @@ If everything went well you should see:
41
54
 
42
55
  [07:01:15 PM 2010-05-04] Rhoconnect Server v3.0.0 started...
43
56
 
44
- Defining RhoConnect Source Adapters
45
- ---
57
+ ## Defining RhoConnect Source Adapters
46
58
 
47
59
  Once RhoConnect is installed we're ready to build a RhoConnect source to integrate with our backend application. To define a RhoConnect source you just need to identify a handful of operations to interact with your backend data source: login, query, sync, create, update, delete and logoff. For more information please see the [RhoConnect source adapter](/rhoconnect/source-adapters) documentation.
48
60
 
49
- From the storemanager-sever directory, generate a source adapter for the product model:
61
+ ### Generating the Source Adapter from RhoStudio
62
+
63
+ To generate a RhoConnect source adapter and create the associated Controller templates, right-click on the application project in the Project Explorer and select New->Rhodes model.
64
+
65
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/menu-new-rhoconnect_source-adapter.png"/>
66
+
67
+ In the Model Information window, enter the name for your source adapter: in this case, product.
68
+
69
+ Click the Finish button to create the source adapter.
70
+
71
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/source-adapter-information.png"/>
72
+
73
+ After pressing the Finish button, you'll see the RhoConnect source adapter generator script output in the output console (Rhodes build log console).
74
+
75
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/rhoconnect-source-generator-output.png"/>
76
+
77
+ You should now have files for the source adapter in your storeserver application. The files are organized as follows:
78
+
79
+ * product.rb -> This is the source adapter file which contains the login, query, create, update, delete and logoff methods to call a backend service. You will add code to implement these methods.
80
+ * product_spec.rb -> This file contains the spec with tests which relate to our source adapter.
81
+
82
+ ### Generating the Source Adapter from the Command Line
83
+
84
+ From the command line, navigate to the main folder for your RhoConnect app: in this case, storeserver.
85
+
86
+ Then run the command to generate a source adapter for the product model. The product model is used as an example for a Rhodes storemanager in the [RhoStudio tutorial](rhostudio.tutorial) and the [documentation to generate a Rhodes application](rhodes/generator).
50
87
 
51
88
  :::term
52
89
  $ rhoconnect source product
@@ -57,7 +94,13 @@ which generates two files, the product adapter and the product spec:
57
94
  [ADDED] sources/product.rb
58
95
  [ADDED] spec/sources/product_spec.rb
59
96
 
60
- You'll see a file similar to the following one below. The generated source adapter has code to raise an exception for any required method. Note that you don't need to use the source generator. You can just create a Ruby file and place it into your lib directory. The class name of the source adapter must match that of the client model.
97
+ In RhoStudio, you can open the sources/product.rb file and edit it.
98
+
99
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/rhostudio-rhoconnect-product-rb.png"/>
100
+
101
+ You can also use the command line to navigate to the sources/product.rb file in your RhoConnect application folder.
102
+
103
+ You'll see a product.rb file similar to the code listing below. The generated source adapter has code to raise an exception for any required method. Note that you don't need to use the source generator; you can create a Ruby file and place it into your lib directory. The class name (in this case, product) of the RhoConnect source adapter must match that of the Rhodes client model.
61
104
 
62
105
  :::ruby
63
106
  class Product < SourceAdapter
@@ -122,9 +165,11 @@ The next step is for you to fill in the login, query, create, update, delete and
122
165
 
123
166
  The description below shows what such code might look like.
124
167
 
125
- A RhoConnect Query
126
- ---
127
- If you're doing a readonly non-authenticated source adapter, you can get away with just writing one method, query, to retrieve records as we describe here. The following is a sample query method to interact with a simple product catalog (available at http://rhostore.heroku.com) that exposes a REST interface. Note that RhoConnect can work with any protocol. This example simply shows JSON over HTTP with a REST interface since that is common. The RhoConnect source adapter is pure Ruby code and there are ruby libraries (aka gems) that will make it easy to connect to and parse whatever you need -- the query code would just be slightly different.
168
+ ## A RhoConnect Query
169
+
170
+ If you're doing a readonly non-authenticated source adapter, you can just write one method, query, to retrieve records as we describe here. The following is a sample query method to interact with a simple product catalog (available at http://rhostore.heroku.com) that exposes a REST interface. Note that RhoConnect can work with any protocol. This example shows JSON over HTTP with a REST interface, since that is common. The RhoConnect source adapter is Ruby code and there are ruby libraries (aka gems) that will make it easy to connect to and parse whatever you need -- the query code would just be slightly different.
171
+
172
+ For a more complete example of rewriting the source adapter methods (such as create, update, and delete), refer to the [source adapter example](rhoconnect/source-adapters#sample-adapter) in the RhoConnect Developer Reference.
128
173
 
129
174
  Our sample web service for returning all products in the catalog (http://rhostore.heroku.com/products.json) returns data like this:
130
175
 
@@ -156,15 +201,17 @@ Our sample web service for returning all products in the catalog (http://rhostor
156
201
  }
157
202
  ]
158
203
 
159
- The Ruby code for parsing that data listed below uses the standard Ruby JSON library and the RestClient library for easy access to the REST web service. This example uses the id of the product record as the hash key. Note that the key for this hash must be a string and the value can be any set of name-value pairs which are represented as a Ruby hash. The instance variable @result must be set by the query method to this "hash of hashes", indexed by a unique identifier, so that the base SourceAdapter class sync method can populate Redis data store.
204
+ The Ruby code for parsing that data, sources.product.rb, is listed below. It uses the standard Ruby JSON library and the RestClient library for easy access to the REST web service. This example uses the id of the product record as the hash key. Note that the key for this hash must be a string and the value can be any set of name-value pairs which are represented as a Ruby hash. The instance variable @result must be set by the query method to this "hash of hashes", indexed by a unique identifier, so that the base SourceAdapter class sync method can populate Redis data store.
205
+
206
+ You can edit sources/product.rb within RhoStudio, or you can navigate to it within your RhoConnect application folder and edit it with a text editor.
160
207
 
161
- We need to declare the standard libraries that we are using at the top of the file:
208
+ We need to declare the standard libraries that we are using at the top of the sources/product.rb file:
162
209
 
163
210
  :::ruby
164
211
  require 'json'
165
212
  require 'rest_client'
166
213
 
167
- For convenience, we'll add an instance variable @base which contains the base URL of the web service and set the value in the constructor:
214
+ For convenience, we'll add an instance variable @base which contains the base URL of the web service and sets the value in the constructor:
168
215
 
169
216
  :::ruby
170
217
  def initialize(source)
@@ -187,8 +234,8 @@ Then fill in the query method:
187
234
  end
188
235
  end
189
236
 
190
- **NOTE: The code above could be much more concise, but it is written to be easily readable by programmers who are unfamiliar with the Ruby language. If you are new to Ruby, you can read [Ruby from other languages](http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/) for a good introduction.
191
- Each hash key in the inner hash represents an attribute of an individual object. All datatypes must be strings (so the hash values need to all be strings not integers).**
237
+ **NOTE: The code above could be much more concise, but it is written to be easily readable by programmers who are unfamiliar with the Ruby language. If you are new to Ruby, you can read [Ruby from other languages](http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/) for a good introduction.
238
+ Each hash key in the inner hash represents an attribute of an individual object. All datatypes must be strings (so the hash values need to all be strings, not integers).**
192
239
 
193
240
  For example:
194
241
 
@@ -204,20 +251,27 @@ For example:
204
251
  }
205
252
  }
206
253
 
207
- Testing Sync from the Client
208
- ---
209
- Make sure you are running redis and start (or restart) your server:
254
+ ## Testing Sync from the Client
255
+
256
+ Make sure you are running redis.
257
+
258
+ :::term
259
+ rake redis:start
260
+
261
+ Then start (or restart) your server:
210
262
 
211
263
  :::term
212
264
  $ rake rhoconnect:start
213
265
 
214
- The code for the source adapter loads when the server starts. If you have a syntax error in your Ruby code, it will be reported and the server will not start; however, if you have a runtime error, that will not be reported until the source adapter is called.
266
+ **Note: The RhoConnect application must be run from the command line. It does not run from RhoStudio.**
267
+
268
+ The code for the source adapter loads when the server starts. If you have a syntax error in your Ruby code, it will be reported and the server will not start; however, if you have a runtime error, that will not be reported until the source adapter is called.
215
269
 
216
- Make sure your server URL is configured in the app. If your server is running on localhost with the default port, the following line should be at the bottom of rhoconfig.txt:
270
+ Make sure your server URL is configured in the Rhodes app. If your server is running on localhost with the default port, the following line should be at the bottom of your corresponding Rhodes app, storemanager/rhoconfig.txt:
217
271
 
218
272
  syncserver = 'http://localhost:9292/application'
219
273
 
220
- Enable sync in your storemanager/app/Product/product.rb model:
274
+ Enable sync in your corresponding Rhodes app, storemanager/app/Product/product.rb model:
221
275
 
222
276
  :::ruby
223
277
  class Product
@@ -226,21 +280,29 @@ Enable sync in your storemanager/app/Product/product.rb model:
226
280
  enable :sync
227
281
  end
228
282
 
229
- To get a feel for what is happening, it is helpful to watch the server log (the output of rake rhoconnect:start) in one window, and tail the client log in another window. For example, on the iPhone, display the end of the client log with:
283
+ To get a feel for what is happening, it is helpful to watch the server log (the output of rake rhoconnect:start) in one window, and tail the client log in another window. For example, on the iPhone, display the end of the client log with:
230
284
 
231
285
  :::term
232
286
  $ tail -f rholog-User.txt
233
287
 
234
- To sync with the server, the client must log in. The generated app includes some screens for login and other common functions, which you will typically modify to suit the design of your application. The generated UI is useful since it allows you to focus on the core functionality of your application before implementing the important, but mundane, details of user authentication and settings.
288
+ To sync with the RhoConnect server, the Rhodes client must log in. The Rhodes generated app includes some screens for login and other common functions, which you will typically modify to suit the design of your application. The generated UI is useful since it allows you to focus on the core functionality of your application before implementing the important, but mundane, details of user authentication and settings.
289
+
290
+ 1. From the home page in the Rhodes app, click on the login button in the upper right corner. Alternatively, you can click on the tool icon at the bottom of the screen to go to the Settings screen, and click the login button from there.
291
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/storemanager-rhosimulator-home-arrows.png"/>
292
+
293
+ 2. Login using any name & password. The generated code allows any login, but you can modify that in application.rb.
294
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/rhosimulator-login.png"/>
235
295
 
236
- 1. Click on the gears icon at the bottom of the screen to go to the Settings screen
237
- 2. Login using any name & password. The generated code allows any login, but you can modify that in application.rb.
238
296
  3. If login is successful, you will see a Client ID in the settings screen. The ClientID is generated the first time you log in and is stored in the client database. It serves as a unique identifier which is required for rhoconnect. (Note: this value will persist across logins, but if you reset the client database or the user re-installs the app, a new ClientID will be generated.)
239
- 4. Sync is triggered automatically. Click on the home icon and then select "Products" and you should see the records from the server.
297
+ 4. Sync is triggered automatically. Click on the home icon and then select "Products" and you should see the list of product records from the server.
240
298
 
241
- Creating Objects with RhoConnect
242
- ---
243
- For your create method you can assume that the RhoConnect server will pass you a hash containing the new record called "create_hash". For example it might be:
299
+ This example shows a couple of iPhone products.
300
+
301
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/rhosimulator-product-list.png"/>
302
+
303
+ ## Creating Objects with RhoConnect
304
+
305
+ For your create method, the RhoConnect server will pass you a hash containing the new record, called "create_hash". For example, it might be:
244
306
 
245
307
  :::ruby
246
308
  {
@@ -248,7 +310,7 @@ For your create method you can assume that the RhoConnect server will pass you a
248
310
  "brand" => "Acme"
249
311
  }
250
312
 
251
- The create method will be called once for every object that has been created on the client since the last sync. Your code for create (or edit or delete) needs to use this populated array to do its work. Below is an example of a create method against the [rhostore](http://rhostore.heroku.com), which accepts an HTTP POST to perform a create action. The create method must return a unique id string for the object for it to be later modifiable by the client. If no id is returned, then you should treat the client object as read only, because it will not be able to be synchronized.
313
+ The RhoConnect sources/product.rb create method will be called once for every object that has been created on the client since the last sync. Your code for create (or edit or delete) needs to use this populated array to do its work. Below is an example of a create method against the [rhostore](http://rhostore.heroku.com), which accepts an HTTP POST to perform a create action. The create method should return a unique id string for the object for it to be later modifiable by the client. If no id is returned, then you should treat the client object as read only, because it will not be able to be synchronized.
252
314
 
253
315
  :::ruby
254
316
  def create(create_hash)
@@ -266,11 +328,11 @@ The create method will be called once for every object that has been created on
266
328
  JSON.parse(new_record)["product"]["id"].to_s
267
329
  end
268
330
 
269
- You will need to restart RhoConnect to reload the source adapter after modifying code. Note that the object will be created on the client right away, but it will be sent to the server on the next sync.
331
+ You will need to restart RhoConnect to reload the source adapter after modifying code. Note that the object will be created on the client right away, but it will be sent to the server on the next sync.
270
332
 
271
- Authentication
272
- ---
273
- The generated application code includes a file at the root of the directory called "application.rb" which contains a hook for authentication. The complete file looks like this:
333
+ ## Authentication
334
+
335
+ The generated RhoConnect application code includes a file at the root of the directory called "application.rb" which contains a hook for authentication. The complete file looks like this:
274
336
 
275
337
  :::ruby
276
338
  class Application < Rhoconnect::Base
@@ -301,7 +363,7 @@ The generated application code includes a file at the root of the directory call
301
363
 
302
364
  Application.initializer(ROOT_PATH)
303
365
 
304
- If your back end web service requires authentication, simply add code to the authenticate method and return true if authentication was successful or false to deny access to the application from this client. For example:
366
+ If your back end web service requires authentication, add code to the authenticate method and return true if authentication was successful or false to deny access to the application from this client. For example:
305
367
 
306
368
  :::ruby
307
369
  def authenticate(username, password, session)
@@ -313,6 +375,6 @@ If your back end web service requires authentication, simply add code to the aut
313
375
  return success
314
376
  end
315
377
 
316
- Using RhoConnect from Objective C
317
- ---
318
- You don't have to use Rhodes to use RhoConnect. For this scenario, we offer an [Objective C client for RhoConnect](/rhoconnect/client).
378
+ ## Using RhoConnect from Objective C
379
+
380
+ You don't have to use Rhodes to use RhoConnect. For this scenario, we offer an [Objective C client for RhoConnect](/rhoconnect/client).
Binary file
@@ -8,20 +8,21 @@ module Constants
8
8
  "libaprutil1-dev",
9
9
  "dtach"]
10
10
 
11
- REDIS = "redis-2.4.2"
11
+ REDIS = "redis-2.4.5"
12
12
  SQLITE3 = "sqlite-autoconf-3070701"
13
13
  RUBY = "ruby-enterprise-1.8.7-2011.03"
14
- Nginx = "nginx-1.0.6"
15
- #RUBYGEMS = "rubygems-1.8.5"
14
+ Nginx = "nginx-1.0.10"
16
15
 
17
16
  SOFTWARE = [ REDIS, SQLITE3, RUBY, Nginx ]
18
17
 
19
18
  REDIS_URL = "http://redis.googlecode.com/files/#{ REDIS }.tar.gz"
20
19
  SQLITE3_URL = "http://www.sqlite.org/sqlite-autoconf-3070701.tar.gz"
21
- #RUBYGEMS_URL = "http://rubyforge.org/frs/download.php/74954/" + "#{ RUBYGEMS }.tgz"
22
20
  URLS = [ REDIS_URL, SQLITE3_URL ]
23
21
 
24
- GEMS = ["bundler", "passenger"]
22
+ RUBYGEMS_VERSION = "1.8.11"
23
+ GEMS = ["bundler", "passenger",
24
+ "thor", "ffaker"] # thor and ffaker required by rhoconnect-benchmark utility
25
+
25
26
  SUPPORTED_PKG_MGRS = ["apt-get", "yum"]
26
27
  SUPPORTED_WEB_SERVERS = ["apache2", "nginx"]
27
28
 
@@ -35,10 +35,14 @@ module Installers
35
35
  # Constants file
36
36
  def install_all_gems
37
37
  @gem_path = "#{@options[:prefix]}/bin/gem"
38
+
39
+ # Update the RubyGems system software
40
+ cmd "#{@gem_path} update --system"
41
+
38
42
  Constants::GEMS.each do |gem|
39
43
  install_gem gem
40
- end #do
41
- end #install_all_gems
44
+ end
45
+ end
42
46
 
43
47
  # install_gem
44
48
  # This method installs the given gem unless it is already installed
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
1
3
  $:.unshift File.expand_path(File.dirname(__FILE__))
2
4
  $:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'installer', 'utils'))
3
5
 
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'aws/s3'
5
+ require 'find'
6
+
7
+ # CONSTANTS
8
+
9
+ ACCESS_KEY_FILE = '/Users/rhomobile/.s3/keys'
10
+ SOURCE = ARGV[0]
11
+ BUCKET = ARGV[1]
12
+ PKG_TYPE = ARGV[2]
13
+ PKG_DIR = '/packages'
14
+
15
+ # METHODS
16
+
17
+ def cmd(cmd)
18
+ puts cmd
19
+ system(cmd)
20
+ end #cmd
21
+
22
+ def print_usage
23
+ puts "Usage: #{$0} source_file dest_bucket package_type"
24
+ end #print_usage
25
+
26
+ def check_params
27
+ error = false
28
+ if ARGV.size != 3
29
+ puts "Wrong number of arguments (#{ARGV.size} for 2)"
30
+ error = true
31
+ end #if
32
+
33
+ if !FileTest.exists?(SOURCE)
34
+ puts "#{SOURCE} does not exist!"
35
+ error = true
36
+ end #if
37
+
38
+ begin
39
+ found = AWS::S3::Bucket.find(BUCKET)
40
+ rescue
41
+ puts "#{BUCKET} is not a valid bucket."
42
+ error = true
43
+ end
44
+
45
+ if error
46
+ print_usage
47
+ end #if
48
+
49
+ end #check_params
50
+
51
+ def prepare_destination
52
+ if PKG_TYPE == 'deb'
53
+ # Remove the /deb directory if it exists
54
+ if File.directory?("#{PKG_DIR}/deb")
55
+ cmd "sudo rm -rf #{PKG_DIR}/deb"
56
+ end #if
57
+
58
+ # Create deb directory if it does not already exist
59
+ cmd "sudo mkdir -p #{PKG_DIR}/deb" unless File.directory?("#{PKG_DIR}/deb")
60
+
61
+ # Create configuration file "ditributions" in deb directory
62
+ filename = "#{PKG_DIR}/deb/conf/"
63
+ cmd "sudo mkdir -p #{filename}"
64
+ distributions = "Origin: Rhomobile, Inc.\n" +
65
+ "Label: Rhomobile, Inc.\n" +
66
+ "Codename: rhoconnect\n" +
67
+ "Architectures: i386 amd64\n" +
68
+ "Components: main\n" +
69
+ "Description: Rhoconnect APT Repository"
70
+
71
+ cmd "touch #{filename}/distributions"
72
+
73
+ # Write distributions string to corresponding file
74
+ dist_file = File.new("#{filename}/distributions", "w")
75
+ dist_file.write(distributions)
76
+ dist_file.close
77
+ else
78
+ # Create rpm directory if it does not already exist
79
+ cmd "sudo mkdir -p #{PKG_DIR}/rpm" unless File.directory?("#{PKG_DIR}/rpm")
80
+ end #if
81
+
82
+ end #prepare_destination
83
+
84
+ def get_keys
85
+ lines = IO.readlines ACCESS_KEY_FILE
86
+ @access_key = lines.first.strip
87
+ @secret_access_key = lines.last.strip
88
+ end #get_keys
89
+
90
+ def establish_s3_connection
91
+ get_keys
92
+ @s3_connection = AWS::S3::Base.establish_connection!( :access_key_id => @access_key,
93
+ :secret_access_key => @secret_access_key )
94
+ end #establish_s3_connection
95
+
96
+ def upload(file)
97
+ puts "Uploading #{file} to bucket #{BUCKET}..." unless @raked
98
+ # Upload the given file
99
+ AWS::S3::S3Object.store( file,
100
+ open( file ),
101
+ BUCKET,
102
+ :access => :public_read )
103
+
104
+ # Display the URL of the file just uploaded
105
+ puts AWS::S3::S3Object.url_for((file), BUCKET)[/[^?]+/]
106
+ puts
107
+ end #upload
108
+
109
+ def upload_files
110
+ # Get list of files do be added
111
+ number_of_files = 0
112
+ paths = []
113
+ Find.find(START_DIR) do |path|
114
+ if FileTest.directory?(path)
115
+ next
116
+ else
117
+ paths.push(path)
118
+ number_of_files += 1
119
+ end
120
+ end
121
+
122
+ puts "Uploading #{number_of_files} files."
123
+ paths.each do |path|
124
+ upload path
125
+ end #do
126
+ puts "#{number_of_files} files uploaded."
127
+
128
+ end #upload_files
129
+
130
+ # SCRIPT
131
+
132
+ check_params
133
+
134
+ prepare_destination
135
+
136
+ upload_files
@@ -13,6 +13,8 @@ task "build:repos" => ['build:deb', 'build:rpm'] do
13
13
  system(cmd)
14
14
  end #cmd
15
15
 
16
+ # METHODS
17
+
16
18
  def prepare_destination
17
19
  # Prompt to remove the /deb directory if it exists
18
20
  if File.directory?("#{PKG_DIR}/deb")
@@ -31,7 +33,7 @@ task "build:repos" => ['build:deb', 'build:rpm'] do
31
33
  cmd "sudo mkdir -p #{PKG_DIR}/deb" unless File.directory?("#{PKG_DIR}/deb")
32
34
 
33
35
  # Create configuration file "ditributions" in deb directory
34
- filename = "#{PKG_DIR}/deb/conf/"
36
+ filename = "#{PKG_DIR}/deb/conf"
35
37
  cmd "sudo mkdir -p #{filename}"
36
38
  distributions = "Origin: Rhomobile, Inc.\n" +
37
39
  "Label: Rhomobile, Inc.\n" +
@@ -39,7 +41,8 @@ task "build:repos" => ['build:deb', 'build:rpm'] do
39
41
  "Architectures: i386 amd64\n" +
40
42
  "Components: main\n" +
41
43
  "Description: Rhoconnect APT Repository"
42
- cmd "touch #{filename}/distributions"
44
+ cmd "sudo touch #{filename}/distributions"
45
+ cmd "sudo chmod 777 #{filename}/distributions"
43
46
 
44
47
  # Write distributions string to corresponding file
45
48
  dist_file = File.new("#{filename}/distributions", "w")
@@ -72,7 +75,7 @@ task "build:repos" => ['build:deb', 'build:rpm'] do
72
75
  @raked = true
73
76
 
74
77
  prepare_destination
75
-
78
+
76
79
  copy_files
77
80
 
78
81
  # REPOIFY!
@@ -6,9 +6,11 @@ require 'find'
6
6
 
7
7
  # CONSTANTS
8
8
 
9
- ACCESS_KEY_FILE = '/home/vagrant/.s3/keys'
10
- START_DIR = ARGV[0]
11
- BUCKET = ARGV[1]
9
+ # ACCESS_KEY_FILE = '/home/vagrant/.s3/keys'
10
+ START_DIR = ARGV[0]
11
+ BUCKET = ARGV[1]
12
+ S3_ACCESS_KEY = 'AKIAIFBP7PVF6WBEGLGA'
13
+ S3_SECRET_ACCESS_KEY = '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'
12
14
 
13
15
  # METHODS
14
16
 
@@ -39,9 +41,12 @@ def check_params
39
41
  end #check_params
40
42
 
41
43
  def get_keys
42
- lines = IO.readlines ACCESS_KEY_FILE
43
- @access_key = lines.first.strip
44
- @secret_access_key = lines.last.strip
44
+ # lines = IO.readlines ACCESS_KEY_FILE
45
+ # @access_key = lines.first.strip
46
+ # @secret_access_key = lines.last.strip
47
+ @access_key = S3_ACCESS_KEY
48
+ @secret_access_key = S3_SECRET_ACCESS_KEY
49
+
45
50
  end #get_keys
46
51
 
47
52
  def establish_s3_connection
@@ -99,7 +99,7 @@ section "uninstall"
99
99
  Push "PATH"
100
100
  Push "R"
101
101
  Push "HKLM"
102
- Push "$INSTDIR\redis-2.4.2"
102
+ Push "$INSTDIR\redis-2.4.5"
103
103
  Call un.EnvVarUpdate
104
104
  Pop $R0
105
105
 
@@ -170,25 +170,25 @@ Section "Redis" redisSection
170
170
 
171
171
  SetOutPath $INSTDIR
172
172
 
173
- File /r "redis-2.4.2"
173
+ File /r "redis-2.4.5"
174
174
 
175
175
  ;add to path here
176
176
 
177
177
  Push "PATH"
178
178
  Push "P"
179
179
  Push "HKLM"
180
- Push "$INSTDIR\redis-2.4.2"
180
+ Push "$INSTDIR\redis-2.4.5"
181
181
  Call EnvVarUpdate
182
182
  Pop $R0
183
183
 
184
184
  Push "REDIS_HOME"
185
185
  Push "P"
186
186
  Push "HKLM"
187
- Push "$INSTDIR\redis-2.4.2"
187
+ Push "$INSTDIR\redis-2.4.5"
188
188
  Call EnvVarUpdate
189
189
  Pop $R0
190
190
 
191
- ExecWait '$INSTDIR\redis-2.4.2\redis-service.exe install' $0
191
+ ExecWait '$INSTDIR\redis-2.4.5\redis-service.exe install' $0
192
192
  StrCmp $0 "0" continue wrong
193
193
 
194
194
  wrong:
@@ -25,7 +25,7 @@ module Rhoconnect
25
25
  key,value = op,cud_params[op]
26
26
  processed += _receive_cud(key,value) if value
27
27
  end
28
- @source_sync.process_cud(@client.id) if processed > 0
28
+ @source_sync.process_cud if processed > 0
29
29
  end
30
30
  end
31
31
 
@@ -349,7 +349,7 @@ module Rhoconnect
349
349
 
350
350
  def _receive_cud(operation,params)
351
351
  return 0 if not ['create','update','delete'].include?(operation)
352
- @client.lock(operation) { |c| c.put_data(operation,params,true) }
352
+ @source.lock(operation) { |s| s.put_zdata(operation,@client.id,params,true) }
353
353
  return 1
354
354
  end
355
355
 
@@ -43,6 +43,18 @@ module Document
43
43
  Store.rename(docname(srcdoctype),docname(dstdoctype))
44
44
  end
45
45
 
46
+ def get_zdata(doctype)
47
+ Store.get_zdata(docname(doctype))
48
+ end
49
+
50
+ def flush_zdata(doctype)
51
+ Store.flush_zdata(docname(doctype))
52
+ end
53
+
54
+ def put_zdata(doctype,assoc_key, data={},append=false)
55
+ Store.put_zdata(docname(doctype),assoc_key, data,append)
56
+ end
57
+
46
58
  # Generate the fully-qualified docname
47
59
  def docname(doctype)
48
60
  "#{self.class.class_prefix(self.class)}:#{self.app_id}:#{self.doc_suffix(doctype)}"
@@ -4,12 +4,12 @@ module Rhoconnect
4
4
  attr_accessor :queue
5
5
  end
6
6
 
7
- def self.perform(job_type,source_id,app_id,user_id,client_id,params)
7
+ def self.perform(job_type,source_id,app_id,user_id,params)
8
8
  source = Source.load(source_id,{:app_id => app_id,:user_id => user_id})
9
9
  source_sync = SourceSync.new(source)
10
10
  case job_type.to_sym
11
11
  when :query then source_sync.do_query(params)
12
- when :cud then source_sync.do_cud(client_id)
12
+ when :cud then source_sync.do_cud
13
13
  end
14
14
  end
15
15
  end