Simplifying Apache Geode
with Spring Data
By John Blum
@john_blum
1
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
History
April 2015
SD GemFire 1.7
Branch for
*Apache Geode
June 2015
1.7.0.APACHE-
GEODE-EA-M1
1.0.0-
incubating.M1
April 2016
1.0.0.APACHE-
GEODE-
INCUBATING-M2
1.0.0-
incubating.M2
October 2016
1.0.0.APACHE-
GEODE-
INCUBATING-M3
1.0.0-
incubating.M3
November 2016
1.0.0.APACHE-
GEODE-
INCUBATING-
RELEASE
*1.0.0-incubating
April 2017
SD Geode Kay
2.0.x
1.2.1
2
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
3
Spring Data for
Apache Geode
Kay
“Simple things should be simple;
complex things should be possible”
– Alan Kay
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Core Themes in SDG - 2017
 Get Up & Running as Quickly and Easily as possible
 Using
 Make the Journey to the Cloud as Simple as possible
 On
5
Spring
Data
Blog Post: $ diff –q spring-data-gemfire spring-data-geode
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-gemfire</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-geode</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
6
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Data Geode 2.0 (Kay)
Apache Geode 1.2.1
7
Spring Data GemFire 2.0 (Kay)
Pivotal GemFire 9.1.1
Apache Geode 1.2.1
Kay
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
8
Spring
Cloud
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
How does it work?
New Annotation-based Configuration
 Convention over Configuration
 Use sensible defaults for all configuration parameters OOTB
 Enable users to get up and running, quickly and easily (no hassle).
 Allow user to override and customize the default, provided configuration
