building effective apache geode applications with spring data gemfire

Download Building Effective Apache Geode Applications with Spring Data GemFire

If you can't read please download the document

Upload: john-blum

Post on 12-Jan-2017

1.019 views

Category:

Technology


1 download

TRANSCRIPT

Slide 1

# 2014 Pivotal Software, Inc. All rights reserved.

#TITLEMonth Year

Building Effective Apache Geode Applications with Spring Data GemFireJohn Blum - @john_blum 2015 - Pivotal Software, Inc.

# 2014 Pivotal Software, Inc. All rights reserved.

# 2014 Pivotal Software, Inc. All rights reserved.Presenter

John BlumSpring Data GemFire Project LeadApache Geode CommitterGemFire Engineer/Technical Lead

Responsibilities

Management & Monitoring (Gfsh)Management REST APIDeveloper REST APISpring Data GemFire (v1.3.3 current)

# 2014 Pivotal Software, Inc. All rights reserved.

AgendaQuick Overview of Apache GeodeSpring Data GemFireConfiguration / BootstrappingData Access (DAO patterns)Function ExecutionCaching (JSR-107)ConclusionQA

# 2014 Pivotal Software, Inc. All rights reserved.Why Apache Geode?MotivationVolume of Data (Big Data)Rate of Data (Fast Data)Verity of Data (Data Accuracy)

Enables new and existing Java applications to operate at cloud-scale in a consistent, highly-available and predictable manner in order to transact and analyze big, fast data in real-time thereby achieving meaningful and impactful business results.

# 2014 Pivotal Software, Inc. All rights reserved.Key is to manage large quantities of data under extreme load with accuracy and resilience reliably.

Big Data == data lake (any and all data)Fast Data == processing streams of events in real-time

All about Data Access#TITLEMonth Year

What is Apache Geode?

A distributed, in-memory compute and data management platform that elastically scales to achieve high-throughput, low-latency access to big, fast data powering business critical, analytical applications in real-time. John Blum

Elastic capacity

+/-NodesOps / SecLinear scalabilityLatency optimizeddata distribution

# 2014 Pivotal Software, Inc. All rights reserved.Scale Out rather than Scale Up

Throughput (or number of operations) increases as more nodes are added to the cluster

Data is stored in distributed, highly-concurrent, in-memory data structures to minimize context switching and contentionData is replicated & partitioned for fast, predictable read/write throughput

#TITLEMonth Year

How Apache Geode Works?Stores data In-MemoryJVM Heap + Off-HeapFunctions as a Distributed System, In-Memory Data Grid (IMDG)Pools system resources across multiple nodes in a cluster to manage both application state and behaviorIncludes: Memory, CPU, Network & (optionally) Disk

# 2014 Pivotal Software, Inc. All rights reserved.In a nutshell under-the-hood Apache Geode is implemented

Stores data in-memory with puts.

Stores data to disk (synchronously (default) or asynchronously) on persistence and overflowOplogs are append-only; compaction is necessaryHDFS is new and Geode can feed Apache Spark processing streams.#TITLEMonth Year

Characteristics of Apache GeodeOpen SourceIn-MemoryDistributedScalable (scale-out)High Throughput & Low/Predictable LatencyHighly AvailableConsistentDurableFault Tolerant (resilient)Data-Aware / Parallel Compute

# 2014 Pivotal Software, Inc. All rights reserved.Apache Geode Use CasesPersistent, OLTP/OLAP Database (System of Record)JSR-107 Cache Provider (Key/Value Store)HTTP Session State ManagementDistributed L2 Caching for HibernateMemcached Server (Gemcached)Glorified version of ConcurrentHashMapMessage Bus with guaranteed message delivery

# 2014 Pivotal Software, Inc. All rights reserved.Spring Data GemFireFor Apache Geodehttp://projects.spring.io/spring-data-gemfire/

# 2014 Pivotal Software, Inc. All rights reserved.

# 2014 Pivotal Software, Inc. All rights reserved.Simple things should be simple; complex things should be possible Alan Kay

# 2014 Pivotal Software, Inc. All rights reserved.Misconceptions about Spring

Spring is a Web Application FrameworkSprings programming model is unique and Spring uses its own conventionsBuilt on fundamental OO principles (POJO)Software Design Patterns (IoC/DI, AOP) andOpen Standards (OSS)

Apache Geode is a complex technologyToo many configuration options and settings.Inconsistent behavior between XML configuration (i.e. cache.xml) and API.#TITLEMonth Year

Spring Data GemFire (SDG)Applies Spring's powerful, non-invasive programming model in a consistent fashion to simplify configuration and development of Apache Geode applications.Spring Ecosystem IntegrationSpring Cache Abstraction / Transaction ManagementSpring Data Commons + RESTSpring Integration (Inbound/Outbound Channel Adapters)Spring Session (coming soon)Spring XD (Sources & Sinks)

# 2014 Pivotal Software, Inc. All rights reserved.

++Apache Geode with Spring Data GemFire and Springs Cache Abstraction is a JSR-107 (JCache) caching provider

# 2014 Pivotal Software, Inc. All rights reserved.

