SlideShare a Scribd company logo
Javier de Pedro López
SYNCHRONIZING DATA
FROM ARCHITECTURE TO IMPLEMENTATION
Architecture evolution
Architecture elements
Web services and performance
Thread manager
Job scheduler and family
When, what and how
Q&A
TABLE OF CONTENTS
ACT LOCALLY, SYNC GLOBALLY
All the requests are made from a thousand lines activity with async
tasks
1. ARCHITECTURE EVOLUTION
Multiple sources handled by a manager providing data
1. ARCHITECTURE EVOLUTION
Repository pattern with chain of responsability: from MVP
1. ARCHITECTURE EVOLUTION
WHAT ABOUT THE...
Sync engine with event hub noti cations in repository
1. ARCHITECTURE EVOLUTION
Can contain a memory cache
Plain object
Easy to handle
Easy to inject
Easy to test
Hard threading
Dependent from other layer
Service
Easy to handle
Hard to inject
Hard to test
Easy threading
Independent from other
layer
2. ARCHITECTURE ELEMENTS: REPOSITORY
The only source of truth
Plain object
Easy to handle
Easy to inject
Easy to test
Hard threading
Dependent from other layer
Content provider
Hard to handle
Hard to inject
Hard to test
Easy threading
Independent from other
layer
2. ARCHITECTURE ELEMENTS: DATABASE REPOSITORY
With reference to the network client
Plain object
Easy to handle
Easy to inject
Easy to test
Hard threading
Dependent from other layer
2. ARCHITECTURE ELEMENTS: NETWORK REPOSITORY
Make it from Android
Plain object
Easy to handle
Easy to inject
Easy to test
Hard threading
Dependent from
other layer
Service
Hard to handle
Hard to inject
Hard to test
Easy threading
Independent
from other layer
Make it intelligent
Sync adapter
Job scheduler (or
similar)
2. ARCHITECTURE ELEMENTS: SYNC ENGINE
Read fresh
2. ARCHITECTURE ELEMENTS: LIFECYCLE
Read cached
2. ARCHITECTURE ELEMENTS: LIFECYCLE
Write
2. ARCHITECTURE ELEMENTS: LIFECYCLE
The backend have to be prepared to make the sync more smooth
{
"syncTimestamp": 1467361858958,
"created": [
{
"name": "Instance 1057",
"module": "571f38b9bb7f372900a14cbc",
"createdAt": 1464000087974,
"updatedAt": null,
"deletedAt": null,
"id": "5742de576ec1322f00d796c5"
}
],
"updated": [],
"deleted": []
}
Not json patch, just timestamp!
3. WEB SERVICES AND PERFORMANCE: BACKEND
How to dispatch in Backend
Without timestamp cache
With timestamp bring only the changes
Prepare to receive a bunch of very small requests
3. WEB SERVICES AND PERFORMANCE: BACKEND
How to request in Android
First request send without timestamp and with cache ag
Inmediatly make a request with the timestamp from server to
now
Request every 'n' time or when the user needs to (internet
connection handing)
Use a cursor to display it and not ll your memory
3. WEB SERVICES AND PERFORMANCE: FRONTEND
Depending on the device, database used and network
Fetch, save and display takes...
3. WEB SERVICES AND PERFORMANCE: TIMING
1500 INSTANCES / SEC
4. THREAD MANAGER
Handle all your threading in the same class
If you are not a hipster that uses RxJava
4. THREAD MANAGER
39. case SAME_THREAD_POLICY:
40. future = new FutureTask<>(runnable,
null);
41. runnable.run();
42. break;
32. switch (thread) {
33. case POOL_QUEUE_POLICY:
34. future = mPoolQueue.submit(runnable);
35. break;
36. case SINGLE_QUEUE_POLICY:
37. future =
mSingleQueue.submit(runnable);
38. break;
43. default:
44. throw new
HaloConfigurationException("Unsupported option or
an Action operation");
45. }
46. return future;
47. }
48. }
JobScheduler jobScheduler = (JobScheduler) getApplicationContext().getSystemService(JOB_SCHEDULER_SERVICE);
ComponentName componentName = new ComponentName(getApplicationContext(), TestService.class);
JobInfo jobInfo = new JobInfo.Builder(1, componentName)
.setOverrideDeadline(10)
.setRequiresCharging(true)
.build();
jobScheduler.schedule(jobInfo);
Only for 5.0+!!!
5. JOB SCHEDULER AND FAMILY
You can use GCMNetworkManager from google
or Trigger
5. JOB SCHEDULER AND FAMILY
Trigger sample
Job job = new Job(new Action() {
@Override
protected void act() {
//do something
}
}).withExtra(new Condition() {
@Override
public String[] getAction() {
return new String[]{YOUR_BROARCAST};
}
});
trigger.schedule(job);
5. JOB SCHEDULER AND FAMILY
Halo scheduler
HaloFramework framework = Halo.instance().framework();
framework.sync().schedule(Job.builder(new Schedule() {
@Override
protected void exec() {
enqueueOnReady(action);
}
})
.needsNetwork(Job.NETWORK_TYPE_ANY)
.thread(threading)
.tag("syncUser")
.build());
5. JOB SCHEDULER AND FAMILY
The big rule is: use every element depending on your needs and
the time you have for it
6. WHEN, WHAT AND HOW
Q & A
Android minutes: synchronization presentation

