SlideShare a Scribd company logo
High Performance Cloud Native APIs
Using Apache Geode
Anna Jung Paul Vermeulen
1
@antheajung pvermeulen@pivotal.io
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
What is Cloud Native….
2
● Cloud-native is about how applications are created and deployed, not where
● 12 factor manifesto outlines rules/guidelines for building a cloud native apps
● Must be a micro-service
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Health Care Service Corporation
3
#6on Diversity MBA’s
50 Out Front for Diversity
Leadership Best Places to Work for Women
& Diverse Managers
Operating Blue Cross
and Blue Shield plans in
FIVE states: IL, MT,
NM, OK, TX
OUR PURPOSE
To do everything in our power to stand
with our members in sickness and in
health®
1936
year founded
+$1
billion
in IT
spend
Over
21,000
employees
15 million
members
2,100
IT employees
208.3million
claims processed
annually
LARGESTcustomer-
owned
health insurer in the U.S. and
4th largest overall
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Business Problem
4
● Inquiry Service and Not Information Service
● Heavy weight, Hard to use SOAP services
● Constraints with Performance and Scalability
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Architecture
5
Consumer
Consumer
Pivotal Cloud Foundry
Data Aware Functions
RESTful API
Pivotal Cloud Foundry
Micro-service is a collection of small services
- Implements business capabilities
- Runs in its own process space
- Communicates via HTTP API
- Deployed, upgrade, scaled and restarted independent of other services
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Why Pivotal Cloud Foundry?
6
Cloud Foundry’s architectural structure includes components and
a high-enough level of interoperability to permit
● Fast application development and deployment
● Continuous integration
● DevOps-friendly workflows
● Integration with various cloud providers
● Integration with Spring frameworks for developer productivity
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Why Apache Geode?
7
Apache Geode architecture provides low latency performance
and scalability at all levels
● Scalability of Geode cache
● Continuous availability of Geode
● High performance reads
● Caching patterns
● Supports cloning of micro-services for performance and scalability
● Provided isolation layer for making backing store changes
● Integration with Spring framework for developer productivity
Demo Overview
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Demo Overview
9
Client
● Act as independent client or Spring Boot
● REST API Controller
Server
● Client Function Provider
● Abstract Function Provider
● Function Test Setup
● Function Test
● Server-side Service Function
● Server-side Abstract Service Function
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
REST API Spring Boot Application
10
@SpringBootApplication
public class CustomerOrderClientApplication {
public static void main(String[] args) {
SpringApplication.run(CustomerOrderClientApplication.class, args);
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
REST API Controller
11
@RestController
public class CustomerOrderController {
@Autowired
private CustomerListProvider customerListProvider;
. . .
@GetMapping(value = "/customers")
public List<CustomerIO> customers() throws IOException {
return customerListProvider.execute();
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Client Function Provider
12
public class CustomerListProvider
extends AbstractProvider<String, CustomerIO> {
private static final String FUNCTION_NAME = "CustomerListFunction";
private static final String REGION_NAME = "customer";
public CustomerListProvider(GemFireCache cache) { super(cache); }
public Set<?> getFilters(String request) { return emptySet(); }
public String getRegionName() { return REGION_NAME; }
public String getFunctionId() { return FUNCTION_NAME; }
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Abstract Function Provider
13
public abstract class AbstractProvider<V, R> implements ServiceProvider<V, R> {
private GemFireCache cache;
private Provider provider;
AbstractProvider(GemFireCache cache, Provider provider) { . . . }
public Collection<R> execute() { . . . }
private Provider getProvider() { return this.provider; }
static class Provider {
Provider() { }
Execution getExecution(Region<?, ?> region) {
return FunctionService.onRegion(region);
}
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Function Test Setup
14
@RunWith(SpringRunner.class)
public class CustomerListFunctionTest {
@MockBean private GemFireCache cache;
@MockBean(name = "customer")
private Region<CustomerKey, Customer> customerRegion;
@Mock private RegionFunctionContext regionFunctionContext;
@Mock private QueryService queryService;
@Mock private Query query;
@Mock private SelectResults<Entry<CustomerKey, Customer>> results;
@Autowired private CustomerListFunction customerListFunction;
@Before public void setUp() throws Exception {
when(cache.getQueryService()).thenReturn(queryService);
when(queryService.newQuery(any())).thenReturn(query);
when(query.execute(regionFunctionContext)).thenReturn(results);
}
. . .
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Function Test
15
@Test
public void customerListFunction_returnsAllCustomers() {
ResultSender resultSender = mock(ResultSender.class);
when(regionFunctionContext.getResultSender()).thenReturn(resultSender);
when(results.asList()).thenReturn(getAllCustomers());
customerListFunction.processRequest(regionFunctionContext);
ArgumentCaptor<CustomerIO> captor =
ArgumentCaptor.forClass(CustomerIO.class);
verify(resultSender).lastResult(captor.capture());
CustomerIO customerIO = captor.getValue();
assertThat(customerIO.getId()).isEqualTo("customer1");
assertThat(customerIO.getName()).isEqualTo("Demo Person");
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Server-Side Service Function
16
public class CustomerListFunction extends AbstractServiceFunction {
@Autowired private GemFireCache cache;
@Resource(name = "customer")
private Region<CustomerKey, Customer> customerRegion;
. . .
@Override
protected void processRequest(RegionFunctionContext regionFunctionContext) {
String queryString = "SELECT * FROM /customer.entries entry";
Query query = cache.getQueryService().newQuery(queryString);
SelectResults<Entry<CustomerKey, Customer>> results =
query.execute(regionFunctionContext);
//iterate over query result set
regionFunctionContext.getResultSender().sendResult(customerIO);
. . .
regionFunctionContext.getResultSender().lastResult(customerIO);
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-
NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Server-Side Abstract Service Function
17
public abstract class AbstractServiceFunction implements Function, Declarable {
protected abstract void validateRequest(RegionFunctionContext var1);
protected abstract void processRequest(RegionFunctionContext var1);
public void execute(FunctionContext ctx) { . . . }
public String getId() { . . . }
public boolean hasResult() { . . . }
public boolean isHA() { . . . }
public boolean optimizeForWrite() { . . . }
}
Demo
Learn More. Stay Connected.
12/05 5:00pm Apache Geode Test Automation and Continuous Integration &
Deployment (CI-CD)
12/07 9:00am Main Stage Keynote by Mark Ardito
12/07 11:50am RDBMS and Apache Geode Data Movement
19
#springone@s1
p
Q & A

More Related Content

PDF
Serverless Spring
PPT
Java EE and Spring Side-by-Side
PPTX
What's new in Spring Boot 2.0
PDF
Modern web application development with java ee 7
PDF
Contributors Guide to the Jakarta EE 10 Galaxy
PPTX
Java EE vs Spring Framework
PPT
Testing Java EE Applications Using Arquillian
PDF
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...
Serverless Spring
Java EE and Spring Side-by-Side
What's new in Spring Boot 2.0
Modern web application development with java ee 7
Contributors Guide to the Jakarta EE 10 Galaxy
Java EE vs Spring Framework
Testing Java EE Applications Using Arquillian
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...

What's hot (18)

PDF
Java EE 8: On the Horizon
PPT
Reactive Java EE - Let Me Count the Ways!
PDF
MicroProfile for MicroServices
PPT
What's New in WebLogic 12.1.3 and Beyond
PDF
Spring Framework 5.2: Core Container Revisited
PDF
Utilizing JSF Front Ends with Microservices
PDF
Java on Azure
PDF
Java EE Revisits GoF Design Patterns
PPTX
Best Practices for JSF, Gameduell 2013
PPTX
Introduction to Spring Framework
PPT
Developing modular Java applications
PDF
jDays2015 - JavaEE vs. Spring Smackdown
PPTX
Jakarta EE: Today and Tomorrow
PPT
Have You Seen Java EE Lately?
PDF
Spring MVC 4.2: New and Noteworthy
KEY
Enterprise Java Web Application Frameworks Sample Stack Implementation
PDF
Finally, EE Security API JSR 375
PPT
JavaScript Frameworks and Java EE – A Great Match
Java EE 8: On the Horizon
Reactive Java EE - Let Me Count the Ways!
MicroProfile for MicroServices
What's New in WebLogic 12.1.3 and Beyond
Spring Framework 5.2: Core Container Revisited
Utilizing JSF Front Ends with Microservices
Java on Azure
Java EE Revisits GoF Design Patterns
Best Practices for JSF, Gameduell 2013
Introduction to Spring Framework
Developing modular Java applications
jDays2015 - JavaEE vs. Spring Smackdown
Jakarta EE: Today and Tomorrow
Have You Seen Java EE Lately?
Spring MVC 4.2: New and Noteworthy
Enterprise Java Web Application Frameworks Sample Stack Implementation
Finally, EE Security API JSR 375
JavaScript Frameworks and Java EE – A Great Match
Ad

Similar to High Performance Cloud Native APIs Using Apache Geode (20)

PPTX
Designing, Implementing, and Using Reactive APIs
PDF
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache Calcite
PDF
How to Architect and Develop Cloud Native Applications
PDF
Building .NET Microservices
PDF
Spring boot microservice metrics monitoring
PDF
Spring Boot - Microservice Metrics Monitoring
PDF
Spring 4.3-component-design
PPTX
Mean stack Magics
PDF
Cloud Native Java with Spring Cloud Services
PDF
Steeltoe: Develop .NET Microservices Without Cloud Platform Lock-In
PDF
MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...
PDF
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache Calcite
PDF
Consumer Driven Contracts and Your Microservice Architecture
PPTX
Consumer Driven Contracts and Your Microservice Architecture
PDF
Cassandra and DataStax Enterprise on PCF
PDF
P to V to C: The Value of Bringing “Everything” to Containers
PPTX
Serverless Spring 오충현
PDF
Building a Secure App with Google Polymer and Java / Spring
PPTX
Nyc mule soft_meetup_13_march_2021
PPTX
Developing Real-Time Data Pipelines with Apache Kafka
Designing, Implementing, and Using Reactive APIs
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache Calcite
How to Architect and Develop Cloud Native Applications
Building .NET Microservices
Spring boot microservice metrics monitoring
Spring Boot - Microservice Metrics Monitoring
Spring 4.3-component-design
Mean stack Magics
Cloud Native Java with Spring Cloud Services
Steeltoe: Develop .NET Microservices Without Cloud Platform Lock-In
MuleSoft Surat Virtual Meetup#16 - Anypoint Deployment Option, API and Operat...
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache Calcite
Consumer Driven Contracts and Your Microservice Architecture
Consumer Driven Contracts and Your Microservice Architecture
Cassandra and DataStax Enterprise on PCF
P to V to C: The Value of Bringing “Everything” to Containers
Serverless Spring 오충현
Building a Secure App with Google Polymer and Java / Spring
Nyc mule soft_meetup_13_march_2021
Developing Real-Time Data Pipelines with Apache Kafka
Ad

More from VMware Tanzu (20)

PDF
Spring into AI presented by Dan Vega 5/14
PDF
What AI Means For Your Product Strategy And What To Do About It
PDF
Make the Right Thing the Obvious Thing at Cardinal Health 2023
PPTX
Enhancing DevEx and Simplifying Operations at Scale
PDF
Spring Update | July 2023
PPTX
Platforms, Platform Engineering, & Platform as a Product
PPTX
Building Cloud Ready Apps
PDF
Spring Boot 3 And Beyond
PDF
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
PDF
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
PDF
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
PPTX
tanzu_developer_connect.pptx
PDF
Tanzu Virtual Developer Connect Workshop - French
PDF
Tanzu Developer Connect Workshop - English
PDF
Virtual Developer Connect Workshop - English
PDF
Tanzu Developer Connect - French
PDF
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
PDF
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
PDF
SpringOne Tour: The Influential Software Engineer
PDF
SpringOne Tour: Domain-Driven Design: Theory vs Practice
Spring into AI presented by Dan Vega 5/14
What AI Means For Your Product Strategy And What To Do About It
Make the Right Thing the Obvious Thing at Cardinal Health 2023
Enhancing DevEx and Simplifying Operations at Scale
Spring Update | July 2023
Platforms, Platform Engineering, & Platform as a Product
Building Cloud Ready Apps
Spring Boot 3 And Beyond
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
tanzu_developer_connect.pptx
Tanzu Virtual Developer Connect Workshop - French
Tanzu Developer Connect Workshop - English
Virtual Developer Connect Workshop - English
Tanzu Developer Connect - French
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: The Influential Software Engineer
SpringOne Tour: Domain-Driven Design: Theory vs Practice

Recently uploaded (20)

PPTX
A Presentation on Artificial Intelligence
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Encapsulation theory and applications.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
cuic standard and advanced reporting.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Electronic commerce courselecture one. Pdf
A Presentation on Artificial Intelligence
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Empathic Computing: Creating Shared Understanding
The Rise and Fall of 3GPP – Time for a Sabbatical?
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Encapsulation theory and applications.pdf
sap open course for s4hana steps from ECC to s4
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Big Data Technologies - Introduction.pptx
cuic standard and advanced reporting.pdf
The AUB Centre for AI in Media Proposal.docx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Machine learning based COVID-19 study performance prediction
Dropbox Q2 2025 Financial Results & Investor Presentation
Review of recent advances in non-invasive hemoglobin estimation
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Electronic commerce courselecture one. Pdf

High Performance Cloud Native APIs Using Apache Geode

  • 1. High Performance Cloud Native APIs Using Apache Geode Anna Jung Paul Vermeulen 1 @antheajung pvermeulen@pivotal.io
  • 2. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ What is Cloud Native…. 2 ● Cloud-native is about how applications are created and deployed, not where ● 12 factor manifesto outlines rules/guidelines for building a cloud native apps ● Must be a micro-service
  • 3. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Health Care Service Corporation 3 #6on Diversity MBA’s 50 Out Front for Diversity Leadership Best Places to Work for Women & Diverse Managers Operating Blue Cross and Blue Shield plans in FIVE states: IL, MT, NM, OK, TX OUR PURPOSE To do everything in our power to stand with our members in sickness and in health® 1936 year founded +$1 billion in IT spend Over 21,000 employees 15 million members 2,100 IT employees 208.3million claims processed annually LARGESTcustomer- owned health insurer in the U.S. and 4th largest overall
  • 4. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Business Problem 4 ● Inquiry Service and Not Information Service ● Heavy weight, Hard to use SOAP services ● Constraints with Performance and Scalability
  • 5. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Architecture 5 Consumer Consumer Pivotal Cloud Foundry Data Aware Functions RESTful API Pivotal Cloud Foundry Micro-service is a collection of small services - Implements business capabilities - Runs in its own process space - Communicates via HTTP API - Deployed, upgrade, scaled and restarted independent of other services
  • 6. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Why Pivotal Cloud Foundry? 6 Cloud Foundry’s architectural structure includes components and a high-enough level of interoperability to permit ● Fast application development and deployment ● Continuous integration ● DevOps-friendly workflows ● Integration with various cloud providers ● Integration with Spring frameworks for developer productivity
  • 7. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Why Apache Geode? 7 Apache Geode architecture provides low latency performance and scalability at all levels ● Scalability of Geode cache ● Continuous availability of Geode ● High performance reads ● Caching patterns ● Supports cloning of micro-services for performance and scalability ● Provided isolation layer for making backing store changes ● Integration with Spring framework for developer productivity
  • 9. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo Overview 9 Client ● Act as independent client or Spring Boot ● REST API Controller Server ● Client Function Provider ● Abstract Function Provider ● Function Test Setup ● Function Test ● Server-side Service Function ● Server-side Abstract Service Function
  • 10. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ REST API Spring Boot Application 10 @SpringBootApplication public class CustomerOrderClientApplication { public static void main(String[] args) { SpringApplication.run(CustomerOrderClientApplication.class, args); } }
  • 11. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ REST API Controller 11 @RestController public class CustomerOrderController { @Autowired private CustomerListProvider customerListProvider; . . . @GetMapping(value = "/customers") public List<CustomerIO> customers() throws IOException { return customerListProvider.execute(); } }
  • 12. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Client Function Provider 12 public class CustomerListProvider extends AbstractProvider<String, CustomerIO> { private static final String FUNCTION_NAME = "CustomerListFunction"; private static final String REGION_NAME = "customer"; public CustomerListProvider(GemFireCache cache) { super(cache); } public Set<?> getFilters(String request) { return emptySet(); } public String getRegionName() { return REGION_NAME; } public String getFunctionId() { return FUNCTION_NAME; } }
  • 13. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Abstract Function Provider 13 public abstract class AbstractProvider<V, R> implements ServiceProvider<V, R> { private GemFireCache cache; private Provider provider; AbstractProvider(GemFireCache cache, Provider provider) { . . . } public Collection<R> execute() { . . . } private Provider getProvider() { return this.provider; } static class Provider { Provider() { } Execution getExecution(Region<?, ?> region) { return FunctionService.onRegion(region); } } }
  • 14. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Function Test Setup 14 @RunWith(SpringRunner.class) public class CustomerListFunctionTest { @MockBean private GemFireCache cache; @MockBean(name = "customer") private Region<CustomerKey, Customer> customerRegion; @Mock private RegionFunctionContext regionFunctionContext; @Mock private QueryService queryService; @Mock private Query query; @Mock private SelectResults<Entry<CustomerKey, Customer>> results; @Autowired private CustomerListFunction customerListFunction; @Before public void setUp() throws Exception { when(cache.getQueryService()).thenReturn(queryService); when(queryService.newQuery(any())).thenReturn(query); when(query.execute(regionFunctionContext)).thenReturn(results); } . . . }
  • 15. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Function Test 15 @Test public void customerListFunction_returnsAllCustomers() { ResultSender resultSender = mock(ResultSender.class); when(regionFunctionContext.getResultSender()).thenReturn(resultSender); when(results.asList()).thenReturn(getAllCustomers()); customerListFunction.processRequest(regionFunctionContext); ArgumentCaptor<CustomerIO> captor = ArgumentCaptor.forClass(CustomerIO.class); verify(resultSender).lastResult(captor.capture()); CustomerIO customerIO = captor.getValue(); assertThat(customerIO.getId()).isEqualTo("customer1"); assertThat(customerIO.getName()).isEqualTo("Demo Person"); }
  • 16. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Server-Side Service Function 16 public class CustomerListFunction extends AbstractServiceFunction { @Autowired private GemFireCache cache; @Resource(name = "customer") private Region<CustomerKey, Customer> customerRegion; . . . @Override protected void processRequest(RegionFunctionContext regionFunctionContext) { String queryString = "SELECT * FROM /customer.entries entry"; Query query = cache.getQueryService().newQuery(queryString); SelectResults<Entry<CustomerKey, Customer>> results = query.execute(regionFunctionContext); //iterate over query result set regionFunctionContext.getResultSender().sendResult(customerIO); . . . regionFunctionContext.getResultSender().lastResult(customerIO); } }
  • 17. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Server-Side Abstract Service Function 17 public abstract class AbstractServiceFunction implements Function, Declarable { protected abstract void validateRequest(RegionFunctionContext var1); protected abstract void processRequest(RegionFunctionContext var1); public void execute(FunctionContext ctx) { . . . } public String getId() { . . . } public boolean hasResult() { . . . } public boolean isHA() { . . . } public boolean optimizeForWrite() { . . . } }
  • 18. Demo
  • 19. Learn More. Stay Connected. 12/05 5:00pm Apache Geode Test Automation and Continuous Integration & Deployment (CI-CD) 12/07 9:00am Main Stage Keynote by Mark Ardito 12/07 11:50am RDBMS and Apache Geode Data Movement 19 #springone@s1 p
  • 20. Q & A