Top Banner
JNoSQL Otávio Santana @otaviojava [email protected]
38

NoSQL, no Limits, lots of Fun!

Jan 28, 2018

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: NoSQL, no Limits, lots of Fun!

JNoSQL

Otávio Santana@[email protected]

Page 2: NoSQL, no Limits, lots of Fun!

NoSQL

● Database● Doesn't use structure● Not Transaction● BASE● Five different types

Page 3: NoSQL, no Limits, lots of Fun!

Key Value

● AmazonDynamo● AmazonS3● Redis● Scalaris● Voldemort ● Couchbase● Hazelcast

valuekey

valuekey

valuekey

Page 4: NoSQL, no Limits, lots of Fun!

Document

● AmazonSimpleD● ApacheCouchdb● MongoDb● Riak● Couchbase

Page 5: NoSQL, no Limits, lots of Fun!

Column Family

● Hbase● Cassandra● Scylla● Clouddata● SimpleDb● DynamoDB

Row-key Columns...

Apollo

Aphrodite

Ares

SunDuty

{Love, happy}Duty

WarDuty

Swordweapon

Color

KratosDead Gods

13

Page 6: NoSQL, no Limits, lots of Fun!

Graph

● Neo4j● InfoGrid● Sones● HyperGraphDB

Apollo Ares

Kratoswas killed by was killed by

Is brother

killed killed

Page 7: NoSQL, no Limits, lots of Fun!

Multi-Model● OrientDB (graph, document)

● Couchbase (key value, document)

● Elasticsearch (document, graph)

● Cassandra (column family, graph - in progress)

Page 8: NoSQL, no Limits, lots of Fun!

SQL Key-value Document Column Graph

Table Bucket Collection Column Family

Vertex and Edge

Row Key/value pair

Document Column Vertex

Column Key/value pair

Key/value pair

Vertex and Edge property

Relationship Link Edge

Page 9: NoSQL, no Limits, lots of Fun!

Relational Application

DAO

API API API

Data Tier

Logic Tier

DAO

Logic Tier

Data Tier

JPA

JDBC

JPA

JDBC

JPA

JDBC

NoSQL Application

Page 10: NoSQL, no Limits, lots of Fun!

The Current Solution

● Spring Data● Hibernate OGM● TopLink

DAO

Solution Solution

Page 11: NoSQL, no Limits, lots of Fun!

JPA problem for NoSQL

● Saves Async● Async Callback● Time to Live (TTL)● Consistency Level● SQL based● Diversity in NoSQL

Page 12: NoSQL, no Limits, lots of Fun!

The Challenge● 4 Types

● Differents goals

● Differents behaviors

Page 13: NoSQL, no Limits, lots of Fun!

JNoSQL

● Mapping API● Communication API● No lock-in● Divide and conquer

DAO

Mapping

Communication

DocumentKey

Column Graph

DIANA

ARTEMIS

JNoSQL

Data Tier

Page 14: NoSQL, no Limits, lots of Fun!

JNoSQL

● Eclipse Foundation● Apache + Eclipse License● API to each NoSQL type● Configurable● Extensible

Mapping

Communication DIANA

ARTEMIS

Page 15: NoSQL, no Limits, lots of Fun!

Why Diana?

● Goddess of the hunt, nature and moon

● Fought in Troy● Brave warrior and hunter● Diana Rome = Artemis Greek

Page 16: NoSQL, no Limits, lots of Fun!

Diana

● API Communication layer

● Document, key-value, Column, Graph

● Universal Adapter

● Standard

Page 17: NoSQL, no Limits, lots of Fun!

Communication Issue

ODocument document = new ODocument(“collection”);document.field(name, value);

JsonObject jsonObject = JsonObject.create();jsonObject.put(name, value);

BaseDocument baseDocument = new BaseDocument();baseDocument.addAttribute(name, value);

Document document = new Document();document.append(name, value);

Page 18: NoSQL, no Limits, lots of Fun!

Communication Issue

ODocument document = new ODocument(“collection”);document.field(name, value);

JsonObject jsonObject = JsonObject.create();jsonObject.put(name, value);

BaseDocument baseDocument = new BaseDocument();baseDocument.addAttribute(name, value);

Document document = new Document();document.append(name, value);

Page 19: NoSQL, no Limits, lots of Fun!

Communication Issue

