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/net-plugin.txt CHANGED
@@ -3,7 +3,7 @@ rhoconnect.NET
3
3
 
4
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/rhoconnect/).
6
+ Using rhoconnect.NET, your [ASP.NET MVC](http://www.asp.net/mvc/mvc4) 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
 
@@ -14,17 +14,20 @@ Copy the [`rhoconnect.NET`](https://github.com/rhomobile/rhoconnect.NET) github
14
14
  By default, the `rhoconnect.NET` repository contains the pre-built `RhoconnectNET.dll` library in the `bin/Release` subdirectory.
15
15
  However, you can build your own library using the provided Microsoft Visual Studio .NET solution file and the source code files.
16
16
 
17
- In order to use `Rhoconnect.NET` functionality in your `ASP.NET MVC 3` application, first you need to include the `Rhoconnect.NET` library
17
+ You can download and use the sample [`ASP.NET MVC4`](https://github.com/rhomobile/RhoconnectNET_MVC4_App) application to repeat the steps described below.
18
+
19
+ In order to use `Rhoconnect.NET` functionality in your `ASP.NET MVC` application, first you need to include the `Rhoconnect.NET` library
18
20
  as a dependency to your application. Click `Project => Add Reference` menu item in the Visual Studio and navigate to the `RhoconnectNET.dll` library.
19
21
  After this step is completed, you can add references to the `Rhoconnect.NET` namespace into the application's and Controller's files:
20
22
 
21
23
  using RhoconnectNET;
22
24
  using RhoconnectNET.Controllers;
25
+
23
26
 
24
27
 
25
28
  ## Registering Rhoconnect.NET routes for your application
26
29
 
27
- To establish the communication channel between ASP.NET MVC 3 application and Rhoconnect server,
30
+ To establish the communication channel between ASP.NET MVC application and Rhoconnect server,
28
31
  you need to implement the following `init_rhoconnect` and `rhoconnect_authenticate` methods in the `Global.asax.cs` file
29
32
  and call them from the `Application_Start` method:
30
33
 
@@ -40,8 +43,8 @@ and call them from the `Application_Start` method:
40
43
 
41
44
  // implement init_rhoconnect() method to establish
42
45
  // communication link between `Rhoconnect` server
43
- // and ASP.NET MVC 3 application
44
- const bool init_rhoconnect()
46
+ // and ASP.NET MVC application
47
+ private void init_rhoconnect()
45
48
  {
46
49
  // this call allows parsing JSON structures into Objects
47
50
  ValueProviderFactories.Factories.Add(new JsonValueProviderFactory());
@@ -55,14 +58,14 @@ and call them from the `Application_Start` method:
55
58
  rhoconnect_authenticate);
56
59
  }
57
60
 
58
- const bool rhoconnect_authenticate(String username, String password, Hashtable params)
61
+ private bool rhoconnect_authenticate(String username, String password, Hashtable auth_attrs)
59
62
  {
60
63
  // perform your authentication here
61
64
  return true;
62
65
  }
63
66
 
64
67
  `RhoconnectNET.Client.set_app_point` method is a main point
65
- in establishing the communication link between `Rhoconnect` server and the ASP.NET MVC 3 application
68
+ in establishing the communication link between `Rhoconnect` server and the ASP.NET MVC application
66
69
  and it has the following parameters:
67
70
 
68
71
  <table border="1">
@@ -104,7 +107,7 @@ invokes to perform CRUD operations on the data for the dataset you want to synch
104
107
  Each of the routes is mapped to a corresponding `rhoconnect_<operation>` method in the **IRhoconnectCRUD** interface
105
108
  which you must implement in the dataset's Controller class.
106
109
 
107
- public class MyDataController : Controller, IRhoconnectCRUD
110
+ public class ContactController : Controller, IRhoconnectCRUD
108
111
  {
109
112
  ... implementation of Controller routes
110
113
 
@@ -120,14 +123,14 @@ which you must implement in the dataset's Controller class.
120
123
  The route `/rhoconnect/query` is mapped to the `rhoconnect_query_objects` method of the **IRhoconnectCRUD**
121
124
  interface that you must implement in the corresponding dataset's Controller class. It must
122
125
  return a collection of source objects in the form of a JsonResult:
123
-
124
- JsonResult rhoconnect_query_objects(String partition)
126
+
127
+ public JsonResult rhoconnect_query_objects(String partition)
125
128
  {
126
- return Json(db.Products.ToDictionary("id"));
129
+ return Json(db.Contacts.ToDictionary(c => c.ID.ToString()));
127
130
  }
128
131
 
129
- In the above example, the Products object set is converted to `Dictionary<String, Object>`
130
- where the dictionary's key must correspond to an unique object's `id` field.
132
+ In the above example, the Contacts Db set is converted to `Dictionary<String, Object>`
133
+ where the dictionary's key must correspond to an unique object's `ID` field.
131
134
  After dictionary is created , it is converted to JsonResult and sent to the Rhoconnect server.
132
135
 
133
136
  ## Create new objects
@@ -137,10 +140,10 @@ return a newly created object's id in case of success:
137
140
 
138
141
  public ActionResult rhoconnect_create(String objJson, String partition)
139
142
  {
140
- Product new_product = (Product)RhoconnectNET.Helpers.deserialize_json(objJson, typeof(Product));
141
- db.Products.AddObject(new_product);
143
+ Contact new_contact = (Contact)RhoconnectNET.Helpers.deserialize_json(objJson, typeof(Contact));
144
+ db.Contacts.Add(new_contact);
142
145
  db.SaveChanges();
143
- return RhoconnectNET.Helpers.serialize_result(new_product.id);
146
+ return RhoconnectNET.Helpers.serialize_result(new_contact.ID);
144
147
  }
145
148
 
146
149
  ## Update existing objects
@@ -150,13 +153,13 @@ return an updated object's id in case of success:
150
153
 
151
154
  public ActionResult rhoconnect_update(Dictionary<string, object> changes, String partition)
152
155
  {
153
- String obj_id = changes["id"]);
154
- Product product_to_update = db.Products.First(p => p.id == obj_id);
155
- // this method will update only the modified fields
156
- RhoconnectNET.Helpers.merge_changes(product_to_update, changes);
157
- db.ObjectStateManager.ChangeObjectState(product_to_update, EntityState.Modified);
156
+ int obj_id = Convert.ToInt32(changes["id"]);
157
+ Contact contact_to_update = db.Contacts.First(c => c.ID == obj_id);
158
+ // this method will update only the modified fields
159
+ RhoconnectNET.Helpers.merge_changes(contact_to_update, changes);
160
+ db.Entry(contact_to_update).State = EntityState.Modified;
158
161
  db.SaveChanges();
159
- return RhoconnectNET.Helpers.serialize_result(obj_id);
162
+ return RhoconnectNET.Helpers.serialize_result(contact_to_update.ID);
160
163
  }
161
164
 
162
165
  ## Delete objects from the dataset
@@ -166,21 +169,21 @@ return a deleted object's id in case of success:
166
169
 
167
170
  public ActionResult rhoconnect_delete(Object objId, String partition)
168
171
  {
169
- String key = objId.ToString();
172
+ int key = Convert.ToInt32(objId);
170
173
 
171
- Product product_to_delete = db.Products.Single(p => p.id == key);
172
- db.Products.DeleteObject(product_to_delete);
174
+ Contact contact = db.Contacts.Find(key);
175
+ db.Contacts.Remove(contact);
173
176
  db.SaveChanges();
174
- return RhoconnectNET.Helpers.serialize_result(objId);
177
+ return RhoconnectNET.Helpers.serialize_result(key);
175
178
  }
176
179
 
177
180
  ## Partitioning Datasets
178
181
  Each of the above methods have a partition key supplied with the CRUD request. This partition key is used by `Rhoconnect` 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` supports two types of partitions:
179
182
 
180
- * :app - No unique key will be used, a shared dataset is synchronized for all users.
181
- * lambda { some lambda } - Execute a lambda which returns the unique key string.
183
+ * app - No unique key will be used, a shared dataset is synchronized for all users.
184
+ * String partition key - unique key string identifying the partition (typically, user name).
182
185
 
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.
186
+ For example, the `Contact` model above might have a relationship to the User model. This provides us a simple way to organize the `Contact` dataset for rhoconnect by reusing this relationship.
184
187
  In this case, your implementation might filter out data on a per user basis.
185
188
 
186
189
  For more information about Rhoconnect partitions, please refer to the [Rhoconnect docs](http://docs.rhomobile.com/rhoconnect/source-adapters#data-partitioning).
@@ -191,81 +194,111 @@ However, to complete the implementation, it is necessary to implement a reverse
191
194
  Typically, your MVC Controller class reacts to the actions by implementing the CRUD POST routes, for example:
192
195
 
193
196
  [HttpPost]
194
- public ActionResult Create(Product new_product)
197
+ public ActionResult Create(Contact new_contact)
195
198
  {
196
199
  if (ModelState.IsValid)
197
200
  {
198
- db.Product.AddObject(new_product);
201
+ db.Contacts.Add(new_contact);
199
202
  db.SaveChanges();
200
203
  return RedirectToAction("Index");
201
204
  }
202
205
 
203
- return View(new_product);
206
+ return View(new_contact);
204
207
  }
205
208
 
206
209
  Here, you need to insert a call which will notify the Rhoconnect instance that a new object has been created.
207
210
  For this reason, `RhoconnectNET` library provides three callback routines for CUD notifications.
208
211
  The above example will look like this after inserting the corresponding callback routine:
209
212
 
213
+ // This method is used to access current partition
214
+ // in Rhoconnect notification callbacks
215
+ private String partition()
216
+ {
217
+ return "testuser";
218
+ }
219
+
210
220
  [HttpPost]
211
- public ActionResult Create(Product product)
212
- {
213
- if (ModelState.IsValid)
214
- {
215
- db.Product.AddObject(product);
221
+ public ActionResult Create(Contact contact)
222
+ {
223
+ if (ModelState.IsValid)
224
+ {
225
+ db.Contacts.Add(contact);
216
226
  db.SaveChanges();
217
227
 
218
- // insert these lines to provide
219
- // notifications to Rhoconnect server
220
- Hashtable reqHash = new Hashtable();
221
- reqHash.Add(new_product.id.ToString(), new_products);
222
- RhoconnectNET.Client.notify_on_create("Product", "partition_string", reqHash);
228
+ // insert these lines to provide
229
+ // notifications to Rhoconnect server
230
+ RhoconnectNET.Client.notify_on_create(partition(), contact);
223
231
 
224
232
  return RedirectToAction("Index");
225
- }
233
+ }
226
234
 
227
- return View(new_product);
235
+ return View(contact);
228
236
  }
229
237
 
230
238
  In the example above, user need to call `RhoconnectNET.Client.notify_on_create` method
231
239
  with the following parameters:
232
240
 
233
- - String rhoconnect_source_name : dataset's name
234
- - String rhoconnect_partition : partition to which the object belongs (see above section "Partitioning datasets")
235
- - Hashtable<String, Object> object_hash : Hashtable with object's id as a key and the object itself as a value
241
+ <table border="1">
242
+ <tr>
243
+ <td>String</td>
244
+ <td><code>partition</code></td>
245
+ <td>partition to which the object belongs (see above section "Partitioning datasets")
246
+ In the above example, the partition string is returned from the partition() method</td>
247
+ </tr>
248
+ <tr>
249
+ <td>Object</td>
250
+ <td><code>new_object</code></td>
251
+ <td>newly inserted object, which will be passed to Rhoconnect in a Json form</td>
252
+ </tr>
253
+ </table>
254
+
255
+ NOTE: The above notification callback has several overloads. In its simplest form,
256
+ `notify_on_create` callback will obtain information about the source name from the `Contact` object
257
+ class name (since it is equal) and will get the `id` field from the object itself. If your model
258
+ stores `id` field under the custom name, then, you can use the following override to pass its name into
259
+ the callback, where its value will be accessed through the Reflection mechanism:
260
+
261
+ // insert these lines to provide
262
+ // notifications to Rhoconnect server
263
+ RhoconnectNET.Client.notify_on_create(partition(), "MyContactCustomID", contact);
264
+
265
+ In addition to that, if your model's class is not equal to the Rhoconnect's Source Adapter name, you can
266
+ use the following override to pass it along:
267
+
268
+ // insert these lines to provide
269
+ // notifications to Rhoconnect server
270
+ RhoconnectNET.Client.notify_on_create("MyCustomContactSourceName", partition(), "MyContactCustomID", contact);
271
+
236
272
 
237
273
  In the same fashion , your dataset's Controller need to implement `Edit` and `Delete` callback notifications:
238
274
 
239
275
  [HttpPost]
240
- public ActionResult Edit(Product product)
276
+ public ActionResult Edit(Contact contact)
241
277
  {
242
278
  if (ModelState.IsValid)
243
279
  {
244
- db.Products.Attach(product);
245
- db.ObjectStateManager.ChangeObjectState(product, EntityState.Modified);
280
+ db.Entry(contact).State = EntityState.Modified;
246
281
  db.SaveChanges();
247
-
248
- // insert this callback to notify Rhoconnect
249
- // about the update operation
250
- Hashtable reqHash = new Hashtable();
251
- reqHash.Add(product.id.ToString(), product);
252
- RhoconnectNET.Client.notify_on_update("Product", "partition_string", reqHash);
282
+
283
+ // insert this callback to notify Rhoconnect
284
+ // about the update operation
285
+ RhoconnectNET.Client.notify_on_update(partition(), contact);
253
286
 
254
287
  return RedirectToAction("Index");
255
288
  }
256
- return View(product);
289
+ return View(contact);
257
290
  }
258
-
291
+
259
292
  [HttpPost, ActionName("Delete")]
260
- public ActionResult DeleteConfirmed(String id)
293
+ public ActionResult DeleteConfirmed(int id)
261
294
  {
262
- Product product = db.Products.Single(p => p.id == id);
263
- db.Products.DeleteObject(product);
295
+ Contact contact = db.Contacts.Find(id);
296
+ db.Contacts.Remove(contact);
264
297
  db.SaveChanges();
265
298
 
266
- // insert this callback to notify Rhoconnect
267
- // about the delete operation
268
- RhoconnectNET.Client.notify_on_delete("Product", rhoconnect_partition(), id);
299
+ // insert this callback to notify Rhoconnect
300
+ // about the delete operation
301
+ RhoconnectNET.Client.notify_on_delete("Contact", partition(), id);
269
302
 
270
303
  return RedirectToAction("Index");
271
304
  }
data/doc/plugin-intro.txt CHANGED
@@ -1,6 +1,8 @@
1
1
  RhoConnect Plugins Introduction
2
2
  ===
3
3
 
4
- Rhoconnect Plugins allow you to connect your backend apps seamlessly with rhoconnect.
4
+ Rhoconnect Plugins allow you to connect your backend apps seamlessly with rhoconnect. You can write the source (query, create, update and delete operations) into a backend application, and write a RhoConnect plugin in the language that matchs your backend application, such as Java or .NET.
5
5
 
6
- <img src='https://s3.amazonaws.com/rhodocs/rhoconnect-service/intro-plugin.png' alt='image' height='467' width='800' />
6
+ <img src='https://s3.amazonaws.com/rhodocs/rhoconnect-service/intro-plugin.png' alt='image' height='467' width='800' />
7
+
8
+ **NOTE:** Another way to connect particular backend applications (such as for Salesforce or Oracle) is to generate a [RhoConnect source adapter](/rhoconnect/source-adapters) which contains the query, create, update and delete operations.
@@ -0,0 +1,63 @@
1
+ # Preparing App for Production
2
+ By default your RhoConnect application generates a few files that you should be familiar with and understand the settings.
3
+
4
+ ## config.ru
5
+ This rackup file contains runtime configuration for the RhoConnect sinatra application:
6
+
7
+ :::ruby
8
+ Rhoconnect::Server.disable :run
9
+ Rhoconnect::Server.disable :clean_trace
10
+ Rhoconnect::Server.enable :raise_errors
11
+ Rhoconnect::Server.set :secret, '<changeme>'
12
+ Rhoconnect::Server.set :root, ROOT_PATH
13
+ Rhoconnect::Server.use Rack::Static, :urls => ["/data"], :root => Rhoconnect::Server.root
14
+
15
+ The important setting here `:secret` you will want to change. `:secret` should be set to a long random string, it ___should not___ be set to a dictionary word or short string (30 characters or more is sufficient). This is used for the session storage using a digest algorithm as described [here](http://guides.rubyonrails.org/security.html#session-storage).
16
+
17
+ If you don't change the `:secret` setting, RhoConnect automatically warns you each time the application starts:
18
+
19
+ [11:34:56 AM 2011-01-12] ************************************************************
20
+
21
+ [11:34:56 AM 2011-01-12] WARNING: Change the session secret in config.ru from <changeme> to something secure.
22
+ [11:34:56 AM 2011-01-12] i.e. running `rake rhoconnect:secret` in your app will generate a secret you could use.
23
+
24
+ [11:34:56 AM 2011-01-12] ************************************************************
25
+
26
+
27
+ As this warning states, a good way to generate a cryptographically secure secret is by running `rake rhoconnect:secret` in your RhoConnect application.
28
+
29
+ :::term
30
+ $ cd storemanager-server
31
+ $ rake rhoconnect:secret
32
+ 040a2355475e9d0fb591ef78d5b9ca61a34cbcfd3f11942b18bc1d91f1ca66c27b2e0386333843a7efa29f40fff03624cd908d0883364ffbfa3208ab23fa2664
33
+
34
+ Then plug this secret into your `config.ru`:
35
+
36
+ :::ruby
37
+ Rhoconnect::Server.set :secret, '040a2355475e9d0fb591ef78d5b9ca61a34cbcfd3f11942b18bc1d91f1ca66c27b2e0386333843a7efa29f40fff03624cd908d0883364ffbfa3208ab23fa2664'
38
+
39
+ To run RhoConnect in production mode, use `RACK_ENV` environment variable set to "production". This ensures RhoConnect will use the `:production` section of the settings. For example:
40
+
41
+ :::term
42
+ $ thin start -e production -p 9292
43
+
44
+ Will start thin in with `RACK_ENV` set to "production".
45
+
46
+ NOTE: If you deploy using passenger or on RhoHub, this variable is automatically set to production.
47
+
48
+ ## settings/settings.yml
49
+ This file contains all source adapter options and settings like the redis server connection. Before deploying to production, make sure you have the appropriate production settings:
50
+
51
+ :::yaml
52
+ :sources:
53
+ Product:
54
+ :poll_interval: 300
55
+
56
+ :production:
57
+ :redis: myredishost:6379
58
+ :licensefile: settings/license.key
59
+ :syncserver: http://localhost:9292/application/
60
+
61
+ ## settings/license.key
62
+ This contains your RhoConnect license key text. By default, a RhoConnect application comes with a 10 device license. Please see the [licensing page](/rhoconnect/licensing) for more details.
63
+
@@ -0,0 +1,252 @@
1
+ # Creating a RhoConnect Stack in Amazon Web Services
2
+
3
+ This tutorial will guide you through setting up a Redis stack and a RhoConnect application stack in the Amazon Web Service (AWS) cloud.
4
+
5
+ The RhoConnect application stack is scalable; it uses load balancing to automatically distribute and balance the incoming application traffic among all the instances you are running. You will set the maximum number of instances that the load balancer can create for your RhoConnect application.
6
+
7
+ ## Logging onto the Amazon Web Service
8
+
9
+ Go to the [Amazon Web Service (AWS) Console](http://aws.amazon.com/console/) and click on the Sign in to the AWS Console button. You can sign into an existing AWS account, or create a new one.
10
+
11
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/AWS-login-button.png" alt="AWS login button" />
12
+
13
+ Or you can open the URL for your account directly if you have the account number:
14
+
15
+ :::term
16
+ https://<your_account_number>.signin.aws.amazon.com/console
17
+
18
+ Enter your User Name and Password for your AWS account, then click the Sign in button.
19
+
20
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/aws-sign-in-account-number.png" alt="AWS login page" />
21
+
22
+ ## Creating a Custom RhoConnect Image
23
+
24
+ In the AWS Management Console, change the Region to US West (N. California).
25
+
26
+ **NOTE:** The stacks created in this document only work in the N. California region.
27
+
28
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/cloudformation-tab-ncalif-crop.png" alt="Cloud Formation page N California region" />
29
+
30
+ We provide a public preconfigured image that contains a blank RhoConnect app:
31
+
32
+ * `ami-65e4bb20` (Us West N. California)
33
+
34
+ ### Launching an Instance
35
+
36
+ To create your own RhoConnect Image, launch an EC2 Image:
37
+
38
+ Click the EC2 tab, click EC2 Dashboard, then click the Launch Instance button.
39
+
40
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/ec2-launch-instance.png" alt="Launch Instance button" />
41
+
42
+ Click the Launch Classic Wizard radio button. Click Continue.
43
+
44
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/create-new-instance-launch-classic-wizard.png" alt="create new instance classic wizard" />
45
+
46
+ ### Requesting the Instance
47
+
48
+ In the Choose an AMI section click the Community AMIs tab.
49
+ Then paste in the AMI `ami-65e4bb20`. When the preconfigured RhoConnect AMI appears, click Select.
50
+
51
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/request-instances-wizard-community-AMIs.png" alt="request instances - choose AMI" />
52
+
53
+ In the Instance Details section, select the Instance Type (such as Large).
54
+
55
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/request-instances-instance-details.png" alt="request instances - instance details" />
56
+
57
+ In the Instance Details section, Advanced Instance Options screen, change nothing. Click Continue.
58
+
59
+ In the Instance Details section, Add Tags screen, enter a name for your custom RhoConnect EC2 instance in the Value Column of the Name key, then click Continue.
60
+
61
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/request-instances-instance-details-add-tags.png" alt="request instances - add tags" />
62
+
63
+ In the Create Key Pair section, select your existing key pair or create a new keypair.
64
+
65
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/request-instances-key-pair.png" alt="request instances - key pair" />
66
+
67
+ ### Requesting the Instance - Configuring the Firewall
68
+
69
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/request-instances-configure-firewall.png" alt="request instances - configure firewall" />
70
+
71
+ In the Configure Firewall section, click the Create New Security Group radio button.
72
+
73
+ CLick the Add Rule button to add each port.
74
+
75
+ * Add port 22 for SSH.
76
+ * Add port 80 for HTTP.
77
+ * Add port 6379 for redis.
78
+
79
+ **NOTE:** You may use a preexisting security group if it has ports 22, 80, and 6379 open.
80
+
81
+ Enter a firewall name and a group description, then click Continue.
82
+
83
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/request-instances-review.png" alt="request instances - review" />
84
+
85
+ Make sure all the instance information is correct as shown on the Review page and then click Launch.
86
+
87
+ In the window titled "Launch Instance Wizard", click Close and wait for your instance to be Running.
88
+
89
+ ### Customizing the Instance
90
+
91
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/instances-instances.png" alt="instances - instances" />
92
+
93
+ In the EC2 tab, Click on Instances.
94
+
95
+ For Viewing, select Running Instances. Select your newly created RhoConnect instance and scroll down to see Private DNS in the lower section of the My Instances screen.
96
+
97
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/running-instances-public-dns.png" alt="running instances - public dns" />
98
+
99
+ You will need:
100
+
101
+ * your keypair (the .pem file AWS gives you when the keypair is created)
102
+ * the public DNS name of the Instance, which you will see as the public DNS name in the running instance. For Example: `ec2-184-72-16-39.us-west-1.compute.amazonaws.com`.
103
+ * the username: `ec2-user`
104
+
105
+ From the command line, use ssh to login to the running instance, using the keypair, DNS name, and user name. For example:
106
+
107
+ :::term
108
+ $ ssh -i ~/.ssh/devkey.pem ec2-user@ec2-50-18-229-26.us-west-1.compute.amazonaws.com
109
+
110
+ Replace the blank 'rhoapp' application in the /opt/nginx/html folder with your app, and set its owner as 'nginx' user.
111
+
112
+ :::term
113
+ $ cd /opt/nginx/html
114
+ # ... copy your application here under name 'rhoapp'
115
+ $ sudo chown -R nginx:nginx rhoapp
116
+
117
+ You can test the application.
118
+
119
+ :::term
120
+ $ sudo /etc/init.d/redis start
121
+ $ sudo /etc/init.d/nginx start
122
+
123
+ If everything is configured properly, then you can login to the RhoConnect web console in your browser by using the instance's public DNS name as the URL in your browser. When you are done, you can stop the application.
124
+
125
+ :::term
126
+ $ sudo /etc/init.d/nginx stop
127
+ $ sudo /etc/init.d/redis stop
128
+
129
+ ## Create the Image
130
+
131
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/running-instances-public-dns.png" alt="Create Image popup" />
132
+
133
+ In the EC2 tab, right-click the RhoConnect instance and select Create Image (EBS AMI).
134
+
135
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/create-image.png" alt="Create Image" />
136
+
137
+ In the Create Image window, enter the image name and description for your custom image. Then click Create This Image.
138
+
139
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/create-image-request.png" alt="Create Image request" />
140
+
141
+ In the Create Image window showing that the request is received, click on "View pending image: ami-XXXXXXXX to go to your Amazon Machine Image.
142
+
143
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/ami-image.png" alt="amazon machine image" />
144
+
145
+ Copy the AMI number; you will use it when you create the scaleable RhoConnect stack.
146
+
147
+ ## Creating the Scalable RhoConnect Stack
148
+
149
+ Click the Cloud Formation tab.
150
+
151
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/cloudformation-tab.png" alt="Cloud Formation page" />
152
+
153
+ Ensure that the Region selected is US West (N. California) and Click the Create New Stack button.
154
+
155
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/cloudformation-tab-new-stack-button.png" alt="Cloud Formation page new stack button" />
156
+
157
+ ### Create Stack - Select Template
158
+
159
+ In the Select Template section, you must select the template file for your redis stack. This is the template to run the AMI image with the Redis server.
160
+
161
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/create-stack-select-template.png" alt="Create Stack Select Template window" />
162
+
163
+ First, enter the name that you want for your stack into the Stack Name field.
164
+
165
+ Now get the template by either providing the URL for the template file, or by uploading the template file.
166
+
167
+ #### Providing the URL for the Template File
168
+
169
+ Click the Provide a Template URL radio button.
170
+
171
+ Copy the following URL and paste it into the text field below the Provide a Template URL radio button.
172
+
173
+ `https://s3-us-west-1.amazonaws.com/rhoconnect-ca-deploy/rhoconnect_template.txt`
174
+
175
+ #### Uploading the Template File
176
+
177
+ Click the Upload a Template File radio button.
178
+
179
+ In another browser window, go to [https://s3-us-west-1.amazonaws.com/rhoconnect-ca-deploy/rhoconnect_template.txt](https://s3-us-west-1.amazonaws.com/rhoconnect-ca-deploy/rhoconnect_template.txt).
180
+
181
+ Save that text file to your computer.
182
+
183
+ Click the Choose File button, and navigate to and select your template file.
184
+
185
+ Click Continue.
186
+
187
+ ### Create Stack - Specify Parameters
188
+
189
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/create-stack-specify-parameters.png" alt="Create Stack Specify Parameters window" />
190
+
191
+ In the Create Stack: Specify Parameters window:
192
+
193
+ * Enter the AMI image number that you saved earlier.
194
+ * Enter the maximum number of RhoConnect application servers that you want to run in your stack. Default = 2.
195
+ * Enter the name for your existing EC2 KeyPair to enable SSH access to the stack instances.
196
+
197
+ Click Continue.
198
+
199
+ ### Create Stack - Review
200
+
201
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/create-stack-review.png" alt="Create Stack Review window" />
202
+
203
+ Click Continue to see a window entitled \"Create Stack\" showing that the stack is being created.
204
+
205
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/create-stack-being-created.png" alt="Create Stack being created window" />
206
+
207
+ Click Close.
208
+
209
+ ## Checking the Status
210
+
211
+ In the AWS Management Console, Cloud Formation tab, click the checkbox for your stack. To see the progress of the creation of your stack, click the Refresh button; the status should become CREATE_COMPLETE soon.
212
+
213
+ To see the progress of the components in your stack, you can click the Events tab. You can click the refresh button to see the progress.
214
+
215
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/aws-management-create-complete.png" alt="AWS Management CREATE_COMPLETE window" />
216
+
217
+ ## Using the RhoConnect Application URL
218
+
219
+ In the AWS Management Console, Cloud Formation tab, click the Outputs tab. You will see a list of the Stack Outputs.
220
+
221
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/aws-management-outputs.png" alt="AWS Management Stack Outputs window" />
222
+
223
+ At the top of the output list is the URL of the RhoConnect application. You can click on it to see the RhoConnect Console for the running RhoConnect server.
224
+
225
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/rhoconnect-console.png" alt="RhoConnect Console" />
226
+
227
+ To use this scaleable RhoConnect server in your Rhodes application, copy the URL for the RhoConnect application into the rhoconfig.txt file in your Rhodes application as the syncserver variable. For example:
228
+
229
+ :::term
230
+ syncserver = http://rhoconnec-RhoLoadB-OX64XR1IKNT2-1364705573.us-west-1.elb.amazonaws.com
231
+
232
+ ## Deleting the Stack
233
+
234
+ You are charged for the stack that you have created, by the hour. When you no longer want to use the stack, you can delete it by right-clicking on the stack name in the AWS Management Console, Cloud Formation tab, and clicking Delete Stack.
235
+
236
+ <img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/delete-stack.png" alt="Delete Stack" />
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
@@ -1,7 +1,9 @@
1
1
  RhoConnect Source Adapters
2
2
  ===
3
3
 
4
- Connecting to a backend service with 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".
4
+ Connecting to a backend service with RhoConnect requires that you write a small amount of code for the query, create, update and delete operations of your particular enterprise backend. A RhoConnect source adapter is a collection of the Ruby code for these operations.
5
+
6
+ **NOTE:** You can also write this source code (the query, create, update and delete operations) into a backend application, and [write a RhoConnect plugin](plugin-intro) in the language that matchs your backend application, such as Java or .NET.
5
7
 
6
8
  ## Generate Source Adapter
7
9