SlideShare a Scribd company logo
1 of 29
Download to read offline
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

Rails 4 & server sent events
Rails 4 & server sent eventsRails 4 & server sent events
Rails 4 & server sent eventsPiotr Karbownik
 
The server side story: Parallel and Asynchronous programming in .NET - ITPro...
The server side story:  Parallel and Asynchronous programming in .NET - ITPro...The server side story:  Parallel and Asynchronous programming in .NET - ITPro...
The server side story: Parallel and Asynchronous programming in .NET - ITPro...Panagiotis Kanavos
 
Asynchronous Programming in C# - Part 1
Asynchronous Programming in C# - Part 1Asynchronous Programming in C# - Part 1
Asynchronous Programming in C# - Part 1Mindfire Solutions
 
YAPC::EU 2015 - Perl Conferences
YAPC::EU 2015 - Perl ConferencesYAPC::EU 2015 - Perl Conferences
YAPC::EU 2015 - Perl Conferencesℕicolas ℝ.
 
A SOA approximation on symfony
A SOA approximation on symfonyA SOA approximation on symfony
A SOA approximation on symfonyJoseluis Laso
 
Web Design World Flickr
Web Design World FlickrWeb Design World Flickr
Web Design World Flickrroyans
 
SOA with PHP and Symfony
SOA with PHP and SymfonySOA with PHP and Symfony
SOA with PHP and SymfonyMichalSchroeder
 
Meteor intro-2015
Meteor intro-2015Meteor intro-2015
Meteor intro-2015MeteorJS
 
Flickr Services
Flickr ServicesFlickr Services
Flickr Servicesroyans
 
Live Streaming & Server Sent Events
Live Streaming & Server Sent EventsLive Streaming & Server Sent Events
Live Streaming & Server Sent Eventstkramar
 
Filesystems
FilesystemsFilesystems
Filesystemsroyans
 
Websocket vs SSE - Paris.js - 24/06/15
Websocket vs SSE - Paris.js - 24/06/15Websocket vs SSE - Paris.js - 24/06/15
Websocket vs SSE - Paris.js - 24/06/15streamdata.io
 
MobConf - session on C# async-await on 18june2016 at Kochi
MobConf - session on C# async-await on 18june2016 at KochiMobConf - session on C# async-await on 18june2016 at Kochi
MobConf - session on C# async-await on 18june2016 at KochiPraveen Nair
 

What's hot (20)

Flux and React.js
Flux and React.jsFlux and React.js
Flux and React.js
 
Rails 4 & server sent events
Rails 4 & server sent eventsRails 4 & server sent events
Rails 4 & server sent events
 
Mini-Training Owin Katana
Mini-Training Owin KatanaMini-Training Owin Katana
Mini-Training Owin Katana
 
The server side story: Parallel and Asynchronous programming in .NET - ITPro...
The server side story:  Parallel and Asynchronous programming in .NET - ITPro...The server side story:  Parallel and Asynchronous programming in .NET - ITPro...
The server side story: Parallel and Asynchronous programming in .NET - ITPro...
 
Meet with Meteor
Meet with MeteorMeet with Meteor
Meet with Meteor
 
Asynchronous Programming in C# - Part 1
Asynchronous Programming in C# - Part 1Asynchronous Programming in C# - Part 1
Asynchronous Programming in C# - Part 1
 
YAPC::EU 2015 - Perl Conferences
YAPC::EU 2015 - Perl ConferencesYAPC::EU 2015 - Perl Conferences
YAPC::EU 2015 - Perl Conferences
 
A SOA approximation on symfony
A SOA approximation on symfonyA SOA approximation on symfony
A SOA approximation on symfony
 
Web Design World Flickr
Web Design World FlickrWeb Design World Flickr
Web Design World Flickr
 
SOA with PHP and Symfony
SOA with PHP and SymfonySOA with PHP and Symfony
SOA with PHP and Symfony
 
SignalR
SignalRSignalR
SignalR
 
Meteor intro-2015
Meteor intro-2015Meteor intro-2015
Meteor intro-2015
 
Flickr Services
Flickr ServicesFlickr Services
Flickr Services
 
ASP.NET: Present and future
ASP.NET: Present and futureASP.NET: Present and future
ASP.NET: Present and future
 
Live Streaming & Server Sent Events
Live Streaming & Server Sent EventsLive Streaming & Server Sent Events
Live Streaming & Server Sent Events
 
Introduction to Node.JS
Introduction to Node.JSIntroduction to Node.JS
Introduction to Node.JS
 
Containerize!
Containerize!Containerize!
Containerize!
 
Filesystems
FilesystemsFilesystems
Filesystems
 
Websocket vs SSE - Paris.js - 24/06/15
Websocket vs SSE - Paris.js - 24/06/15Websocket vs SSE - Paris.js - 24/06/15
Websocket vs SSE - Paris.js - 24/06/15
 
MobConf - session on C# async-await on 18june2016 at Kochi
MobConf - session on C# async-await on 18june2016 at KochiMobConf - session on C# async-await on 18june2016 at Kochi
MobConf - session on C# async-await on 18june2016 at Kochi
 

Similar to Android minutes: synchronization presentation

Microservices: Architecture and Practice
Microservices:  Architecture and PracticeMicroservices:  Architecture and Practice
Microservices: Architecture and PracticeIron.io
 
iOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h editioniOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h editionJorge Ortiz
 
Clean architecture workshop
Clean architecture workshopClean architecture workshop
Clean architecture workshopJorge Ortiz
 
