data replication in sling

Post on 27-May-2015

499 Views

Category:

Technology

4 Downloads

Preview:

Click to see full reader

DESCRIPTION

Overview of Sling Replication module with usecases and design prinicples

TRANSCRIPT

APACHE SLING & FRIENDS TECH MEETUP BERLIN, 22-24 SEPTEMBER 2014

Data replication in Sling Tommaso Teofili, Adobe Systems

adaptTo() 2014 2

Use cases

Replication in AEM

adaptTo() 2014 3

§  Moving authored content to publish servers

author   publish  

Replication in AEM

adaptTo() 2014 4

§  Moving user generated content back to author for moderation

author   publish  

Replication in AEM

adaptTo() 2014 5

§  Moving user generated content to other publish instances  

author  

publish  

publish  

Replication module should ...

adaptTo() 2014 6

§  transfer resources between Sling instances §  push from server A to server B §  pull from server C to server D

Example: replication of /foo/bar

adaptTo() 2014 7

§  HTTP request for pushing /foo/bar §  Resources get

§  packaged

§  sent §  received

§  persisted

we’re not in 1999 ... anymore

adaptTo() 2014 8

NRT sync on N servers

adaptTo() 2014 9

publish1    

publish2  

author1  

publish3  

publish4    

publish5    

author2  

Oak instances served by same MongoDB

adaptTo() 2014 10

publish1    

publish2  author  

oak  

oak  

mongo  

mongo  mongo  

mongo  

p1    or  p2  

Cloud based infrastructures

adaptTo() 2014 11

publish1    publish2  

author1  

P1  to  pN  

author2  

publish3  

publish4  publish4  publish4  publish4  publish4  publishN  

adaptTo() 2014 12

Overview

Sling Replication

adaptTo() 2014 13

§  Contributed to Sling in November 2013 §  First release ? §  Main goals

§  Simple §  Resilient

§  Fast

Replication agents

adaptTo() 2014 14

§  Execute replication requests by: §  exporting replication packages from a (remote)

Sling instance §  importing replication packages into a (remote)

Sling instance

Replication agents

adaptTo() 2014 15

§  A “push” agent has §  A “local” exporter

§  Creating a package locally for the resources to be replicated (e.g. from the underlying JCR repo)

§  A “remote” importer §  Importing the exported package remotely by sending

it to a designated endpoint to persist it

Replication agents

adaptTo() 2014 16

§  A “pull” agent has §  A “remote” exporter

§  Pulling a package from a remote Sling instance designated endpoint

§  A “local” importer §  Importing the package locally by persisting it into the

Sling instance

Replication agents

adaptTo() 2014 17

§  A “coordinating” agent has §  A “remote” exporter

§  Pulling a package from a remote endpoint

§  A “remote” importer §  Importing the package remotely into a Sling instance

Replication agents

adaptTo() 2014 18

§  A “queuing” agent has §  A “local” exporter

§  Creating a package locally for the resources to be replicated (e.g. from the underlying JCR repo)

§  No importer

Replication package serialization

adaptTo() 2014 19

§  Payload to be sent / received §  Package builders for (de)serialization

§  Jackrabbit FileVault based package builder

Replication queues

adaptTo() 2014 20

§  Multiple queue providers §  Sling Jobs based (sling.event bundle) §  In memory

§  Multiple queue distribution strategies §  Single

§  Error aware §  Priority

Replication rules

adaptTo() 2014 21

§  Rules can be defined within agents §  To trigger replications upon resource changes §  To schedule periodic replications

§  To chain replicate §  ...

Accessing replication resources

adaptTo() 2014 22

§  Agents as OSGi services §  Can be defined via ConfigurationAdmin §  Resource providers control

§  Service access

§  CRUD operations on configs

Agent configuration example (1/3)

adaptTo() 2014 23

§  Config for a ‘push agent’ {

"jcr:primaryType" : "sling:OsgiConfig",

"name" : "publish",

"type" : "simple",

"packageExporter": [

"type=local”,

"packageBuilder/type=vlt",

...

],

...

Agent configuration example (2/3)

adaptTo() 2014 24

... "packageImporter" : [

"type=remote",

"endpoints[0]=http://.../replication/services/importers/default”,

"authenticationFactory/type=service",

"authenticationFactory/name=user",

...

"packageBuilder/type=vlt",

...

],

...

Agent configuration example (3/3)

adaptTo() 2014 25

... "queueProvider" : [

"type=service",

"name=sjh"

],

"queueDistributionStrategy" : [

"type=service",

"name=error"

]

}

adaptTo() 2014 26

Anatomy of a forward replication request

Anatomy of a fwd. replication (1/4)

adaptTo() 2014 27

§  HTTP POST on /libs/sling/replication/service/agents/publish with form parameters

§  Action = ADD

§  Path = /content/replication

§  Agent with name ‘publish’ gets picked up by the agent resource provider  

Anatomy of a fwd. replication (2/4)

adaptTo() 2014 28

§  Agent ‘publish’ calls its Exporter (local) to create the payload §  the ‘local’ exporter calls its Package builder

§  the ‘vlt’ package builder creates a FileVault package for resources under /foo/bar

Anatomy of a fwd. replication (3/4)

adaptTo() 2014 29

§  Agent ‘publish’ dispatches the package to its queue provider and distribution algorithm §  The queue provider is asked to provide queues

depending on the distribution strategy §  The request gets queued

Anatomy of a fwd. replication (4/4)

adaptTo() 2014 30

§  When queue entry gets processed the (remote) importer is called

§  Package sent over the wire to an endpoint bound to a local importer on the receiving server

§  The local importer on the receiving side deserializes and persists the replication package via its package builder  

Reverse replication

adaptTo() 2014 31

§  Pull agent on author §  Periodically polling

§  Queuing agent on publish

Event based reverse replication

adaptTo() 2014 32

§  No scheduled polling §  The publish instance notifies author when to

pull §  Notification through server sent events

Looking forward

adaptTo() 2014 33

§  Get information on other instances §  e.g. replicate to all instances with run mode ‘xyz’

§  NRT publish sync §  Coordinate agents++

§  Performance

Thanks!

adaptTo() 2014 34

§  Questions?

top related