terrastore - a document database for developers
TRANSCRIPT
![Page 1: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/1.jpg)
TerrastoreA document database for
developers
Sergio Bossa @sbtourist
![Page 2: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/2.jpg)
About MeSoftware architect and engineer
Gioco Digitale (online gambling and casinos).
Long time open source enthusiast and contributorSpring.Taconite.Terracotta.Actorom, Terrastore ...
(Micro)-Bloggerhttp://twitter.com/sbtouristhttp://sbtourist.blogspot.com
![Page 3: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/3.jpg)
NOSQL ... what?1998
Just a tiny non-relational database.2009
Non-relational databases as a replacement for relational ones?
Nowadays ...Not Only SQL.
Use the right tool for your job.
![Page 4: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/4.jpg)
NOSQL ... why?When you're in troubles with ...
Data Model.Relational mismatch.Variable schema.
Data Access Patterns.Expensive joins.Denormalized data.
Scalability.More data.More processing.
![Page 5: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/5.jpg)
No SQL, Yes ... ?Heterogeneity.
Key/Value based.Voldemort.
Document based.MongoDB.Riak.Terrastore.
Column based.Cassandra.HBase.
Graph based.Neo4J.
![Page 6: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/6.jpg)
Terrastore!Document Store.
Ubiquitous.Consistent.Distributed.Scalable.
Written in Java.Based on Terracotta.Open Source.Apache-licensed.
![Page 7: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/7.jpg)
Your data, your documents{ "name" : "Sergio", "surname" : "Bossa", "twitter" : "@sbtourist"}
![Page 8: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/8.jpg)
Access everywhere
![Page 9: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/9.jpg)
Keep consistent
![Page 10: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/10.jpg)
Distribute as a single cluster
![Page 11: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/11.jpg)
Distribute as multiple clusters
![Page 12: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/12.jpg)
But ... Why Terrastore?!?!
![Page 13: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/13.jpg)
Make ...
![Page 14: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/14.jpg)
Simple things easy
![Page 15: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/15.jpg)
Complex things possible
( almost ;)
![Page 16: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/16.jpg)
Get started in seconds
$> ant -f terrastore-install.xml \ quickstart -Dquickstart.dir=...
One command installation and startup ...
![Page 17: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/17.jpg)
Easy installation
$> ant -f terrastore-install.xml \ single-master \-Dmaster.server.port 9510 \-Dinstall.dir=...
Master:
$> ant -f terrastore-install.xml \server \-Dinstall.dir=...
Server:
![Page 18: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/18.jpg)
No complex configuration
$master>./start.sh
Master:
$server>./start.sh \--master \--httpHost \--httpPort \--nodeHost \--nodePort \...
Server:
![Page 19: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/19.jpg)
No impedence mismatch
public class Character { private String name; private List<Character> friends; private List<Character> foes; // ...}
{"name" : "Spider-man", "friends" : [{"name" : "Iceman"}]"foes" : [{"name" : "Kingpin"}]}
Java:
Json:
![Page 20: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/20.jpg)
Simple basic operations
PUT /bucket/keyContent-Type: application/json{...}
Put documents in buckets ...
GET /bucket/keyContent-Type: application/json{...}
Get documents from buckets ...
![Page 21: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/21.jpg)
Range queries
GET /bucket/range?comparator=comparator_name&startKey=start_key&endKey=end_key&timeToLive=max_ageContent-Type: application/json{...}
Find documents in bucket with keys in a given range ...
![Page 22: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/22.jpg)
Built-in comparators
LexicographicalAscendant.Descendant.
Numerical.Ascendant.Descendant.
![Page 23: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/23.jpg)
What if ... custom comparators?
@AutoDetect(name="my-comparator")public class MyComparator implements terrastore.store.operators.Comparator { public int compare(String key1, String key2) { // ... }}
![Page 24: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/24.jpg)
Predicate queries
GET /bucket/predicate?predicate=type:expressionContent-Type: application/json{...}
Find documents in bucket satisfying a given predicate condition ...
![Page 25: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/25.jpg)
Conditional put/get
PUT /bucket/key?predicate=type:expressionContent-Type: application/json{...}
Conditionally put documents in buckets ...
GET /bucket/key?predicate=type:expressionContent-Type: application/json{...}
Conditionally get documents from buckets ...
![Page 26: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/26.jpg)
Built-in predicate conditions
JXPapthBased on X-Path.Find people whose name is 'Sergio':
jxpath:/name[.='Sergio']JavaScript
Applies a JavaScript-like condition.Find people whose name is 'Sergio':
js:value.name=='Sergio'
![Page 27: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/27.jpg)
What if ... custom conditions?
@AutoDetect(name="my-condition")public class MyCondition implements terrastore.store.operators.Condition { public boolean isSatisfied(String key, Map<String, Object> value, String expression) { // ... }}
![Page 28: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/28.jpg)
Server-side updates
PUT /bucket/key/update?function=function_name&timeout=timeout_valueContent-Type: application/json{...}
Atomically execute complex updates to a document ...
![Page 29: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/29.jpg)
Built-in update functions
Atomic CountersAtomically increment/decrement/set-up one or more counters.
MergeMerge the stored document with provided values.
JavaScript custom updateUpdate the stored document by executing a user-provided javascript function.
![Page 30: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/30.jpg)
What if ... custom functions?
@AutoDetect(name="my-function")public class MyFunction implements terrastore.store.operators.Function { public Map<String, Object> apply(String key, Map<String, Object> value, Map<String, Object> parameters) { // ... }}
![Page 31: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/31.jpg)
Easy scale-out
$server>./start.sh \--master \--ensemble
A command line parameter:
{"localCluster" : "apple","discoveryInterval" : 5000,"clusters" : ["apple", "orange"],"seeds" : {"orange" : "192.168.1.2:6001"}}
And a json configuration file:
![Page 32: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/32.jpg)
DSL-like Java APIs
// Create client:TerrastoreClient client = new TerrastoreClient("http://localhost:8080", new HTTPConnectionFactory());
// Create object:Person sbtourist = new Person("Sergio Bossa”, "sbtourist")
// Put:client.bucket("people").key("1").put(person);
// Get:sbtourist = client.bucket("people").key("1").get(Person.class);
Fluent APIs.Http-based.Transparent (yet configurable) object conversion.
![Page 33: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/33.jpg)
Support for other languagesClojure
http://github.com/sbtourist/terrastore-clojPython
http://dnene.bitbucket.org/docs/pyterrastoreScala
http://github.com/ssuravarapu/Terrastore-Scala-Client http://github.com/teigen/terrastore-scala
Easy to add more!
![Page 34: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/34.jpg)
Pure Javascript Web Console
![Page 35: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/35.jpg)
More!Backup
Import/export documents to/from buckets.Events management
Get notified of document updates.Third-party products integration.Write-behind.
ActiveMQ integration for higher reliability.Custom data partitioning
Retain control of where your data is placed.Indexing and searching
Terrastore-Search.ElasticSearch integration.
Cross-origin resource sharing supportIntegrate with browser-based clients.
![Page 36: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/36.jpg)
Now that I have an hammer ...Don't go blinded.
Use the right tool for the job!
Terrastore is best suited for:Data hot spots.Computational data.Complex, rich or variable data.Throw-away data.
![Page 37: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/37.jpg)
Final words ... engaging.Explore
http://code.google.com/p/terrastoreDownload
http://code.google.com/p/terrastore/downloads/listHack
http://code.google.com/p/terrastore/source/checkout
Participatehttp://groups.google.com/group/terrastore-discussions
Enjoy!
![Page 38: Terrastore - A document database for developers](https://reader034.vdocument.in/reader034/viewer/2022052507/559353ca1a28abba1b8b46b1/html5/thumbnails/38.jpg)
Q & AContact me on:
http://twitter.com/sbtourist