More Related Content

What's hot (20)

PPTX
Flux and React.js
sara stanford
 
PDF
Rails 4 & server sent events
Piotr Karbownik
 
PPTX
Mini-Training Owin Katana
Betclic Everest Group Tech Team
 
PPTX
The server side story: Parallel and Asynchronous programming in .NET - ITPro...
Panagiotis Kanavos
 
PPTX
Meet with Meteor
Tahmina Khatoon
 
PPT
Asynchronous Programming in C# - Part 1
Mindfire Solutions
 
PDF
YAPC::EU 2015 - Perl Conferences
ℕicolas ℝ.
 
PPTX
A SOA approximation on symfony
Joseluis Laso
 
PPS
Web Design World Flickr
royans
 
PPTX
SOA with PHP and Symfony
MichalSchroeder
 
PDF
SignalR
Troy Miles
 
PPTX
Meteor intro-2015
MeteorJS
 
PPS
Flickr Services
royans
 
PPTX
ASP.NET: Present and future
Hrvoje Hudoletnjak
 
PDF
Live Streaming & Server Sent Events
tkramar
 
PPTX
Introduction to Node.JS
Collaboration Technologies
 
PDF
Containerize!
Henryk Konsek
 
PPS
Filesystems
royans
 
PPTX
Websocket vs SSE - Paris.js - 24/06/15
streamdata.io
 
PPTX
MobConf - session on C# async-await on 18june2016 at Kochi
Praveen Nair
 
Flux and React.js
sara stanford
 
Rails 4 & server sent events
Piotr Karbownik
 
Mini-Training Owin Katana
Betclic Everest Group Tech Team
 
The server side story: Parallel and Asynchronous programming in .NET - ITPro...
Panagiotis Kanavos
 
Meet with Meteor
Tahmina Khatoon
 
Asynchronous Programming in C# - Part 1
Mindfire Solutions
 
YAPC::EU 2015 - Perl Conferences
ℕicolas ℝ.
 
A SOA approximation on symfony
Joseluis Laso
 
Web Design World Flickr
royans
 
SOA with PHP and Symfony
MichalSchroeder
 
SignalR
Troy Miles
 
Meteor intro-2015
MeteorJS
 
Flickr Services
royans
 
ASP.NET: Present and future
Hrvoje Hudoletnjak
 
Live Streaming & Server Sent Events
tkramar
 
Introduction to Node.JS
Collaboration Technologies
 
Containerize!
Henryk Konsek
 
Filesystems
royans
 
Websocket vs SSE - Paris.js - 24/06/15
streamdata.io
 
MobConf - session on C# async-await on 18june2016 at Kochi
Praveen Nair
 

Similar to Android minutes: synchronization presentation (20)

PPTX
Microservices: Architecture and Practice
Iron.io
 