GRAILSFull-stack, WebXDStream, Taps, Jobs

BOOTBootable, Minimal, Ops-Ready

Big, Fast, FlexibleData

Web, Integration,Batch

WEB

Controllers, REST,WebSocket

INTEGRATIONChannels, Adapters,Filters, Transformers

BATCHJobs, Steps,Readers, Writers

BIG DATAIngestion, Export,Orchestration, Hadoop

DATA

NON-RELATIONALRELATIONAL

COREGROOVYFRAMEWORK

SECURITY

REACTOR

# 2014 Pivotal Software, Inc. All rights reserved.Spring Data GemFire Use CasesConfigure & Bootstrap Apache GeodeReplacement for cache.xml; Can be used with Cluster ConfigurationBuild an Application Peer Cache (Cache)Embedded CacheBuild an Application Cache Client (ClientCache)Client/Server

# 2014 Pivotal Software, Inc. All rights reserved.Spring Data GemFire / Apache Geode Coordinates

spring-libs-snapshot Spring Maven libs-snapshot Repository https://repo.spring.io/libs-snapshot

org.springframework.data spring-data-gemfire 1.7.0.APACHE-GEODE-EA-SNAPSHOT

# 2014 Pivotal Software, Inc. All rights reserved.Spring-based ConfigurationXML

Java-based Configuration

# 2014 Pivotal Software, Inc. All rights reserved.Bootstrapping Apache Geode with Spring@SpringBootApplication@ImportResource("/spring-gemfire-context.xml")public class SpringGemFireApplication { public static void main(String[] args) { SpringApplication.run(SpringGemFireApplication.class, args); }}gfsh>start server -name=Example --spring-xml-location=

# 2014 Pivotal Software, Inc. All rights reserved.Example

# 2014 Pivotal Software, Inc. All rights reserved.Data Access with SpringBasic (Region) Data Access Object (DAO)@Repositorypublic class GolferDao extends DaoSupport {

@Resource(name = Golfers) private Region golfers;

}

# 2014 Pivotal Software, Inc. All rights reserved.Data Access with SDG GemfireTemplateAdvantagesSimple, Convenient Data Access API (CRUD, OQL, Function)Protects developer from GemFire/Geode API changes Exception Translation into Spring DAO Exception HierarchyTransaction Management

# 2014 Pivotal Software, Inc. All rights reserved.Data Access with Spring Data RepositoriesAdvantagesSimple, interface-based, Spring Data Repository definition (CRUD, Querying)Convention over Configuration (Querying)PortableException Translation & Transaction Management Supportpublic interface GolferRepository extends CrudRepository {

List findByName(String name);

}

# 2014 Pivotal Software, Inc. All rights reserved.Example

# 2014 Pivotal Software, Inc. All rights reserved.Annotation-based Function SupportSpring Data GemFire introduces annotation support for Function implementation and execution.Functions are implemented as POJO methodsFunctions are invoked using Object-Oriented method invocation.SDG supports@OnServer / @OnServers (from client only)@OnMember / @OnMembers (from peer only)@OnRegion (from either client or peer)

# 2014 Pivotal Software, Inc. All rights reserved.Annotation-based Function Implementationpackage example.app.function;

@Componentclass CustomerFunctions {

@GemfireFunction public Customer update(Address address, PhoneNumber phoneNumber) { }

@GemfireFunction(id = MyFunction HA=true) public List functionTwo(FunctionContext funcCtx, @Filter Set keys, ) { }

}

or -->

# 2014 Pivotal Software, Inc. All rights reserved.Annotation-based Function Executionpackage example.app.function.executions;

@OnRegion(Customers)interface CustomersFunctionExecution { Customer update(Address address, PhoneNumber phoneNumber);}

@Componentclass ApplicationComponent { @Autowired private CustomersFunctionExecution customersFunction;

public Customer someMethod(Address address, PhoneNumber phoneNumber) { return customersFunction.update(address, phoneNumber); }

# 2014 Pivotal Software, Inc. All rights reserved.Example

# 2014 Pivotal Software, Inc. All rights reserved.Spring Cache AbstractionCaching is useful in cases when an expensive operation (i.e. CPU, IO bound) produces the same output given identical input; results can be reused.Spring enables Declarative, Annotation-based Caching@Cacheable triggers cache population@CacheEvict triggers cache eviction@CachePut updates cache without interfering with method execution@Caching groups multiple cache operations per method@CacheConfig class-level cache-related settings

# 2014 Pivotal Software, Inc. All rights reserved.Spring Supports JSR-107 (JCache)SpringJCache@Cacheable@CacheResult@CachePut@CachePut@CacheEvict@CacheRemove@CacheEvict(allEntries=true)@CacheRemoveAll@CacheConfig@CacheDefaults

http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#cache-jsr-107

# 2014 Pivotal Software, Inc. All rights reserved.Apache Geode Caching Provider@Configuration@EnableCaching@Import(GemFireConfiguration.class)class ApplicationConfiguration {

@Bean public CacheManager cacheManager( Cache gemfireCache) {

GemfireCacheManager cacheManager = new GemfireCacheManager();

cacheManager.setCache(gemfireCache);

return cacheManager; }}