46
Oak the architecture of Apache Jackrabbit 3

Oak, the architecture of Apache Jackrabbit 3

Embed Size (px)

DESCRIPTION

Apache Jackrabbit is just about to reach the 3.0 milestone based on a new architecture called Oak. Based on concepts like eventual consistency and multi-version concurrency control, and borrowing ideas from distributed version control systems and cloud-scale databases, the Oak architecture is a major leap ahead for Jackrabbit. This presentation describes the Oak architecture and shows what it means for the scalability and performance of modern content applications. Changes to existing Jackrabbit functionality are described and the migration process is explained.

Citation preview

Page 1: Oak, the architecture of Apache Jackrabbit 3

Oakthe architecture of Apache Jackrabbit 3

Page 2: Oak, the architecture of Apache Jackrabbit 3

Subsection TitleSubsection Title• Text• Text• Text• Text

Page 3: Oak, the architecture of Apache Jackrabbit 3

Resources

• http://jackrabbit.apache.org/oak/• Docs

• http://jackrabbit.apache.org/oak/docs/• Code

• https://svn.apache.org/repos/asf/jackrabbit/oak/trunk/• https://github.com/apache/jackrabbit-oak

• Builds• http://ci.apache.org/builders/oak-trunk/• https://travis-ci.org/apache/jackrabbit-oak

Page 4: Oak, the architecture of Apache Jackrabbit 3

Outline• Tree model• Updating the tree• Refresh and garbage collection• Concurrency and conflicts• Interlude: Implementations• Replicas and sharding• Access control• Comparing revisions• Commit hooks• Observers• Search• Big picture

Page 5: Oak, the architecture of Apache Jackrabbit 3

Tree model

Page 6: Oak, the architecture of Apache Jackrabbit 3

a d

b c

Paths as identifiers//a/a/b/a/c/d

Page 7: Oak, the architecture of Apache Jackrabbit 3

a d

b c

Paths as identifiers//a/a/b/a/c/d

Page 8: Oak, the architecture of Apache Jackrabbit 3

Updating the tree

Page 9: Oak, the architecture of Apache Jackrabbit 3

?

Page 10: Oak, the architecture of Apache Jackrabbit 3

r1 r2

HEAD

r1: /d r2: /d

r1: /a/cr2: /a/c

Page 11: Oak, the architecture of Apache Jackrabbit 3

Refresh and garbage collection

Page 12: Oak, the architecture of Apache Jackrabbit 3

refresh

Page 13: Oak, the architecture of Apache Jackrabbit 3

garbage

Page 14: Oak, the architecture of Apache Jackrabbit 3
Page 15: Oak, the architecture of Apache Jackrabbit 3

Concurrency and conflicts

Page 16: Oak, the architecture of Apache Jackrabbit 3

r1 r2br2a

Page 17: Oak, the architecture of Apache Jackrabbit 3

r1

r2b

r2a

r3merge

Page 18: Oak, the architecture of Apache Jackrabbit 3

Conflict handling strategiesa. Fully serialized commits

• fail on conflict, no concurrent updates

b. Partially serialized commits• fail on conflict, concurrent conflict-free updates

c. Partial merge logic• conflict markers, manual conflict resolution

d. Full merge logic• conflicting changes may be lost

Page 19: Oak, the architecture of Apache Jackrabbit 3

Interlude: implementations

Page 20: Oak, the architecture of Apache Jackrabbit 3

MicroKernel/NodeStore

• Implementation of the tree/revision model

Responsible for

Clustering

Sharding

Caching

Conflict handling

etc.

Not responsible for

Type validation

Access control

Search

Versioning

etc.

Page 21: Oak, the architecture of Apache Jackrabbit 3

Current implementations

DocumentMK TarMK (SegmentMK)

Persistence backends MongoDB, JDBC (WIP) Local FS (tar files)

Conflict handling Partial serialization Full serialization

Clustering MongoDB clustering Simple failover

Sharding MongoDB sharding N/A

Single-node performance Moderate High

Key use cases Large deployments (>1TB), concurrent writes

Small/medium deployments, mostly read

Page 22: Oak, the architecture of Apache Jackrabbit 3