PDF
iOS advanced architecture workshop 3h edition
Jorge Ortiz
 
PDF
Clean architecture workshop
Jorge Ortiz
 
PDF
Cloud Powered Artificial Intelligence Evolution
Mohamed Belhassen
 
PPTX
Mihai tataran developing modern web applications
ITCamp
 
PDF
Ajax & Reverse Ajax Presenation
Rishabh Garg
 
PPTX
Best practices of building data streaming API
Constantine Slisenka
 
PPTX
DEVNET-1166 Open SDN Controller APIs
Cisco DevNet
 
PDF
Effective Persistence Using ORM With Hibernate
Edureka!
 
PPTX
Transform Any Website into a Conversational Experience with NLWeb
Udaiappa Ramachandran
 
PDF
Streaming to a new Jakarta EE
Markus Eisele
 
PDF
Streaming to a New Jakarta EE
J On The Beach
 
PPT
LarKC Tutorial at ISWC 2009 - Introduction
LarKC
 
PPTX
App fabric introduction
Dennis van der Stelt
 
PDF
Day in the life event-driven workshop
Christina Lin
 
PPT
Web-Socket
Pankaj Kumar Sharma
 
RTF
Synopsis on online shopping by sudeep singh
Sudeep Singh
 
PDF
IBM Think Session 8598 Domino and JavaScript Development MasterClass
Paul Withers
 
PDF
CMPE282_009994036_PROJECT_REPORT
Sandyarathi Das
 
PPTX
Plone FSR
fulv
 
Microservices: Architecture and Practice
Iron.io
 
iOS advanced architecture workshop 3h edition
Jorge Ortiz
 
Clean architecture workshop
Jorge Ortiz
 
Cloud Powered Artificial Intelligence Evolution
Mohamed Belhassen
 
Mihai tataran developing modern web applications
ITCamp
 
Ajax & Reverse Ajax Presenation
Rishabh Garg
 
Best practices of building data streaming API
Constantine Slisenka
 
DEVNET-1166 Open SDN Controller APIs
Cisco DevNet
 
Effective Persistence Using ORM With Hibernate
Edureka!
 
Transform Any Website into a Conversational Experience with NLWeb
Udaiappa Ramachandran
 
Streaming to a new Jakarta EE
Markus Eisele
 
Streaming to a New Jakarta EE
J On The Beach
 
LarKC Tutorial at ISWC 2009 - Introduction
LarKC
 
App fabric introduction
Dennis van der Stelt
 
Day in the life event-driven workshop
Christina Lin
 
Synopsis on online shopping by sudeep singh
Sudeep Singh
 
IBM Think Session 8598 Domino and JavaScript Development MasterClass
Paul Withers
 
CMPE282_009994036_PROJECT_REPORT
Sandyarathi Das
 
Plone FSR
fulv
 
Ad

Recently uploaded (20)

PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PPTX
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Ad

