java ee and nosql using jboss eap 7 and openshift

Post on 13-Feb-2017

805 Views

Category:

Technology

4 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Java  EE  and  NoSQL  using  

JBoss  EAP  7  and  

OpenShiftArun Gupta, @arungupta

Matt Ingenthron, @ingenthr

• Java EE 7 and Java SE 8

• Optimized for containers & cloud

• Enhanced admin & monitoring

• DevOps productivity

DEVELOPER PRODUCTIVITY

MEETING ENTERPRISE DEMANDS

Java EE 7

!  Batch !  Concurrency !  Simplified JMS

!  More annotated POJOs !  Less boilerplate code !  Cohesive integrated

platform !  WebSockets !  JSON !  Servlet 3.1 NIO !  REST

Top 10 Java EE 7 features• WebSocket endpoints

• Batch Applications

• JSON Processing

• Concurrency Utilities

• Simplified JMS API

• Transactions in POJO

• JAX-RS Client API

• Default Resources

• More annotated POJOs

• Faces Flow

Optimized for Container & Clouds• Low-memory footprint, faster startup and higher density

• OpenShift Container support

• Highly scalable Web Server (Undertow)

• Non/blocking I/O

• Port reduction

• HTTP/2, WebSockets, …

Enhanced Admin & Monitoring• Faster, simpler, intuitive web console

• Powerful CLI

• Server suspend/Graceful shutdown

Types of NoSQL databases

• Key/Value

• Document

• Graph

• Columnar

NoSQL Databases: Key-Value

Key Value

Email devadvocates@couchbase.com

Profile { “name”: “Bob”, “location”: “Mountain View, CA”}

Logo

NoSQL Databases - Document

{ “name”: “Erlich”, “location”: “Mountain View, CA”, “like”: [ “running”, “reading”, “music” ]}

{ “name”: “Gilfoyle”, “location”: “Mountain View, CA”, “like”: [ “running”, “reading”, “music” ]}

{ “name”: “Dinesh”, “location”: “Mountain View, CA”, “like”: [ “running”, “reading”, “music” ]}

{ “name”: “Richard”, “location”: “Silicon Valley”, “like”: [ “running”, “reading”, “music” ]}

NoSQL Databases - Columnar

Row Column1

JK Rowling

Harry Potter and the Philosopher’s

Stone

Column2

Author Title Year of Release

Harry Potter and the Chamber of Secrets

Harry Potter and the NoSQL Journey

1997

1998

2016

NoSQL Databases - Graph

Richard Hendricks

Pied Piper

Erlich Bachman

Houseownsworks

founded part-owner

friends

©2016  Couchbase  Inc.

NoSQL  catalog

12

Key-Value

Memcached

Cac

he

(mem

ory

only

)D

atab

ase

(mem

ory/

disk

)

Redis

Data Structure

Riak

Couchbase

MongoDB

Document Column

Cassandra

Graph

Neo4j

HBase InfiniteGraph

Coherence

Membase

©2016  Couchbase  Inc.

What  is  Couchbase?

13

Managed'Cache Key-Value'Store Document'Database Embedded'Database Sync'Management

©2016  Couchbase  Inc.

Couchbase  Developer

14

©2016  Couchbase  Inc.

Couchbase  and  BigData

15

©2016  Couchbase  Inc.

Cross-­‐data  Center  Replication  (XDCR)

16

©2016  Couchbase  Inc.

▪Declarative query language that extends SQL for JSON

▪SELECT, INSERT, UPDATE, DELETE, MERGE, EXPLAIN

▪Sort, filter, transform, group, and combine/join data

▪Query data via language integration

17

©2016  Couchbase  Inc.

▪JSON documents – Rich structure – Structure evolution

▪SQL – General query functionality – Query across relationships

▪Why N1QL? – Developers already know SQL – No need for complex query frameworks

18

©2016  Couchbase  Inc.

SELECT name, code FROM `beer-sample` WHERE city = 'San Francisco' AND type = 'brewery';

19

