MONTREAL JUNE 30, JULY 1ST AND 2ND 2012Practical ERSyncDavid AspinallGlobal Village Consulting Inc.                       ...
Outline1 Sync Overview2 Integrating with WebObjects3 Integrating with iOS4 Development Plan                  2
Introduction•   Who am I    •   David Aspinall    •   Developer / Consultant for Global Village Consulting Inc.           ...
Why ERSync?•   Why not REST/SOAP/...•   Framework to simplify data distribution to mobile apps•   Contribute to the WOComm...
Objective-Sync           Sync ObjectiveThe goal is to make 2 disconnected sets of datamatch    .. as quickly as possible  ...
What is Sync               6
What is that cloud?DropboxiCloud           Miracles            7
We are Wonder-fulDesign Objectives•   Leverage our WO experience, products and services.•   Minimally impact our existing ...
What is ERSync         WO App                  ERRest        ?              ERSync                           9
Integrating with WebObjects•   Built on ERRest (routes, transport ...)•   EOObjectStoreCoordinator.ObjectsChangedInStoreNo...
The Easy Part    public class Application extends ERXApplication {	   public static void main(String[] argv) {	   	 ERXApp...
What did that do?•   ERXSyncHandler extends ERXRouteRequestHandler    •   creates REST routes    •   adds change notificati...
Sync Authenticator•   authenticates a user by username and password    •   does NOT implement authentication, it should ca...
Sync Authenticator    public interface ERXSyncAuthenticator{    public ERXSyncUser userForCredentials(String nme,String pw...
ERSync tracking               TokenERSyncEntity     •Must be able to reconstruct the EO                 •Cannot be a FK be...
ERSync tracking               StatusERSyncEntity     V - Virgin - never by sync’d    token        I - Inserted            ...
ERSync trackingERSyncEntity   UUID                • The Database agnostic, universally unique id    token       • Clients ...
Change Notification Process                                              ERSyncChangeValue   ERSyncChangeBooleanERSyncAuthR...
ERSync API SecurityERSyncClientDeveloper    ERSyncClientApplication   ERSyncAuthRef        disable                  disabl...
Integrating with iOS•   Very similar to the WO approach•   Built on GVC Open frameworks                               20
The Easy Part    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOpti...
What did that do?•   SyncEngine is the client version of ERXSyncHandler    •   adds change notification observer for main c...
iOS Model                SyncChangeset                     uuid                 updatedDate               SyncChangeValueS...
Client Process1. Registration2. Initial / Full / Slow Sync3. Delta / Fast Sync                                24
Client Process - Registration•   Links the client application and device to a   <registration>                            ...
Client Process - Registration                                                     <sync>•   server response provides      ...
Client Process - Sync                                         <sync>                                           <principalU...
Client Process - Sync                                       <sync>                                         <principalUUID>...
We are Wonder-fulDesign Objectives✓ Leverage our WO experience, products and services.✓ Minimally impact our existing code...
Development Plan - WO•   Add support for Additional Change Value Types    •   float, double, char .. scalar types    •   BL...
Development Plan - WO•   Add support for Additional Change Value Types•   Track the SyncEntity status per Principal    •  ...
Development Plan - WO•   Add support for Additional Change Value Types•   Track the Entity status per Principal•   Purge C...
Development Plan - WO•   Add support for Additional Change Value Types•   Track the Entity status per Principal•   Purge C...
Development Plan - WO• Add support for Additional Change Value Types• Track the Entity status per Principal• Purge Changes...
Development Plan - iOS•   Clean up the iOS ERSync framework    •   ARC and Block compatible    •   ERBranding    •   Sync ...
Development Plan - iOS•   Clean up the iOS ERSync framework•   ERSyncEngine    •   Does not need to process anything until...
Development Plan - iOS•   Clean up the iOS ERSync framework•   ERSyncEngine•   Multiple CoreData model migration    1. mer...
MONTREAL JUNE 30, JULY 1ST AND 2ND 2012Q&A                          38
Web Resources•   Source is currently available at:    https://github.com/davidAtGVC/RemoteSync•   The iOS projects have su...
The sync process overview           Start               No - Login              No                                        ...
Why is this important• Data != Files• Pass the TTC test              41
Upcoming SlideShare
Loading in...5
×

Practical ERSync

695

Published on

ERSync is a framework that syncs data between iOS devices and REST services built with Project Wonder.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
695
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Practical ERSync

  1. 1. MONTREAL JUNE 30, JULY 1ST AND 2ND 2012Practical ERSyncDavid AspinallGlobal Village Consulting Inc. 1
  2. 2. Outline1 Sync Overview2 Integrating with WebObjects3 Integrating with iOS4 Development Plan 2
  3. 3. Introduction• Who am I • David Aspinall • Developer / Consultant for Global Village Consulting Inc. 3
  4. 4. Why ERSync?• Why not REST/SOAP/...• Framework to simplify data distribution to mobile apps• Contribute to the WOCommunity• Leverage for my clients and projects 4
  5. 5. Objective-Sync Sync ObjectiveThe goal is to make 2 disconnected sets of datamatch .. as quickly as possible .. in a way the user expects 5
  6. 6. What is Sync 6
  7. 7. What is that cloud?DropboxiCloud Miracles 7
  8. 8. We are Wonder-fulDesign Objectives• Leverage our WO experience, products and services.• Minimally impact our existing code base. • No server database changes in existing business system. • No sprinkling of interfaces or special logic in current system• Simple client protocol and supporting library 8
  9. 9. What is ERSync WO App ERRest ? ERSync 9
  10. 10. Integrating with WebObjects• Built on ERRest (routes, transport ...)• EOObjectStoreCoordinator.ObjectsChangedInStoreNotification• No model changes required in existing system• ERSync database can be different schema, host or database• All relevant data changes must notify the sync engine • framework is linked in, turned on • distributed change notification (ERChangeNotificationJMS) 10
  11. 11. The Easy Part public class Application extends ERXApplication { public static void main(String[] argv) { ERXApplication.main(argv, Application.class); } public Application() { ERXApplication.log.info("Welcome to " + name() + " !"); /* ** put your initialization code in here ** */ ERXDatabaseContextMulticastingDelegate.addDefaultDelegate(new ERXEntityDependencyOrderingDelegate()); ERXSyncHandler syncHandler = new ERXSyncHandler(); syncHandler.setSyncAuthenticator(new SyncAuthenticationProvider()); ERXSyncHandler.register(syncHandler); }} 11
  12. 12. What did that do?• ERXSyncHandler extends ERXRouteRequestHandler • creates REST routes • adds change notification observer• Sync Authenticator • this is the gateway class between ERSync and your Application 12
  13. 13. Sync Authenticator• authenticates a user by username and password • does NOT implement authentication, it should call your logic• provides list of Sync’able Entity Names• provide all EOKeyGlobalID’s for a given user• basically CRUD processor 13
  14. 14. Sync Authenticator public interface ERXSyncAuthenticator{ public ERXSyncUser userForCredentials(String nme,String pwd, EOEditingContext ec); public NSArray<String> syncEntityNames(); public NSArray<EOKeyGlobalID> syncObjectsForEntityUser(String entityName, ERXSyncUser usr, EOEditingContext ec); public EOEnterpriseObject syncInsertObject(EOEditingContext editingContext, EOEntity eoEntity, NSDictionary dict, ERXSyncUser user); public void syncUpdateObject(EOEnterpriseObject eo, NSDictionary dict, ERXSyncUser user); public void syncDeleteObject(EOEnterpriseObject eo, ERXSyncUser user);} 14
  15. 15. ERSync tracking TokenERSyncEntity •Must be able to reconstruct the EO •Cannot be a FK because we need to track deletes token •Currently using status •EntityName:pk[-pk*] •Note:1000001 uuid •Planning to change it to URI •ersync://EntityName/pk[/pk*] updatedDate •ersync://Note/100001 •ersync://Compound/10001/4432 15
  16. 16. ERSync tracking StatusERSyncEntity V - Virgin - never by sync’d token I - Inserted U - Updated status D - Deleted uuid updatedDate 16
  17. 17. ERSync trackingERSyncEntity UUID • The Database agnostic, universally unique id token • Clients will ALWAYS provide a UUID status • usually the UUID assigned by the server • where the client inserts, it assigns the uuid UUID and leaves the token blank • Removes primary key distribution and updatedDate collision problems 17
  18. 18. Change Notification Process ERSyncChangeValue ERSyncChangeBooleanERSyncAuthRef ERSyncChangeset booleanValue attibuteName valueType ERSyncChangeInteger token uuid intValue uuid updatedDate name ERSyncChangeString booleanValue ERSyncChange .. M-M Float .. Double .. BLOB .. ERSyncEntity ERSyncChangeToOne token toOneValue status uuid M-M ERSyncChangeToMany updatedDate 18
  19. 19. ERSync API SecurityERSyncClientDeveloper ERSyncClientApplication ERSyncAuthRef disable disable token name name uuid uuid uuid name ERSyncPrincipalERSyncClientDevice deviceUUID disable principalUUID name lastSyncDate uuid 19
  20. 20. Integrating with iOS• Very similar to the WO approach• Built on GVC Open frameworks 20
  21. 21. The Easy Part - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{! [super application:application didFinishLaunchingWithOptions:launchOptions];! [self setEngine:[[SyncEngine alloc]! ! initWithEditingContext:[self managedObjectContext]]];! [[self engine] addSupportedEntity:[Note entityName]];! [[self engine] addSupportedEntity:[Category entityName]];! [self setPrincipal:[SyncPrincipal! ! ! pseudoSingletonInContext:[self managedObjectContext]]; return YES;} 21
  22. 22. What did that do?• SyncEngine is the client version of ERXSyncHandler • adds change notification observer for main context• SyncPrincipal • Core Data record to store configuration information. 22
  23. 23. iOS Model SyncChangeset uuid updatedDate SyncChangeValueSyncPrincipal attibuteName username valueType password value site ERSyncEntityprincipaluuid lastSync token toOneValue name status M-M toManyValue uuid updatedDate 23
  24. 24. Client Process1. Registration2. Initial / Full / Slow Sync3. Delta / Fast Sync 24
  25. 25. Client Process - Registration• Links the client application and device to a <registration> <appid> user on the server 5AC343C6-2C35-4BB0-9A00-CE2938A12260• must provide server assigned </appid> <deviceType> • application UUID 743E2D47-DDA4-4827-A164-0C61547CD4D5 </deviceType> • device Type UUID <deviceUUID>• provide client assigned and locally stored D9781163-2A97-4E90-B978-DE2B9F86A9D5 </deviceUUID> • device UUID <user>david</user> <password>tester</password> • user credentials </registration> 25
  26. 26. Client Process - Registration <sync>• server response provides <principalUUID> dce87db1-0e87-44b6-9680-19dcd672eadb • principal UUID </principalUUID> <lastSync type = "datetime"> • last Sync date (only if previously sync’d) 2012-06-30T10:25:10Z </lastSync> </sync> 26
  27. 27. Client Process - Sync <sync> <principalUUID> dce87db1-0e87-44b6-9680-19dcd672eadb </principalUUID>• Client initiates communication <lastSync>2012-06-30T09:39:11Z</lastSync> • sends principal UUID and last Sync <data> • data in the Insert / Update / Delete <Note id="EA3E9977-8B58-40FE-85CF-4E4027723DF8" status="update"> order <subject>My new subject</subject> <category> <Category id="Category:1000000" /> </category> ... 27
  28. 28. Client Process - Sync <sync> <principalUUID>• dce87db1-0e87-44b6-9680-19dcd672eadb Server response </principalUUID> <lastSync>2012-06-30T09:55:11Z</lastSync> • echo principal UUID • provides new last Sync date <data> <Reminder id="EA3E9977-8B58-40FE-85CF-4E4027723DF8" • data in the Insert / Update / Delete status="update"> <name>Get Siri off my back</name> order <type> <ReminderType id="ReminderType:active"/> </type> ... 28
  29. 29. We are Wonder-fulDesign Objectives✓ Leverage our WO experience, products and services.✓ Minimally impact our existing code base. ✓ No server database changes in existing business system. ✓ No sprinkling of interfaces or special logic in current system✓ Simple client protocol and supporting library 29
  30. 30. Development Plan - WO• Add support for Additional Change Value Types • float, double, char .. scalar types • BLOB, CLOB, LOB .. SLOBs 30
  31. 31. Development Plan - WO• Add support for Additional Change Value Types• Track the SyncEntity status per Principal • a principal represents a client/device combo • entity status can be different on each device 31
  32. 32. Development Plan - WO• Add support for Additional Change Value Types• Track the Entity status per Principal• Purge Changesets once all Principals have sync’d • if all the registered client/devices have the change then it is not needed • new registrations will be ‘Virgin’ and require the current record anyway. (ERSync is not a History engine) 32
  33. 33. Development Plan - WO• Add support for Additional Change Value Types• Track the Entity status per Principal• Purge Changesets once all Principals have sync’d• Make SyncEntity a composite of several EOEntity types • Related but De-normalized data • virtual entity for non-relational data (images/thumbnails) 33
  34. 34. Development Plan - WO• Add support for Additional Change Value Types• Track the Entity status per Principal• Purge Changesets once all Principals have sync’d• Make SyncEntity a composite of several EOEntity types• Allow the client to sync a subset of data • date range (example bank transactions in 30 day window) • data group (example Toronto address book as a window into a larger address book) 34
  35. 35. Development Plan - iOS• Clean up the iOS ERSync framework • ARC and Block compatible • ERBranding • Sync related UI components? 35
  36. 36. Development Plan - iOS• Clean up the iOS ERSync framework• ERSyncEngine • Does not need to process anything until registration • Manage operations automatically • detect errors/resets from server and perform full sync cycle 36
  37. 37. Development Plan - iOS• Clean up the iOS ERSync framework• ERSyncEngine• Multiple CoreData model migration 1. merged models cannot be migrated automatically 2. Individual Stores cannot be migrated automatically 37
  38. 38. MONTREAL JUNE 30, JULY 1ST AND 2ND 2012Q&A 38
  39. 39. Web Resources• Source is currently available at: https://github.com/davidAtGVC/RemoteSync• The iOS projects have submodule references for the GVC Open kits: https://github.com/davidAtGVC/GVCFoundation https://github.com/davidAtGVC/GVCUIKit https://github.com/davidAtGVC/GVCCoreData 39
  40. 40. The sync process overview Start No - Login No Should Should Session Push Pull 1 Yes Negotiate 2 Yes 3 Yes No Push Pull Mode StopSource: Apple Sync Services Programming Guide 40
  41. 41. Why is this important• Data != Files• Pass the TTC test 41
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×