Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Eclipse JNoSQL: The Definitive Solution for Java and NoSQL Databases

21 Aufrufe

Veröffentlicht am

JNoSQL is a framework and collection of tools that make integration between Java applications and NoSQL quick and easy—for developers as well as vendors. The API is easy to implement, so NoSQL vendors can quickly implement, test, and become compliant by themselves. And with its low learning curve and just a minimal set of artifacts, Java developers can start coding by worrying not about the complexity of specific NoSQL databases but only their core aspects (such as graph or document properties). Built with functional programming in mind, it leverages all the features of Java 8. This session covers how the API is structured, how it relates to the multiple NoSQL database types, and how you can get started and involved in this open source technology.

Veröffentlicht in: Software
  • Als Erste(r) kommentieren

  • Gehören Sie zu den Ersten, denen das gefällt!

Eclipse JNoSQL: The Definitive Solution for Java and NoSQL Databases

  1. 1. Werner Keil @wernerkeil Eclipse JNoSQL
  2. 2. Who am I? Werner Keil Consultant – Coach Open Source Evangelist Software Architect Apache, Eclipse Committer, Agile Alliance Member Expert Group member in many JSRs Spec Lead – JSR385 Jakarta EE Specification Committee Member Twitter @wernerkeil [www.linkedin.com/in/catmedia]
  3. 3. NoSQL 01 Database 02 Doesn't use structure 03 No Transactions 04 Base Five different types05
  4. 4. Key Value AmazonDynamo AmazonS3 Redis Hazelcast Apollo Ares Aphrodite Sun War Love Beauty
  5. 5. Column Family Apollo Aphrodite Ares Kratos Duty Duty Duty Dead Gods Love, happy Sun War 13 Color weapon Sword Row-key ColumnsHBase Scylla SimpleDb Cassandra DynamoDB Clouddata
  6. 6. Document { "name":"Diana", "duty":[ "Hunting", "Moon", "Nature" ], "siblings":{ "Apollo":"brother" } } ApacheCouchDB MongoDB Couchbase
  7. 7. Graph Apollo Ares Kratos was killed by was killed by killed killed Neo4j InfoGrid Sones HyperGraphDB
  8. 8. Multi-Model 01 02 03 04 OrientDB (graph, document) Couchbase (key value, document) Elasticsearch (document, graph) ArangoDB (document, graph, key-value)
  9. 9. SQL vs NoSQL SQL KEY-VALUE COLUMN DOCUMENTS GRAPH Table Bucket Column family Collection Row Key/value pair column Documents Vertex Column Key/value pair Key/value pair Vertex and Edge property Relationship Link Edge
  10. 10. BASE vs ACID • Basically Available • Soft state • Eventual consistency • Atomicity • Consistency • Isolation • Durability
  11. 11. CAP
  12. 12. Scalability vs Complexity Scalability Complexity key-value Column Document Graph
  13. 13. Relational Application NoSQL Application Logic Tier Logic Tier DAO DAO JP A JP A JP A JP A JDBC JDBCJDBCJDBC Data Tier APIAPI API Data Tier
  14. 14. The Current Solution DAO Solution Solution Hibernate OGM TopLink
  15. 15. JPA problem for NoSQL 01 02 03 04 05 06 Saves Async Async Callback Time to Live (TTL) Consistency Level SQL based Diversity in NoSQL
  16. 16. The Eclipse JNoSQL Solution DIANA ARTEMIS JNoSQL DAO Mapping Communication Column Documents Key Graph Data Tier 01 02 03 04 Mapping API Communication API No lock-in Divide and Conquer
  17. 17. Why Diana? 01 02 03 04 Goddess of hunting, nature and moon Fought in Troy Brave warrior and hunter Diana Rome = Artemis Greek
  18. 18. Diana API Communication layer Document, key-value, Column, Graph (TinkerPop)
  19. 19. 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);
  20. 20. Eclipse JNoSQL DocumentEntity entity = DocumentEntity.of("collection"); entity.add(name, value);
  21. 21. 01 02 03 04 Configuratio n Factory Manager Entity Names & Definitions
  22. 22. Names & Definitions ColumnConfiguration<?> configuration = new DriverConfiguration(); try(ColumnFamilyManagerFactory managerFactory = configuration.get()) { ColumnFamilyManager entityManager = managerFactory.get(KEY_SPACE); entityManager.insert(entity); ColumnQuery select = select().from(COLUMN_FAMILY) .where("id").eq("Ada").build(); ColumnDeleteQuery delete = delete().from(COLUMN_FAMILY) .where("id").eq("Ada").build(); Optional<ColumnEntity> result = entityManager.singleResult(query); entityManager.delete(delete);
  23. 23. Diversity ColumnEntity 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))); //cassandra only List<ColumnEntity> entities = entityManagerCassandra .cql("select * from newKeySpace.newColumnFamily where id=10;"); entityManagerCassandra.insert(entity, ConsistencyLevel.ALL); //mutiple implementation entityManager.insert(entity); ColumnQuery query = select().from(COLUMN_FAMILY).where("id").eq(10L).build(); Optional<ColumnEntity> result = entityManager.singleResult(query);
  24. 24. 01 02 03 04 05 06 Artemis CDI Based Diana Based Annotation Based Events to insert, delete, update Supports to Bean Validation Configurable and Extensible 07 Query Method
  25. 25. 01 02 03 04 Annotated Entities Template Repository Configuration Names & Definitions
  26. 26. Annotated Entities 01 02 03 Mapped Superclass Entity Column @Entity("god") public class God { @Column private String name; @Column private long age; @Column private Set<String> powers; }
  27. 27. Template God artemis = ...; DocumentTemplate template = … template.insert(artemis); template.update(artemis); DocumentQuery query = ... List<God> gods = template.select(query);
  28. 28. Repository interface GodRepository extends Repository<God, String> { Optional<God> findByName(String name); Stream<God> findByNameAndAgeOrderByName(String name, Integer age); }
  29. 29. Repository @Inject @Database(DatabaseType.COLUMN) private GodRepository godRepository; @Inject @Database(DatabaseType.KEY_VALUE) private GodRepository godRepository;
  30. 30. Support for JSON XML YAML
  31. 31. Configuration @Inject @ConfigurationUnit private DocumentCollectionManagerFactory<?> entityManager;
  32. 32. Diversity @Entity("god") public class God { @Column private String name; @UDT("weapon") @Column private Weapon weapon; } interface GodRepository extends CassandraRepository<God, String> { @CQL("select * from God where name = ?") List<God> findByName(String name); }
  33. 33. We have Query by Text DocumentTemplate documentTemplate = ...; ColumnTemplate columnTemplate = ...; KeyValueTempalte keyValueTemplate =...; GraphTemplate graphTemplate =...; List<Movie> movies = documentTemplate.query("select * from Movie where year > 2012"); List<Person> people = columnTemplate.query("select * from Person where age = 25"); Optional<God> god = keyValueTemplate.query("get "Diana""); List<City> cities = graphTemplate.query("g.V().hasLabel('City')");
  34. 34. We have Query by Text PreparedStatement preparedStatement = template.prepare("select * from Person where name = @name"); preparedStatement.bind("name", "Ada"); List<Person> adas = preparedStatement.getResultList(); //to graph just keep using gremlin PreparedStatement prepare = graphTemplate().prepare("g.V().hasLabel(param)"); prepare.bind("param", "Person"); List<Person> people = preparedStatement.getResultList();
  35. 35. We have Query by Text interface PersonRepository extends Repository<Person, Long> { @Query("select * from Person") Optional<Person> findByQuery(); @Query("select * from Person where id = @id") Optional<Person> findByQuery(@Param("id") String id); }
  36. 36. Demo Hazelcast MongoDB Neo4J CDI 2.0 with Java SE Configuration JNoSQL
  37. 37. NoSQL Providers
  38. 38. Draft and code proposal Community Feedback Involve NoSQL Vendors Involve Solution Vendors Eclipse Project Road Map Development
  39. 39. Specification Process ● Java EE now contributed to Eclipse Foundation ● Jakarta EE ● Code First Jakarta EE forwards with new specifications ● Hopefully a new spec and namespace confirmed around Oracle Code One / ECE “jakarta.nosql” See https://www.tomitribe.com/blog/jnosql-and-jakarta-ee/
  40. 40. JUGs/Communities
  41. 41. Oracle Code SF ● HOL5998 Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL ● DEV6043 Let’s Make Graph Databases Fun Again with Java ● DEV6109 Jakarta EE Meets NoSQL in the Cloud Age See https://www.oracle.com/code-one/index.html
  42. 42. Eclipse Community Day ● Eclipse Foundation Orientation for Jakarta EE ● Meet the spec: JNoSQL See https://wiki.eclipse.org/JakartaEE_-_MicroProfile_-_Community_day
  43. 43. References Communication API Support to Async operations APIs Mapping API Bean Validation Events Repository Template Query by text Prepared Statement http://jnosql.org/ https://github.com/eclipse?q=Jnosql https://dev.eclipse.org/mailman/listinfo/jnosql-dev https://gitter.im/JNOSQL/developers https://wiki.eclipse.org/JNoSQL
  44. 44. Werner Keil @wernerkeil Thank you