Replicas and sharding

Page 23: Oak, the architecture of Apache Jackrabbit 3

master copy full replica cache

Replicas and caches

Page 24: Oak, the architecture of Apache Jackrabbit 3

by path by level by hash

Sharding strategies

with caching

Page 25: Oak, the architecture of Apache Jackrabbit 3

Access control

Page 26: Oak, the architecture of Apache Jackrabbit 3

Accessible paths//a/b/d

Page 27: Oak, the architecture of Apache Jackrabbit 3

Existentialism

• All (syntactically valid) paths can be traversed

• But the identified node might not exist• For example:

root.getChildNode(“a”).exists() -> false

root.getChildNode(“a”).getChildNode(“b”).exists() -> true!

• Implemented as a decorator over the MK

Page 28: Oak, the architecture of Apache Jackrabbit 3

Comparing revisions

Page 29: Oak, the architecture of Apache Jackrabbit 3

What changed?

Page 30: Oak, the architecture of Apache Jackrabbit 3

Content diff

• Tells what changed between two content trees• Cornerstone of most higher-level functionality• validation• indexing• observation• etc.

Page 31: Oak, the architecture of Apache Jackrabbit 3

r1

r2b

r2a

r3

Examples

r1 -> r3“a” modified

“b” removed“d” modified

“e” added

r1 -> r2a“a” modified

“b” removed

r1 -> r2b“d” modified

“e” added

Page 32: Oak, the architecture of Apache Jackrabbit 3

Commit hooks

Page 33: Oak, the architecture of Apache Jackrabbit 3

If this changed, commit this instead

Page 34: Oak, the architecture of Apache Jackrabbit 3

Commit hooks

• Based on given before and after states, a hook can:• fail the commit, or• pass the commit unmodified, or• pass the commit with modifications

• Key plugin mechanism in Oak• All configured hooks are applied in sequence• Used for much higher level functionality

• Often implemented using a content diff

Page 35: Oak, the architecture of Apache Jackrabbit 3

Examples

• All kinds of validation• node types, access control, references, etc.

• Trigger-like functionality• autocreated content, default values, etc.

• In-content index updates• etc.

Page 36: Oak, the architecture of Apache Jackrabbit 3

Types of hooks

CommitHook Editor Validator

Content diff Optional Always Always

Can modify commit Yes Yes No

Programming model

Simple Callbacks Callbacks

Performance impact

High Medium Low

Page 37: Oak, the architecture of Apache Jackrabbit 3

Observers

Page 38: Oak, the architecture of Apache Jackrabbit 3

Observers

• Based on given before and after states, an observer can:• observe what changed in the content tree

• Invoked after the commit, unlike commit hooks• Always asynchronous for changes from other cluster

nodes• Depending on backend, can be synchronous for

changes on the local cluster node• Often implemented using a content diff

Page 39: Oak, the architecture of Apache Jackrabbit 3

Examples

• JCR Observation• External index updates• Cache invalidation• Logging• etc.

Page 40: Oak, the architecture of Apache Jackrabbit 3

Search

Page 41: Oak, the architecture of Apache Jackrabbit 3

SELECTWHERE x=y

/a//*

Parser

Parser

ParserIndex

Index

Index

Parser Index

Query engine

Page 42: Oak, the architecture of Apache Jackrabbit 3

Query processing steps

1. Parsinga. Select matching parserb. Parse the query string

2. Executiona. Estimate cost per indexb. Select index with the least cost estimatec. Execute the query against the index

3. Post-processinga. Filter results on access control and additional constraintsb. Apply sorting, grouping, faceting, etc.

Page 43: Oak, the architecture of Apache Jackrabbit 3

Index implementations

• Property index• Reference index• Lucene index• in-content• local file system

• Solr index• embedded• external

Page 44: Oak, the architecture of Apache Jackrabbit 3

Big picture

Page 45: Oak, the architecture of Apache Jackrabbit 3

MicroKernel

Oak Core

Oak JCR

Oak API

NodeStore API

JCR API

Plugins

Page 46: Oak, the architecture of Apache Jackrabbit 3

Questions?