DocumentEntity entity = DocumentEntity.of("documentCollection");Document document = Document.of(name, value);entity.add(document);

Page 20: NoSQL, no Limits, lots of Fun!

Issues

● insert vs save● delete vs remove● update vs merge● find vs. search● callback interface to

asynchronous callback

● long to seconds● int to seconds● long to milliseconds● int to milliseconds

Page 21: NoSQL, no Limits, lots of Fun!

Diana Project

● Document API● Graph API● Key-value API● Column API● Four TCKs

Database

API

Implementation

TCK

Page 22: NoSQL, no Limits, lots of Fun!

Nomenclature

● Configuration● Factory● Manager● Entity● Value

Page 23: NoSQL, no Limits, lots of Fun!

DiversityColumnEntity entity = ColumnEntity.of(COLUMN_FAMILY);Column id = Column.of("id", 10L);entity.add(id);entity.add(Column.of("version", 0.001));entity.add(Column.of("name", "Diana"));entity.add(Column.of("options", Arrays.asList(1, 2, 3)));

//mutiple implementationcolumnEntityManager.save(entity);ColumnQuery query = ColumnQuery.of(COLUMN_FAMILY);query.addCondition(ColumnCondition.eq(id));Optional<ColumnEntity> result = columnEntityManager.singleResult(query);

//cassandra onlyList<ColumnEntity> entities = columnEntityManagerCassandra.cql("select * from newKeySpace.newColumnFamily where id=10;");columnEntityManagerCassandra.save(entity, ConsistencyLevel.ALL);

Page 24: NoSQL, no Limits, lots of Fun!

NoSQL Providers

Page 25: NoSQL, no Limits, lots of Fun!

JUGs/Communities

Page 26: NoSQL, no Limits, lots of Fun!

Artemis● CDI Based● Diana Based● Annotation Based● Events to insert, delete, update● Supports to Bean Validation● Configurable and Extensible● Query Method

Page 27: NoSQL, no Limits, lots of Fun!

Annotations

● MappedSuperclass● Entity● Column

@Entity("movie")public class Movie {

@Column private String name;

@Column private long year;

@Column private Set<String> actors;

Page 28: NoSQL, no Limits, lots of Fun!

interface PersonRepository extends Repository<Person> {

Person findByName(String name);

void deleteByName(String name);

Optional<Person> findByAge(Integer age);

List<Person> findByNameAndAge(String name, Integer age);

Set<Person> findByAgeAndName(Integer age, String name);

Stream<Person> findByNameAndAgeOrderByName(String name, Integer age);

Queue<Person> findByNameAndAgeOrderByAge(String name, Integer age);}

Dynamic Query

Page 29: NoSQL, no Limits, lots of Fun!

Events

Movie

firePreEntity firePreAPI firePostAPI firePostEntity

Interceptor

Page 30: NoSQL, no Limits, lots of Fun!

Configurable and extensible● EventManager● CrudOperation● ClassRepresentations● Converter● Decorate● Replace

Page 31: NoSQL, no Limits, lots of Fun!

@Entity("person")public class Person {

@Columnprivate String name;

@Columnprivate Integer age;

@UDT("address")@Columnprivate Address home;

}

interface PersonRepository extends CassandraRepository<Person> {

Person findByName(String name, ConsistencyLevel level);

void deleteByName(String name, ConsistencyLevel level);

@CQL("select * from Person") List<Person> findAll();

@CQL("select * from Person where name = ?") List<Person> findByName(String name);}

Page 32: NoSQL, no Limits, lots of Fun!

Road Map

✓ Draft and code proposal

✓ Community Feedback

✓ Involve NoSQL Vendors

✓ Involve Solution Vendors

✓ Eclipse Project

✓ Development

✓ JSR

Page 33: NoSQL, no Limits, lots of Fun!

Site

http://jnosql.org/

Page 34: NoSQL, no Limits, lots of Fun!

Code

https://github.com/JNOSQL

Page 35: NoSQL, no Limits, lots of Fun!

Mailing List

https://dev.eclipse.org/mailman/listinfo/jnosql-dev

Page 36: NoSQL, no Limits, lots of Fun!

Gitter

https://gitter.im/JNOSQL/developers

Page 37: NoSQL, no Limits, lots of Fun!

Wiki

https://wiki.eclipse.org/JNoSQL