SELECT DISTINCT brewery_id FROM `beer-sample` WHERE brewery_id IS NOT MISSING ORDER BY brewery_idLIMIT 5;

©2016  Couchbase  Inc.

Couchbase  Java  SDK//connect to the clusterCouchbaseCluster cluster = CouchbaseCluster.create("localhost");

//open a bucketBucket bucket = cluster.openBucket(“bucket", "password");

//create JSON and a documentJsonObject json = JsonObject.create().put("name", "John");JsonDocument doc = JsonDocument.create("key1", json);

//store the documentbucket.insert(doc);

20

©2016  Couchbase  Inc.

Access  NoSQL  using  JDBC▪JDBC driver for accessing Couchbase ▪Run N1QL queries ▪Get JSON data through standard JDBC interfaces ▪JSON types supported

– Simple values (string, numbers, boolean, …) – Compound (objects, arrays, …)

▪Users – BI/ETL Tools (Tableau, Informatica, …) – Persistence providers (EclipseLink, Hibernate, …)

▪github.com/jdbc-json/jdbc-cb21

©2016  Couchbase  Inc.

Getting  Started  with  JDBC  Driver

<dependency>

<groupId>com.couchbase.jdbc</groupId>

<artifactId>jdbc-n1ql</artifactId>

<version>1.0-BETA</version>

</dependency>

22

©2016  Couchbase  Inc.

Accessing  Couchbase  using  JDBCpackage com.couchbase.jdbc.examples;

import java.sql.*;

public class SimpleVerification {

public static void main(String[] args) throws Exception {

Connection con = DriverManager.getConnection("jdbc:couchbase://localhost:8093");

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("select name, code from `beer-sample` " +

"where city = 'San Francisco' and type = 'brewery'");

while (rs.next()) {

String name = rs.getString("name");

String code = rs.getString("code");

System.out.println("name: " + name + ", code: " + code);

}

}

}

23

©2016  Couchbase  Inc.

Hibernate  OGM

▪Power and simplicity of JPA for NoSQL databases ▪Currently supported

– Key/value: Infinispan, Ehcache – Document: MongoDB, Couchbase – Graph: Neo4J

▪hibernate.org/ogm

24

Community Powered Innovation

OpenShift 3

©2016  Couchbase  Inc. 28

©2016  Couchbase  Inc.

▪Technical readiness for OpenShift

▪First and only NoSQL database primed for OpenShift

29

©2016  Couchbase  Inc.

OpenShift  All-­‐in-­‐One  VM

30

©2016  Couchbase  Inc. 31

©2016  Couchbase  Inc. 32

©2016  Couchbase  Inc.

WildFly  Swarm

▪Package and run Java EE applications ▪Just enough of the server runtime ▪Creates an über JAR ▪Integrated stack

– Single sign-on using Keycloak – Monitoring using Hawkular – Swagger – Netflix OSS stack - Hystrix, Turbine, …

33

©2016  Couchbase  Inc.

Java  EE  Microservices  Stack

34

https://github.com/arun-gupta/wildfly-swarm-couchbase

©2016  Couchbase  Inc. 35

@Path("airline")public class AirlineResource { @Inject Database database; @GET public String getAll() { N1qlQuery query = N1qlQuery.simple("SELECT * FROM `travel-sample` LIMIT 10"); N1qlQueryResult result = database.getBucket().query(query); return result.allRows().toString(); }}

@Singleton@Startuppublic class Database { CouchbaseCluster cluster; public CouchbaseCluster getCluster() { return CouchbaseCluster.create(“localhost”); } public Bucket getBucket() { return getCluster().openBucket("travel-sample"); }}

©2016  Couchbase  Inc.

Demo36

©2016  Couchbase  Inc.

References

▪JBoss EAP: jboss.org/products/eap ▪OpenShift: openshift.com ▪Getting Started with NoSQL: couchbase.com/get-started-developing-nosql ▪Couchbase Developer Portal: developer.couchbase.com ▪N1QL interactive tutorial: query.pub.couchbase.com/tutorial/

37

©2016  Couchbase  Inc.

top related