https://docs.spring.io/spring-data/geode/docs/current/reference/html/#bootstrap-annotation-config
9
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
@Demo
11
https://docs.spring.io/spring-data/geode/docs/current/reference/html/#bootstrap-annotation-config
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Client Annotations
14
@SpringBootApplication
@ClientCacheApplication
public class MySpringBootApacheGeodeClient { .. }
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Client Annotations: Pools
15
@SpringBootApplication
@ClientCacheApplication
@EnablePools(pools = { @EnablePool(host = “hostname”, port = 1234), … })
public class MySpringBootApacheGeodeClient { .. }
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Client Annotations: Entity-defined Regions
16
@SpringBootApplication
@ClientCacheApplication
@EnableGemfireRepositories(basePackageClasses = EntityRepository.class)
@EnableEntityDefinedRegions(basePackageClasses = EntityType.class)
@EnableIndexing(..)
public class MySpringBootApacheGeodeClient { .. }
@Region(name = “Customers”)
class Customer {
@Id Long id;
@Indexed(..) String name;
@LuceneIndexed(..) String title;
}
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Client Annotations: Caching-defined Regions
17
@SpringBootApplication
@ClientCacheApplication
@EnableGemfireCaching
@EnableCachingDefinedRegions(..)
public class MySpringBootApacheGeodeClient { .. }
@Service
class CustomerService {
@Cacheable(“Accounts”)
Account getAccount(Customer customer) { .. }
}
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Client Annotations: Cluster Configuration*
18
@SpringBootApplication
@ClientCacheApplication
@EnableClusterConfiguration(useHttp = true)
public class MySpringBootApacheGeodeClient { .. }
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Client Annotations: CQ
19
@SpringBootApplication
@ClientCacheApplication
@EnableContinuousQueries(..)
public class MySpringBootApacheGeodeClient { .. }
@Service
class CustomerService {
@ContinuousQuery(name = “CreditScoreUpdates”,
query = “SELECT * FROM /Customers WHERE …”)
void creditScoreChange(CqEvent event) { .. }
}
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Client Annotations: Serialization
20
@SpringBootApplication
@ClientCacheApplication
@EnablePdx(..)
public class MySpringBootApacheGeodeClient { .. }
Registers the SDG o.s.d.g.mapping.MappingPdxSerializer by default
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Client Annotations: Security
21
@SpringBootApplication
@ClientCacheApplication
@EnableSecurity(..)
@EnableSsl(..)
public class MySpringBootApacheGeodeClient { .. }
# application.properties
spring.data.gemfire.security.username = jblum
spring.data.gemfire.security.password = secret
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Client Annotations: Other
22
@SpringBootApplication
@ClientCacheApplication
@EnableGemFireProperties(..)
@EnableLogging(logLevel = “info”, …)
public class MySpringBootApacheGeodeClient { .. }
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Server Annotations
24
@SpringBootApplication
@CacheServerApplication(name = “MySpringBootApacheGeodeServer”)
public class MySpringBootApacheGeodeServer { .. }
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Server Annotations: CacheServers
25
@SpringBootApplication
@CacheServerApplication(name = “MySpringBootApacheGeodeServer”)
@EnableCacheServers(servers = { @EnableCacheServer(..), … })
public class MySpringBootApacheGeodeServer { .. }
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Server Annotations: Processes
26
@SpringBootApplication
@CacheServerApplication(name = “MySpringBootApacheGeodeServer”)
@EnableLocator(port = 11235)
@EnableManager(port = 1199)
public class MySpringBootApacheGeodeServer { .. }
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Server Annotations: Services
27
@SpringBootApplication
@CacheServerApplication(name = “MySpringBootApacheGeodeServer”)
@EnableHttpService(..)
@EnableMemcachedServer(..)
@EnableRedisServer(..)
public class MySpringBootApacheGeodeServer { .. }
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Server Annotations: Regions
28
@SpringBootApplication
@CacheServerApplication(name = “MySpringBootApacheGeodeServer”)
@EnableCompression(..)
@EnableDiskStores(diskStores = { @EnableDiskStore(..), … })
@EnableEntityDefinedRegions(basePackageClasses = EntityType.class)
@EnableEviction(..)
@EnableExpiration(..)
@EnableOffHeap(memorySize = “1024g”)
public class MySpringBootApacheGeodeServer { .. }
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Server Annotations: Expiration
29
@SpringBootApplication
@CacheServerApplication(name = “MySpringBootApacheGeodeServer”)
@EnableExpiration(..)
…
public class MySpringBootApacheGeodeServer { .. }
@Region(”Customers”)
@TimeToLiveExpiration(timeout = “600”, action = “LOCAL_DESTROY”)
@IdleTimeoutExpiration(timeout = “120”, action = “INVALIDATE”)
@Expiration(..)
class Customer { .. }
https://docs.spring.io/spring-data/geode/docs/current/reference/html/#bootstrap-annotation-config-region-expiration
https://docs.spring.io/spring-data/geode/docs/current/reference/html/#bootstrap:region:expiration:annotation
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Server Annotations: Security
30
@SpringBootApplication
@CacheServerApplication(name = “MySpringBootApacheGeodeServer”)
@EnableSecurity(..)
@EnableSsl(..)
public class MySpringBootApacheGeodeServer {
@Bean
AuthorizingRealm ldapRealm(LdapContextFactory contextFactory) {
DefaultLdapRealm ldapRealm = new DefaultLdapRealm();
ldapRealm.setContextFactory(contextFactory);
return ldapRealm;
}
https://spring.io/blog/2016/11/10/spring-data-geode-1-0-0-incubating-release-released#apache-shiro-realms
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Server Annotations: Other
31
@SpringBootApplication
@CacheServerApplication(name = “MySpringBootApacheGeodeServer”)
@EnableGemFireProperties(remoteLocators = “..”, …)
@EnableLogging(logLevel = “warning”, …)
@EnableStatistics(..)
public class MySpringBootApacheGeodeServer { .. }
Configuration @Runtime
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Annotations: Properties Configuration
33
@SpringBootApplication
@ClientCacheApplication(locators = {
@Locator(host = “HostnameOne”, port = 1111),
@Locator(host = “HostnameTwo”, port = 2222),
…
})
public class MySpringBootApacheGeodeClient { .. }
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Annotations: Properties Configuration
34
@SpringBootApplication
@ClientCacheApplication
public class MySpringBootApacheGeodeClient { .. }
# application.properties
spring.data.gemfire.pool.locators=HostnameOne[1111],HostnameTwo[2222], …
spring.data.gemfire.pool.default.locators=…
spring.data.gemfire.pool.swimming.locators=…
…
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Annotations: Properties Configuration
35
public @interface ClientCacheApplication {
/**
* Configures the GemFire {@link org.apache.geode.distributed.Locator Locators} to which
* this cache client will connect.
*
* Use either the {@literal spring.data.gemfire.pool.default.locators} property
* or the {@literal spring.data.gemfire.pool.locators} property in {@literal application.properties}.
*/
Locator[] locators() default {};
…
}
https://docs.spring.io/spring-data/geode/docs/current/api/org/springframework/data/gemfire/config/annotation/ClientCacheApplication.html
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Annotations: Configurers
36
@SpringBootApplication
@ClientCacheApplication
public class MySpringBootApacheGeodeClient {
@Bean
ClientCacheConfigurer locatorsConfigurer(
@Value(“${geode.locators.hostsPorts:localhost[10334]}”)
String hostsPorts) {
return (beanName, clientCacheFactoryBean) ->
clientCacheFactoryBean.setLocators(
ConnectionEndpointList.parse(10334, hostsPorts));
}
}
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
What’s Next?
• Function Executions from Repository
• Paging support in Repository
• Query Projections
• Reactive Repository extensions for CQ
• Spring Security support
• Annotation support for CacheCallbacks
• Auto-generated IDs (Region keys)
• New Spring-driven Test (Context) Framework
37
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Function Executions from Repository
38
public interface CustomerRepository
implements CrudRepository<Customer, Long> {
@Function(..)
CreditScore calculateCreditScore(Customer customer);
}
Customer jonDoe = …
CreditScore creditScore = customerRepository.calculateCreditScore(jonDoe);
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Paging (& Sorting) Support
39
public interface CustomerRepository
implements CrudRepository<Customer, Long> {
List<Customer> findByLastNameOrderByCustomerFirstNameAsc(
String firstName);
List<Customer> findByLastName(String lastName, Sort sort);
// NEW!
Page<Customer> findTop100ByCreditScoreGreaterThan(CreditScore score,
Pageable pageable);
}
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Query Projections (DTO)
40
public interface CustomerRepository
implements CrudRepository<Customer, Long> {
Iterable<CustomerNameProjection> findByLastName(String lastName);
}
@Region(“Customers”)
class Customer {
@Id Long id;
String firstName, lastName;
String getName() {
return String.format(“%1$s %2$s”,
firstName, lastName);
}
class CustomerNameProjection {
String name;
}
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Reactive Repository Extensions for CQ
41
public interface CustomerRepository
implements CrudRepository<Customer, Long> {
@ContinuousQuery(..)
Flux<Customer> findByCreditScoreGreaterThanAndCreditScoreLessThan(
CreditScore low, CreditScore high);
}
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Annotation-based CacheCallbacks Support
42
@Component
public class MyCallbacks {
@CacheListener(regions = { “Customers”, “Accounts” })
public <K, V> void afterCreate(EntryEvent<K, V> event) { .. }
@CacheWriter(region = “Customers”)
public <K, V> void beforeCreate(EntryEvent(K, V> event) { .. }
. . .
}
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Unit Testing Apache Geode with Spring
With Integration Testing support in-progress…
@TestDemo
43
https://github.com/jxblum/spring-data-tests-4-gemfire
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Data Geode 2.1 (Lovelace)
Apache Geode 1.3.0
44
Spring Data GemFire 2.1 (Lovelace)
Pivotal GemFire 9.2.0
Apache Geode 1.3.0
Unless otherwise indicated, these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
References
• Reference Documentation: https://docs.spring.io/spring-data/geode/docs/current/reference/html/
• Javadoc: https://docs.spring.io/spring-data/geode/docs/current/api/
• GitHub: https://github.com/spring-projects/spring-data-geode
• JIRA: https://jira.spring.io/browse/DATAGEODE
• StackOverflow: https://stackoverflow.com/questions/tagged/spring-data-gemfire
• Presentation Examples: https://github.com/jxblum/simple-spring-geode-application
• Examples: https://github.com/jxblum/contacts-application
Me: @john_blum (Twitter) https://spring.io/team/jxblum (GitHub)
Questions
Answers
47© 2014 Pivotal Software, Inc. All rights reserved.
Thank You
Learn More. Stay Connected.
Refactoring to a System of Systems - Oliver Gierke
Thursday @ 11:50 AM – Room #2008
48
#springone@s1p

Simplifying Apache Geode with Spring Data