Mihai tataran developing modern web applications
Mihai tataran   developing modern web applicationsMihai tataran   developing modern web applications
Mihai tataran developing modern web applicationsITCamp
 
Ajax & Reverse Ajax Presenation
Ajax & Reverse Ajax PresenationAjax & Reverse Ajax Presenation
Ajax & Reverse Ajax PresenationRishabh Garg
 
Best practices of building data streaming API
Best practices of building data streaming APIBest practices of building data streaming API
Best practices of building data streaming APIConstantine Slisenka
 
DEVNET-1166 Open SDN Controller APIs
DEVNET-1166	Open SDN Controller APIsDEVNET-1166	Open SDN Controller APIs
DEVNET-1166 Open SDN Controller APIsCisco DevNet
 
Effective Persistence Using ORM With Hibernate
Effective Persistence Using ORM With HibernateEffective Persistence Using ORM With Hibernate
Effective Persistence Using ORM With HibernateEdureka!
 
Streaming to a New Jakarta EE
Streaming to a New Jakarta EEStreaming to a New Jakarta EE
Streaming to a New Jakarta EEJ On The Beach
 
Streaming to a new Jakarta EE
Streaming to a new Jakarta EEStreaming to a new Jakarta EE
Streaming to a new Jakarta EEMarkus Eisele
 
LarKC Tutorial at ISWC 2009 - Introduction
LarKC Tutorial at ISWC 2009 - IntroductionLarKC Tutorial at ISWC 2009 - Introduction
LarKC Tutorial at ISWC 2009 - IntroductionLarKC
 
Day in the life event-driven workshop
Day in the life  event-driven workshopDay in the life  event-driven workshop
Day in the life event-driven workshopChristina Lin
 
Synopsis on online shopping by sudeep singh
Synopsis on online shopping by  sudeep singhSynopsis on online shopping by  sudeep singh
Synopsis on online shopping by sudeep singhSudeep Singh
 
IBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClassIBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClassPaul Withers
 
CMPE282_009994036_PROJECT_REPORT
CMPE282_009994036_PROJECT_REPORTCMPE282_009994036_PROJECT_REPORT
CMPE282_009994036_PROJECT_REPORTSandyarathi Das
 
Plone FSR
Plone FSRPlone FSR
Plone FSRfulv
 
TechTalk_Cloud Performance Testing_0.6
TechTalk_Cloud Performance Testing_0.6TechTalk_Cloud Performance Testing_0.6
TechTalk_Cloud Performance Testing_0.6Sravanthi N
 

Similar to Android minutes: synchronization presentation (20)

Microservices: Architecture and Practice
Microservices:  Architecture and PracticeMicroservices:  Architecture and Practice
Microservices: Architecture and Practice
 
iOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h editioniOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h edition
 
Clean architecture workshop
Clean architecture workshopClean architecture workshop
Clean architecture workshop
 
Mihai tataran developing modern web applications
Mihai tataran   developing modern web applicationsMihai tataran   developing modern web applications
Mihai tataran developing modern web applications
 
Ajax & Reverse Ajax Presenation
Ajax & Reverse Ajax PresenationAjax & Reverse Ajax Presenation
Ajax & Reverse Ajax Presenation
 
Best practices of building data streaming API
Best practices of building data streaming APIBest practices of building data streaming API
Best practices of building data streaming API
 
DEVNET-1166 Open SDN Controller APIs
DEVNET-1166	Open SDN Controller APIsDEVNET-1166	Open SDN Controller APIs
DEVNET-1166 Open SDN Controller APIs
 
Effective Persistence Using ORM With Hibernate
Effective Persistence Using ORM With HibernateEffective Persistence Using ORM With Hibernate
Effective Persistence Using ORM With Hibernate
 
Streaming to a New Jakarta EE
Streaming to a New Jakarta EEStreaming to a New Jakarta EE
Streaming to a New Jakarta EE
 
Streaming to a new Jakarta EE
Streaming to a new Jakarta EEStreaming to a new Jakarta EE
Streaming to a new Jakarta EE
 
LarKC Tutorial at ISWC 2009 - Introduction
LarKC Tutorial at ISWC 2009 - IntroductionLarKC Tutorial at ISWC 2009 - Introduction
LarKC Tutorial at ISWC 2009 - Introduction
 
App fabric introduction
App fabric introductionApp fabric introduction
App fabric introduction
 
Day in the life event-driven workshop
Day in the life  event-driven workshopDay in the life  event-driven workshop
Day in the life event-driven workshop
 
Web-Socket
Web-SocketWeb-Socket
Web-Socket
 
Synopsis on online shopping by sudeep singh
Synopsis on online shopping by  sudeep singhSynopsis on online shopping by  sudeep singh
Synopsis on online shopping by sudeep singh
 
IBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClassIBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClass
 
CMPE282_009994036_PROJECT_REPORT
CMPE282_009994036_PROJECT_REPORTCMPE282_009994036_PROJECT_REPORT
CMPE282_009994036_PROJECT_REPORT
 
Plone FSR
Plone FSRPlone FSR
Plone FSR
 
TechTalk_Cloud Performance Testing_0.6
TechTalk_Cloud Performance Testing_0.6TechTalk_Cloud Performance Testing_0.6
TechTalk_Cloud Performance Testing_0.6
 
70487.pdf
70487.pdf70487.pdf
70487.pdf
 

Recently uploaded

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 

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