Android minutes: synchronization presentation

  • 1. Javier de Pedro López SYNCHRONIZING DATA FROM ARCHITECTURE TO IMPLEMENTATION
  • 2. Architecture evolution Architecture elements Web services and performance Thread manager Job scheduler and family When, what and how Q&A TABLE OF CONTENTS
  • 3. ACT LOCALLY, SYNC GLOBALLY
  • 4. All the requests are made from a thousand lines activity with async tasks 1. ARCHITECTURE EVOLUTION
  • 5. Multiple sources handled by a manager providing data 1. ARCHITECTURE EVOLUTION
  • 6. Repository pattern with chain of responsability: from MVP 1. ARCHITECTURE EVOLUTION
  • 8. Sync engine with event hub noti cations in repository 1. ARCHITECTURE EVOLUTION
  • 9. Can contain a memory cache Plain object Easy to handle Easy to inject Easy to test Hard threading Dependent from other layer Service Easy to handle Hard to inject Hard to test Easy threading Independent from other layer 2. ARCHITECTURE ELEMENTS: REPOSITORY
  • 10. The only source of truth Plain object Easy to handle Easy to inject Easy to test Hard threading Dependent from other layer Content provider Hard to handle Hard to inject Hard to test Easy threading Independent from other layer 2. ARCHITECTURE ELEMENTS: DATABASE REPOSITORY
  • 11. With reference to the network client Plain object Easy to handle Easy to inject Easy to test Hard threading Dependent from other layer 2. ARCHITECTURE ELEMENTS: NETWORK REPOSITORY
  • 12. Make it from Android Plain object Easy to handle Easy to inject Easy to test Hard threading Dependent from other layer Service Hard to handle Hard to inject Hard to test Easy threading Independent from other layer Make it intelligent Sync adapter Job scheduler (or similar) 2. ARCHITECTURE ELEMENTS: SYNC ENGINE
  • 13. Read fresh 2. ARCHITECTURE ELEMENTS: LIFECYCLE
  • 14. Read cached 2. ARCHITECTURE ELEMENTS: LIFECYCLE
  • 16. The backend have to be prepared to make the sync more smooth { "syncTimestamp": 1467361858958, "created": [ { "name": "Instance 1057", "module": "571f38b9bb7f372900a14cbc", "createdAt": 1464000087974, "updatedAt": null, "deletedAt": null, "id": "5742de576ec1322f00d796c5" } ], "updated": [], "deleted": [] } Not json patch, just timestamp! 3. WEB SERVICES AND PERFORMANCE: BACKEND
  • 17. How to dispatch in Backend Without timestamp cache With timestamp bring only the changes Prepare to receive a bunch of very small requests 3. WEB SERVICES AND PERFORMANCE: BACKEND
  • 18. How to request in Android First request send without timestamp and with cache ag Inmediatly make a request with the timestamp from server to now Request every 'n' time or when the user needs to (internet connection handing) Use a cursor to display it and not ll your memory 3. WEB SERVICES AND PERFORMANCE: FRONTEND
  • 19. Depending on the device, database used and network Fetch, save and display takes... 3. WEB SERVICES AND PERFORMANCE: TIMING 1500 INSTANCES / SEC
  • 21. Handle all your threading in the same class If you are not a hipster that uses RxJava 4. THREAD MANAGER
  • 22. 39. case SAME_THREAD_POLICY: 40. future = new FutureTask<>(runnable, null); 41. runnable.run(); 42. break; 32. switch (thread) { 33. case POOL_QUEUE_POLICY: 34. future = mPoolQueue.submit(runnable); 35. break; 36. case SINGLE_QUEUE_POLICY: 37. future = mSingleQueue.submit(runnable); 38. break; 43. default: 44. throw new HaloConfigurationException("Unsupported option or an Action operation"); 45. } 46. return future; 47. } 48. }
  • 23. JobScheduler jobScheduler = (JobScheduler) getApplicationContext().getSystemService(JOB_SCHEDULER_SERVICE); ComponentName componentName = new ComponentName(getApplicationContext(), TestService.class); JobInfo jobInfo = new JobInfo.Builder(1, componentName) .setOverrideDeadline(10) .setRequiresCharging(true) .build(); jobScheduler.schedule(jobInfo); Only for 5.0+!!! 5. JOB SCHEDULER AND FAMILY
  • 24. You can use GCMNetworkManager from google or Trigger 5. JOB SCHEDULER AND FAMILY
  • 25. Trigger sample Job job = new Job(new Action() { @Override protected void act() { //do something } }).withExtra(new Condition() { @Override public String[] getAction() { return new String[]{YOUR_BROARCAST}; } }); trigger.schedule(job); 5. JOB SCHEDULER AND FAMILY
  • 26. Halo scheduler HaloFramework framework = Halo.instance().framework(); framework.sync().schedule(Job.builder(new Schedule() { @Override protected void exec() { enqueueOnReady(action); } }) .needsNetwork(Job.NETWORK_TYPE_ANY) .thread(threading) .tag("syncUser") .build()); 5. JOB SCHEDULER AND FAMILY
  • 27. The big rule is: use every element depending on your needs and the time you have for it 6. WHEN, WHAT AND HOW
  • 28. Q & A