  • 1.
    Simplifying Apache Geode withSpring Data By John Blum @john_blum 1
  • 2.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ History April 2015 SD GemFire 1.7 Branch for *Apache Geode June 2015 1.7.0.APACHE- GEODE-EA-M1 1.0.0- incubating.M1 April 2016 1.0.0.APACHE- GEODE- INCUBATING-M2 1.0.0- incubating.M2 October 2016 1.0.0.APACHE- GEODE- INCUBATING-M3 1.0.0- incubating.M3 November 2016 1.0.0.APACHE- GEODE- INCUBATING- RELEASE *1.0.0-incubating April 2017 SD Geode Kay 2.0.x 1.2.1 2
  • 3.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 3 Spring Data for Apache Geode Kay
  • 4.
    “Simple things shouldbe simple; complex things should be possible” – Alan Kay
  • 5.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Core Themes in SDG - 2017  Get Up & Running as Quickly and Easily as possible  Using  Make the Journey to the Cloud as Simple as possible  On 5 Spring Data Blog Post: $ diff –q spring-data-gemfire spring-data-geode
  • 6.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-gemfire</artifactId> <version>2.0.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-geode</artifactId> <version>2.0.2.RELEASE</version> </dependency> 6
  • 7.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Geode 2.0 (Kay) Apache Geode 1.2.1 7 Spring Data GemFire 2.0 (Kay) Pivotal GemFire 9.1.1 Apache Geode 1.2.1 Kay
  • 8.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 8 Spring Cloud
  • 9.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ How does it work? New Annotation-based Configuration  Convention over Configuration  Use sensible defaults for all configuration parameters OOTB  Enable users to get up and running, quickly and easily (no hassle).  Allow user to override and customize the default, provided configuration https://docs.spring.io/spring-data/geode/docs/current/reference/html/#bootstrap-annotation-config 9
  • 10.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ @Demo 11 https://docs.spring.io/spring-data/geode/docs/current/reference/html/#bootstrap-annotation-config
  • 11.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Client Annotations 14 @SpringBootApplication @ClientCacheApplication public class MySpringBootApacheGeodeClient { .. }
  • 12.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Client Annotations: Pools 15 @SpringBootApplication @ClientCacheApplication @EnablePools(pools = { @EnablePool(host = “hostname”, port = 1234), … }) public class MySpringBootApacheGeodeClient { .. }
  • 13.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Client Annotations: Entity-defined Regions 16 @SpringBootApplication @ClientCacheApplication @EnableGemfireRepositories(basePackageClasses = EntityRepository.class) @EnableEntityDefinedRegions(basePackageClasses = EntityType.class) @EnableIndexing(..) public class MySpringBootApacheGeodeClient { .. } @Region(name = “Customers”) class Customer { @Id Long id; @Indexed(..) String name; @LuceneIndexed(..) String title; }
  • 14.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Client Annotations: Caching-defined Regions 17 @SpringBootApplication @ClientCacheApplication @EnableGemfireCaching @EnableCachingDefinedRegions(..) public class MySpringBootApacheGeodeClient { .. } @Service class CustomerService { @Cacheable(“Accounts”) Account getAccount(Customer customer) { .. } }
  • 15.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Client Annotations: Cluster Configuration* 18 @SpringBootApplication @ClientCacheApplication @EnableClusterConfiguration(useHttp = true) public class MySpringBootApacheGeodeClient { .. }
  • 16.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Client Annotations: CQ 19 @SpringBootApplication @ClientCacheApplication @EnableContinuousQueries(..) public class MySpringBootApacheGeodeClient { .. } @Service class CustomerService { @ContinuousQuery(name = “CreditScoreUpdates”, query = “SELECT * FROM /Customers WHERE …”) void creditScoreChange(CqEvent event) { .. } }
  • 17.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Client Annotations: Serialization 20 @SpringBootApplication @ClientCacheApplication @EnablePdx(..) public class MySpringBootApacheGeodeClient { .. } Registers the SDG o.s.d.g.mapping.MappingPdxSerializer by default
  • 18.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Client Annotations: Security 21 @SpringBootApplication @ClientCacheApplication @EnableSecurity(..) @EnableSsl(..) public class MySpringBootApacheGeodeClient { .. } # application.properties spring.data.gemfire.security.username = jblum spring.data.gemfire.security.password = secret
  • 19.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Client Annotations: Other 22 @SpringBootApplication @ClientCacheApplication @EnableGemFireProperties(..) @EnableLogging(logLevel = “info”, …) public class MySpringBootApacheGeodeClient { .. }
  • 20.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Server Annotations 24 @SpringBootApplication @CacheServerApplication(name = “MySpringBootApacheGeodeServer”) public class MySpringBootApacheGeodeServer { .. }
  • 21.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Server Annotations: CacheServers 25 @SpringBootApplication @CacheServerApplication(name = “MySpringBootApacheGeodeServer”) @EnableCacheServers(servers = { @EnableCacheServer(..), … }) public class MySpringBootApacheGeodeServer { .. }
  • 22.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Server Annotations: Processes 26 @SpringBootApplication @CacheServerApplication(name = “MySpringBootApacheGeodeServer”) @EnableLocator(port = 11235) @EnableManager(port = 1199) public class MySpringBootApacheGeodeServer { .. }
  • 23.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Server Annotations: Services 27 @SpringBootApplication @CacheServerApplication(name = “MySpringBootApacheGeodeServer”) @EnableHttpService(..) @EnableMemcachedServer(..) @EnableRedisServer(..) public class MySpringBootApacheGeodeServer { .. }
  • 24.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Server Annotations: Regions 28 @SpringBootApplication @CacheServerApplication(name = “MySpringBootApacheGeodeServer”) @EnableCompression(..) @EnableDiskStores(diskStores = { @EnableDiskStore(..), … }) @EnableEntityDefinedRegions(basePackageClasses = EntityType.class) @EnableEviction(..) @EnableExpiration(..) @EnableOffHeap(memorySize = “1024g”) public class MySpringBootApacheGeodeServer { .. }
  • 25.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Server Annotations: Expiration 29 @SpringBootApplication @CacheServerApplication(name = “MySpringBootApacheGeodeServer”) @EnableExpiration(..) … public class MySpringBootApacheGeodeServer { .. } @Region(”Customers”) @TimeToLiveExpiration(timeout = “600”, action = “LOCAL_DESTROY”) @IdleTimeoutExpiration(timeout = “120”, action = “INVALIDATE”) @Expiration(..) class Customer { .. } https://docs.spring.io/spring-data/geode/docs/current/reference/html/#bootstrap-annotation-config-region-expiration https://docs.spring.io/spring-data/geode/docs/current/reference/html/#bootstrap:region:expiration:annotation
  • 26.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Server Annotations: Security 30 @SpringBootApplication @CacheServerApplication(name = “MySpringBootApacheGeodeServer”) @EnableSecurity(..) @EnableSsl(..) public class MySpringBootApacheGeodeServer { @Bean AuthorizingRealm ldapRealm(LdapContextFactory contextFactory) { DefaultLdapRealm ldapRealm = new DefaultLdapRealm(); ldapRealm.setContextFactory(contextFactory); return ldapRealm; } https://spring.io/blog/2016/11/10/spring-data-geode-1-0-0-incubating-release-released#apache-shiro-realms
  • 27.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Server Annotations: Other 31 @SpringBootApplication @CacheServerApplication(name = “MySpringBootApacheGeodeServer”) @EnableGemFireProperties(remoteLocators = “..”, …) @EnableLogging(logLevel = “warning”, …) @EnableStatistics(..) public class MySpringBootApacheGeodeServer { .. }
  • 28.
  • 29.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Annotations: Properties Configuration 33 @SpringBootApplication @ClientCacheApplication(locators = { @Locator(host = “HostnameOne”, port = 1111), @Locator(host = “HostnameTwo”, port = 2222), … }) public class MySpringBootApacheGeodeClient { .. }
  • 30.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Annotations: Properties Configuration 34 @SpringBootApplication @ClientCacheApplication public class MySpringBootApacheGeodeClient { .. } # application.properties spring.data.gemfire.pool.locators=HostnameOne[1111],HostnameTwo[2222], … spring.data.gemfire.pool.default.locators=… spring.data.gemfire.pool.swimming.locators=… …
  • 31.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Annotations: Properties Configuration 35 public @interface ClientCacheApplication { /** * Configures the GemFire {@link org.apache.geode.distributed.Locator Locators} to which * this cache client will connect. * * Use either the {@literal spring.data.gemfire.pool.default.locators} property * or the {@literal spring.data.gemfire.pool.locators} property in {@literal application.properties}. */ Locator[] locators() default {}; … } https://docs.spring.io/spring-data/geode/docs/current/api/org/springframework/data/gemfire/config/annotation/ClientCacheApplication.html
  • 32.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Annotations: Configurers 36 @SpringBootApplication @ClientCacheApplication public class MySpringBootApacheGeodeClient { @Bean ClientCacheConfigurer locatorsConfigurer( @Value(“${geode.locators.hostsPorts:localhost[10334]}”) String hostsPorts) { return (beanName, clientCacheFactoryBean) -> clientCacheFactoryBean.setLocators( ConnectionEndpointList.parse(10334, hostsPorts)); } }
  • 33.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ What’s Next? • Function Executions from Repository • Paging support in Repository • Query Projections • Reactive Repository extensions for CQ • Spring Security support • Annotation support for CacheCallbacks • Auto-generated IDs (Region keys) • New Spring-driven Test (Context) Framework 37
  • 34.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Function Executions from Repository 38 public interface CustomerRepository implements CrudRepository<Customer, Long> { @Function(..) CreditScore calculateCreditScore(Customer customer); } Customer jonDoe = … CreditScore creditScore = customerRepository.calculateCreditScore(jonDoe);
  • 35.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Paging (& Sorting) Support 39 public interface CustomerRepository implements CrudRepository<Customer, Long> { List<Customer> findByLastNameOrderByCustomerFirstNameAsc( String firstName); List<Customer> findByLastName(String lastName, Sort sort); // NEW! Page<Customer> findTop100ByCreditScoreGreaterThan(CreditScore score, Pageable pageable); }
  • 36.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Query Projections (DTO) 40 public interface CustomerRepository implements CrudRepository<Customer, Long> { Iterable<CustomerNameProjection> findByLastName(String lastName); } @Region(“Customers”) class Customer { @Id Long id; String firstName, lastName; String getName() { return String.format(“%1$s %2$s”, firstName, lastName); } class CustomerNameProjection { String name; }
  • 37.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Reactive Repository Extensions for CQ 41 public interface CustomerRepository implements CrudRepository<Customer, Long> { @ContinuousQuery(..) Flux<Customer> findByCreditScoreGreaterThanAndCreditScoreLessThan( CreditScore low, CreditScore high); }
  • 38.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Annotation-based CacheCallbacks Support 42 @Component public class MyCallbacks { @CacheListener(regions = { “Customers”, “Accounts” }) public <K, V> void afterCreate(EntryEvent<K, V> event) { .. } @CacheWriter(region = “Customers”) public <K, V> void beforeCreate(EntryEvent(K, V> event) { .. } . . . }
  • 39.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Unit Testing Apache Geode with Spring With Integration Testing support in-progress… @TestDemo 43 https://github.com/jxblum/spring-data-tests-4-gemfire
  • 40.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Geode 2.1 (Lovelace) Apache Geode 1.3.0 44 Spring Data GemFire 2.1 (Lovelace) Pivotal GemFire 9.2.0 Apache Geode 1.3.0
  • 41.
    Unless otherwise indicated,these slides are © 2013 -2016 Piv otal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ References • Reference Documentation: https://docs.spring.io/spring-data/geode/docs/current/reference/html/ • Javadoc: https://docs.spring.io/spring-data/geode/docs/current/api/ • GitHub: https://github.com/spring-projects/spring-data-geode • JIRA: https://jira.spring.io/browse/DATAGEODE • StackOverflow: https://stackoverflow.com/questions/tagged/spring-data-gemfire • Presentation Examples: https://github.com/jxblum/simple-spring-geode-application • Examples: https://github.com/jxblum/contacts-application Me: @john_blum (Twitter) https://spring.io/team/jxblum (GitHub)
  • 42.
  • 43.
    47© 2014 PivotalSoftware, Inc. All rights reserved. Thank You
  • 44.
    Learn More. StayConnected. Refactoring to a System of Systems - Oliver Gierke Thursday @ 11:50 AM – Room #2008 48 #springone@s1p

Editor's Notes

  • #4 Spring Data for Apache Geode joins the Spring Data Kay Release Train as of RC1 Regular, predictable release cadence
  • #5 Misconceptions about Spring… Spring is a Web Application Framework Spring’s programming model is unique and Spring uses it’s own conventions Built on fundamental OO principles (POJO) Software Design Patterns (IoC/DI, AOP) and… Builds on Standards Open Source (OSS)
  • #7 No Code Changes No Import Statement Changes No Class Name Changes (Geode -> GemFire; Geode -> GemFire) Pivotal GemFire uses the org.apache.geode package namespace Apache Geode uses Pivotal GemFire class names… org.apache.geode.cache.GemFireCacheImpl
  • #9 To the Cloud (from the IDE) and back again
  • #14 SDG Repository infrastructure and extension already supports Sorting https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.special-parameters
  • #15 SDG Repository infrastructure and extension already supports Sorting https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.special-parameters
  • #16 SDG Repository infrastructure and extension already supports Sorting https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.special-parameters
  • #17 SDG Repository infrastructure and extension already supports Sorting https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.special-parameters
  • #18 SDG Repository infrastructure and extension already supports Sorting https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.special-parameters
  • #19 SDG Repository infrastructure and extension already supports Sorting https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.special-parameters
  • #20 SDG Repository infrastructure and extension already supports Sorting https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.special-parameters
  • #21 SDG Repository infrastructure and extension already supports Sorting https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.special-parameters
  • #22 SDG Repository infrastructure and extension already supports Sorting https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.special-parameters
  • #23 SDG Repository infrastructure and extension already supports Sorting https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.special-parameters
  • #31 Define multiple Apache Shiro Realms; Order them.
  • #33 Annotation attributes are strongly-typed
  • #34 SDG Repository infrastructure and extension already supports Sorting https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.special-parameters
  • #35 SDG Repository infrastructure and extension already supports Sorting https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.special-parameters
  • #36 SDG Repository infrastructure and extension already supports Sorting https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.special-parameters
  • #37 SDG Repository infrastructure and extension already supports Sorting https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.special-parameters
  • #39 Similar to SDG’s Function Execution support with @OnRegion today. https://docs.spring.io/spring-data/geode/docs/current/reference/html/#function-annotations https://docs.spring.io/spring-data/geode/docs/current/reference/html/#function-execution
  • #40 SDG Repository infrastructure and extension already supports Sorting https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.special-parameters
  • #41 The Value-Type DTO https://docs.spring.io/spring-data/commons/docs/current/reference/html/#projections.dtos