From e572c5ce88141e6ff6f3062a41357c3d0667885f Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Thu, 13 Oct 2022 09:00:06 +0200 Subject: [PATCH] Remove Geode examples. See #654 --- geode/README.md | 22 --- geode/events/README.md | 5 - geode/events/pom.xml | 16 -- .../geode/server/events/Address.java | 41 ----- .../geode/server/events/Customer.java | 50 ------ .../server/events/CustomerCacheWriter.java | 35 ---- .../server/events/CustomerRepository.java | 24 --- .../geode/server/events/EmailAddress.java | 37 ---- .../geode/server/events/EventServer.java | 89 ---------- .../server/events/EventServerConfig.java | 100 ----------- .../geode/server/events/LineItem.java | 47 ----- .../server/events/LoggingCacheListener.java | 47 ----- .../springdata/geode/server/events/Order.java | 72 -------- .../events/OrderAsyncQueueListener.java | 67 -------- .../server/events/OrderProductSummary.java | 45 ----- .../events/OrderProductSummaryRepository.java | 33 ---- .../geode/server/events/OrderRepository.java | 23 --- .../geode/server/events/Product.java | 67 -------- .../server/events/ProductCacheLoader.java | 51 ------ .../server/events/ProductRepository.java | 23 --- .../geode/server/events/EventServerTests.java | 56 ------ geode/events/src/test/resources/logback.xml | 11 -- geode/expiration-eviction/README.md | 12 -- geode/expiration-eviction/pom.xml | 24 --- .../server/expiration/eviction/Address.java | 41 ----- .../eviction/CustomCustomerExpiry.java | 41 ----- .../server/expiration/eviction/Customer.java | 50 ------ .../eviction/CustomerRepository.java | 25 --- .../expiration/eviction/EmailAddress.java | 37 ---- .../eviction/ExpirationEvictionServer.java | 31 ---- .../ExpirationEvictionServerConfig.java | 99 ----------- .../eviction/ExpirationPolicyConfig.java | 33 ---- .../server/expiration/eviction/Order.java | 50 ------ .../expiration/eviction/OrderRepository.java | 25 --- .../server/expiration/eviction/Product.java | 51 ------ .../eviction/ProductRepository.java | 23 --- .../EntityDefinedExpirationTests.java | 82 --------- .../ExpirationEvictionServerTests.java | 135 --------------- .../src/test/resources/logback.xml | 11 -- geode/function-invocation/README.md | 37 ---- geode/function-invocation/pom.xml | 16 -- .../geode/client/function/Address.java | 41 ----- .../geode/client/function/Customer.java | 57 ------ .../geode/client/function/EmailAddress.java | 37 ---- .../geode/client/function/LineItem.java | 43 ----- .../geode/client/function/Order.java | 74 -------- .../geode/client/function/Product.java | 67 -------- .../client/CustomerFunctionExecutions.java | 33 ---- .../function/client/CustomerRepository.java | 45 ----- ...tionInvocationClientApplicationConfig.java | 73 -------- .../client/OrderFunctionExecutions.java | 32 ---- .../function/client/OrderRepository.java | 27 --- .../client/ProductFunctionExecutions.java | 32 ---- .../function/client/ProductRepository.java | 27 --- .../function/server/CustomerFunctions.java | 45 ----- .../function/server/FunctionServer.java | 31 ---- .../FunctionServerApplicationConfig.java | 78 --------- .../function/server/OrderFunctions.java | 37 ---- .../function/server/ProductFunctions.java | 37 ---- .../client/FunctionInvocationClientTests.java | 141 --------------- .../src/test/resources/logback.xml | 11 -- geode/pom.xml | 72 -------- geode/queries/README.md | 8 - geode/queries/pom.xml | 24 --- .../geode/client/queries/Customer.java | 51 ------ .../geode/client/queries/EmailAddress.java | 37 ---- .../queries/client/CustomerRepository.java | 45 ----- .../queries/client/QueryClientConfig.java | 51 ------ .../client/queries/server/QueryServer.java | 31 ---- .../queries/server/QueryServerConfig.java | 45 ----- .../geode/client/queries/QueryTests.java | 162 ------------------ geode/queries/src/test/resources/logback.xml | 11 -- geode/security/README.md | 15 -- geode/security/pom.xml | 35 ---- .../geode/client/security/Constants.java | 29 ---- .../geode/client/security/Customer.java | 46 ----- .../geode/client/security/EmailAddress.java | 36 ---- .../geode/client/security/Role.java | 118 ------------- .../geode/client/security/User.java | 143 ---------------- .../security/client/CustomerRepository.java | 32 ---- .../SecurityEnabledClientConfiguration.java | 32 ---- .../server/ApacheShiroIniConfiguration.java | 25 --- .../server/CachingSecurityRepository.java | 54 ------ ...eIntegratedSecurityProxyConfiguration.java | 28 --- .../server/JdbcSecurityRepository.java | 84 --------- .../server/SecurityEnabledServer.java | 32 ---- .../SecurityEnabledServerConfiguration.java | 56 ------ .../security/server/SecurityManagerProxy.java | 112 ------------ .../server/SecurityManagerSupport.java | 106 ------------ .../security/server/SecurityRepository.java | 156 ----------------- .../server/SimpleSecurityManager.java | 127 -------------- .../src/main/resources/application.properties | 2 - geode/security/src/main/resources/shiro.ini | 42 ----- .../define-roles-permissions-table-ddl.sql | 7 - .../resources/sql/define-roles-table-ddl.sql | 4 - .../sql/define-users-roles-table-ddl.sql | 4 - .../resources/sql/define-users-table-ddl.sql | 5 - .../sql/geode-security-schema-ddl.sql | 1 - .../main/resources/sql/insert-roles-dml.sql | 5 - .../sql/insert-roles-permissions-dml.sql | 11 -- .../main/resources/sql/insert-users-dml.sql | 4 - .../resources/sql/insert-users-roles-dml.sql | 5 - .../SecurityEnabledClientShiroTests.java | 84 --------- .../client/SecurityEnabledClientTests.java | 85 --------- geode/security/src/test/resources/logback.xml | 11 -- geode/storage/README.md | 5 - geode/storage/pom.xml | 23 --- .../geode/server/storage/Address.java | 41 ----- .../geode/server/storage/Customer.java | 50 ------ .../server/storage/CustomerRepository.java | 24 --- .../geode/server/storage/EmailAddress.java | 37 ---- .../geode/server/storage/LineItem.java | 43 ----- .../geode/server/storage/Order.java | 72 -------- .../geode/server/storage/OrderRepository.java | 23 --- .../geode/server/storage/Product.java | 67 -------- .../server/storage/ProductRepository.java | 23 --- .../geode/server/storage/StorageServer.java | 85 --------- .../server/storage/StorageServerConfig.java | 94 ---------- .../server/storage/StorageServerTests.java | 70 -------- geode/storage/src/test/resources/logback.xml | 11 -- geode/transactions/README.md | 21 --- geode/transactions/pom.xml | 23 --- .../geode/client/transactions/Customer.java | 44 ----- .../client/transactions/EmailAddress.java | 34 ---- .../client/CustomerRepository.java | 27 --- .../transactions/client/CustomerService.java | 88 ---------- .../client/TransactionalClientConfig.java | 40 ----- .../server/CustomerTransactionListener.java | 53 ------ .../server/CustomerTransactionWriter.java | 49 ------ .../server/TransactionalServer.java | 32 ---- .../server/TransactionalServerConfig.java | 51 ------ .../client/TransactionalClientTests.java | 85 --------- .../src/test/resources/logback.xml | 11 -- geode/wan/README.md | 5 - geode/wan/pom.xml | 23 --- .../geode/server/wan/event/Customer.java | 46 ----- .../server/wan/event/CustomerRepository.java | 23 --- .../geode/server/wan/event/EmailAddress.java | 36 ---- .../server/EvenNumberedKeyWanEventFilter.java | 41 ----- .../server/WanEventSubstitutionFilter.java | 37 ---- .../server/wan/event/server/WanServer.java | 70 -------- .../wan/event/server/WanServerConfig.java | 98 ----------- .../WanTransportEncryptionListener.java | 50 ------ .../siteA/SiteAWanEnabledServerConfig.java | 60 ------- .../server/siteB/SiteBWanServerConfig.java | 77 --------- .../server/wan/event/WanServerTests.java | 70 -------- .../wan/event/client/WanClientConfig.java | 64 ------- geode/wan/src/test/resources/logback.xml | 11 -- pom.xml | 1 - 149 files changed, 6763 deletions(-) delete mode 100755 geode/README.md delete mode 100755 geode/events/README.md delete mode 100755 geode/events/pom.xml delete mode 100755 geode/events/src/main/java/example/springdata/geode/server/events/Address.java delete mode 100755 geode/events/src/main/java/example/springdata/geode/server/events/Customer.java delete mode 100755 geode/events/src/main/java/example/springdata/geode/server/events/CustomerCacheWriter.java delete mode 100755 geode/events/src/main/java/example/springdata/geode/server/events/CustomerRepository.java delete mode 100755 geode/events/src/main/java/example/springdata/geode/server/events/EmailAddress.java delete mode 100755 geode/events/src/main/java/example/springdata/geode/server/events/EventServer.java delete mode 100755 geode/events/src/main/java/example/springdata/geode/server/events/EventServerConfig.java delete mode 100755 geode/events/src/main/java/example/springdata/geode/server/events/LineItem.java delete mode 100644 geode/events/src/main/java/example/springdata/geode/server/events/LoggingCacheListener.java delete mode 100755 geode/events/src/main/java/example/springdata/geode/server/events/Order.java delete mode 100755 geode/events/src/main/java/example/springdata/geode/server/events/OrderAsyncQueueListener.java delete mode 100644 geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummary.java delete mode 100755 geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummaryRepository.java delete mode 100755 geode/events/src/main/java/example/springdata/geode/server/events/OrderRepository.java delete mode 100755 geode/events/src/main/java/example/springdata/geode/server/events/Product.java delete mode 100755 geode/events/src/main/java/example/springdata/geode/server/events/ProductCacheLoader.java delete mode 100755 geode/events/src/main/java/example/springdata/geode/server/events/ProductRepository.java delete mode 100755 geode/events/src/test/java/example/springdata/geode/server/events/EventServerTests.java delete mode 100644 geode/events/src/test/resources/logback.xml delete mode 100755 geode/expiration-eviction/README.md delete mode 100755 geode/expiration-eviction/pom.xml delete mode 100755 geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Address.java delete mode 100755 geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomCustomerExpiry.java delete mode 100755 geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Customer.java delete mode 100755 geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomerRepository.java delete mode 100755 geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/EmailAddress.java delete mode 100755 geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServer.java delete mode 100755 geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerConfig.java delete mode 100644 geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationPolicyConfig.java delete mode 100755 geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Order.java delete mode 100644 geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/OrderRepository.java delete mode 100755 geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Product.java delete mode 100644 geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ProductRepository.java delete mode 100644 geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/EntityDefinedExpirationTests.java delete mode 100755 geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerTests.java delete mode 100644 geode/expiration-eviction/src/test/resources/logback.xml delete mode 100755 geode/function-invocation/README.md delete mode 100755 geode/function-invocation/pom.xml delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/Address.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/Customer.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/EmailAddress.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/LineItem.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/Order.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/Product.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerFunctionExecutions.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerRepository.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/FunctionInvocationClientApplicationConfig.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderFunctionExecutions.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderRepository.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductFunctionExecutions.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductRepository.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/CustomerFunctions.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServer.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServerApplicationConfig.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/OrderFunctions.java delete mode 100755 geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/ProductFunctions.java delete mode 100755 geode/function-invocation/src/test/java/example/springdata/geode/client/function/client/FunctionInvocationClientTests.java delete mode 100644 geode/function-invocation/src/test/resources/logback.xml delete mode 100755 geode/pom.xml delete mode 100755 geode/queries/README.md delete mode 100755 geode/queries/pom.xml delete mode 100755 geode/queries/src/main/java/example/springdata/geode/client/queries/Customer.java delete mode 100755 geode/queries/src/main/java/example/springdata/geode/client/queries/EmailAddress.java delete mode 100755 geode/queries/src/main/java/example/springdata/geode/client/queries/client/CustomerRepository.java delete mode 100755 geode/queries/src/main/java/example/springdata/geode/client/queries/client/QueryClientConfig.java delete mode 100755 geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServer.java delete mode 100755 geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServerConfig.java delete mode 100755 geode/queries/src/test/java/example/springdata/geode/client/queries/QueryTests.java delete mode 100644 geode/queries/src/test/resources/logback.xml delete mode 100755 geode/security/README.md delete mode 100755 geode/security/pom.xml delete mode 100755 geode/security/src/main/java/example/springdata/geode/client/security/Constants.java delete mode 100755 geode/security/src/main/java/example/springdata/geode/client/security/Customer.java delete mode 100755 geode/security/src/main/java/example/springdata/geode/client/security/EmailAddress.java delete mode 100755 geode/security/src/main/java/example/springdata/geode/client/security/Role.java delete mode 100755 geode/security/src/main/java/example/springdata/geode/client/security/User.java delete mode 100755 geode/security/src/main/java/example/springdata/geode/client/security/client/CustomerRepository.java delete mode 100755 geode/security/src/main/java/example/springdata/geode/client/security/client/SecurityEnabledClientConfiguration.java delete mode 100644 geode/security/src/main/java/example/springdata/geode/client/security/server/ApacheShiroIniConfiguration.java delete mode 100755 geode/security/src/main/java/example/springdata/geode/client/security/server/CachingSecurityRepository.java delete mode 100644 geode/security/src/main/java/example/springdata/geode/client/security/server/GeodeIntegratedSecurityProxyConfiguration.java delete mode 100644 geode/security/src/main/java/example/springdata/geode/client/security/server/JdbcSecurityRepository.java delete mode 100755 geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityEnabledServer.java delete mode 100755 geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityEnabledServerConfiguration.java delete mode 100644 geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityManagerProxy.java delete mode 100755 geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityManagerSupport.java delete mode 100755 geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityRepository.java delete mode 100644 geode/security/src/main/java/example/springdata/geode/client/security/server/SimpleSecurityManager.java delete mode 100755 geode/security/src/main/resources/application.properties delete mode 100755 geode/security/src/main/resources/shiro.ini delete mode 100755 geode/security/src/main/resources/sql/define-roles-permissions-table-ddl.sql delete mode 100755 geode/security/src/main/resources/sql/define-roles-table-ddl.sql delete mode 100755 geode/security/src/main/resources/sql/define-users-roles-table-ddl.sql delete mode 100755 geode/security/src/main/resources/sql/define-users-table-ddl.sql delete mode 100755 geode/security/src/main/resources/sql/geode-security-schema-ddl.sql delete mode 100755 geode/security/src/main/resources/sql/insert-roles-dml.sql delete mode 100755 geode/security/src/main/resources/sql/insert-roles-permissions-dml.sql delete mode 100755 geode/security/src/main/resources/sql/insert-users-dml.sql delete mode 100755 geode/security/src/main/resources/sql/insert-users-roles-dml.sql delete mode 100755 geode/security/src/test/java/example/springdata/geode/client/security/client/SecurityEnabledClientShiroTests.java delete mode 100755 geode/security/src/test/java/example/springdata/geode/client/security/client/SecurityEnabledClientTests.java delete mode 100644 geode/security/src/test/resources/logback.xml delete mode 100644 geode/storage/README.md delete mode 100644 geode/storage/pom.xml delete mode 100755 geode/storage/src/main/java/example/springdata/geode/server/storage/Address.java delete mode 100755 geode/storage/src/main/java/example/springdata/geode/server/storage/Customer.java delete mode 100755 geode/storage/src/main/java/example/springdata/geode/server/storage/CustomerRepository.java delete mode 100755 geode/storage/src/main/java/example/springdata/geode/server/storage/EmailAddress.java delete mode 100755 geode/storage/src/main/java/example/springdata/geode/server/storage/LineItem.java delete mode 100755 geode/storage/src/main/java/example/springdata/geode/server/storage/Order.java delete mode 100755 geode/storage/src/main/java/example/springdata/geode/server/storage/OrderRepository.java delete mode 100755 geode/storage/src/main/java/example/springdata/geode/server/storage/Product.java delete mode 100755 geode/storage/src/main/java/example/springdata/geode/server/storage/ProductRepository.java delete mode 100755 geode/storage/src/main/java/example/springdata/geode/server/storage/StorageServer.java delete mode 100755 geode/storage/src/main/java/example/springdata/geode/server/storage/StorageServerConfig.java delete mode 100755 geode/storage/src/test/java/example/springdata/geode/server/storage/StorageServerTests.java delete mode 100644 geode/storage/src/test/resources/logback.xml delete mode 100755 geode/transactions/README.md delete mode 100755 geode/transactions/pom.xml delete mode 100755 geode/transactions/src/main/java/example/springdata/geode/client/transactions/Customer.java delete mode 100755 geode/transactions/src/main/java/example/springdata/geode/client/transactions/EmailAddress.java delete mode 100755 geode/transactions/src/main/java/example/springdata/geode/client/transactions/client/CustomerRepository.java delete mode 100755 geode/transactions/src/main/java/example/springdata/geode/client/transactions/client/CustomerService.java delete mode 100755 geode/transactions/src/main/java/example/springdata/geode/client/transactions/client/TransactionalClientConfig.java delete mode 100644 geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/CustomerTransactionListener.java delete mode 100644 geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/CustomerTransactionWriter.java delete mode 100755 geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/TransactionalServer.java delete mode 100755 geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/TransactionalServerConfig.java delete mode 100755 geode/transactions/src/test/java/example/springdata/geode/client/transactions/client/TransactionalClientTests.java delete mode 100644 geode/transactions/src/test/resources/logback.xml delete mode 100755 geode/wan/README.md delete mode 100755 geode/wan/pom.xml delete mode 100755 geode/wan/src/main/java/example/springdata/geode/server/wan/event/Customer.java delete mode 100755 geode/wan/src/main/java/example/springdata/geode/server/wan/event/CustomerRepository.java delete mode 100755 geode/wan/src/main/java/example/springdata/geode/server/wan/event/EmailAddress.java delete mode 100755 geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/EvenNumberedKeyWanEventFilter.java delete mode 100755 geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanEventSubstitutionFilter.java delete mode 100755 geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanServer.java delete mode 100755 geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanServerConfig.java delete mode 100755 geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanTransportEncryptionListener.java delete mode 100755 geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/siteA/SiteAWanEnabledServerConfig.java delete mode 100755 geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/siteB/SiteBWanServerConfig.java delete mode 100755 geode/wan/src/test/java/example/springdata/geode/server/wan/event/WanServerTests.java delete mode 100755 geode/wan/src/test/java/example/springdata/geode/server/wan/event/client/WanClientConfig.java delete mode 100644 geode/wan/src/test/resources/logback.xml diff --git a/geode/README.md b/geode/README.md deleted file mode 100755 index 047dd6c8..00000000 --- a/geode/README.md +++ /dev/null @@ -1,22 +0,0 @@ -Spring Data For GemFire and Apache Geode Examples -========================================================= - -This project provides a number of examples to get you started using Spring Data for Apache Geode or Pivotal GemFire. These examples are designed to work with [Spring Data for Pivotal GemFire](http://projects.spring.io/spring-data-gemfire) 2.0.9-RELEASE or higher and are organized into the following subprojects: - -It is important to note that all examples will follow the prescribed Maven directory structure. - -Examples: - -* **events** - In this example the test will make use of event handlers and async event queue to handle events. -* **expiration-eviction** - In these examples the server is configured to delete entries after a certain idle period or after a Time-To-Live period (expiration) or remove data from memory when certain thresholds are reached (eviction). -* **function-invocation** - In this example the server will have 3 functions registered. The client will invoke each of the functions. -* **queries** - In this example a client will query the data in various ways using OQl, continuous queries, and Apache Lucene indexes. -* **security** - In this example the servers and clients are set up with security (username/password) authentication using Geode Security and Apache Shiro. -* **storage** - In this example the server is configured to store data off of hte JVM heap using the `@EnableOffHeap` annotation and to compress region data using SnappyCompressor`. -* **transactions** - In this example the client will perform operations within a transaction. First, it will do a successful transaction where entries are saved to the server, and then a failed transaction where all changes are reverted. -* **wan** - In these example two servers are deployed. One server populates itself with data, and the other server gets populated with that data via WAN replication. - -# Running The Examples - -Each example has at least one test file located in the test directory. The examples are driven by the tests, so simply run the test either through your IDE or via the commandline. -The logging level of the examples is set to "error", so there will be no output. To see output, simply find the `logback.xml` file located in src/test/resources and set the loglevel to "info". diff --git a/geode/events/README.md b/geode/events/README.md deleted file mode 100755 index 12933162..00000000 --- a/geode/events/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Events Example - -In this example you will how to handle events using Async event queue, Cache Listeners, Cache Loaders, and Cache Writers. - -NOTE: Inorder to see output, you must change the loglevel from "error" to "info" in the `logback.xml` file located under src/test/resources. \ No newline at end of file diff --git a/geode/events/pom.xml b/geode/events/pom.xml deleted file mode 100755 index b8cd2397..00000000 --- a/geode/events/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - 4.0.0 - - - org.springframework.data.examples - spring-data-geode-examples - 2.0.0.BUILD-SNAPSHOT - - - spring-data-geode-events-example - Spring Data Geode - Events - - diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/Address.java b/geode/events/src/main/java/example/springdata/geode/server/events/Address.java deleted file mode 100755 index 3c961a81..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/Address.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import lombok.Data; - -import java.io.Serializable; - -/** - * An address used in the examples. - * - * @author Oliver Gierke - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -public class Address implements Serializable { - - private String street; - private String city; - private String country; - - public Address(String street, String city, String country) { - this.street = street; - this.city = city; - this.country = country; - } -} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/Customer.java b/geode/events/src/main/java/example/springdata/geode/server/events/Customer.java deleted file mode 100755 index 9c7c5669..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/Customer.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.gemfire.mapping.annotation.Region; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.List; - -/** - * A customer used for Lucene examples. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@Region(name = "Customers") -public class Customer implements Serializable { - - @Id - private Long id; - private EmailAddress emailAddress; - private String firstName; - private String lastName; - private List
addresses; - - public Customer(Long id, EmailAddress emailAddress, String firstName, String lastName, Address... addresses) { - this.id = id; - this.emailAddress = emailAddress; - this.firstName = firstName; - this.lastName = lastName; - this.addresses = Arrays.asList(addresses); - } -} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/CustomerCacheWriter.java b/geode/events/src/main/java/example/springdata/geode/server/events/CustomerCacheWriter.java deleted file mode 100755 index 42401f41..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/CustomerCacheWriter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import org.apache.geode.cache.CacheWriterException; -import org.apache.geode.cache.EntryEvent; -import org.apache.geode.cache.util.CacheWriterAdapter; -import org.apache.geode.internal.cache.EntryEventImpl; -import org.springframework.stereotype.Component; - -/** - * @author Patrick Johnson - */ -@Component -public class CustomerCacheWriter extends CacheWriterAdapter { - - @Override - public void beforeCreate(EntryEvent event) throws CacheWriterException { - var e = (EntryEventImpl) event; - super.beforeCreate(e); - } -} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/CustomerRepository.java b/geode/events/src/main/java/example/springdata/geode/server/events/CustomerRepository.java deleted file mode 100755 index e589f067..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/CustomerRepository.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -public interface CustomerRepository extends CrudRepository { -} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/EmailAddress.java b/geode/events/src/main/java/example/springdata/geode/server/events/EmailAddress.java deleted file mode 100755 index 73394bf2..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/EmailAddress.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import lombok.Data; - -import java.io.Serializable; - -/** - * Value object to represent email addresses. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -public class EmailAddress implements Serializable { - - private String value; - - public EmailAddress(String value) { - - this.value = value; - } -} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/EventServer.java b/geode/events/src/main/java/example/springdata/geode/server/events/EventServer.java deleted file mode 100755 index 3029540e..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/EventServer.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import java.math.BigDecimal; -import java.util.List; -import java.util.Random; -import java.util.stream.IntStream; -import java.util.stream.LongStream; - -import lombok.extern.apachecommons.CommonsLog; -import org.apache.geode.cache.Region; - -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.ApplicationRunner; -import org.springframework.boot.WebApplicationType; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.context.annotation.Bean; - -/** - * @author Patrick Johnson - */ -@SpringBootApplication -@CommonsLog -public class EventServer { - - public static void main(String[] args) { - new SpringApplicationBuilder(EventServer.class).web(WebApplicationType.NONE).build().run(args); - } - - @Bean - public ApplicationRunner runner(CustomerRepository customerRepository, OrderRepository orderRepository, - ProductRepository productRepository, OrderProductSummaryRepository orderProductSummaryRepository, - @Qualifier("Products") Region products) { - return args -> { - createCustomerData(customerRepository); - - createProducts(productRepository); - - createOrders(productRepository, orderRepository); - - log.info("Completed creating orders "); - - var allForProductID = orderProductSummaryRepository.findAllForProductID(3L); - allForProductID.forEach(orderProductSummary -> log.info("orderProductSummary = " + orderProductSummary)); - }; - } - - private void createOrders(ProductRepository productRepository, OrderRepository orderRepository) { - var random = new Random(System.nanoTime()); - var address = new Address("it", "doesn't", "matter"); - LongStream.rangeClosed(1, 10).forEach((orderId) -> LongStream.rangeClosed(1, 300).forEach((customerId) -> { - var order = new Order(orderId, customerId, address); - IntStream.rangeClosed(0, random.nextInt(3) + 1).forEach((lineItemCount) -> { - var quantity = random.nextInt(3) + 1; - long productId = random.nextInt(3) + 1; - order.add(new LineItem(productRepository.findById(productId).get(), quantity)); - }); - orderRepository.save(order); - })); - } - - private void createProducts(ProductRepository productRepository) { - productRepository.save(new Product(1L, "Apple iPod", new BigDecimal("99.99"), "An Apple portable music player")); - productRepository.save(new Product(2L, "Apple iPad", new BigDecimal("499.99"), "An Apple tablet device")); - var macbook = new Product(3L, "Apple macBook", new BigDecimal("899.99"), "An Apple notebook computer"); - macbook.addAttribute("warranty", "included"); - productRepository.save(macbook); - } - - private void createCustomerData(CustomerRepository customerRepository) { - LongStream.rangeClosed(0, 300).parallel().forEach(customerId -> customerRepository.save( - new Customer(customerId, new EmailAddress(customerId + "@2.com"), "John" + customerId, "Smith" + customerId))); - } -} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/EventServerConfig.java b/geode/events/src/main/java/example/springdata/geode/server/events/EventServerConfig.java deleted file mode 100755 index 5d936c5b..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/EventServerConfig.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.CacheListener; -import org.apache.geode.cache.CacheLoader; -import org.apache.geode.cache.CacheWriter; -import org.apache.geode.cache.DataPolicy; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.asyncqueue.AsyncEventListener; -import org.apache.geode.cache.asyncqueue.AsyncEventQueue; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.gemfire.PartitionedRegionFactoryBean; -import org.springframework.data.gemfire.ReplicatedRegionFactoryBean; -import org.springframework.data.gemfire.config.annotation.CacheServerApplication; -import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories; -import org.springframework.data.gemfire.wan.AsyncEventQueueFactoryBean; - -@Configuration -@ComponentScan -@CacheServerApplication(logLevel = "error") -@EnableGemfireRepositories(basePackageClasses = CustomerRepository.class) -public class EventServerConfig { - - @Bean - AsyncEventListener orderAsyncEventListener(@Qualifier("OrderProductSummary") Region orderProductSummary) { - return new OrderAsyncQueueListener(orderProductSummary); - } - - @Bean - AsyncEventQueueFactoryBean orderAsyncEventQueue(GemFireCache gemFireCache, AsyncEventListener orderAsyncEventListener) { - var asyncEventQueueFactoryBean = new AsyncEventQueueFactoryBean((Cache) gemFireCache); - asyncEventQueueFactoryBean.setBatchTimeInterval(1000); - asyncEventQueueFactoryBean.setBatchSize(5); - asyncEventQueueFactoryBean.setAsyncEventListener(orderAsyncEventListener); - return asyncEventQueueFactoryBean; - } - - @Bean(name = "OrderProductSummary") - PartitionedRegionFactoryBean createOrderProductSummaryRegion(GemFireCache gemFireCache) { - PartitionedRegionFactoryBean partitionedRegionFactoryBean = new PartitionedRegionFactoryBean<>(); - partitionedRegionFactoryBean.setCache(gemFireCache); - partitionedRegionFactoryBean.setRegionName("OrderProductSummary"); - partitionedRegionFactoryBean.setDataPolicy(DataPolicy.PARTITION); - return partitionedRegionFactoryBean; - } - - @Bean("Orders") - PartitionedRegionFactoryBean createOrderRegion(GemFireCache gemFireCache, AsyncEventQueue orderAsyncEventQueue) { - PartitionedRegionFactoryBean partitionedRegionFactoryBean = new PartitionedRegionFactoryBean<>(); - partitionedRegionFactoryBean.setCache(gemFireCache); - partitionedRegionFactoryBean.setRegionName("Orders"); - partitionedRegionFactoryBean.setDataPolicy(DataPolicy.PARTITION); - partitionedRegionFactoryBean.setAsyncEventQueues(new AsyncEventQueue[]{orderAsyncEventQueue}); - return partitionedRegionFactoryBean; - } - - @Bean("Products") - ReplicatedRegionFactoryBean createProductRegion(GemFireCache gemFireCache, CacheListener loggingCacheListener, - CacheLoader productCacheLoader) { - ReplicatedRegionFactoryBean replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>(); - replicatedRegionFactoryBean.setCache(gemFireCache); - replicatedRegionFactoryBean.setRegionName("Products"); - replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE); - replicatedRegionFactoryBean.setCacheLoader(productCacheLoader); - replicatedRegionFactoryBean.setCacheListeners(new CacheListener[]{loggingCacheListener}); - return replicatedRegionFactoryBean; - } - - @Bean("Customers") - ReplicatedRegionFactoryBean createCustomerRegion(GemFireCache gemFireCache, - CacheWriter customerCacheWriter, - CacheListener loggingCacheListener) { - ReplicatedRegionFactoryBean replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>(); - replicatedRegionFactoryBean.setCache(gemFireCache); - replicatedRegionFactoryBean.setRegionName("Customers"); - replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE); - replicatedRegionFactoryBean.setCacheListeners(new CacheListener[]{loggingCacheListener}); - replicatedRegionFactoryBean.setCacheWriter(customerCacheWriter); - return replicatedRegionFactoryBean; - } -} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/LineItem.java b/geode/events/src/main/java/example/springdata/geode/server/events/LineItem.java deleted file mode 100755 index 0d3e2cd6..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/LineItem.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * A LineItem used in the examples - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -public class LineItem implements Serializable { - - private Product product; - private Integer amount; - - public LineItem(Product product, Integer amount) { - this.product = product; - this.amount = amount; - } - - public BigDecimal calcTotal() { - return product.getPrice().multiply(BigDecimal.valueOf(amount)); - } - - public Long getProductId() { - return product.getId(); - } -} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/LoggingCacheListener.java b/geode/events/src/main/java/example/springdata/geode/server/events/LoggingCacheListener.java deleted file mode 100644 index 1d23e296..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/LoggingCacheListener.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import lombok.extern.apachecommons.CommonsLog; -import org.apache.geode.cache.EntryEvent; -import org.apache.geode.cache.util.CacheListenerAdapter; -import org.springframework.stereotype.Component; - -/** - * @author Patrick Johnson - */ -@Component -@CommonsLog -public class LoggingCacheListener extends CacheListenerAdapter { - - - @Override - public void afterCreate(EntryEvent event) { - log.info("In region [" + event.getRegion().getName() + "] created key [" + event.getKey() + "] value [" - + event.getNewValue() + "]"); - } - - @Override - public void afterDestroy(EntryEvent event) { - log.info("In region [" + event.getRegion().getName() + "] destroyed key [" + event.getKey() + "] "); - } - - @Override - public void afterUpdate(EntryEvent event) { - log.info("In region [" + event.getRegion().getName() + "] updated key [" + event.getNewValue() + "] [oldValue [" - + event.getOldValue() + "]] new value [" + event.getNewValue() + "]"); - } -} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/Order.java b/geode/events/src/main/java/example/springdata/geode/server/events/Order.java deleted file mode 100755 index e9ae1434..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/Order.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.gemfire.mapping.annotation.Region; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; - -/** - * Orders object used in the examples - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@Region("Orders") -public class Order implements Serializable { - - @Id - private Long id; - private Long customerId; - private Address billingAddress; - private Address shippingAddress; - private List lineItems = new ArrayList<>(); - - public Order(Long orderId, Long customerId, Address address) { - this.id = orderId; - this.customerId = customerId; - this.billingAddress = address; - this.shippingAddress = address; - } - - /** - * Returns the total of the [Order]. - * - * @return - */ - public BigDecimal calcTotal() { - if (lineItems.size() == 0) { - return BigDecimal.ZERO; - } else { - return lineItems.stream().map(LineItem::calcTotal).reduce(BigDecimal::add).get(); - } - } - - /** - * Adds the given [LineItem] to the [Order]. - * - * @param lineItem - */ - public void add(LineItem lineItem) { - lineItems.add(lineItem); - } -} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/OrderAsyncQueueListener.java b/geode/events/src/main/java/example/springdata/geode/server/events/OrderAsyncQueueListener.java deleted file mode 100755 index 1f0e7212..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/OrderAsyncQueueListener.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.geode.cache.Region; -import org.apache.geode.cache.asyncqueue.AsyncEvent; -import org.apache.geode.cache.asyncqueue.AsyncEventListener; - -/** - * @author Patrick Johnson - */ -public class OrderAsyncQueueListener implements AsyncEventListener { - - private Region summaryRegion; - - public OrderAsyncQueueListener(Region summaryRegion) { - this.summaryRegion = summaryRegion; - } - - @Override - public boolean processEvents(List list) { - Map summaryMap = new HashMap<>(); - list.forEach(asyncEvent -> { - var order = (Order) asyncEvent.getDeserializedValue(); - if (order != null) { - order.getLineItems().forEach(lineItem -> { - var orderProductSummary = summaryMap.get(lineItem.getProductId()); - if (orderProductSummary == null) { - orderProductSummary = new OrderProductSummary(lineItem.getProductId(), new BigDecimal("0.00")); - } - orderProductSummary.setSummaryAmount(orderProductSummary.getSummaryAmount().add(lineItem.calcTotal())); - summaryMap.put(lineItem.getProductId(), orderProductSummary); - }); - } - }); - - summaryMap.forEach((orderProductSummaryKey, orderProductSummary) -> { - OrderProductSummary productSummary = summaryRegion.get(orderProductSummaryKey); - if (productSummary != null) { - BigDecimal newSummaryAmount = productSummary.getSummaryAmount().add(orderProductSummary.getSummaryAmount()); - summaryRegion.put(orderProductSummaryKey, new OrderProductSummary(orderProductSummaryKey, newSummaryAmount)); - } else { - summaryRegion.put(orderProductSummaryKey, orderProductSummary); - } - }); - - return true; - } -} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummary.java b/geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummary.java deleted file mode 100644 index 9971223c..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummary.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.gemfire.mapping.annotation.Region; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * OrderProductSummary is an object used in the examples to show a summary of all Orders on a per-product basis, on a per - * timeframe shard (every 10s, or every 1hr) - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@Region("OrderProductSummary") -public class OrderProductSummary implements Serializable { - - @Id - private Long summaryKey; - - private BigDecimal summaryAmount; - - public OrderProductSummary(Long summaryKey, BigDecimal summaryAmount) { - this.summaryKey = summaryKey; - this.summaryAmount = summaryAmount; - } -} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummaryRepository.java b/geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummaryRepository.java deleted file mode 100755 index 0625c7f5..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummaryRepository.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import java.util.List; - -import org.springframework.data.gemfire.mapping.annotation.Region; -import org.springframework.data.gemfire.repository.Query; -import org.springframework.data.gemfire.repository.query.annotation.Hint; -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -@Region("OrderProductSummary") -public interface OrderProductSummaryRepository extends CrudRepository { - @Hint("emailAddressIndex") - @Query("select orderSummary.value from /OrderProductSummary.entrySet orderSummary where orderSummary.key = $1") - List findAllForProductID(long l); -} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/OrderRepository.java b/geode/events/src/main/java/example/springdata/geode/server/events/OrderRepository.java deleted file mode 100755 index 582dde34..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/OrderRepository.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -public interface OrderRepository extends CrudRepository {} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/Product.java b/geode/events/src/main/java/example/springdata/geode/server/events/Product.java deleted file mode 100755 index c45d8589..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/Product.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.annotation.PersistenceConstructor; -import org.springframework.data.annotation.Transient; -import org.springframework.data.gemfire.mapping.annotation.Region; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.Map; - -/** - * A product used in the examples. - * - * @author Oliver Gierke - * @author David Turanski - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@Region("Products") -public class Product implements Serializable { - - @Id - private Long id; - private String name; - private BigDecimal price; - private String description; - - @Transient - private Map attributes = new HashMap<>(); - - @PersistenceConstructor - public Product(Long id, String name, BigDecimal price, String description) { - this.id = id; - this.name = name; - this.price = price; - this.description = description; - } - - /** - * Sets the attribute with the given name to the given value. - * - * @param name must not be null or empty. - * @param value - */ - public void addAttribute(String name, String value) { - this.attributes.put(name, value); - } -} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/ProductCacheLoader.java b/geode/events/src/main/java/example/springdata/geode/server/events/ProductCacheLoader.java deleted file mode 100755 index 488e5409..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/ProductCacheLoader.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import lombok.SneakyThrows; - -import java.math.BigDecimal; -import java.text.DecimalFormat; - -import org.apache.geode.cache.CacheLoader; -import org.apache.geode.cache.CacheLoaderException; -import org.apache.geode.cache.LoaderHelper; - -import org.springframework.stereotype.Component; - -import com.github.javafaker.Faker; - -/** - * @author Patrick Johnson - */ -@Component -public class ProductCacheLoader implements CacheLoader { - private Faker faker = new Faker(); - - @Override - public Product load(LoaderHelper loaderHelper) throws CacheLoaderException { - return new Product((long) loaderHelper.getKey(), randomStringName(), randomPrice(), ""); - } - - @SneakyThrows - private BigDecimal randomPrice() { - return new BigDecimal(new DecimalFormat("#0.00").parse(faker.commerce().price()).toString()); - } - - private String randomStringName() { - return faker.commerce().productName(); - } -} diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/ProductRepository.java b/geode/events/src/main/java/example/springdata/geode/server/events/ProductRepository.java deleted file mode 100755 index 12bf841b..00000000 --- a/geode/events/src/main/java/example/springdata/geode/server/events/ProductRepository.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -public interface ProductRepository extends CrudRepository {} diff --git a/geode/events/src/test/java/example/springdata/geode/server/events/EventServerTests.java b/geode/events/src/test/java/example/springdata/geode/server/events/EventServerTests.java deleted file mode 100755 index 82190d09..00000000 --- a/geode/events/src/test/java/example/springdata/geode/server/events/EventServerTests.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.events; - -import static org.assertj.core.api.Assertions.*; - -import org.apache.geode.cache.Cache; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Patrick Johnson - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class EventServerTests { - - @Autowired Cache cache; - - @Autowired private ProductRepository productRepository; - - @Autowired private OrderProductSummaryRepository orderProductSummaryRepository; - - @Test - public void asyncEventQueueEasConfiguredCorrectly() { - assertThat(this.orderProductSummaryRepository.count()).isEqualTo(3); - } - - @Test - public void productCacheLoaderWorks() { - - var size = productRepository.count(); - - assertThat(this.productRepository.findById(777L)).isNotNull(); - assertThat(productRepository.count()).isEqualTo(size + 1); - - productRepository.deleteById(777L); - } -} diff --git a/geode/events/src/test/resources/logback.xml b/geode/events/src/test/resources/logback.xml deleted file mode 100644 index f3b82068..00000000 --- a/geode/events/src/test/resources/logback.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - %msg%n - - - - - - - \ No newline at end of file diff --git a/geode/expiration-eviction/README.md b/geode/expiration-eviction/README.md deleted file mode 100755 index b7f95b2f..00000000 --- a/geode/expiration-eviction/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Expiration and Eviction Example - -In this example we will show you ways to automatically remove data from your region. There are two ways to do this; Expiration and Eviction. - -1. Expiration removes data after it has existed for a certain amount of time or after it has been unused for a certain amount of time. There are multiple ways to configure Expiration that will be shown in this example. - 1. Configure an eviction policy on the region using the `@EnableExpiration` and `@ExpirationPolicy` annotations. - 2. Configure a custom eviction policy to extending `CustomExpiry`. - 3. Entity defined expiration using the `@IdleTimeoutExpiration` and `@TimeToLiveExpiration` annotations. - -Entity defined expiration has its own test class because it has a lower priority and is trumped by the expiration policy defined on the `@EnableExpiration` annotation. The polices defined on the `@EnableExpiration` annotation can be found in ExpirationPolicyConfig. - -NOTE: Inorder to see output, you must change the loglevel from "error" to "info" in the `logback.xml` file located under src/test/resources. \ No newline at end of file diff --git a/geode/expiration-eviction/pom.xml b/geode/expiration-eviction/pom.xml deleted file mode 100755 index 2df41222..00000000 --- a/geode/expiration-eviction/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - 4.0.0 - - - org.springframework.data.examples - spring-data-geode-examples - 2.0.0.BUILD-SNAPSHOT - - - spring-data-geode-expiration-eviction-example - Spring Data Geode - Expiration - - - - org.awaitility - awaitility - test - - - - diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Address.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Address.java deleted file mode 100755 index d71862f0..00000000 --- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Address.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.expiration.eviction; - -import lombok.Data; - -import java.io.Serializable; - -/** - * An address used in the examples. - * - * @author Oliver Gierke - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -public class Address implements Serializable { - - private String street; - private String city; - private String country; - - public Address(String street, String city, String country) { - this.street = street; - this.city = city; - this.country = country; - } -} diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomCustomerExpiry.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomCustomerExpiry.java deleted file mode 100755 index c9cb5469..00000000 --- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomCustomerExpiry.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.expiration.eviction; - -import org.apache.geode.cache.CustomExpiry; -import org.apache.geode.cache.ExpirationAction; -import org.apache.geode.cache.ExpirationAttributes; -import org.apache.geode.cache.Region; - -/** - * @author Patrick Johnson - */ -public class CustomCustomerExpiry implements CustomExpiry { - - private final int timeout; - - public CustomCustomerExpiry(int timeout) { - this.timeout = timeout; - } - - @Override - public ExpirationAttributes getExpiry(Region.Entry entry) { - if (entry.getKey() % 3 == 0) { - return new ExpirationAttributes(timeout, ExpirationAction.DESTROY); - } - return null; - } -} diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Customer.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Customer.java deleted file mode 100755 index f21c76fd..00000000 --- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Customer.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.expiration.eviction; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.gemfire.mapping.annotation.Region; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.List; - -/** - * A customer used for Lucene examples. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@Region(name = "Customers") -public class Customer implements Serializable { - - @Id - private Long id; - private EmailAddress emailAddress; - private String firstName; - private String lastName; - private List
addresses; - - public Customer(Long id, EmailAddress emailAddress, String firstName, String lastName, Address... addresses) { - this.id = id; - this.emailAddress = emailAddress; - this.firstName = firstName; - this.lastName = lastName; - this.addresses = Arrays.asList(addresses); - } -} diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomerRepository.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomerRepository.java deleted file mode 100755 index 09f73c12..00000000 --- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomerRepository.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.expiration.eviction; - -import org.springframework.data.gemfire.mapping.annotation.Region; -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -@Region("Customers") -public interface CustomerRepository extends CrudRepository {} diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/EmailAddress.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/EmailAddress.java deleted file mode 100755 index f0a0fba9..00000000 --- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/EmailAddress.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.expiration.eviction; - -import lombok.Data; - -import java.io.Serializable; - -/** - * Value object to represent email addresses. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -public class EmailAddress implements Serializable { - - private String value; - - public EmailAddress(String value) { - - this.value = value; - } -} diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServer.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServer.java deleted file mode 100755 index 5b2b07ec..00000000 --- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServer.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.expiration.eviction; - -import org.springframework.boot.WebApplicationType; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; - -/** - * @author Patrick Johnson - */ -@SpringBootApplication -public class ExpirationEvictionServer { - - public static void main(String[] args) { - new SpringApplicationBuilder(ExpirationEvictionServer.class).web(WebApplicationType.NONE).build().run(args); - } -} diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerConfig.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerConfig.java deleted file mode 100755 index 0633a29f..00000000 --- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerConfig.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.expiration.eviction; - -import org.apache.geode.cache.CustomExpiry; -import org.apache.geode.cache.DataPolicy; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.cache.Scope; - -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.data.gemfire.ReplicatedRegionFactoryBean; -import org.springframework.data.gemfire.config.annotation.CacheServerApplication; -import org.springframework.data.gemfire.config.annotation.EnableEviction; -import org.springframework.data.gemfire.config.annotation.EnableExpiration; -import org.springframework.data.gemfire.config.annotation.EnableLocator; -import org.springframework.data.gemfire.eviction.EvictionActionType; -import org.springframework.data.gemfire.eviction.EvictionPolicyType; -import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories; - -import com.github.javafaker.Faker; - -/** - * @author Patrick Johnson - */ -@Configuration -@CacheServerApplication(logLevel = "error") -@EnableLocator -@EnableGemfireRepositories(basePackageClasses = CustomerRepository.class) -@EnableExpiration -@Import(ExpirationPolicyConfig.class) -@EnableEviction(policies = @EnableEviction.EvictionPolicy(regionNames = "Orders", maximum = 10, - action = EvictionActionType.LOCAL_DESTROY, type = EvictionPolicyType.ENTRY_COUNT)) -public class ExpirationEvictionServerConfig { - - @Bean - public Faker createDataFaker() { - return new Faker(); - } - - @Bean("IDLE") - CustomExpiry createIdleExpiration() { - return new CustomCustomerExpiry(2); - } - - @Bean("TTL") - CustomExpiry createTtlExpiration() { - return new CustomCustomerExpiry(4); - } - - @Bean("Products") - public ReplicatedRegionFactoryBean createProductRegion(GemFireCache gemFireCache, - @Qualifier("IDLE") CustomExpiry idleExpiry, - @Qualifier("TTL") CustomExpiry ttlExpiry) { - ReplicatedRegionFactoryBean regionFactoryBean = new ReplicatedRegionFactoryBean<>(); - regionFactoryBean.setCache(gemFireCache); - regionFactoryBean.setScope(Scope.DISTRIBUTED_ACK); - regionFactoryBean.setDataPolicy(DataPolicy.REPLICATE); - regionFactoryBean.setName("Products"); - regionFactoryBean.setCustomEntryIdleTimeout(idleExpiry); - regionFactoryBean.setCustomEntryTimeToLive(ttlExpiry); - return regionFactoryBean; - } - - @Bean("Customers") - public ReplicatedRegionFactoryBean createCustomerRegion(GemFireCache gemFireCache) { - ReplicatedRegionFactoryBean regionFactoryBean = new ReplicatedRegionFactoryBean<>(); - regionFactoryBean.setCache(gemFireCache); - regionFactoryBean.setScope(Scope.DISTRIBUTED_ACK); - regionFactoryBean.setDataPolicy(DataPolicy.REPLICATE); - regionFactoryBean.setName("Customers"); - return regionFactoryBean; - } - - @Bean("Orders") - public ReplicatedRegionFactoryBean createOrderRegion(GemFireCache gemFireCache) { - ReplicatedRegionFactoryBean regionFactoryBean = new ReplicatedRegionFactoryBean<>(); - regionFactoryBean.setCache(gemFireCache); - regionFactoryBean.setScope(Scope.DISTRIBUTED_ACK); - regionFactoryBean.setDataPolicy(DataPolicy.REPLICATE); - regionFactoryBean.setName("Orders"); - return regionFactoryBean; - } -} diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationPolicyConfig.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationPolicyConfig.java deleted file mode 100644 index 513e9fca..00000000 --- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationPolicyConfig.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.expiration.eviction; - -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.data.gemfire.config.annotation.EnableExpiration; -import org.springframework.data.gemfire.expiration.ExpirationActionType; - -/** - * @author Patrick Johnson - */ -@Profile("!default") -@Configuration -@EnableExpiration(policies = { - @EnableExpiration.ExpirationPolicy(timeout = 2, action = ExpirationActionType.DESTROY, - regionNames = { "Customers" }, types = { EnableExpiration.ExpirationType.TIME_TO_LIVE }), - @EnableExpiration.ExpirationPolicy(timeout = 1, action = ExpirationActionType.DESTROY, - regionNames = { "Customers" }, types = { EnableExpiration.ExpirationType.IDLE_TIMEOUT }) }) -public class ExpirationPolicyConfig {} diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Order.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Order.java deleted file mode 100755 index b838b0c9..00000000 --- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Order.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.expiration.eviction; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.gemfire.expiration.IdleTimeoutExpiration; -import org.springframework.data.gemfire.expiration.TimeToLiveExpiration; -import org.springframework.data.gemfire.mapping.annotation.Region; - -import java.io.Serializable; - -/** - * Orders object used in the examples - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@IdleTimeoutExpiration(action = "DESTROY", timeout = "1") -@TimeToLiveExpiration(action = "DESTROY", timeout = "2") -@Region("Orders") -public class Order implements Serializable { - - @Id - private Long id; - private Long total; - private Address billingAddress; - private Address shippingAddress; - - public Order(Long orderId, Long total, Address address) { - this.id = orderId; - this.total = total; - this.billingAddress = address; - this.shippingAddress = address; - } -} diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/OrderRepository.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/OrderRepository.java deleted file mode 100644 index 217d4b99..00000000 --- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/OrderRepository.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.expiration.eviction; - -import org.springframework.data.gemfire.mapping.annotation.Region; -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -@Region("Orders") -public interface OrderRepository extends CrudRepository {} diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Product.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Product.java deleted file mode 100755 index 0dcb8d90..00000000 --- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Product.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.expiration.eviction; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.annotation.PersistenceConstructor; -import org.springframework.data.gemfire.mapping.annotation.Region; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * A product used in the examples. - * - * @author Oliver Gierke - * @author David Turanski - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@Region("Products") -public class Product implements Serializable { - - @Id - private Long id; - private String name; - private BigDecimal price; - private String description; - - @PersistenceConstructor - public Product(Long id, String name, BigDecimal price, String description) { - this.id = id; - this.name = name; - this.price = price; - this.description = description; - } -} diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ProductRepository.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ProductRepository.java deleted file mode 100644 index ff0a5c4d..00000000 --- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ProductRepository.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.expiration.eviction; - -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -public interface ProductRepository extends CrudRepository {} diff --git a/geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/EntityDefinedExpirationTests.java b/geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/EntityDefinedExpirationTests.java deleted file mode 100644 index c5dd698c..00000000 --- a/geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/EntityDefinedExpirationTests.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.expiration.eviction; - -import static org.assertj.core.api.Assertions.*; - -import lombok.extern.apachecommons.CommonsLog; - -import java.time.Instant; -import java.util.concurrent.TimeUnit; - -import org.awaitility.Awaitility; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; - -import com.github.javafaker.Faker; - -/** - * @author Patrick Johnson - */ -@RunWith(SpringRunner.class) -@SpringBootTest -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -@CommonsLog -public class EntityDefinedExpirationTests { - - @Autowired private OrderRepository orderRepository; - - @Autowired Faker faker; - - @Test - public void entityDefinedExpirationIsConfiguredCorrectly() { - - orderRepository.save(new Order(1L, 50L, - new Address(faker.address().streetAddress(), faker.address().city(), faker.address().country()))); - - assertThat(orderRepository.count()).isEqualTo(1); - - log.info("Starting TTL wait period: " + Instant.now()); - // Due to the constant "getting" of the entry, the idle expiry timeout will not be met and the time-to-live - // will be used. - Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(10, TimeUnit.SECONDS) - .until(() -> !orderRepository.findById(1L).isPresent()); - - assertThat(orderRepository.count()).isEqualTo(0); - - log.info("Ending TTL wait period: " + Instant.now()); - - orderRepository.save(new Order(1L, 50L, - new Address(faker.address().streetAddress(), faker.address().city(), faker.address().country()))); - - assertThat(orderRepository.count()).isEqualTo(1); - - log.info("Starting Idle wait period: " + Instant.now()); - - // Due to the delay in "getting" the entry, the idle timeout of 2s should delete the entry. - Awaitility.await().pollDelay(2, TimeUnit.SECONDS).pollInterval(100, TimeUnit.MILLISECONDS) - .atMost(10, TimeUnit.SECONDS).until(() -> !orderRepository.findById(1L).isPresent()); - - assertThat(orderRepository.count()).isEqualTo(0); - - log.info("Ending Idle wait period: " + Instant.now()); - } -} diff --git a/geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerTests.java b/geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerTests.java deleted file mode 100755 index 2b7194b1..00000000 --- a/geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerTests.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.expiration.eviction; - -import static org.assertj.core.api.Assertions.*; - -import lombok.extern.apachecommons.CommonsLog; - -import java.math.BigDecimal; -import java.time.Instant; -import java.util.concurrent.TimeUnit; - -import org.awaitility.Awaitility; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; - -import com.github.javafaker.Faker; - -/** - * @author Patrick Johnson - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = ExpirationEvictionServer.class) -@ActiveProfiles("expiration_policy") -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -@CommonsLog -public class ExpirationEvictionServerTests { - - @Autowired private CustomerRepository customerRepository; - - @Autowired private ProductRepository productRepository; - - @Autowired private OrderRepository orderRepository; - - @Autowired Faker faker; - - @Test - public void cacheDefinedExpirationIsConfiguredCorrectly() { - - customerRepository.save(new Customer(1L, new EmailAddress(faker.internet().emailAddress()), - faker.name().firstName(), faker.name().lastName(), - new Address(faker.address().streetAddress(), faker.address().city(), faker.address().country()))); - - assertThat(customerRepository.count()).isEqualTo(1); - - log.info(String.format("Starting TTL wait period: %s", Instant.now())); - // Due to the constant "getting" of the entry, the idle expiry timeout will not be met and the time-to-live - // will be used. - Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(10, TimeUnit.SECONDS) - .until(() -> !customerRepository.findById(1L).isPresent()); - - assertThat(customerRepository.count()).isEqualTo(0); - - log.info(String.format("Ending TTL wait period: %s", Instant.now())); - - customerRepository.save(new Customer(1L, new EmailAddress(faker.internet().emailAddress()), - faker.name().firstName(), faker.name().lastName(), - new Address(faker.address().streetAddress(), faker.address().city(), faker.address().country()))); - - assertThat(customerRepository.count()).isEqualTo(1); - - log.info(String.format("Starting Idle wait period: %s", Instant.now())); - - // Due to the delay in "getting" the entry, the idle timeout of 2s should delete the entry. - Awaitility.await().pollDelay(2, TimeUnit.SECONDS).pollInterval(100, TimeUnit.MILLISECONDS) - .atMost(10, TimeUnit.SECONDS).until(() -> !customerRepository.findById(1L).isPresent()); - - assertThat(customerRepository.count()).isEqualTo(0); - - log.info(String.format("Ending Idle wait period: %s", Instant.now())); - } - - @Test - public void customExpirationIsConfiguredCorrectly() { - productRepository.save(new Product(3L, "MacBook Pro", BigDecimal.valueOf(20), "A cool computing device")); - - assertThat(productRepository.count()).isEqualTo(1); - - log.info(String.format("Starting TTL wait period: %s", Instant.now())); - // Due to the constant "getting" of the entry, the idle expiry timeout will not be met and the time-to-live - // will be used. - Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(10, TimeUnit.SECONDS) - .until(() -> !productRepository.findById(3L).isPresent()); - - assertThat(productRepository.count()).isEqualTo(0); - - log.info("Ending TTL wait period: " + Instant.now()); - - productRepository.save(new Product(3L, "MacBook Pro", BigDecimal.valueOf(20), "A cool computing device")); - - assertThat(productRepository.count()).isEqualTo(1); - - log.info(String.format("Starting Idle wait period: %s", Instant.now())); - - // Due to the delay in "getting" the entry, the idle timeout of 2s should delete the entry. - Awaitility.await().pollDelay(2, TimeUnit.SECONDS).pollInterval(100, TimeUnit.MILLISECONDS) - .atMost(10, TimeUnit.SECONDS).until(() -> !productRepository.findById(3L).isPresent()); - - assertThat(productRepository.count()).isEqualTo(0); - - log.info(String.format("Ending Idle wait period: %s", Instant.now())); - } - - @Test - public void evictionIsConfiguredCorrectly() { - - final var evictionThreshold = 10; - for (long i = 0; i < evictionThreshold + 1; i++) { - orderRepository.save(new Order(i, i, - new Address(faker.address().streetName(), faker.address().city(), faker.address().country()))); - } - - assertThat(orderRepository.count()).isEqualTo(evictionThreshold); - orderRepository.deleteAll(); - } -} diff --git a/geode/expiration-eviction/src/test/resources/logback.xml b/geode/expiration-eviction/src/test/resources/logback.xml deleted file mode 100644 index f3b82068..00000000 --- a/geode/expiration-eviction/src/test/resources/logback.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - %msg%n - - - - - - - \ No newline at end of file diff --git a/geode/function-invocation/README.md b/geode/function-invocation/README.md deleted file mode 100755 index 8b497e3e..00000000 --- a/geode/function-invocation/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# Function Invocation Example - -In this example a [Pivotal GemFire](https://pivotal.io/pivotal-gemfire) / [Apache Geode](http://geode.apache.org/) client will invoke remote functions registered on the server. - -To run the example simply run the tests located under function-invocation/src/test in your IDE. - -The client is configured to connect to the deployed/started server on `localhost` port `40404`. - -## Running the example - -The example is broken up into multiple steps: -1. Insert (Put) three Customer entries into the `Customers` region using the repositories `save` method. -2. Insert (Put) three Product entries into the `Products` region using the repositories `save` method. -3. Insert (Put) 100 Order entries into the `Orders` region using the repositories `save` method. - -Your output from the test `functionsExecuteCorrectly` should look similar to the following: - - Inserting 3 entries for keys: 1, 2, 3 - [FORK] - [info 2019/09/06 09:24:49.274 PDT tid=0x47] In region [Customers] created key [1] value [Customer(id=1, emailAddress=EmailAddress(value=2@2.com), firstName=John, lastName=Smith)] - [FORK] - - [FORK] - [info 2019/09/06 09:24:49.278 PDT tid=0x47] In region [Customers] created key [2] value [Customer(id=2, emailAddress=EmailAddress(value=3@3.com), firstName=Frank, lastName=Lamport)] - [FORK] - - [FORK] - [info 2019/09/06 09:24:49.279 PDT tid=0x47] In region [Customers] created key [3] value [Customer(id=3, emailAddress=EmailAddress(value=5@5.com), firstName=Jude, lastName=Simmons)] - [FORK] - - All customers for emailAddresses:3@3.com,2@2.com using function invocation: - [Customer(id=2, emailAddress=EmailAddress(value=3@3.com), firstName=Frank, lastName=Lamport), Customer(id=1, emailAddress=EmailAddress(value=2@2.com), firstName=John, lastName=Smith)] - Running function to sum up all product prices: - 1499.97 - Running function to sum up all order lineItems prices for order 1: - 2399.96 - For order: - Order(id=1, customerId=3, billingAddress=Address(street=it, city=doesn't, country=matter), shippingAddress=Address(street=it, city=doesn't, country=matter)) - LineItems:[Purchased 1 of Product Apple macBook at 899.99 for total of 899.99, Purchased 3 of Product Apple iPad at 499.99 for total of 1499.97] - -NOTE: Inorder to see output, you must change the loglevel from "error" to "info" in the `logback.xml` file located under src/test/resources. - -NOTE: Number of products purchased and total cost may vary from the above run as they are determined randomly. \ No newline at end of file diff --git a/geode/function-invocation/pom.xml b/geode/function-invocation/pom.xml deleted file mode 100755 index 57971708..00000000 --- a/geode/function-invocation/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - 4.0.0 - - - org.springframework.data.examples - spring-data-geode-examples - 2.0.0.BUILD-SNAPSHOT - - - spring-data-geode-function-invocation-example - Spring Data Geode - Functions - - diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Address.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Address.java deleted file mode 100755 index 0de8ba60..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Address.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function; - -import lombok.Data; - -import java.io.Serializable; - -/** - * An address used in the examples. - * - * @author Oliver Gierke - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -public class Address implements Serializable { - - private String street; - private String city; - private String country; - - public Address(String street, String city, String country) { - this.street = street; - this.city = city; - this.country = country; - } -} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Customer.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Customer.java deleted file mode 100755 index 11a355fe..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Customer.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.gemfire.mapping.annotation.Region; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.List; - -/** - * A customer used for Lucene examples. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@Region(name = "Customers") -public class Customer implements Serializable { - - @Id - private Long id; - private EmailAddress emailAddress; - private String firstName; - private String lastName; - private List
addresses; - - public Customer(Long id, EmailAddress emailAddress, String firstName, String lastName, Address... addresses) { - this.id = id; - this.emailAddress = emailAddress; - this.firstName = firstName; - this.lastName = lastName; - this.addresses = Arrays.asList(addresses); - } - - /** - * Adds the given [Address] to the [Customer]. - */ - public void add(Address address) { - this.addresses.add(address); - } -} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/EmailAddress.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/EmailAddress.java deleted file mode 100755 index fecb24ca..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/EmailAddress.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function; - -import lombok.Data; - -import java.io.Serializable; - -/** - * Value object to represent email addresses. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -public class EmailAddress implements Serializable { - - private String value; - - public EmailAddress(String value) { - - this.value = value; - } -} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/LineItem.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/LineItem.java deleted file mode 100755 index f86c320b..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/LineItem.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * A LineItem used in the examples - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -public class LineItem implements Serializable { - - private Product product; - private Integer amount; - - public LineItem(Product product, Integer amount) { - this.product = product; - this.amount = amount; - } - - public BigDecimal calcTotal() { - return product.getPrice().multiply(BigDecimal.valueOf(amount)); - } -} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Order.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Order.java deleted file mode 100755 index 65fd2a59..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Order.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package example.springdata.geode.client.function; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.gemfire.mapping.annotation.Region; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; - -/** - * Orders object used in the examples - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@Region("Orders") -public class Order implements Serializable { - - @Id - private Long id; - private Long customerId; - private Address billingAddress; - private Address shippingAddress; - private List lineItems = new ArrayList<>(); - - public Order(Long orderId, Long customerId, Address address) { - this.id = orderId; - this.customerId = customerId; - this.billingAddress = address; - this.shippingAddress = address; - } - - /** - * Returns the total of the [Order]. - * - * @return - */ - - public BigDecimal calcTotal() { - if (lineItems.size() == 0) { - return BigDecimal.ZERO; - } else { - return lineItems.stream().map(LineItem::calcTotal).reduce(BigDecimal::add).get(); - } - } - - /** - * Adds the given [LineItem] to the [Order]. - * - * @param lineItem - */ - public void add(LineItem lineItem) { - lineItems.add(lineItem); - } -} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Product.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Product.java deleted file mode 100755 index 6a8f3672..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Product.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.annotation.PersistenceConstructor; -import org.springframework.data.annotation.Transient; -import org.springframework.data.gemfire.mapping.annotation.Region; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.Map; - -/** - * A product used in the examples. - * - * @author Oliver Gierke - * @author David Turanski - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@Region("Products") -public class Product implements Serializable { - - @Id - private Long id; - private String name; - private BigDecimal price; - private String description; - - @Transient - private Map attributes = new HashMap<>(); - - @PersistenceConstructor - public Product(Long id, String name, BigDecimal price, String description) { - this.id = id; - this.name = name; - this.price = price; - this.description = description; - } - - /** - * Sets the attribute with the given name to the given value. - * - * @param name must not be null or empty. - * @param value - */ - public void addAttribute(String name, String value) { - this.attributes.put(name, value); - } -} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerFunctionExecutions.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerFunctionExecutions.java deleted file mode 100755 index 930f00db..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerFunctionExecutions.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function.client; - -import example.springdata.geode.client.function.Customer; - -import java.util.List; - -import org.springframework.data.gemfire.function.annotation.FunctionId; -import org.springframework.data.gemfire.function.annotation.OnRegion; - -/** - * @author Patrick Johnson - */ -@OnRegion(region = "Customers") -public interface CustomerFunctionExecutions { - - @FunctionId("listConsumersForEmailAddressesFnc") - List> listAllCustomersForEmailAddress(String... emailAddresses); -} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerRepository.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerRepository.java deleted file mode 100755 index b9dbb5ae..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerRepository.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function.client; - -import example.springdata.geode.client.function.Customer; - -import java.util.List; - -import org.springframework.data.gemfire.mapping.annotation.ClientRegion; -import org.springframework.data.gemfire.repository.Query; -import org.springframework.data.gemfire.repository.query.annotation.Hint; -import org.springframework.data.gemfire.repository.query.annotation.Limit; -import org.springframework.data.gemfire.repository.query.annotation.Trace; -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -@ClientRegion("Customers") -public interface CustomerRepository extends CrudRepository { - - @Trace - @Limit(100) - @Hint("emailAddressIndex") - @Query("select * from /Customers customer where customer.emailAddress.value = $1") - List findByEmailAddressUsingIndex(String emailAddress); - - @Trace - @Limit(100) - @Query("select * from /Customers customer where customer.firstName = $1") - List findByFirstNameUsingIndex(String firstName); -} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/FunctionInvocationClientApplicationConfig.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/FunctionInvocationClientApplicationConfig.java deleted file mode 100755 index 815e5aa1..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/FunctionInvocationClientApplicationConfig.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function.client; - -import example.springdata.geode.client.function.Customer; -import example.springdata.geode.client.function.Order; -import example.springdata.geode.client.function.Product; - -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.cache.client.ClientRegionShortcut; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.gemfire.client.ClientRegionFactoryBean; -import org.springframework.data.gemfire.config.annotation.ClientCacheApplication; -import org.springframework.data.gemfire.function.config.EnableGemfireFunctionExecutions; -import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories; -import org.springframework.data.gemfire.transaction.config.EnableGemfireCacheTransactions; - -/** - * Spring JavaConfig configuration class to setup a Spring container and infrastructure components. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Configuration -@EnableGemfireRepositories(basePackageClasses = CustomerRepository.class) -@EnableGemfireFunctionExecutions(basePackageClasses = CustomerFunctionExecutions.class) -@ClientCacheApplication(name = "FunctionInvocationClient", logLevel = "error", pingInterval = 5000L, - readTimeout = 15000, retryAttempts = 1) -@EnableGemfireCacheTransactions -public class FunctionInvocationClientApplicationConfig { - - @Bean("Customers") - protected ClientRegionFactoryBean configureProxyClientCustomerRegion(GemFireCache gemFireCache) { - ClientRegionFactoryBean clientRegionFactoryBean = new ClientRegionFactoryBean<>(); - clientRegionFactoryBean.setCache(gemFireCache); - clientRegionFactoryBean.setName("Customers"); - clientRegionFactoryBean.setShortcut(ClientRegionShortcut.PROXY); - return clientRegionFactoryBean; - } - - @Bean("Products") - protected ClientRegionFactoryBean configureProxyClientProductRegion(GemFireCache gemFireCache) { - ClientRegionFactoryBean clientRegionFactoryBean = new ClientRegionFactoryBean<>(); - clientRegionFactoryBean.setCache(gemFireCache); - clientRegionFactoryBean.setName("Products"); - clientRegionFactoryBean.setShortcut(ClientRegionShortcut.PROXY); - return clientRegionFactoryBean; - } - - @Bean("Orders") - protected ClientRegionFactoryBean configureProxyClientOrderRegion(GemFireCache gemFireCache) { - ClientRegionFactoryBean clientRegionFactoryBean = new ClientRegionFactoryBean<>(); - clientRegionFactoryBean.setCache(gemFireCache); - clientRegionFactoryBean.setName("Orders"); - clientRegionFactoryBean.setShortcut(ClientRegionShortcut.PROXY); - return clientRegionFactoryBean; - } -} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderFunctionExecutions.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderFunctionExecutions.java deleted file mode 100755 index 49683ea4..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderFunctionExecutions.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function.client; - -import java.math.BigDecimal; -import java.util.List; - -import org.springframework.data.gemfire.function.annotation.FunctionId; -import org.springframework.data.gemfire.function.annotation.OnRegion; - -/** - * @author Patrick Johnson - */ -@OnRegion(region = "Orders") -public interface OrderFunctionExecutions { - - @FunctionId("sumPricesForAllProductsForOrderFnc") - List sumPricesForAllProductsForOrder(Long orderId); -} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderRepository.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderRepository.java deleted file mode 100755 index 4cecddd9..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderRepository.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function.client; - -import example.springdata.geode.client.function.Order; - -import org.springframework.data.gemfire.mapping.annotation.ClientRegion; -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -@ClientRegion("Orders") -public interface OrderRepository extends CrudRepository {} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductFunctionExecutions.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductFunctionExecutions.java deleted file mode 100755 index 803fc5ca..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductFunctionExecutions.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function.client; - -import java.math.BigDecimal; -import java.util.List; - -import org.springframework.data.gemfire.function.annotation.FunctionId; -import org.springframework.data.gemfire.function.annotation.OnRegion; - -/** - * @author Patrick Johnson - */ -@OnRegion(region = "Products") -public interface ProductFunctionExecutions { - - @FunctionId("sumPricesForAllProductsFnc") - List sumPricesForAllProducts(); -} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductRepository.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductRepository.java deleted file mode 100755 index fd5bbc34..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductRepository.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function.client; - -import example.springdata.geode.client.function.Product; - -import org.springframework.data.gemfire.mapping.annotation.ClientRegion; -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -@ClientRegion("Products") -public interface ProductRepository extends CrudRepository {} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/CustomerFunctions.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/CustomerFunctions.java deleted file mode 100755 index 6a017fe5..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/CustomerFunctions.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function.server; - -import example.springdata.geode.client.function.Customer; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.springframework.data.gemfire.function.annotation.GemfireFunction; -import org.springframework.data.gemfire.function.annotation.RegionData; -import org.springframework.stereotype.Component; - -/** - * @author Patrick Johnson - */ -@Component -public class CustomerFunctions { - - @GemfireFunction(id = "listConsumersForEmailAddressesFnc", HA = true, optimizeForWrite = true, batchSize = 3, - hasResult = true) - public List listAllCustomersForEmailAddress(@RegionData Map customerData, - String... emailAddresses) { - var emailAddressesAsList = Arrays.asList(emailAddresses); - var collect = customerData.values().parallelStream() - .filter((customer) -> emailAddressesAsList.contains(customer.getEmailAddress().getValue())) - .collect(Collectors.toList()); - return collect; - } -} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServer.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServer.java deleted file mode 100755 index 422ec296..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServer.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function.server; - -import org.springframework.boot.WebApplicationType; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; - -/** - * @author Patrick Johnson - */ -@SpringBootApplication -public class FunctionServer { - - public static void main(String[] args) { - new SpringApplicationBuilder(FunctionServer.class).web(WebApplicationType.NONE).build().run(args); - } -} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServerApplicationConfig.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServerApplicationConfig.java deleted file mode 100755 index cc6f6ef1..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServerApplicationConfig.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function.server; - -import example.springdata.geode.client.function.Customer; -import example.springdata.geode.client.function.Order; -import example.springdata.geode.client.function.Product; -import example.springdata.geode.client.function.client.CustomerRepository; - -import org.apache.geode.cache.DataPolicy; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.cache.Scope; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.gemfire.ReplicatedRegionFactoryBean; -import org.springframework.data.gemfire.config.annotation.CacheServerApplication; -import org.springframework.data.gemfire.config.annotation.EnableIndexing; -import org.springframework.data.gemfire.config.annotation.EnableLocator; -import org.springframework.data.gemfire.config.annotation.EnableManager; -import org.springframework.data.gemfire.function.config.EnableGemfireFunctions; -import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories; - -/** - * @author Patrick Johnson - */ -@Configuration -@ComponentScan(basePackageClasses = CustomerFunctions.class) -@EnableGemfireFunctions -@EnableGemfireRepositories(basePackageClasses = CustomerRepository.class) -@EnableLocator -@EnableIndexing -@EnableManager -@CacheServerApplication(port = 0, logLevel = "error") -public class FunctionServerApplicationConfig { - - @Bean("Customers") - ReplicatedRegionFactoryBean createCustomerRegion(GemFireCache gemfireCache) { - ReplicatedRegionFactoryBean replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>(); - replicatedRegionFactoryBean.setCache(gemfireCache); - replicatedRegionFactoryBean.setRegionName("Customers"); - replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE); - replicatedRegionFactoryBean.setScope(Scope.DISTRIBUTED_ACK); - return replicatedRegionFactoryBean; - } - - @Bean("Orders") - ReplicatedRegionFactoryBean createOrderRegion(GemFireCache gemfireCache) { - ReplicatedRegionFactoryBean replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>(); - replicatedRegionFactoryBean.setCache(gemfireCache); - replicatedRegionFactoryBean.setRegionName("Orders"); - replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE); - return replicatedRegionFactoryBean; - } - - @Bean("Products") - ReplicatedRegionFactoryBean createProductRegion(GemFireCache gemfireCache) { - ReplicatedRegionFactoryBean replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>(); - replicatedRegionFactoryBean.setCache(gemfireCache); - replicatedRegionFactoryBean.setRegionName("Products"); - replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE); - return replicatedRegionFactoryBean; - } -} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/OrderFunctions.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/OrderFunctions.java deleted file mode 100755 index 4516d0f1..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/OrderFunctions.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function.server; - -import example.springdata.geode.client.function.Order; - -import java.math.BigDecimal; -import java.util.Map; - -import org.springframework.data.gemfire.function.annotation.GemfireFunction; -import org.springframework.data.gemfire.function.annotation.RegionData; -import org.springframework.stereotype.Component; - -/** - * @author Patrick Johnson - */ -@Component -public class OrderFunctions { - - @GemfireFunction(id = "sumPricesForAllProductsForOrderFnc", HA = true, optimizeForWrite = false, hasResult = true) - public BigDecimal sumPricesForAllProductsForOrderFnc(Long orderId, @RegionData Map orderData) { - return orderData.get(orderId).calcTotal(); - } -} diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/ProductFunctions.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/ProductFunctions.java deleted file mode 100755 index e52fb5c1..00000000 --- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/ProductFunctions.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function.server; - -import example.springdata.geode.client.function.Product; - -import java.math.BigDecimal; -import java.util.Map; - -import org.springframework.data.gemfire.function.annotation.GemfireFunction; -import org.springframework.data.gemfire.function.annotation.RegionData; -import org.springframework.stereotype.Component; - -/** - * @author Patrick Johnson - */ -@Component -public class ProductFunctions { - - @GemfireFunction(id = "sumPricesForAllProductsFnc", HA = true, hasResult = true) - public BigDecimal sumPricesForAllProductsFnc(@RegionData Map productData) { - return productData.values().stream().map(Product::getPrice).reduce(BigDecimal::add).get(); - } -} diff --git a/geode/function-invocation/src/test/java/example/springdata/geode/client/function/client/FunctionInvocationClientTests.java b/geode/function-invocation/src/test/java/example/springdata/geode/client/function/client/FunctionInvocationClientTests.java deleted file mode 100755 index 1bded694..00000000 --- a/geode/function-invocation/src/test/java/example/springdata/geode/client/function/client/FunctionInvocationClientTests.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.function.client; - -import static org.assertj.core.api.Assertions.*; - -import example.springdata.geode.client.function.Address; -import example.springdata.geode.client.function.Customer; -import example.springdata.geode.client.function.EmailAddress; -import example.springdata.geode.client.function.LineItem; -import example.springdata.geode.client.function.Order; -import example.springdata.geode.client.function.Product; -import example.springdata.geode.client.function.server.FunctionServer; -import lombok.extern.apachecommons.CommonsLog; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Random; -import java.util.stream.IntStream; -import java.util.stream.LongStream; - -import jakarta.annotation.Resource; - -import org.apache.geode.cache.Region; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Patrick Johnson - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = FunctionInvocationClientApplicationConfig.class) -@CommonsLog -public class FunctionInvocationClientTests extends ForkingClientServerIntegrationTestsSupport { - - @Autowired private CustomerRepository customerRepository; - - @Autowired private OrderRepository orderRepository; - - @Autowired private ProductRepository productRepository; - - @Autowired private CustomerFunctionExecutions customerFunctionExecutions; - - @Autowired private OrderFunctionExecutions orderFunctionExecutions; - - @Autowired private ProductFunctionExecutions productFunctionExecutions; - - @Resource(name = "Customers") private Region customers; - - @Resource(name = "Orders") private Region orders; - - @Resource(name = "Products") private Region products; - - @BeforeClass - public static void setup() throws IOException { - startGemFireServer(FunctionServer.class); - } - - @Test - public void functionsExecuteCorrectly() { - createCustomerData(); - - var cust = customerFunctionExecutions.listAllCustomersForEmailAddress("2@2.com", "3@3.com").get(0); - assertThat(cust.size()).isEqualTo(2); - log.info("All customers for emailAddresses:3@3.com,2@2.com using function invocation: \n\t " + cust); - - createProducts(); - var sum = productFunctionExecutions.sumPricesForAllProducts().get(0); - assertThat(sum).isEqualTo(BigDecimal.valueOf(1499.97)); - log.info("Running function to sum up all product prices: \n\t" + sum); - - createOrders(); - - sum = orderFunctionExecutions.sumPricesForAllProductsForOrder(1L).get(0); - assertThat(sum).isGreaterThanOrEqualTo(BigDecimal.valueOf(99.99)); - log.info("Running function to sum up all order lineItems prices for order 1: \n\t" + sum); - var order = orderRepository.findById(1L).get(); - log.info("For order: \n\t " + order); - } - - public void createCustomerData() { - - log.info("Inserting 3 entries for keys: 1, 2, 3"); - - customerRepository.save(new Customer(1L, new EmailAddress("2@2.com"), "John", "Smith")); - customerRepository.save(new Customer(2L, new EmailAddress("3@3.com"), "Frank", "Lamport")); - customerRepository.save(new Customer(3L, new EmailAddress("5@5.com"), "Jude", "Simmons")); - - assertThat(customers.keySetOnServer().size()).isEqualTo(3); - } - - public void createProducts() { - - productRepository.save(new Product(1L, "Apple iPod", new BigDecimal("99.99"), "An Apple portable music player")); - productRepository.save(new Product(2L, "Apple iPad", new BigDecimal("499.99"), "An Apple tablet device")); - var macbook = new Product(3L, "Apple macBook", new BigDecimal("899.99"), "An Apple notebook computer"); - macbook.addAttribute("warranty", "included"); - - productRepository.save(macbook); - - assertThat(products.keySetOnServer().size()).isEqualTo(3); - } - - public void createOrders() { - - var random = new Random(); - var address = new Address("it", "doesn't", "matter"); - - LongStream.rangeClosed(1, 100).forEach((orderId) -> LongStream.rangeClosed(1, 3).forEach((customerId) -> { - var order = new Order(orderId, customerId, address); - IntStream.rangeClosed(0, random.nextInt(3) + 1).forEach((lineItemCount) -> { - var quantity = random.nextInt(3) + 1; - long productId = random.nextInt(3) + 1; - order.add(new LineItem(productRepository.findById(productId).get(), quantity)); - }); - orderRepository.save(order); - })); - - assertThat(orders.keySetOnServer().size()).isEqualTo(100); - } -} diff --git a/geode/function-invocation/src/test/resources/logback.xml b/geode/function-invocation/src/test/resources/logback.xml deleted file mode 100644 index f3b82068..00000000 --- a/geode/function-invocation/src/test/resources/logback.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - %msg%n - - - - - - - \ No newline at end of file diff --git a/geode/pom.xml b/geode/pom.xml deleted file mode 100755 index 714e83f7..00000000 --- a/geode/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - 4.0.0 - - spring-data-geode-examples - pom - - - org.springframework.data.examples - spring-data-examples - 2.0.0.BUILD-SNAPSHOT - - - Spring Data for Apache Geode - Examples - Sample projects for Spring Data for Apache Geode - https://projects.spring.io/spring-data-geode - - - events - expiration-eviction - function-invocation - queries - security - storage - transactions - wan - - - - 0.1.2 - - - - - - org.iq80.snappy - snappy - 0.4 - - - - - - - org.springframework.data - spring-data-geode - - - com.github.javafaker - javafaker - 1.0.1 - - - org.springframework.data - spring-data-geode-test - ${spring.test.data.geode.version} - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/geode/queries/README.md b/geode/queries/README.md deleted file mode 100755 index fb464edf..00000000 --- a/geode/queries/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Queries Example - -In this example we will demonstrate different kinds of queries. The kinds of queries we will demonstrate are listed below. -1. OQL Queries - OQL is similar to SQl and can be used to query regions like SQl queries tables in a relational database. -2. Continuous Queries - Continuous queries are special OQl queries that run continuously and are updated when th returned result set changes (like then more data is added/removed on the region) -3. Lucene Queries - Lucene Queries allow you ot query data that has been indexed with Apache Geode's Apache Lucene support. - -NOTE: Inorder to see output, you must change the loglevel from "error" to "info" in the `logback.xml` file located under src/test/resources. \ No newline at end of file diff --git a/geode/queries/pom.xml b/geode/queries/pom.xml deleted file mode 100755 index 6e1e9e23..00000000 --- a/geode/queries/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - 4.0.0 - - - org.springframework.data.examples - spring-data-geode-examples - 2.0.0.BUILD-SNAPSHOT - - - spring-data-geode-queries-example - Spring Data Geode - Queries - - - - org.awaitility - awaitility - test - - - - diff --git a/geode/queries/src/main/java/example/springdata/geode/client/queries/Customer.java b/geode/queries/src/main/java/example/springdata/geode/client/queries/Customer.java deleted file mode 100755 index 8a1d80a9..00000000 --- a/geode/queries/src/main/java/example/springdata/geode/client/queries/Customer.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package example.springdata.geode.client.queries; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.gemfire.mapping.annotation.LuceneIndexed; -import org.springframework.data.gemfire.mapping.annotation.PartitionRegion; - -import java.io.Serializable; - -/** - * A customer used for Lucene examples. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ - -@Data -@PartitionRegion(name = "Customers") -public class Customer implements Serializable { - - @Id - private Long id; - private EmailAddress emailAddress; - private String firstName; - - @LuceneIndexed(name = "lastName_lucene") - private String lastName; - - public Customer(long id, EmailAddress emailAddress, String firstName, String lastName) { - this.id = id; - this.emailAddress = emailAddress; - this.firstName = firstName; - this.lastName = lastName; - } -} diff --git a/geode/queries/src/main/java/example/springdata/geode/client/queries/EmailAddress.java b/geode/queries/src/main/java/example/springdata/geode/client/queries/EmailAddress.java deleted file mode 100755 index e7d80374..00000000 --- a/geode/queries/src/main/java/example/springdata/geode/client/queries/EmailAddress.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.queries; - -import lombok.Data; - -import java.io.Serializable; - -/** - * Value object to represent email addresses. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -public class EmailAddress implements Serializable { - - private String value; - - public EmailAddress(String value) { - - this.value = value; - } -} diff --git a/geode/queries/src/main/java/example/springdata/geode/client/queries/client/CustomerRepository.java b/geode/queries/src/main/java/example/springdata/geode/client/queries/client/CustomerRepository.java deleted file mode 100755 index a4df4820..00000000 --- a/geode/queries/src/main/java/example/springdata/geode/client/queries/client/CustomerRepository.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.queries.client; - -import example.springdata.geode.client.queries.Customer; - -import java.util.List; - -import org.springframework.data.gemfire.mapping.annotation.ClientRegion; -import org.springframework.data.gemfire.repository.Query; -import org.springframework.data.gemfire.repository.query.annotation.Hint; -import org.springframework.data.gemfire.repository.query.annotation.Limit; -import org.springframework.data.gemfire.repository.query.annotation.Trace; -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -@ClientRegion(name = "Customers") -public interface CustomerRepository extends CrudRepository { - - @Trace - @Limit(100) - @Hint("emailAddressIndex") - @Query("select * from /Customers customer where customer.emailAddress.value = $1") - List findByEmailAddressUsingIndex(String emailAddress); - - @Trace - @Limit(100) - @Query("select * from /Customers customer where customer.firstName = $1") - List findByFirstNameUsingIndex(String firstName); -} diff --git a/geode/queries/src/main/java/example/springdata/geode/client/queries/client/QueryClientConfig.java b/geode/queries/src/main/java/example/springdata/geode/client/queries/client/QueryClientConfig.java deleted file mode 100755 index 1a95f4bf..00000000 --- a/geode/queries/src/main/java/example/springdata/geode/client/queries/client/QueryClientConfig.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.queries.client; - -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.cache.client.ClientRegionShortcut; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.DependsOn; -import org.springframework.data.gemfire.GemfireTemplate; -import org.springframework.data.gemfire.config.annotation.ClientCacheApplication; -import org.springframework.data.gemfire.config.annotation.EnableClusterDefinedRegions; -import org.springframework.data.gemfire.config.annotation.EnableContinuousQueries; -import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories; -import org.springframework.data.gemfire.search.lucene.LuceneTemplate; - -/** - * @author Patrick Johnson - */ -@Configuration -@EnableGemfireRepositories -@ClientCacheApplication(name = "CQClientCache", logLevel = "error", pingInterval = 5000L, readTimeout = 15000, - subscriptionEnabled = true, readyForEvents = true) -@EnableContinuousQueries -@EnableClusterDefinedRegions(clientRegionShortcut = ClientRegionShortcut.PROXY) -public class QueryClientConfig { - - @Bean("customerTemplate") - @DependsOn("Customers") - protected GemfireTemplate configureCustomerTemplate(GemFireCache gemfireCache) { - return new GemfireTemplate(gemfireCache.getRegion("Customers")); - } - - @Bean - LuceneTemplate createCustomerLuceneTemplate() { - return new LuceneTemplate("lastName_lucene", "/Customers"); - } -} diff --git a/geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServer.java b/geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServer.java deleted file mode 100755 index cbd501e6..00000000 --- a/geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServer.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.queries.server; - -import org.springframework.boot.WebApplicationType; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; - -/** - * @author Patrick Johnson - */ -@SpringBootApplication -public class QueryServer { - - public static void main(String[] args) { - new SpringApplicationBuilder(QueryServer.class).web(WebApplicationType.NONE).build().run(args); - } -} diff --git a/geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServerConfig.java b/geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServerConfig.java deleted file mode 100755 index ed36eeef..00000000 --- a/geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServerConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.queries.server; - -import example.springdata.geode.client.queries.Customer; -import example.springdata.geode.client.queries.client.CustomerRepository; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.DependsOn; -import org.springframework.data.gemfire.config.annotation.CacheServerApplication; -import org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions; -import org.springframework.data.gemfire.config.annotation.EnableIndexing; -import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories; -import org.springframework.data.gemfire.search.lucene.LuceneTemplate; - -/** - * @author Patrick Johnson - */ -@Configuration -@CacheServerApplication(logLevel = "error") -@EnableGemfireRepositories(basePackageClasses = CustomerRepository.class) -@EnableEntityDefinedRegions(basePackageClasses = Customer.class) -@EnableIndexing -public class QueryServerConfig { - - @Bean - @DependsOn("lastName_lucene") - LuceneTemplate createCustomerLuceneTemplate() { - return new LuceneTemplate("lastName_lucene", "/Customers"); - } -} diff --git a/geode/queries/src/test/java/example/springdata/geode/client/queries/QueryTests.java b/geode/queries/src/test/java/example/springdata/geode/client/queries/QueryTests.java deleted file mode 100755 index 38582db6..00000000 --- a/geode/queries/src/test/java/example/springdata/geode/client/queries/QueryTests.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.queries; - -import static org.assertj.core.api.Assertions.*; - -import example.springdata.geode.client.queries.client.CustomerRepository; -import example.springdata.geode.client.queries.client.QueryClientConfig; -import example.springdata.geode.client.queries.server.QueryServer; -import lombok.extern.apachecommons.CommonsLog; - -import java.io.IOException; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import jakarta.annotation.Resource; - -import org.apache.geode.cache.Region; -import org.apache.geode.cache.lucene.LuceneResultStruct; -import org.apache.geode.cache.query.CqEvent; -import org.awaitility.Awaitility; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.gemfire.GemfireTemplate; -import org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer; -import org.springframework.data.gemfire.listener.annotation.ContinuousQuery; -import org.springframework.data.gemfire.search.lucene.LuceneTemplate; -import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Patrick Johnson - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = QueryClientConfig.class) -@CommonsLog -public class QueryTests extends ForkingClientServerIntegrationTestsSupport { - - @Autowired private ContinuousQueryListenerContainer container; - - @Autowired private CustomerRepository customerRepository; - - @Autowired private GemfireTemplate customerTemplate; - - @Resource(name = "Customers") private Region customers; - - @Autowired private LuceneTemplate luceneTemplate; - - private AtomicInteger counter = new AtomicInteger(0); - - @BeforeClass - public static void setup() throws IOException { - startGemFireServer(QueryServer.class); - } - - @Test - public void luceneIsConfiguredCorrectly() { - - customerRepository.save(new Customer(1L, new EmailAddress("name@internet.com"), "Stephanie", "Demarco")); - customerRepository.save(new Customer(2L, new EmailAddress("cool_Guy57@mail.com"), "Patrick", "Dunham")); - customerRepository.save(new Customer(3L, new EmailAddress("scientist@mail.com"), "Jasmine", "Oliander")); - customerRepository.save(new Customer(4L, new EmailAddress("catlover42@mail.com"), "Erica", "Shu")); - customerRepository.save(new Customer(5L, new EmailAddress("zolander@mail.com"), "Tom", "Darude")); - - List> lastName = luceneTemplate.query("D*", "lastName", 10); - - assertThat(lastName.size()).isEqualTo(3); - log.info("Customers with last names beginning with 'D':"); - lastName.forEach(result -> log.info(result.getValue().toString())); - } - - @Test - public void oqlQueriesConfiguredCorrectly() { - - log.info("Inserting 3 entries for keys: 1, 2, 3"); - var john = new Customer(1L, new EmailAddress("2@2.com"), "John", "Smith"); - var frank = new Customer(2L, new EmailAddress("3@3.com"), "Frank", "Lamport"); - var jude = new Customer(3L, new EmailAddress("5@5.com"), "Jude", "Simmons"); - customerRepository.save(john); - customerRepository.save(frank); - customerRepository.save(jude); - assertThat(customers.keySetOnServer().size()).isEqualTo(3); - - var customer = customerRepository.findById(2L).get(); - assertThat(customer).isEqualTo(frank); - log.info("Find customer with key=2 using GemFireRepository: " + customer); - List customerList = customerTemplate.find("select * from /Customers where id=$1", 2L).asList(); - assertThat(customerList.size()).isEqualTo(1); - assertThat(customerList.contains(frank)).isTrue(); - log.info("Find customer with key=2 using GemFireTemplate: " + customerList); - - customer = new Customer(1L, new EmailAddress("3@3.com"), "Jude", "Smith"); - customerRepository.save(customer); - assertThat(customers.keySetOnServer().size()).isEqualTo(3); - - customerList = customerRepository.findByEmailAddressUsingIndex("3@3.com"); - assertThat(customerList.size()).isEqualTo(2); - assertThat(customerList.contains(frank)).isTrue(); - assertThat(customerList.contains(customer)).isTrue(); - log.info("Find customers with emailAddress=3@3.com: " + customerList); - - customerList = customerRepository.findByFirstNameUsingIndex("Frank"); - assertThat(customerList.get(0)).isEqualTo(frank); - - log.info("Find customers with firstName=Frank: " + customerList); - - customerList = customerRepository.findByFirstNameUsingIndex("Jude"); - - assertThat(customerList.size()).isEqualTo(2); - assertThat(customerList.contains(jude)).isTrue(); - assertThat(customerList.contains(customer)).isTrue(); - - log.info("Find customers with firstName=Jude: " + customerList); - } - - @Test - public void continuousQueryWorkingCorrectly() { - - assertThat(this.customers).isEmpty(); - - log.info("Inserting 3 entries for keys: 1, 2, 3"); - - customerRepository.save(new Customer(1L, new EmailAddress("2@2.com"), "John", "Smith")); - customerRepository.save(new Customer(2L, new EmailAddress("3@3.com"), "Frank", "Lamport")); - customerRepository.save(new Customer(3L, new EmailAddress("5@5.com"), "Jude", "Simmons")); - - assertThat(customers.keySetOnServer().size()).isEqualTo(3); - - Awaitility.await().atMost(30, TimeUnit.SECONDS).until(() -> this.counter.get() == 3); - } - - @ContinuousQuery(name = "CustomerCQ", query = "SELECT * FROM /Customers") - public void handleEvent(CqEvent event) { - log.info("Received message for CQ 'CustomerCQ'" + event); - counter.incrementAndGet(); - } - - @After - public void cleanup() { - customerRepository.deleteAll(customerRepository.findAll()); - container.getQueryService().closeCqs(); - } -} diff --git a/geode/queries/src/test/resources/logback.xml b/geode/queries/src/test/resources/logback.xml deleted file mode 100644 index f3b82068..00000000 --- a/geode/queries/src/test/resources/logback.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - %msg%n - - - - - - - \ No newline at end of file diff --git a/geode/security/README.md b/geode/security/README.md deleted file mode 100755 index af8732ed..00000000 --- a/geode/security/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Security Example - -In this example a [Pivotal GemFire](https://pivotal.io/pivotal-gemfire) / [Apache Geode](http://geode.apache.org/) client and server will set up with security (username/password) authentication using Geode Security and Apache Shiro. - -To run the example simply run the tests located under security/src/test in your IDE. There are two test files; one uses Geode Security and the other uses Apache Shiro. Both versions should behave the same. - -The client is configured to connect to the server on `localhost` port `40404`. There is no need to start the server separately, as that is taken care of by the test. - -## Running the example - -The example is broken up into multiple steps: -1. Insert (Put) three Customer entries into the `Customers` region using the repositories `save` method. -2. Print the customers on the server. - -NOTE: Inorder to see output, you must change the loglevel from "error" to "info" in the `logback.xml` file located under src/test/resources. \ No newline at end of file diff --git a/geode/security/pom.xml b/geode/security/pom.xml deleted file mode 100755 index af22c0e1..00000000 --- a/geode/security/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - 4.0.0 - - - org.springframework.data.examples - spring-data-geode-examples - 2.0.0.BUILD-SNAPSHOT - - - spring-data-geode-security-example - Spring Data Geode - Security - - - - org.springframework - spring-jdbc - - - org.springframework.data - spring-data-jpa - - - org.hsqldb - hsqldb - - - jakarta.persistence - jakarta.persistence-api - - - - diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/Constants.java b/geode/security/src/main/java/example/springdata/geode/client/security/Constants.java deleted file mode 100755 index 570ee573..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/Constants.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security; - -/** - * The [Constants] class contains properties and other constants used in the Apache Geode Integrated Security - * framework. - * - * @author John Blum - * @since 1.0.0 - */ -public class Constants { - - public static final String SECURITY_PASSWORD_PROPERTY = "security-password"; - public static final String SECURITY_USERNAME_PROPERTY = "security-username"; -} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/Customer.java b/geode/security/src/main/java/example/springdata/geode/client/security/Customer.java deleted file mode 100755 index 9a7a76a9..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/Customer.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.gemfire.mapping.annotation.Region; - -import java.io.Serializable; - -/** - * A customer used for Lucene examples. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@Region(name = "Customers") -public class Customer implements Serializable { - - @Id - private Long id; - private EmailAddress emailAddress; - private String firstName; - private String lastName; - - public Customer(Long id, EmailAddress emailAddress, String firstName, String lastName) { - this.id = id; - this.emailAddress = emailAddress; - this.firstName = firstName; - this.lastName = lastName; - } -} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/EmailAddress.java b/geode/security/src/main/java/example/springdata/geode/client/security/EmailAddress.java deleted file mode 100755 index b0bc5579..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/EmailAddress.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security; - -import lombok.Data; - -import java.io.Serializable; - -/** - * Value object to represent email addresses. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -public class EmailAddress implements Serializable { - private String value; - - public EmailAddress(String value) { - - this.value = value; - } -} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/Role.java b/geode/security/src/main/java/example/springdata/geode/client/security/Role.java deleted file mode 100755 index bdfe999a..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/Role.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security; - -import lombok.Data; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; - -import org.apache.geode.security.ResourcePermission; - -/** - * The [Role] class is an Abstract Data Type (ADT) modeling a role of a user (e.g. Admin). - * - * @author John Blum - * @see Serializable - * @see Comparable - * @see Iterable - * @see ResourcePermission - * @since 1.0.0 - */ -@Data -public class Role implements Comparable, Iterable, Serializable { - - private String name; - private HashSet permissions = new HashSet<>(); - - public Role(String name) { - this.name = name; - } - - public String getId() { - return name; - } - - public void setId(String id) { - throw new UnsupportedOperationException("Operation Not Supported"); - } - - /** - * @inheritDoc - */ - @Override - public int compareTo(Role other) { - return name.compareTo(other.name); - } - - /** - * Determines whether this [Role] has been assigned (granted) the given [permission][ResourcePermission]. - * - * @param permission [ResourcePermission] to evaluate. - * @return a boolean value indicating whether this [Role] has been assigned (granted) the given - * [permission][ResourcePermission]. - * @see ResourcePermission - */ - public boolean hasPermission(ResourcePermission permission) { - return this.permissions.contains(permission); - } - - /** - * @inheritDoc - */ - @Override - public Iterator iterator() { - return this.permissions.iterator(); - } - - /** - * Adds (assigns/grants) all given [permissions][ResourcePermission] to this [Role]. - * - * @param permissions [ResourcePermission]s to assign/grant to this [Role]. - * @return this [Role]. - * @see ResourcePermission - */ - public Role withPermissions(ResourcePermission... permissions) { - this.permissions.addAll((Arrays.asList(permissions))); - return this; - } - - /** - * Adds (assigns/grants) all given [permissions][ResourcePermission] to this [Role]. - * - * @param permissions [ResourcePermission]s to assign/grant to this [Role]. - * @return this [Role]. - * @see ResourcePermission - */ - public Role withPermissions(Iterable permissions) { - this.permissions.addAll((Collection) permissions); - return this; - } - - /** - * Factory method used to construct a new instance of [Role] initialized with the given name. - * - * @param name [String] indicating the name of the new [Role]. - * @return a new [Role] initialized with the given name. - * @see Role - */ - public static Role newRole(String name) { - return new Role(name); - } -} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/User.java b/geode/security/src/main/java/example/springdata/geode/client/security/User.java deleted file mode 100755 index 5453874d..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/User.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security; - -import lombok.Data; - -import java.io.Serializable; -import java.security.Principal; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.apache.geode.security.ResourcePermission; - -/** - * @author Patrick Johnson - */ -@Data -public class User implements Comparable, Cloneable, Principal, Serializable, Iterable { - - private String name; - private List roles; - - private String credentials = null; - - public User(String name, List roles) { - this.name = name; - this.roles = roles; - } - - public User(String name) { - this(name, new ArrayList<>()); - } - - public void setId(String id) { - throw new UnsupportedOperationException("Operation Not Supported"); - } - - public String getId() { - return name; - } - - @Override - public Iterator iterator() { - return roles.iterator(); - } - - /** - * @inheritDoc - */ - @Override - public Object clone() { - return newUser(name).withCredentials(credentials).withRoles(roles); - } - - /** - * @inheritDoc - */ - @Override - public int compareTo(User other) { - return this.getName().compareTo(other.getName()); - } - - /** - * Determines whether this [User] has been granted (assigned) the given [permission][ResourcePermission]. - * - * @param permission [ResourcePermission] to evaluate. - * @return a boolean value indicating whether this [User] has been granted (assigned) the given [ResourcePermission]. - * @see ResourcePermission - */ - public boolean hasPermission(ResourcePermission permission) { - for (var role : roles) { - if (role.hasPermission(permission)) { - return true; - } - } - return false; - } - - /** - * Determines whether this [User] has the specified [Role]. - * - * @param role [Role] to evaluate. - * @return a boolean value indicating whether this [User] has the specified [Role]. - * @see Role - */ - public boolean hasRole(Role role) { - return roles.contains(role); - } - - /** - * Adds the array of [Roles][Role] granting (resource) permissions to this [User]. - * - * @param roles array of [Roles][Role] granting (resource) permissions to this [User]. - * @return this [User]. - * @see Role - */ - public User withRoles(Role... roles) { - this.roles.addAll(Arrays.asList(roles)); - return this; - } - - public User withRoles(Collection roles) { - this.roles.addAll(roles); - return this; - } - - /** - * Sets this [User's][User] credentials (e.g. password) to the given value. - * - * @param credentials [String] containing this [User's][User] credentials (e.g. password). - * @return this [User]. - * @see User - */ - public User withCredentials(String credentials) { - this.credentials = credentials; - return this; - } - - public static User newUser(String name) { - return new User(name); - } - - @Override - public String getName() { - return name; - } -} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/client/CustomerRepository.java b/geode/security/src/main/java/example/springdata/geode/client/security/client/CustomerRepository.java deleted file mode 100755 index 13aaa686..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/client/CustomerRepository.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security.client; - -import example.springdata.geode.client.security.Customer; - -import java.util.List; - -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -public interface CustomerRepository extends CrudRepository { - - @Override - List findAll(); - -} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/client/SecurityEnabledClientConfiguration.java b/geode/security/src/main/java/example/springdata/geode/client/security/client/SecurityEnabledClientConfiguration.java deleted file mode 100755 index 917367f8..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/client/SecurityEnabledClientConfiguration.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security.client; - -import example.springdata.geode.client.security.Customer; -import org.apache.geode.cache.client.ClientRegionShortcut; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.gemfire.config.annotation.ClientCacheApplication; -import org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions; -import org.springframework.data.gemfire.config.annotation.EnableSecurity; -import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories; - -@Configuration -@EnableSecurity -@EnableGemfireRepositories(basePackageClasses = CustomerRepository.class) -@ClientCacheApplication(name = "SecurityClient", logLevel = "error", pingInterval = 5000L, readTimeout = 15000, retryAttempts = 1) -@EnableEntityDefinedRegions(basePackageClasses = Customer.class, clientRegionShortcut = ClientRegionShortcut.CACHING_PROXY) -public class SecurityEnabledClientConfiguration { -} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/server/ApacheShiroIniConfiguration.java b/geode/security/src/main/java/example/springdata/geode/client/security/server/ApacheShiroIniConfiguration.java deleted file mode 100644 index 9cc87f26..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/server/ApacheShiroIniConfiguration.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security.server; - -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.data.gemfire.config.annotation.EnableSecurity; - -@Configuration -@EnableSecurity(shiroIniResourcePath = "shiro.ini") -@Profile("shiro-ini-configuration") -public class ApacheShiroIniConfiguration {} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/server/CachingSecurityRepository.java b/geode/security/src/main/java/example/springdata/geode/client/security/server/CachingSecurityRepository.java deleted file mode 100755 index 70db0df2..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/server/CachingSecurityRepository.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security.server; - -import example.springdata.geode.client.security.User; - -import java.util.HashMap; -import java.util.Map; - -/** - * The [CachingSecurityRepository] class caches Security Configuration Meta-Data and is meant to be extended - * by classes that are data store specified (e.g. JDBC/RDBMS, LDAP, etc). - * - * @author John Blum - * @see User - * @see SecurityRepository - * @since 1.0.0 - */ -public abstract class CachingSecurityRepository implements SecurityRepository { - - private Map users = new HashMap<>(); - - @Override - public Iterable findAll() { - return users.values(); - } - - @Override - public boolean delete(User user) { - if (user != null) { - return users.remove(user.getName()) != null; - } - return false; - } - - @Override - public User save(User user) { - var putUser = users.put(user.getName(), user); - return putUser != null ? putUser : user; - } -} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/server/GeodeIntegratedSecurityProxyConfiguration.java b/geode/security/src/main/java/example/springdata/geode/client/security/server/GeodeIntegratedSecurityProxyConfiguration.java deleted file mode 100644 index e6ba1c01..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/server/GeodeIntegratedSecurityProxyConfiguration.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security.server; - -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.data.gemfire.config.annotation.EnableSecurity; - -/** - * @author Patrick Johnson - */ -@Configuration -@EnableSecurity(securityManagerClassName = "example.springdata.geode.client.security.server.SecurityManagerProxy") -@Profile({ "default", "geode-security-manager-proxy-configuration" }) -public class GeodeIntegratedSecurityProxyConfiguration {} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/server/JdbcSecurityRepository.java b/geode/security/src/main/java/example/springdata/geode/client/security/server/JdbcSecurityRepository.java deleted file mode 100644 index 83a397c6..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/server/JdbcSecurityRepository.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security.server; - -import example.springdata.geode.client.security.Role; -import example.springdata.geode.client.security.User; -import lombok.extern.apachecommons.CommonsLog; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; - -import org.apache.geode.security.ResourcePermission; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.core.RowMapper; -import org.springframework.stereotype.Repository; - -/** - * @author Patrick Johnson - */ -@Repository -@CommonsLog -public class JdbcSecurityRepository extends CachingSecurityRepository implements InitializingBean { - - private final JdbcTemplate jdbcTemplate; - private static final String ROLES_QUERY = "SELECT name FROM geode_security.roles"; - private static final String ROLE_PERMISSIONS_QUERY = "" - + " SELECT rolePerms.resource, rolePerms.operation, rolePerms.region_name, rolePerms.key_name" - + " FROM geode_security.roles_permissions rolePerms" - + " INNER JOIN geode_security.roles roles ON roles.id = rolePerms.role_id " + " WHERE roles.name = ?"; - private static final String USERS_QUERY = "SELECT name, credentials FROM geode_security.users"; - private static final String USER_ROLES_QUERY = "" + " SELECT roles.name" + " FROM geode_security.roles roles" - + " INNER JOIN geode_security.users_roles userRoles ON roles.id = userRoles.role_id" - + " INNER JOIN geode_security.users users ON userRoles.user_id = users.id" + " WHERE users.name = ?"; - - public JdbcSecurityRepository(JdbcTemplate jdbcTemplate) { - this.jdbcTemplate = jdbcTemplate; - } - - public void afterPropertiesSet() { - - var roles = this.jdbcTemplate.query(ROLES_QUERY, (resultSet, i) -> Role.newRole(resultSet.getString(1))); - var roleMapping = new HashMap(roles.size()); - - roles.forEach((role) -> { - this.jdbcTemplate.query(ROLE_PERMISSIONS_QUERY, Collections.singleton(role.getName()).toArray(), - (RowMapper) (resultSet, i) -> role.withPermissions(newResourcePermission(resultSet.getString(1), - resultSet.getString(2), resultSet.getString(3), resultSet.getString(4)))); - - roleMapping.put(role.getName(), role); - }); - - var users = this.jdbcTemplate.query(USERS_QUERY, - (resultSet, i) -> createUser(resultSet.getString(1)).withCredentials(resultSet.getString(2))); - - users.forEach((role) -> { - this.jdbcTemplate.query(USER_ROLES_QUERY, Collections.singleton(role.getName()).toArray(), - (RowMapper) (resultSet, i) -> role.withRoles(roleMapping.get(resultSet.getString(1)))); - - save(role); - }); - - log.debug(String.format("Users %s", users)); - } - - protected ResourcePermission newResourcePermission(String resource, String operation, String region, String key) { - return new ResourcePermission(resource, operation, region, key); - } -} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityEnabledServer.java b/geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityEnabledServer.java deleted file mode 100755 index 1a773873..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityEnabledServer.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security.server; - -import org.springframework.boot.WebApplicationType; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; - -/** - * @author Patrick Johnson - */ -@SpringBootApplication -public class SecurityEnabledServer { - - public static void main(String[] args) { - new SpringApplicationBuilder(SecurityEnabledServer.class).web(WebApplicationType.NONE).build().run(args); - } - -} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityEnabledServerConfiguration.java b/geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityEnabledServerConfiguration.java deleted file mode 100755 index 1012e0a2..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityEnabledServerConfiguration.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security.server; - -import example.springdata.geode.client.security.Customer; - -import javax.sql.DataSource; - -import org.apache.geode.cache.RegionShortcut; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.data.gemfire.config.annotation.CacheServerApplication; -import org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions; -import org.springframework.data.gemfire.config.annotation.EnableIndexing; -import org.springframework.data.gemfire.config.annotation.EnableLocator; -import org.springframework.data.gemfire.config.annotation.EnableManager; -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; - -/** - * @author Patrick Johnson - */ -@Configuration -@EnableLocator -@EnableIndexing -@EnableManager -@Import({ ApacheShiroIniConfiguration.class, GeodeIntegratedSecurityProxyConfiguration.class }) -@CacheServerApplication(port = 0, logLevel = "error") -@EnableEntityDefinedRegions(basePackageClasses = Customer.class, serverRegionShortcut = RegionShortcut.REPLICATE) -public class SecurityEnabledServerConfiguration { - - @Bean - DataSource hsqlDataSource() { - return new EmbeddedDatabaseBuilder().setName("geode_security").setScriptEncoding("UTF-8") - .setType(EmbeddedDatabaseType.HSQL).addScript("sql/geode-security-schema-ddl.sql") - .addScript("sql/define-roles-table-ddl.sql").addScript("sql/define-roles-permissions-table-ddl.sql") - .addScript("sql/define-users-table-ddl.sql").addScript("sql/define-users-roles-table-ddl.sql") - .addScript("sql/insert-roles-dml.sql").addScript("sql/insert-roles-permissions-dml.sql") - .addScript("sql/insert-users-dml.sql").addScript("sql/insert-users-roles-dml.sql").build(); - } -} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityManagerProxy.java b/geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityManagerProxy.java deleted file mode 100644 index 27c35231..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityManagerProxy.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security.server; - -import java.util.Properties; - -import org.apache.geode.security.AuthenticationFailedException; -import org.apache.geode.security.ResourcePermission; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.gemfire.support.LazyWiringDeclarableSupport; -import org.springframework.util.Assert; - -/** - * The {@link SecurityManagerProxy} class is a Proxy delegating to an underlying Apache Geode - * {@link org.apache.geode.security.SecurityManager} implementation, that maybe a Spring managed bean in a Spring - * context that may have been configured and auto-wired the Spring container, or possibly other managed environment - * (Cloud or Java EE Server, etc). - * - * @author John Blum - * @see org.apache.geode.security.SecurityManager - * @see org.springframework.data.gemfire.support.LazyWiringDeclarableSupport - * @since 1.0.0 - */ -@SuppressWarnings("unused") -public class SecurityManagerProxy extends LazyWiringDeclarableSupport - implements org.apache.geode.security.SecurityManager { - - private org.apache.geode.security.SecurityManager securityManager; - - /** - * Constructs an instance of the {@link SecurityManagerProxy}, which will delegate all Apache Geode security - * operations to a Spring managed {@link org.apache.geode.security.SecurityManager} bean. - */ - public SecurityManagerProxy() { - // TODO remove init() call when GEODE-2083 (https://issues.apache.org/jira/browse/GEODE-2083) is resolved! - // NOTE the init(:Properties) call in the constructor is less than ideal since... - // 1) it allows the *this* reference to escape, and... - // 2) it is Geode's responsibility to identify Geode Declarable objects and invoke their init(:Properties) method - // However, the init(:Properties) method invocation in the constructor is necessary to enable this Proxy to be - // identified and auto-wired in a Spring context. - init(new Properties()); - } - - /** - * Returns a reference to the Apache Geode {@link org.apache.geode.security.SecurityManager} instance delegated to by - * this {@link SecurityManagerProxy}. - * - * @return a reference to the underlying, Apache Geode {@link org.apache.geode.security.SecurityManager} instance - * delegated to by this {@link SecurityManagerProxy}. - * @throws IllegalStateException if the configured Apache Geode {@link org.apache.geode.security.SecurityManager} was - * not properly initialized. - * @see org.apache.geode.security.SecurityManager - */ - protected org.apache.geode.security.SecurityManager getSecurityManager() { - Assert.state(this.securityManager != null, "SecurityManager was not properly initialized"); - return this.securityManager; - } - - /** - * Sets a reference to the Apache Geode {@link org.apache.geode.security.SecurityManager} instance delegated to by - * this {@link SecurityManagerProxy}. - * - * @param securityManager reference to the underlying, Apache Geode {@link org.apache.geode.security.SecurityManager} - * instance delegated to by this {@link SecurityManagerProxy}. - * @throws IllegalArgumentException if the Apache Geode {@link org.apache.geode.security.SecurityManager} reference is - * {@literal null}. - * @see org.apache.geode.security.SecurityManager - */ - @Autowired - public void setSecurityManager(org.apache.geode.security.SecurityManager securityManager) { - Assert.notNull(securityManager, "SecurityManager must not be null"); - this.securityManager = securityManager; - } - - /** - * @inheritDoc - */ - @Override - public Object authenticate(Properties properties) throws AuthenticationFailedException { - return getSecurityManager().authenticate(properties); - } - - /** - * @inheritDoc - */ - @Override - public boolean authorize(Object principal, ResourcePermission permission) { - return getSecurityManager().authorize(principal, permission); - } - - /** - * @inheritDoc - */ - @Override - public void close() { - getSecurityManager().close(); - } -} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityManagerSupport.java b/geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityManagerSupport.java deleted file mode 100755 index c71bdb31..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityManagerSupport.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security.server; - -import example.springdata.geode.client.security.Constants; -import org.apache.geode.security.ResourcePermission; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.security.Principal; -import java.util.Properties; - -/** - * The [SecurityManagerSupport] class is an Apache Geode [SecurityManager] interface adapter providing - * default implementations of the [SecurityManager] interface operations. - * - * @author John Blum - * @see Principal - * @see ResourcePermission - * @see org.apache.geode.security.SecurityManager - * @since 1.0.0 - */ -public abstract class SecurityManagerSupport implements org.apache.geode.security.SecurityManager { - - protected Logger logger = LoggerFactory.getLogger(this.getClass()); - - /* (non-Javadoc)*/ - protected String getName(Object principal) { - if (principal instanceof Principal) { - return ((Principal) principal).getName(); - } else { - return principal.toString(); - } - } - - /* (non-Javadoc)*/ - protected String getPassword(Properties securityProperties) { - return getPropertyValue(securityProperties, Constants.SECURITY_PASSWORD_PROPERTY); - } - - /* (non-Javadoc)*/ - protected String getUsername(Properties securityProperties) { - return getPropertyValue(securityProperties, Constants.SECURITY_USERNAME_PROPERTY); - } - - /* (non-Javadoc)*/ - protected String getPropertyValue(Properties properties, String propertyName) { - return properties.getProperty(propertyName); - } - - /* (non-Javadoc)*/ - protected void logDebug(String message, Object... args) { - if (logger.isDebugEnabled()) { - logger.debug(message, args); - } - } - - /** - * @inheritDoc - */ - @Override - public void init(Properties securityProperties) { - if (logger.isDebugEnabled()) { - logger.debug("Security Properties [{}]", securityProperties); - } - } - - /** - * @inheritDoc - */ - @Override - public Object authenticate(Properties securityProperties) { - return null; - } - - /** - * @inheritDoc - */ - @Override - public boolean authorize(Object principal, ResourcePermission permission) { - return principal != null; - } - - /** - * @inheritDoc - */ - @Override - public void close() { - if (logger.isDebugEnabled()) { - logger.debug("Closing SecurityManager [{}]", this.getClass().getName()); - } - } -} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityRepository.java b/geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityRepository.java deleted file mode 100755 index 086fe7e7..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/server/SecurityRepository.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security.server; - -import example.springdata.geode.client.security.Role; -import example.springdata.geode.client.security.User; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * The [SecurityRepository] interface is a contract for Data Access Objects (DAO) implementing this interface to perform - * CRUD and query operations on [User] information, pertinent to the security of the system. - * - * @author John Blum - * @author Udo Kohlmeyer - * @see Role - * @see User - * @see org.springframework.stereotype.Repository - * @since 1.0.0 - */ -public interface SecurityRepository { - - /** - * Finds all [Users][User] of the system. - * - * @return an [Iterable] of [Users][User] of the system. - * @see User - * @see Iterable - */ - Iterable findAll(); - - /** - * Deletes the given [User] from the system. - * - * @param user [User] to delete. - * @return a boolean value indicating if the [User] was deleted successfully. - * @see User - */ - boolean delete(User user); - - /** - * Records (persist) the information (state) of the [User]. - * - * @param user [User] to store. - * @return the [User]. - * @see User - */ - User save(User user); - - /* (non-Javadoc) */ - default int count() { - var count = 0; - var users = findAll(); - for (var user : users) { - count++; - } - return count; - } - - /* (non-Javadoc) */ - default User createUser(String username, Role... roles) { - return save(User.newUser(username).withRoles(roles)); - } - - /* (non-Javadoc) */ - default boolean delete(String username) { - var user = findBy(username); - if (user != null) { - return delete(user); - } - return false; - } - - /* (non-Javadoc) */ - default boolean deleteAll(String... username) { - return deleteAll(findAll(username)); - } - - /* (non-Javadoc) */ - default boolean deleteAll(User... users) { - return deleteAll(Arrays.asList(users)); - } - - /* (non-Javadoc) */ - default boolean deleteAll(Iterable users) { - for (var user : users) { - if (!delete(user)) { - return false; - } - } - return true; - } - - /* (non-Javadoc) */ - default boolean deleteAll() { - return deleteAll(findAll()); - } - - /* (non-Javadoc) */ - default boolean exists(String username) { - return findBy(username) != null; - } - - /* (non-Javadoc) */ - default Iterable findAll(String... username) { - return findAll(Arrays.asList(username)); - } - - /* (non-Javadoc) */ - default Iterable findAll(Iterable username) { - List all = new ArrayList<>(); - username.forEach(u -> { - if (u != null) { - all.add(findBy(u)); - } - }); - return all; - } - - /* (non-Javadoc) */ - default User findBy(String username) { - for (var user : findAll()) { - if (user.getName().equals(username)) { - return user; - } - } - return null; - } - - /* (non-Javadoc) */ - default Iterable saveAll(User... users) { - return saveAll(Arrays.asList(users)); - } - - /* (non-Javadoc) */ - default Iterable saveAll(Iterable users) { - List saved = new ArrayList<>(); - users.forEach(user -> saved.add(save(user))); - return saved; - } -} diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/server/SimpleSecurityManager.java b/geode/security/src/main/java/example/springdata/geode/client/security/server/SimpleSecurityManager.java deleted file mode 100644 index 4f572788..00000000 --- a/geode/security/src/main/java/example/springdata/geode/client/security/server/SimpleSecurityManager.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security.server; - -import example.springdata.geode.client.security.Role; -import example.springdata.geode.client.security.User; - -import java.util.Properties; - -import org.apache.geode.security.AuthenticationFailedException; -import org.apache.geode.security.ResourcePermission; - -import org.springframework.stereotype.Service; - -/** - * The [SimpleSecurityManager] class is an example Apache Geode [SecurityManager] provider implementation used to secure - * Apache Geode. - * - * @author John Blum - * @see SecurityManagerSupport - * @see Role - * @see User - * @see SecurityRepository - * @see ResourcePermission - * @see org.apache.geode.security.SecurityManager - * @see org.springframework.stereotype.Service - * @since 1.0.0 - */ -@Service -public class SimpleSecurityManager extends SecurityManagerSupport { - - protected SecurityRepository securityRepository; - - public SimpleSecurityManager(SecurityRepository securityRepository) { - this.securityRepository = securityRepository; - } - - /** - * @inheritDoc - */ - @Override - public Object authenticate(Properties securityProperties) { - var username = getUsername(securityProperties); - var password = getPassword(securityProperties); - - logDebug("User with name [{}] is attempting to login with password [{}]", username, password); - - var user = securityRepository.findBy(username); - - if (isNotAuthentic(user, password)) { - throw new AuthenticationFailedException(String.format("Failed to authenticate user [%s]", username)); - } - - return user; - } - - /* (non-Javadoc) */ - protected boolean isAuthentic(User user, String credentials) { - return user != null && user.getCredentials().equals(credentials); - } - - /* (non-Javadoc) */ - protected boolean isNotAuthentic(User user, String credentials) { - return !isAuthentic(user, credentials); - } - - /** - * @inheritDoc - */ - @Override - public boolean authorize(Object principal, ResourcePermission permission) { - logDebug("Principal [{}] is requesting access to a Resource {} with the required Permission [{}]", principal, - permission.getResource(), permission); - - return isAuthorized(principal, permission); - } - - /* (non-Javadoc) */ - protected boolean isAuthorized(Object principal, ResourcePermission permission) { - var user = resolveUser(principal); - - return user != null && isAuthorized(user, permission); - } - - /* (non-Javadoc) */ - protected User resolveUser(Object principal) { - if (principal instanceof User) { - return (User) principal; - } else { - return securityRepository.findBy(getName(principal)); - } - } - - /* (non-Javadoc) */ - protected boolean isAuthorized(User user, ResourcePermission requiredPermission) { - if (!user.hasPermission(requiredPermission)) { - for (Role role : user.getRoles()) { - for (ResourcePermission userPermission : role.getPermissions()) { - if (isPermitted(userPermission, requiredPermission)) { - return true; - } - } - } - return false; - } - return true; - } - - /* (non-Javadoc) */ - protected boolean isPermitted(ResourcePermission userPermission, ResourcePermission resourcePermission) { - return userPermission.implies(resourcePermission); - } - -} diff --git a/geode/security/src/main/resources/application.properties b/geode/security/src/main/resources/application.properties deleted file mode 100755 index c2759850..00000000 --- a/geode/security/src/main/resources/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -spring.data.gemfire.security.username=scientist -spring.data.gemfire.security.password=w0rk!ng4u \ No newline at end of file diff --git a/geode/security/src/main/resources/shiro.ini b/geode/security/src/main/resources/shiro.ini deleted file mode 100755 index 2cd25350..00000000 --- a/geode/security/src/main/resources/shiro.ini +++ /dev/null @@ -1,42 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Shiro INI configuration - -# Objects and their properties are defined here, such as the securityManager, Realms and anything else needed -# to build the SecurityManager -[main] - -# The 'users' section is for simple deployments when you only need a small number of statically-defined -# set of User accounts. -# username = password, roleName1, roleName2, …, roleNameN -[users] -root = s3cr3t!, ADMIN, DBA -scientist = w0rk!ng4u, DATA_SCIENTIST -analyst = p@55w0rd, DATA_ANALYST -guest = guest, GUEST - -# The 'roles' section is for simple deployments when you only need a small number of statically-defined roles. -# rolename = permissionDefinition1, permissionDefinition2, …, permissionDefinitionN -[roles] -ADMIN = CLUSTER:MANAGE, CLUSTER:READ, CLUSTER:WRITE -DBA = DATA:MANAGE, DATA:READ, DATA:WRITE -DATA_SCIENTIST = DATA:READ, DATA:WRITE -DATA_ANALYST = DATA:READ -GUEST = NULL - -# The 'urls' section is used for url-based security in web applications. We'll discuss this section -# in the Web documentation -[urls] diff --git a/geode/security/src/main/resources/sql/define-roles-permissions-table-ddl.sql b/geode/security/src/main/resources/sql/define-roles-permissions-table-ddl.sql deleted file mode 100755 index 73a35e1b..00000000 --- a/geode/security/src/main/resources/sql/define-roles-permissions-table-ddl.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE IF NOT EXISTS geode_security.roles_permissions ( - role_id INTEGER REFERENCES geode_security.roles(id), - resource VARCHAR(32) NOT NUll, - operation VARCHAR(32) NOT NULL, - region_name VARCHAR(255), - key_name VARCHAR(255) -); diff --git a/geode/security/src/main/resources/sql/define-roles-table-ddl.sql b/geode/security/src/main/resources/sql/define-roles-table-ddl.sql deleted file mode 100755 index ca8198a0..00000000 --- a/geode/security/src/main/resources/sql/define-roles-table-ddl.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE IF NOT EXISTS geode_security.roles ( - id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY(START WITH 1, INCREMENT BY 1), - name VARCHAR(32) NOT NULL -); diff --git a/geode/security/src/main/resources/sql/define-users-roles-table-ddl.sql b/geode/security/src/main/resources/sql/define-users-roles-table-ddl.sql deleted file mode 100755 index eb540d2c..00000000 --- a/geode/security/src/main/resources/sql/define-users-roles-table-ddl.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE IF NOT EXISTS geode_security.users_roles ( - user_id INTEGER REFERENCES geode_security.users(id), - role_id INTEGER REFERENCES geode_security.roles(id) -); diff --git a/geode/security/src/main/resources/sql/define-users-table-ddl.sql b/geode/security/src/main/resources/sql/define-users-table-ddl.sql deleted file mode 100755 index e6bfc568..00000000 --- a/geode/security/src/main/resources/sql/define-users-table-ddl.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE IF NOT EXISTS geode_security.users ( - id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY(START WITH 1, INCREMENT BY 1), - name VARCHAR(255) NOT NULL, - credentials VARCHAR(255) -); diff --git a/geode/security/src/main/resources/sql/geode-security-schema-ddl.sql b/geode/security/src/main/resources/sql/geode-security-schema-ddl.sql deleted file mode 100755 index 6a7e3967..00000000 --- a/geode/security/src/main/resources/sql/geode-security-schema-ddl.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE SCHEMA geode_security diff --git a/geode/security/src/main/resources/sql/insert-roles-dml.sql b/geode/security/src/main/resources/sql/insert-roles-dml.sql deleted file mode 100755 index 93f2b2bd..00000000 --- a/geode/security/src/main/resources/sql/insert-roles-dml.sql +++ /dev/null @@ -1,5 +0,0 @@ -INSERT INTO geode_security.roles (name) VALUES ('ADMIN'); -INSERT INTO geode_security.roles (name) VALUES ('DBA'); -INSERT INTO geode_security.roles (name) VALUES ('DATA_SCIENTIST'); -INSERT INTO geode_security.roles (name) VALUES ('DATA_ANALYST'); -INSERT INTO geode_security.roles (name) VALUES ('GUEST'); diff --git a/geode/security/src/main/resources/sql/insert-roles-permissions-dml.sql b/geode/security/src/main/resources/sql/insert-roles-permissions-dml.sql deleted file mode 100755 index 0261d108..00000000 --- a/geode/security/src/main/resources/sql/insert-roles-permissions-dml.sql +++ /dev/null @@ -1,11 +0,0 @@ -INSERT INTO geode_security.roles_permissions (role_id, resource, operation) VALUES ((SELECT id FROM geode_security.roles WHERE name = 'ADMIN'), 'CLUSTER', 'MANAGE'); -INSERT INTO geode_security.roles_permissions (role_id, resource, operation) VALUES ((SELECT id FROM geode_security.roles WHERE name = 'ADMIN'), 'CLUSTER', 'READ'); -INSERT INTO geode_security.roles_permissions (role_id, resource, operation) VALUES ((SELECT id FROM geode_security.roles WHERE name = 'ADMIN'), 'CLUSTER', 'WRITE'); -INSERT INTO geode_security.roles_permissions (role_id, resource, operation) VALUES ((SELECT id FROM geode_security.roles WHERE name = 'DBA'), 'DATA', 'MANAGE'); -INSERT INTO geode_security.roles_permissions (role_id, resource, operation) VALUES ((SELECT id FROM geode_security.roles WHERE name = 'DBA'), 'DATA', 'READ'); -INSERT INTO geode_security.roles_permissions (role_id, resource, operation) VALUES ((SELECT id FROM geode_security.roles WHERE name = 'DBA'), 'DATA', 'WRITE'); -INSERT INTO geode_security.roles_permissions (role_id, resource, operation) VALUES ((SELECT id FROM geode_security.roles WHERE name = 'DATA_SCIENTIST'), 'DATA', 'READ'); -INSERT INTO geode_security.roles_permissions (role_id, resource, operation) VALUES ((SELECT id FROM geode_security.roles WHERE name = 'DATA_SCIENTIST'), 'DATA', 'WRITE'); -INSERT INTO geode_security.roles_permissions (role_id, resource, operation) VALUES ((SELECT id FROM geode_security.roles WHERE name = 'DATA_ANALYST'), 'DATA', 'READ'); -INSERT INTO geode_security.roles_permissions (role_id, resource, operation) VALUES ((SELECT id FROM geode_security.roles WHERE name = 'GUEST'), 'CLUSTER', 'NULL'); -INSERT INTO geode_security.roles_permissions (role_id, resource, operation) VALUES ((SELECT id FROM geode_security.roles WHERE name = 'GUEST'), 'DATA', 'NULL'); diff --git a/geode/security/src/main/resources/sql/insert-users-dml.sql b/geode/security/src/main/resources/sql/insert-users-dml.sql deleted file mode 100755 index 0afd2cb9..00000000 --- a/geode/security/src/main/resources/sql/insert-users-dml.sql +++ /dev/null @@ -1,4 +0,0 @@ -INSERT INTO geode_security.users (name, credentials) VALUES ('root', 's3cr3t!'); -INSERT INTO geode_security.users (name, credentials) VALUES ('scientist', 'w0rk!ng4u'); -INSERT INTO geode_security.users (name, credentials) VALUES ('analyst', 'p@55w0rd'); -INSERT INTO geode_security.users (name, credentials) VALUES ('guest', 'guest'); diff --git a/geode/security/src/main/resources/sql/insert-users-roles-dml.sql b/geode/security/src/main/resources/sql/insert-users-roles-dml.sql deleted file mode 100755 index 7d0da905..00000000 --- a/geode/security/src/main/resources/sql/insert-users-roles-dml.sql +++ /dev/null @@ -1,5 +0,0 @@ -INSERT INTO geode_security.users_roles (user_id, role_id) VALUES ((SELECT id FROM geode_security.users WHERE name = 'root'), (SELECT id FROM geode_security.roles WHERE name = 'ADMIN')); -INSERT INTO geode_security.users_roles (user_id, role_id) VALUES ((SELECT id FROM geode_security.users WHERE name = 'root'), (SELECT id FROM geode_security.roles WHERE name = 'DBA')); -INSERT INTO geode_security.users_roles (user_id, role_id) VALUES ((SELECT id FROM geode_security.users WHERE name = 'scientist'), (SELECT id FROM geode_security.roles WHERE name = 'DATA_SCIENTIST')); -INSERT INTO geode_security.users_roles (user_id, role_id) VALUES ((SELECT id FROM geode_security.users WHERE name = 'analyst'), (SELECT id FROM geode_security.roles WHERE name = 'DATA_ANALYST')); -INSERT INTO geode_security.users_roles (user_id, role_id) VALUES ((SELECT id FROM geode_security.users WHERE name = 'guest'), (SELECT id FROM geode_security.roles WHERE name = 'GUEST')); diff --git a/geode/security/src/test/java/example/springdata/geode/client/security/client/SecurityEnabledClientShiroTests.java b/geode/security/src/test/java/example/springdata/geode/client/security/client/SecurityEnabledClientShiroTests.java deleted file mode 100755 index de1ec3f0..00000000 --- a/geode/security/src/test/java/example/springdata/geode/client/security/client/SecurityEnabledClientShiroTests.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security.client; - -import static org.assertj.core.api.Assertions.*; - -import example.springdata.geode.client.security.Customer; -import example.springdata.geode.client.security.EmailAddress; -import example.springdata.geode.client.security.server.SecurityEnabledServer; -import lombok.extern.apachecommons.CommonsLog; - -import java.io.IOException; -import java.util.List; - -import jakarta.annotation.Resource; - -import org.apache.geode.cache.Region; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Patrick Johnson - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = SecurityEnabledClientConfiguration.class) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -@CommonsLog -public class SecurityEnabledClientShiroTests extends ForkingClientServerIntegrationTestsSupport { - - @Autowired private CustomerRepository customerRepository; - - @Resource(name = "Customers") private Region customers; - - @BeforeClass - public static void setup() throws IOException { - startGemFireServer(SecurityEnabledServer.class, "-Dspring.profiles.active=shiro-ini-configuration"); - } - - @Test - public void securityWasConfiguredCorrectly() { - - log.info("Inserting 3 entries for keys: 1, 2, 3"); - - var john = new Customer(1L, new EmailAddress("2@2.com"), "John", "Smith"); - var frank = new Customer(2L, new EmailAddress("3@3.com"), "Frank", "Lamport"); - var jude = new Customer(3L, new EmailAddress("5@5.com"), "Jude", "Simmons"); - - customerRepository.save(john); - customerRepository.save(frank); - customerRepository.save(jude); - - assertThat(customers.keySetOnServer().size()).isEqualTo(3); - log.info("Customers saved on server:"); - - var customerList = customerRepository.findAll(); - - assertThat(customerList.size()).isEqualTo(3); - assertThat(customerList.contains(john)).isTrue(); - assertThat(customerList.contains(frank)).isTrue(); - assertThat(customerList.contains(jude)).isTrue(); - - customerList.forEach(customer -> log.info("\t Entry: \n \t\t " + customer)); - } -} diff --git a/geode/security/src/test/java/example/springdata/geode/client/security/client/SecurityEnabledClientTests.java b/geode/security/src/test/java/example/springdata/geode/client/security/client/SecurityEnabledClientTests.java deleted file mode 100755 index 899ae860..00000000 --- a/geode/security/src/test/java/example/springdata/geode/client/security/client/SecurityEnabledClientTests.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.security.client; - -import static org.assertj.core.api.Assertions.*; - -import example.springdata.geode.client.security.Customer; -import example.springdata.geode.client.security.EmailAddress; -import example.springdata.geode.client.security.server.SecurityEnabledServer; -import lombok.extern.apachecommons.CommonsLog; - -import java.io.IOException; -import java.util.List; - -import jakarta.annotation.Resource; - -import org.apache.geode.cache.Region; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Patrick Johnson - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = SecurityEnabledClientConfiguration.class) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -@CommonsLog -public class SecurityEnabledClientTests extends ForkingClientServerIntegrationTestsSupport { - - @Autowired private CustomerRepository customerRepository; - - @Resource(name = "Customers") private Region customers; - - @BeforeClass - public static void setup() throws IOException { - startGemFireServer(SecurityEnabledServer.class); - } - - @Test - public void SecurityWasConfiguredCorrectly() { - - log.info("Inserting 3 entries for keys: 1, 2, 3"); - - var john = new Customer(1L, new EmailAddress("2@2.com"), "John", "Smith"); - var frank = new Customer(2L, new EmailAddress("3@3.com"), "Frank", "Lamport"); - var jude = new Customer(3L, new EmailAddress("5@5.com"), "Jude", "Simmons"); - - customerRepository.save(john); - customerRepository.save(frank); - customerRepository.save(jude); - - assertThat(customers.keySetOnServer()).hasSize(3); - - log.info("Customers saved on server:"); - - var customerList = customerRepository.findAll(); - - assertThat(customerList.size()).isEqualTo(3); - assertThat(customerList.contains(john)).isTrue(); - assertThat(customerList.contains(frank)).isTrue(); - assertThat(customerList.contains(jude)).isTrue(); - - customerList.forEach(customer -> log.info("\t Entry: \n \t\t " + customer)); - } -} diff --git a/geode/security/src/test/resources/logback.xml b/geode/security/src/test/resources/logback.xml deleted file mode 100644 index f3b82068..00000000 --- a/geode/security/src/test/resources/logback.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - %msg%n - - - - - - - \ No newline at end of file diff --git a/geode/storage/README.md b/geode/storage/README.md deleted file mode 100644 index 5a13064c..00000000 --- a/geode/storage/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Storage Example - -In this example you will see how to configure your server to compress regions, store data off-heap, and customize the way region is stored in the region, such as the number of buckets and duplicate copies. - -NOTE: Inorder to see output, you must change the loglevel from "error" to "info" in the `logback.xml` file located under src/test/resources. \ No newline at end of file diff --git a/geode/storage/pom.xml b/geode/storage/pom.xml deleted file mode 100644 index 525c71df..00000000 --- a/geode/storage/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - 4.0.0 - - - org.springframework.data.examples - spring-data-geode-examples - 2.0.0.BUILD-SNAPSHOT - - - spring-data-geode-storage-example - Spring Data Geode - Storage - - - - org.iq80.snappy - snappy - - - - diff --git a/geode/storage/src/main/java/example/springdata/geode/server/storage/Address.java b/geode/storage/src/main/java/example/springdata/geode/server/storage/Address.java deleted file mode 100755 index 042705b9..00000000 --- a/geode/storage/src/main/java/example/springdata/geode/server/storage/Address.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.storage; - -import lombok.Data; - -import java.io.Serializable; - -/** - * An address used in the examples. - * - * @author Oliver Gierke - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -public class Address implements Serializable { - - private String street; - private String city; - private String country; - - public Address(String street, String city, String country) { - this.street = street; - this.city = city; - this.country = country; - } -} diff --git a/geode/storage/src/main/java/example/springdata/geode/server/storage/Customer.java b/geode/storage/src/main/java/example/springdata/geode/server/storage/Customer.java deleted file mode 100755 index f2c4814a..00000000 --- a/geode/storage/src/main/java/example/springdata/geode/server/storage/Customer.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.storage; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.gemfire.mapping.annotation.Region; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.List; - -/** - * A customer used for Lucene examples. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@Region(name = "Customers") -public class Customer implements Serializable { - - @Id - private Long id; - private EmailAddress emailAddress; - private String firstName; - private String lastName; - private List
addresses; - - public Customer(Long id, EmailAddress emailAddress, String firstName, String lastName, Address... addresses) { - this.id = id; - this.emailAddress = emailAddress; - this.firstName = firstName; - this.lastName = lastName; - this.addresses = Arrays.asList(addresses); - } -} diff --git a/geode/storage/src/main/java/example/springdata/geode/server/storage/CustomerRepository.java b/geode/storage/src/main/java/example/springdata/geode/server/storage/CustomerRepository.java deleted file mode 100755 index 8a55e832..00000000 --- a/geode/storage/src/main/java/example/springdata/geode/server/storage/CustomerRepository.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.storage; - -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -public interface CustomerRepository extends CrudRepository { -} diff --git a/geode/storage/src/main/java/example/springdata/geode/server/storage/EmailAddress.java b/geode/storage/src/main/java/example/springdata/geode/server/storage/EmailAddress.java deleted file mode 100755 index 86fb0906..00000000 --- a/geode/storage/src/main/java/example/springdata/geode/server/storage/EmailAddress.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.storage; - -import lombok.Data; - -import java.io.Serializable; - -/** - * Value object to represent email addresses. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -public class EmailAddress implements Serializable { - - private String value; - - public EmailAddress(String value) { - - this.value = value; - } -} diff --git a/geode/storage/src/main/java/example/springdata/geode/server/storage/LineItem.java b/geode/storage/src/main/java/example/springdata/geode/server/storage/LineItem.java deleted file mode 100755 index 59481953..00000000 --- a/geode/storage/src/main/java/example/springdata/geode/server/storage/LineItem.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.storage; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * A LineItem used in the examples - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -public class LineItem implements Serializable { - - private Product product; - private Integer amount; - - public LineItem(Product product, Integer amount) { - this.product = product; - this.amount = amount; - } - - public BigDecimal calcTotal() { - return product.getPrice().multiply(BigDecimal.valueOf(amount)); - } -} diff --git a/geode/storage/src/main/java/example/springdata/geode/server/storage/Order.java b/geode/storage/src/main/java/example/springdata/geode/server/storage/Order.java deleted file mode 100755 index 31623cef..00000000 --- a/geode/storage/src/main/java/example/springdata/geode/server/storage/Order.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.storage; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; - -import org.springframework.data.annotation.Id; -import org.springframework.data.gemfire.mapping.annotation.Region; - -/** - * Orders object used in the examples - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@Region("Orders") -public class Order implements Serializable { - - @Id private Long id; - private Long customerId; - private Address billingAddress; - private Address shippingAddress; - private List lineItems = new ArrayList<>(); - - public Order(Long orderId, Long customerId, Address address) { - this.id = orderId; - this.customerId = customerId; - this.billingAddress = address; - this.shippingAddress = address; - } - - /** - * Returns the total of the [Order]. - * - * @return - */ - public BigDecimal calcTotal() { - if (lineItems.size() == 0) { - return BigDecimal.ZERO; - } else { - return lineItems.stream().map(LineItem::calcTotal).reduce(BigDecimal::add).get(); - } - } - - /** - * Adds the given [LineItem] to the [Order]. - * - * @param lineItem - */ - public void add(LineItem lineItem) { - lineItems.add(lineItem); - } -} diff --git a/geode/storage/src/main/java/example/springdata/geode/server/storage/OrderRepository.java b/geode/storage/src/main/java/example/springdata/geode/server/storage/OrderRepository.java deleted file mode 100755 index 8b9caec1..00000000 --- a/geode/storage/src/main/java/example/springdata/geode/server/storage/OrderRepository.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.storage; - -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -public interface OrderRepository extends CrudRepository {} diff --git a/geode/storage/src/main/java/example/springdata/geode/server/storage/Product.java b/geode/storage/src/main/java/example/springdata/geode/server/storage/Product.java deleted file mode 100755 index be448f66..00000000 --- a/geode/storage/src/main/java/example/springdata/geode/server/storage/Product.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.storage; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.annotation.PersistenceConstructor; -import org.springframework.data.annotation.Transient; -import org.springframework.data.gemfire.mapping.annotation.Region; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.Map; - -/** - * A product used in the examples. - * - * @author Oliver Gierke - * @author David Turanski - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@Region("Products") -public class Product implements Serializable { - - @Id - private Long id; - private String name; - private BigDecimal price; - private String description; - - @Transient - private Map attributes = new HashMap<>(); - - @PersistenceConstructor - public Product(Long id, String name, BigDecimal price, String description) { - this.id = id; - this.name = name; - this.price = price; - this.description = description; - } - - /** - * Sets the attribute with the given name to the given value. - * - * @param name must not be null or empty. - * @param value - */ - public void addAttribute(String name, String value) { - this.attributes.put(name, value); - } -} diff --git a/geode/storage/src/main/java/example/springdata/geode/server/storage/ProductRepository.java b/geode/storage/src/main/java/example/springdata/geode/server/storage/ProductRepository.java deleted file mode 100755 index eeb10624..00000000 --- a/geode/storage/src/main/java/example/springdata/geode/server/storage/ProductRepository.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.storage; - -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -public interface ProductRepository extends CrudRepository {} diff --git a/geode/storage/src/main/java/example/springdata/geode/server/storage/StorageServer.java b/geode/storage/src/main/java/example/springdata/geode/server/storage/StorageServer.java deleted file mode 100755 index a563f122..00000000 --- a/geode/storage/src/main/java/example/springdata/geode/server/storage/StorageServer.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.storage; - -import lombok.extern.apachecommons.CommonsLog; - -import java.math.BigDecimal; -import java.util.Random; -import java.util.stream.IntStream; -import java.util.stream.LongStream; - -import org.apache.geode.cache.Region; - -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.ApplicationRunner; -import org.springframework.boot.WebApplicationType; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.context.annotation.Bean; - -/** - * @author Patrick Johnson - */ -@SpringBootApplication -@CommonsLog -public class StorageServer { - - public static void main(String[] args) { - new SpringApplicationBuilder(StorageServer.class).web(WebApplicationType.NONE).build().run(args); - } - - @Bean - public ApplicationRunner runner(CustomerRepository customerRepository, OrderRepository orderRepository, - ProductRepository productRepository, @Qualifier("Products") Region products) { - return args -> { - createCustomerData(customerRepository); - - createProducts(productRepository); - - createOrders(productRepository, orderRepository); - - log.info("Completed creating orders "); - }; - } - - private void createOrders(ProductRepository productRepository, OrderRepository orderRepository) { - var random = new Random(System.nanoTime()); - var address = new Address("it", "doesn't", "matter"); - LongStream.rangeClosed(1, 10).forEach((orderId) -> LongStream.rangeClosed(1, 300).forEach((customerId) -> { - var order = new Order(orderId, customerId, address); - IntStream.rangeClosed(0, random.nextInt(3) + 1).forEach((lineItemCount) -> { - var quantity = random.nextInt(3) + 1; - long productId = random.nextInt(3) + 1; - order.add(new LineItem(productRepository.findById(productId).get(), quantity)); - }); - orderRepository.save(order); - })); - } - - private void createProducts(ProductRepository productRepository) { - productRepository.save(new Product(1L, "Apple iPod", new BigDecimal("99.99"), "An Apple portable music player")); - productRepository.save(new Product(2L, "Apple iPad", new BigDecimal("499.99"), "An Apple tablet device")); - var macbook = new Product(3L, "Apple macBook", new BigDecimal("899.99"), "An Apple notebook computer"); - macbook.addAttribute("warranty", "included"); - productRepository.save(macbook); - } - - private void createCustomerData(CustomerRepository customerRepository) { - LongStream.rangeClosed(0, 300).parallel().forEach(customerId -> customerRepository.save( - new Customer(customerId, new EmailAddress(customerId + "@2.com"), "John" + customerId, "Smith" + customerId))); - } -} diff --git a/geode/storage/src/main/java/example/springdata/geode/server/storage/StorageServerConfig.java b/geode/storage/src/main/java/example/springdata/geode/server/storage/StorageServerConfig.java deleted file mode 100755 index 2edfaebf..00000000 --- a/geode/storage/src/main/java/example/springdata/geode/server/storage/StorageServerConfig.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.storage; - -import org.apache.geode.cache.DataPolicy; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.cache.PartitionAttributes; -import org.apache.geode.cache.RegionAttributes; -import org.apache.geode.compression.Compressor; -import org.apache.geode.compression.SnappyCompressor; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.gemfire.PartitionAttributesFactoryBean; -import org.springframework.data.gemfire.PartitionedRegionFactoryBean; -import org.springframework.data.gemfire.RegionAttributesFactoryBean; -import org.springframework.data.gemfire.ReplicatedRegionFactoryBean; -import org.springframework.data.gemfire.config.annotation.CacheServerApplication; -import org.springframework.data.gemfire.config.annotation.EnableOffHeap; -import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories; - -/** - * @author Patrick Johnson - */ -@Configuration -@ComponentScan -@CacheServerApplication(logLevel = "error") -@EnableGemfireRepositories(basePackageClasses = CustomerRepository.class) -@EnableOffHeap(memorySize = "512m", regionNames = "Products") -public class StorageServerConfig { - - @Bean - Compressor createSnappyCompressor() { - return new SnappyCompressor(); - } - - @Bean - RegionAttributesFactoryBean regionAttributes(PartitionAttributes partitionAttributes) { - RegionAttributesFactoryBean regionAttributesFactoryBean = new RegionAttributesFactoryBean<>(); - regionAttributesFactoryBean.setPartitionAttributes(partitionAttributes); - return regionAttributesFactoryBean; - } - - @Bean - PartitionAttributesFactoryBean partitionAttributes() { - PartitionAttributesFactoryBean partitionAttributesFactoryBean = new PartitionAttributesFactoryBean<>(); - partitionAttributesFactoryBean.setTotalNumBuckets(11); - partitionAttributesFactoryBean.setRedundantCopies(1); - return partitionAttributesFactoryBean; - } - - @Bean("Orders") - PartitionedRegionFactoryBean createOrderRegion(GemFireCache gemFireCache, - RegionAttributes regionAttributes) { - PartitionedRegionFactoryBean partitionedRegionFactoryBean = new PartitionedRegionFactoryBean<>(); - partitionedRegionFactoryBean.setCache(gemFireCache); - partitionedRegionFactoryBean.setRegionName("Orders"); - partitionedRegionFactoryBean.setDataPolicy(DataPolicy.PARTITION); - partitionedRegionFactoryBean.setAttributes(regionAttributes); - return partitionedRegionFactoryBean; - } - - @Bean("Products") - ReplicatedRegionFactoryBean createProductRegion(GemFireCache gemFireCache) { - ReplicatedRegionFactoryBean replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>(); - replicatedRegionFactoryBean.setCache(gemFireCache); - replicatedRegionFactoryBean.setRegionName("Products"); - replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE); - return replicatedRegionFactoryBean; - } - - @Bean("Customers") - ReplicatedRegionFactoryBean createCustomerRegion(GemFireCache gemFireCache, Compressor compressor) { - ReplicatedRegionFactoryBean replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>(); - replicatedRegionFactoryBean.setCache(gemFireCache); - replicatedRegionFactoryBean.setRegionName("Customers"); - replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE); - replicatedRegionFactoryBean.setCompressor(compressor); - return replicatedRegionFactoryBean; - } -} diff --git a/geode/storage/src/test/java/example/springdata/geode/server/storage/StorageServerTests.java b/geode/storage/src/test/java/example/springdata/geode/server/storage/StorageServerTests.java deleted file mode 100755 index 4e1c1f0d..00000000 --- a/geode/storage/src/test/java/example/springdata/geode/server/storage/StorageServerTests.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.storage; - -import static org.assertj.core.api.Assertions.*; - -import jakarta.annotation.Resource; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.Region; -import org.apache.geode.compression.SnappyCompressor; -import org.apache.geode.internal.cache.GemFireCacheImpl; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Patrick Johnson - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class StorageServerTests { - - @Resource(name = "Customers") private Region customers; - - @Resource(name = "Orders") private Region orders; - - @Resource(name = "Products") private Region products; - - @Autowired Cache cache; - - @Test - public void partitionAttributesConfiguredCorrectly() { - assertThat(this.orders.getAttributes().getPartitionAttributes().getTotalNumBuckets()).isEqualTo(11); - assertThat(this.orders.getAttributes().getPartitionAttributes().getRedundantCopies()).isEqualTo(1); - } - - @Test - public void compressorIsEnabled() { - - assertThat(customers.getAttributes().getCompressor()).isInstanceOf(SnappyCompressor.class); - - var impl = (GemFireCacheImpl) cache; - - assertThat(impl.getCachePerfStats().getTotalPostCompressedBytes()) - .isLessThan(impl.getCachePerfStats().getTotalPreCompressedBytes()); - } - - @Test - public void offHeapConfiguredCorrectly() { - assertThat(products.getAttributes().getOffHeap()).isTrue(); - assertThat(customers.getAttributes().getOffHeap()).isFalse(); - } -} diff --git a/geode/storage/src/test/resources/logback.xml b/geode/storage/src/test/resources/logback.xml deleted file mode 100644 index f3b82068..00000000 --- a/geode/storage/src/test/resources/logback.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - %msg%n - - - - - - - \ No newline at end of file diff --git a/geode/transactions/README.md b/geode/transactions/README.md deleted file mode 100755 index 40b457d0..00000000 --- a/geode/transactions/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Transactions Example - -In this example a [Pivotal GemFire](https://pivotal.io/pivotal-gemfire) / [Apache Geode](http://geode.apache.org/) client will be configured to perform the basic CRUD operations within a transaction. First, it will do a successful transaction where entries are saved to the server, and then a failed transaction where all changes are reverted. - -To run the example simply run the tests located under transactions/src/test in your IDE. - -The client is configured to connect to the server on `localhost` port `40404`. There is no need to start the server separately, as that is taken care of by the test. - -## Running the example - -The example is broken up into multiple steps: -1. Print number of entries on server -3. Insert (Put) five Customer entries into the `Customers` region using the repositories `save` method. -3. Printing out the size of the region on the server -4. Update the Customer for id=2 in a transaction. Recording the before and after Customer detail. -5. Fail a transaction to update the Customer with id=2. Recording the before and after Customer detail. -6. Update the Customer for id=2 with a delay of 1000 ms. -7. Update the Customer for id=2 with a delay of 10 ms. -8. Print customer for id=2 - -NOTE: Inorder to see output, you must change the loglevel from "error" to "info" in the `logback.xml` file located under src/test/resources. \ No newline at end of file diff --git a/geode/transactions/pom.xml b/geode/transactions/pom.xml deleted file mode 100755 index c103fa5b..00000000 --- a/geode/transactions/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - 4.0.0 - - - org.springframework.data.examples - spring-data-geode-examples - 2.0.0.BUILD-SNAPSHOT - - - spring-data-geode-transactions-example - Spring Data Geode - Transactions - - - - jakarta.annotation - jakarta.annotation-api - - - - diff --git a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/Customer.java b/geode/transactions/src/main/java/example/springdata/geode/client/transactions/Customer.java deleted file mode 100755 index ac21e51d..00000000 --- a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/Customer.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.transactions; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.gemfire.mapping.annotation.Region; - -/** - * A customer used for Lucene examples. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@Region(name = "Customers") -public class Customer { - - @Id - private Long id; - private EmailAddress emailAddress; - private String firstName; - private String lastName; - - public Customer(Long id, EmailAddress emailAddress, String firstName, String lastName) { - this.id = id; - this.emailAddress = emailAddress; - this.firstName = firstName; - this.lastName = lastName; - } -} diff --git a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/EmailAddress.java b/geode/transactions/src/main/java/example/springdata/geode/client/transactions/EmailAddress.java deleted file mode 100755 index 6b565073..00000000 --- a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/EmailAddress.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.transactions; - -import lombok.Data; - -/** - * Value object to represent email addresses. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -public class EmailAddress { - - private String value; - - public EmailAddress(String value) { - this.value = value; - } -} diff --git a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/client/CustomerRepository.java b/geode/transactions/src/main/java/example/springdata/geode/client/transactions/client/CustomerRepository.java deleted file mode 100755 index 1a6a90f1..00000000 --- a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/client/CustomerRepository.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.transactions.client; - -import example.springdata.geode.client.transactions.Customer; - -import org.springframework.data.gemfire.mapping.annotation.ClientRegion; -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -@ClientRegion("Customers") -public interface CustomerRepository extends CrudRepository {} diff --git a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/client/CustomerService.java b/geode/transactions/src/main/java/example/springdata/geode/client/transactions/client/CustomerService.java deleted file mode 100755 index 62b4447a..00000000 --- a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/client/CustomerService.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.transactions.client; - -import example.springdata.geode.client.transactions.Customer; -import example.springdata.geode.client.transactions.EmailAddress; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import jakarta.annotation.Resource; - -import org.apache.geode.cache.Region; - -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author Patrick Johnson - */ -@Service -public class CustomerService { - private final CustomerRepository customerRepository; - - @Resource(name = "Customers") private Region customerRegion; - - public CustomerService(CustomerRepository customerRepository, - @Qualifier("Customers") Region customerRegion) { - this.customerRepository = customerRepository; - this.customerRegion = customerRegion; - } - - private CustomerRepository getCustomerRepository() { - return customerRepository; - } - - public Optional findById(long id) { - return getCustomerRepository().findById(id); - } - - public int numberEntriesStoredOnServer() { - return customerRegion.keySetOnServer().size(); - } - - @Transactional - public List createFiveCustomers() { - return Arrays - .stream(new Customer[] { new Customer(1L, new EmailAddress("1@1.com"), "John", "Melloncamp"), - new Customer(2L, new EmailAddress("2@2.com"), "Franky", "Hamilton"), - new Customer(3L, new EmailAddress("3@3.com"), "Sebastian", "Horner"), - new Customer(4L, new EmailAddress("4@4.com"), "Chris", "Vettel"), - new Customer(5L, new EmailAddress("5@5.com"), "Kimi", "Rosberg") }) - .map(customerRepository::save).collect(Collectors.toList()); - } - - @Transactional - public void updateCustomersSuccess() { - customerRepository.save(new Customer(2L, new EmailAddress("2@2.com"), "Humpty", "Hamilton")); - } - - @Transactional - public void updateCustomersWithDelay(int millisDelay, Customer customer) throws InterruptedException { - customerRepository.save(customer); - Thread.sleep(millisDelay); - } - - @Transactional - public void updateCustomersFailure() { - customerRepository.save(new Customer(2L, new EmailAddress("2@2.com"), "Numpty", "Hamilton")); - throw new IllegalArgumentException("This is an expected exception that should fail the transactions"); - } -} diff --git a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/client/TransactionalClientConfig.java b/geode/transactions/src/main/java/example/springdata/geode/client/transactions/client/TransactionalClientConfig.java deleted file mode 100755 index 3fc313be..00000000 --- a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/client/TransactionalClientConfig.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.transactions.client; - -import org.apache.geode.cache.client.ClientRegionShortcut; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.gemfire.config.annotation.ClientCacheApplication; -import org.springframework.data.gemfire.config.annotation.EnableClusterDefinedRegions; -import org.springframework.data.gemfire.config.annotation.EnablePdx; -import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories; -import org.springframework.data.gemfire.transaction.config.EnableGemfireCacheTransactions; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -/** - * @author Patrick Johnson - */ -@EnableClusterDefinedRegions(clientRegionShortcut = ClientRegionShortcut.PROXY) -@EnableTransactionManagement -@EnableGemfireCacheTransactions -@Configuration -@EnablePdx -@ComponentScan(basePackageClasses = CustomerService.class) -@EnableGemfireRepositories(basePackageClasses = CustomerRepository.class) -@ClientCacheApplication(name = "TransactionalClient", logLevel = "error", pingInterval = 5000L, readTimeout = 15000, - retryAttempts = 1) -public class TransactionalClientConfig {} diff --git a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/CustomerTransactionListener.java b/geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/CustomerTransactionListener.java deleted file mode 100644 index 69800257..00000000 --- a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/CustomerTransactionListener.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.transactions.server; - -import java.util.stream.Collectors; - -import lombok.extern.apachecommons.CommonsLog; -import org.springframework.stereotype.Component; - -import org.apache.geode.cache.CacheEvent; -import org.apache.geode.cache.EntryEvent; -import org.apache.geode.cache.TransactionEvent; -import org.apache.geode.cache.util.TransactionListenerAdapter; - -/** - * @author Patrick Johnson - */ -@Component -@CommonsLog -public class CustomerTransactionListener extends TransactionListenerAdapter { - - @Override - public void afterFailedCommit(TransactionEvent event) { - - } - - @Override - public void afterRollback(TransactionEvent event) { - log.info("In afterRollback for entry(s) [" - + event.getEvents().stream().map(this::getEventInfo).collect(Collectors.toList()) + "]"); - } - - private String getEventInfo(CacheEvent cacheEvent) { - if (cacheEvent instanceof EntryEvent) { - return ((EntryEvent) cacheEvent).getNewValue().toString(); - } else { - return cacheEvent.toString(); - } - } -} diff --git a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/CustomerTransactionWriter.java b/geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/CustomerTransactionWriter.java deleted file mode 100644 index ceffe414..00000000 --- a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/CustomerTransactionWriter.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.transactions.server; - -import java.util.concurrent.atomic.AtomicBoolean; - -import org.apache.geode.cache.EntryEvent; -import org.apache.geode.cache.TransactionEvent; -import org.apache.geode.cache.TransactionWriter; -import org.apache.geode.cache.TransactionWriterException; - -import org.springframework.stereotype.Component; - -/** - * @author Patrick Johnson - */ -@Component -public class CustomerTransactionWriter implements TransactionWriter { - - @Override - public void beforeCommit(TransactionEvent transactionEvent) throws TransactionWriterException { - - var six_found = new AtomicBoolean(false); - - transactionEvent.getEvents().forEach(event -> { - if (event instanceof EntryEvent - && ((EntryEvent) event).getKey().equals(6L)) { - six_found.set(true); - } - }); - - if (six_found.get()) { - throw new TransactionWriterException("Customer for Key: 6 is being changed. Failing transaction"); - } - } -} diff --git a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/TransactionalServer.java b/geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/TransactionalServer.java deleted file mode 100755 index a4465dce..00000000 --- a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/TransactionalServer.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.transactions.server; - -import org.springframework.boot.WebApplicationType; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; - -/** - * @author Patrick Johnson - */ -@SpringBootApplication -public class TransactionalServer { - - public static void main(String[] args) { - new SpringApplicationBuilder(TransactionalServer.class).web(WebApplicationType.NONE).build().run(args); - } - -} diff --git a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/TransactionalServerConfig.java b/geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/TransactionalServerConfig.java deleted file mode 100755 index ade94971..00000000 --- a/geode/transactions/src/main/java/example/springdata/geode/client/transactions/server/TransactionalServerConfig.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.transactions.server; - -import example.springdata.geode.client.transactions.Customer; - -import org.apache.geode.cache.DataPolicy; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.cache.Scope; - -import org.springframework.context.annotation.Bean; -import org.springframework.data.gemfire.ReplicatedRegionFactoryBean; -import org.springframework.data.gemfire.config.annotation.CacheServerApplication; -import org.springframework.data.gemfire.config.annotation.EnableLocator; -import org.springframework.data.gemfire.config.annotation.EnableManager; -import org.springframework.data.gemfire.transaction.config.EnableGemfireCacheTransactions; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -/** - * @author Patrick Johnson - */ -@EnableLocator -@EnableTransactionManagement -@EnableGemfireCacheTransactions -@EnableManager(start = true) -@CacheServerApplication(logLevel = "error") -public class TransactionalServerConfig { - - @Bean("Customers") - ReplicatedRegionFactoryBean createCustomerRegion(GemFireCache gemfireCache) { - ReplicatedRegionFactoryBean replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>(); - replicatedRegionFactoryBean.setCache(gemfireCache); - replicatedRegionFactoryBean.setRegionName("Customers"); - replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE); - replicatedRegionFactoryBean.setScope(Scope.DISTRIBUTED_ACK); - return replicatedRegionFactoryBean; - } -} diff --git a/geode/transactions/src/test/java/example/springdata/geode/client/transactions/client/TransactionalClientTests.java b/geode/transactions/src/test/java/example/springdata/geode/client/transactions/client/TransactionalClientTests.java deleted file mode 100755 index bb03c57e..00000000 --- a/geode/transactions/src/test/java/example/springdata/geode/client/transactions/client/TransactionalClientTests.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.client.transactions.client; - -import static org.assertj.core.api.Assertions.*; -import static org.junit.jupiter.api.Assertions.assertThrows; - -import example.springdata.geode.client.transactions.Customer; -import example.springdata.geode.client.transactions.EmailAddress; -import example.springdata.geode.client.transactions.server.TransactionalServer; -import lombok.extern.apachecommons.CommonsLog; - -import java.io.IOException; - -import jakarta.annotation.Resource; - -import org.apache.geode.cache.Region; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Patrick Johnson - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = TransactionalClientConfig.class) -@CommonsLog -public class TransactionalClientTests extends ForkingClientServerIntegrationTestsSupport { - - @Autowired private CustomerService customerService; - - @Resource(name = "Customers") private Region customers; - - @BeforeClass - public static void setup() throws IOException { - startGemFireServer(TransactionalServer.class); - } - - @Test - public void transactionsConfiguredCorrectly() throws InterruptedException { - - log.info("Number of Entries stored before = " + customerService.numberEntriesStoredOnServer()); - customerService.createFiveCustomers(); - assertThat(customerService.numberEntriesStoredOnServer()).isEqualTo(5); - log.info("Number of Entries stored after = " + customerService.numberEntriesStoredOnServer()); - log.info("Customer for ID before (transaction commit success) = " + customerService.findById(2L).get()); - customerService.updateCustomersSuccess(); - assertThat(customerService.numberEntriesStoredOnServer()).isEqualTo(5); - var customer = customerService.findById(2L).get(); - assertThat(customer.getFirstName()).isEqualTo("Humpty"); - log.info("Customer for ID after (transaction commit success) = " + customer); - - assertThrows(IllegalArgumentException.class, () -> customerService.updateCustomersFailure()); - - customer = customerService.findById(2L).get(); - assertThat(customer.getFirstName()).isEqualTo("Humpty"); - log.info("Customer for ID after (transaction commit failure) = " + customerService.findById(2L).get()); - - var numpty = new Customer(2L, new EmailAddress("2@2.com"), "Numpty", "Hamilton"); - var frumpy = new Customer(2L, new EmailAddress("2@2.com"), "Frumpy", "Hamilton"); - customerService.updateCustomersWithDelay(1000, numpty); - customerService.updateCustomersWithDelay(10, frumpy); - customer = customerService.findById(2L).get(); - assertThat(customer).isEqualTo(frumpy); - log.info("Customer for ID after 2 updates with delay = " + customer); - } -} diff --git a/geode/transactions/src/test/resources/logback.xml b/geode/transactions/src/test/resources/logback.xml deleted file mode 100644 index f3b82068..00000000 --- a/geode/transactions/src/test/resources/logback.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - %msg%n - - - - - - - \ No newline at end of file diff --git a/geode/wan/README.md b/geode/wan/README.md deleted file mode 100755 index 0cd8cb9d..00000000 --- a/geode/wan/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# WAN Event Filters Example - -In this example two servers (SiteA and SiteB) will use WAN replication to replicate data between them. The example also includes several filters that can customize the replication of data. - -NOTE: Inorder to see output, you must change the loglevel from "error" to "info" in the `logback.xml` file located under src/test/resources. \ No newline at end of file diff --git a/geode/wan/pom.xml b/geode/wan/pom.xml deleted file mode 100755 index 7dfe8e36..00000000 --- a/geode/wan/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - 4.0.0 - - - org.springframework.data.examples - spring-data-geode-examples - 2.0.0.BUILD-SNAPSHOT - - - wan - - - - org.awaitility - awaitility - test - - - - diff --git a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/Customer.java b/geode/wan/src/main/java/example/springdata/geode/server/wan/event/Customer.java deleted file mode 100755 index 0bf5c11e..00000000 --- a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/Customer.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.wan.event; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.gemfire.mapping.annotation.Region; - -import java.io.Serializable; - -/** - * A customer used for Lucene examples. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -@Region(name = "Customers") -public class Customer implements Serializable { - - @Id - private Long id; - private EmailAddress emailAddress; - private String firstName; - private String lastName; - - public Customer(Long id, EmailAddress emailAddress, String firstName, String lastName) { - this.id = id; - this.emailAddress = emailAddress; - this.firstName = firstName; - this.lastName = lastName; - } -} diff --git a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/CustomerRepository.java b/geode/wan/src/main/java/example/springdata/geode/server/wan/event/CustomerRepository.java deleted file mode 100755 index f84d7784..00000000 --- a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/CustomerRepository.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.wan.event; - -import org.springframework.data.repository.CrudRepository; - -/** - * @author Patrick Johnson - */ -public interface CustomerRepository extends CrudRepository {} diff --git a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/EmailAddress.java b/geode/wan/src/main/java/example/springdata/geode/server/wan/event/EmailAddress.java deleted file mode 100755 index d65bf5ac..00000000 --- a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/EmailAddress.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.wan.event; - -import lombok.Data; - -import java.io.Serializable; - -/** - * Value object to represent email addresses. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Data -public class EmailAddress implements Serializable { - - private String value; - - public EmailAddress(String value) { - this.value = value; - } -} diff --git a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/EvenNumberedKeyWanEventFilter.java b/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/EvenNumberedKeyWanEventFilter.java deleted file mode 100755 index 39588716..00000000 --- a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/EvenNumberedKeyWanEventFilter.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package example.springdata.geode.server.wan.event.server; - -import org.apache.geode.cache.wan.GatewayEventFilter; -import org.apache.geode.cache.wan.GatewayQueueEvent; -import org.springframework.stereotype.Component; - -/** - * @author Patrick Johnson - */ -@Component -public class EvenNumberedKeyWanEventFilter implements GatewayEventFilter { - - @Override - public boolean beforeEnqueue(GatewayQueueEvent event) { - return (Long) event.getKey() % 2 == 0; - } - - @Override - public boolean beforeTransmit(GatewayQueueEvent event) { - return true; - } - - @Override - public void afterAcknowledgement(GatewayQueueEvent event) {} -} diff --git a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanEventSubstitutionFilter.java b/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanEventSubstitutionFilter.java deleted file mode 100755 index c6177017..00000000 --- a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanEventSubstitutionFilter.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.wan.event.server; - -import example.springdata.geode.server.wan.event.Customer; - -import org.apache.geode.cache.EntryEvent; -import org.apache.geode.cache.wan.GatewayEventSubstitutionFilter; - -import org.springframework.stereotype.Component; - -/** - * @author Patrick Johnson - */ -@Component -public class WanEventSubstitutionFilter implements GatewayEventSubstitutionFilter { - - @Override - public Object getSubstituteValue(EntryEvent event) { - Customer customer = event.getNewValue(); - return new Customer(customer.getId(), customer.getEmailAddress(), customer.getFirstName(), - customer.getLastName().substring(0, 1)); - } -} diff --git a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanServer.java b/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanServer.java deleted file mode 100755 index 23b71168..00000000 --- a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanServer.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.wan.event.server; - -import example.springdata.geode.server.wan.event.Customer; -import example.springdata.geode.server.wan.event.CustomerRepository; -import example.springdata.geode.server.wan.event.EmailAddress; -import lombok.extern.apachecommons.CommonsLog; - -import java.util.Scanner; -import java.util.stream.LongStream; - -import org.springframework.boot.ApplicationRunner; -import org.springframework.boot.WebApplicationType; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Profile; - -import com.github.javafaker.Faker; -import com.github.javafaker.Internet; -import com.github.javafaker.Name; - -/** - * @author Patrick Johnson - */ -@SpringBootApplication(scanBasePackageClasses = WanServerConfig.class) -@CommonsLog -public class WanServer { - - public static void main(String[] args) { - new SpringApplicationBuilder(WanServer.class).web(WebApplicationType.NONE).build().run(args); - } - - @Bean - @Profile({ "default", "SiteA" }) - public ApplicationRunner siteARunner() { - return args -> new Scanner(System.in).nextLine(); - } - - @Bean - @Profile("SiteB") - public ApplicationRunner siteBRunner(CustomerRepository customerRepository) { - return args -> { - log.info("Inserting 300 customers"); - createCustomers(customerRepository); - }; - } - - private void createCustomers(CustomerRepository repository) { - Faker faker = new Faker(); - Name fakerName = faker.name(); - Internet fakerInternet = faker.internet(); - LongStream.range(0, 300).forEach(index -> repository.save(new Customer(index, - new EmailAddress(fakerInternet.emailAddress()), fakerName.firstName(), fakerName.lastName()))); - } -} diff --git a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanServerConfig.java b/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanServerConfig.java deleted file mode 100755 index b6eda78c..00000000 --- a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanServerConfig.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.wan.event.server; - -import example.springdata.geode.server.wan.event.Customer; -import example.springdata.geode.server.wan.event.CustomerRepository; -import example.springdata.geode.server.wan.event.server.siteA.SiteAWanEnabledServerConfig; -import example.springdata.geode.server.wan.event.server.siteB.SiteBWanServerConfig; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; - -import org.apache.geode.cache.DataPolicy; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.cache.PartitionAttributes; -import org.apache.geode.cache.RegionAttributes; -import org.apache.geode.cache.wan.GatewaySender; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.data.gemfire.DiskStoreFactoryBean; -import org.springframework.data.gemfire.PartitionAttributesFactoryBean; -import org.springframework.data.gemfire.PartitionedRegionFactoryBean; -import org.springframework.data.gemfire.RegionAttributesFactoryBean; -import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories; - -import com.github.javafaker.Faker; - -/** - * @author Patrick Johnson - */ -@Configuration -@EnableGemfireRepositories(basePackageClasses = CustomerRepository.class) -@Import({ SiteAWanEnabledServerConfig.class, SiteBWanServerConfig.class }) -public class WanServerConfig { - - @Bean - Faker faker() { - return new Faker(); - } - - @Bean(name = "DiskStore") - DiskStoreFactoryBean diskStore(GemFireCache gemFireCache, Faker faker) throws IOException { - DiskStoreFactoryBean diskStoreFactoryBean = new DiskStoreFactoryBean(); - File tempDirectory = File.createTempFile("prefix-" + faker.name().firstName(), - "suffix-" + faker.name().firstName()); - tempDirectory.delete(); - tempDirectory.mkdirs(); - tempDirectory.deleteOnExit(); - DiskStoreFactoryBean.DiskDir[] diskDirs = { new DiskStoreFactoryBean.DiskDir(tempDirectory.getAbsolutePath()) }; - diskStoreFactoryBean.setDiskDirs(Arrays.asList(diskDirs)); - diskStoreFactoryBean.setCache(gemFireCache); - return diskStoreFactoryBean; - } - - @Bean - RegionAttributesFactoryBean regionAttributes( - PartitionAttributes partitionAttributes) { - RegionAttributesFactoryBean regionAttributesFactoryBean = new RegionAttributesFactoryBean<>(); - regionAttributesFactoryBean.setPartitionAttributes(partitionAttributes); - return regionAttributesFactoryBean; - } - - @Bean - PartitionAttributesFactoryBean partitionAttributes() { - PartitionAttributesFactoryBean partitionAttributesFactoryBean = new PartitionAttributesFactoryBean<>(); - partitionAttributesFactoryBean.setTotalNumBuckets(13); - partitionAttributesFactoryBean.setRedundantCopies(0); - return partitionAttributesFactoryBean; - } - - @Bean("Customers") - PartitionedRegionFactoryBean createCustomerRegion(GemFireCache gemFireCache, - RegionAttributes regionAttributes, GatewaySender gatewaySender) { - PartitionedRegionFactoryBean partitionedRegionFactoryBean = new PartitionedRegionFactoryBean<>(); - partitionedRegionFactoryBean.setCache(gemFireCache); - partitionedRegionFactoryBean.setRegionName("Customers"); - partitionedRegionFactoryBean.setDataPolicy(DataPolicy.PARTITION); - partitionedRegionFactoryBean.setAttributes(regionAttributes); - partitionedRegionFactoryBean.setGatewaySenders(new GatewaySender[] { gatewaySender }); - return partitionedRegionFactoryBean; - } -} diff --git a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanTransportEncryptionListener.java b/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanTransportEncryptionListener.java deleted file mode 100755 index 75c33bb7..00000000 --- a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/WanTransportEncryptionListener.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.wan.event.server; - -import lombok.extern.apachecommons.CommonsLog; - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.zip.Adler32; -import java.util.zip.CheckedInputStream; -import java.util.zip.CheckedOutputStream; - -import org.apache.geode.cache.wan.GatewayTransportFilter; - -import org.springframework.stereotype.Component; - -/** - * @author Patrick Johnson - */ -@Component -@CommonsLog -public class WanTransportEncryptionListener implements GatewayTransportFilter { - - private final Adler32 CHECKER = new Adler32(); - - @Override - public InputStream getInputStream(InputStream stream) { - log.info("CheckedTransportFilter: Getting input stream"); - return new CheckedInputStream(stream, CHECKER); - } - - @Override - public OutputStream getOutputStream(OutputStream stream) { - log.info("CheckedTransportFilter: Getting output stream"); - return new CheckedOutputStream(stream, CHECKER); - } -} diff --git a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/siteA/SiteAWanEnabledServerConfig.java b/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/siteA/SiteAWanEnabledServerConfig.java deleted file mode 100755 index 2b0047e6..00000000 --- a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/siteA/SiteAWanEnabledServerConfig.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.wan.event.server.siteA; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.GemFireCache; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.DependsOn; -import org.springframework.context.annotation.Profile; -import org.springframework.data.gemfire.config.annotation.CacheServerApplication; -import org.springframework.data.gemfire.config.annotation.EnableGemFireProperties; -import org.springframework.data.gemfire.config.annotation.EnableLocator; -import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean; -import org.springframework.data.gemfire.wan.GatewaySenderFactoryBean; - -/** - * @author Patrick Johnson - */ -@Configuration -@CacheServerApplication(port = 0, locators = "localhost[10334]", name = "SiteA_Server", logLevel = "error") -@Profile({ "default", "SiteA" }) -@EnableLocator -@EnableGemFireProperties(distributedSystemId = 1, remoteLocators = "localhost[20334]") -public class SiteAWanEnabledServerConfig { - - @Bean - GatewayReceiverFactoryBean createGatewayReceiver(GemFireCache gemFireCache) { - GatewayReceiverFactoryBean gatewayReceiverFactoryBean = new GatewayReceiverFactoryBean((Cache) gemFireCache); - gatewayReceiverFactoryBean.setStartPort(15000); - gatewayReceiverFactoryBean.setEndPort(15010); - gatewayReceiverFactoryBean.setManualStart(false); - return gatewayReceiverFactoryBean; - } - - @Bean - @DependsOn("DiskStore") - GatewaySenderFactoryBean createGatewaySender(GemFireCache gemFireCache) { - GatewaySenderFactoryBean gatewaySenderFactoryBean = new GatewaySenderFactoryBean(gemFireCache); - gatewaySenderFactoryBean.setBatchSize(15); - gatewaySenderFactoryBean.setBatchTimeInterval(1000); - gatewaySenderFactoryBean.setRemoteDistributedSystemId(2); - gatewaySenderFactoryBean.setPersistent(false); - gatewaySenderFactoryBean.setDiskStoreRef("DiskStore"); - return gatewaySenderFactoryBean; - } -} diff --git a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/siteB/SiteBWanServerConfig.java b/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/siteB/SiteBWanServerConfig.java deleted file mode 100755 index 8d9f57b4..00000000 --- a/geode/wan/src/main/java/example/springdata/geode/server/wan/event/server/siteB/SiteBWanServerConfig.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.wan.event.server.siteB; - -import example.springdata.geode.server.wan.event.Customer; -import example.springdata.geode.server.wan.event.server.EvenNumberedKeyWanEventFilter; -import example.springdata.geode.server.wan.event.server.WanEventSubstitutionFilter; -import example.springdata.geode.server.wan.event.server.WanTransportEncryptionListener; - -import java.util.Collections; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.cache.wan.GatewayEventFilter; -import org.apache.geode.cache.wan.GatewayEventSubstitutionFilter; -import org.apache.geode.cache.wan.GatewayTransportFilter; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.DependsOn; -import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Profile; -import org.springframework.data.gemfire.config.annotation.CacheServerApplication; -import org.springframework.data.gemfire.config.annotation.EnableGemFireProperties; -import org.springframework.data.gemfire.config.annotation.EnableLocator; -import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean; -import org.springframework.data.gemfire.wan.GatewaySenderFactoryBean; - -/** - * @author Patrick Johnson - */ -@Configuration -@CacheServerApplication(port = 0, locators = "localhost[20334]", name = "SiteB_Server", logLevel = "error") -@Profile("SiteB") -@EnableLocator(port = 20334) -@EnableGemFireProperties(distributedSystemId = 2, remoteLocators = "localhost[10334]") -@Import({ EvenNumberedKeyWanEventFilter.class, WanEventSubstitutionFilter.class, WanTransportEncryptionListener.class }) -public class SiteBWanServerConfig { - - @Bean - GatewayReceiverFactoryBean createGatewayReceiver(GemFireCache gemFireCache) { - GatewayReceiverFactoryBean gatewayReceiverFactoryBean = new GatewayReceiverFactoryBean((Cache) gemFireCache); - gatewayReceiverFactoryBean.setStartPort(25000); - gatewayReceiverFactoryBean.setEndPort(25010); - return gatewayReceiverFactoryBean; - } - - @Bean - @DependsOn("DiskStore") - GatewaySenderFactoryBean createGatewaySender(GemFireCache gemFireCache, GatewayEventFilter gatewayEventFilter, - GatewayTransportFilter gatewayTransportFilter, - GatewayEventSubstitutionFilter gatewayEventSubstitutionFilter) { - GatewaySenderFactoryBean gatewaySenderFactoryBean = new GatewaySenderFactoryBean(gemFireCache); - gatewaySenderFactoryBean.setBatchSize(15); - gatewaySenderFactoryBean.setBatchTimeInterval(1000); - gatewaySenderFactoryBean.setRemoteDistributedSystemId(1); - gatewaySenderFactoryBean.setDiskStoreRef("DiskStore"); - gatewaySenderFactoryBean.setEventFilters(Collections.singletonList(gatewayEventFilter)); - gatewaySenderFactoryBean.setTransportFilters(Collections.singletonList(gatewayTransportFilter)); - gatewaySenderFactoryBean.setEventSubstitutionFilter(gatewayEventSubstitutionFilter); - gatewaySenderFactoryBean.setPersistent(false); - return gatewaySenderFactoryBean; - } -} diff --git a/geode/wan/src/test/java/example/springdata/geode/server/wan/event/WanServerTests.java b/geode/wan/src/test/java/example/springdata/geode/server/wan/event/WanServerTests.java deleted file mode 100755 index 4aaf1871..00000000 --- a/geode/wan/src/test/java/example/springdata/geode/server/wan/event/WanServerTests.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package example.springdata.geode.server.wan.event; - -import static org.assertj.core.api.Assertions.*; - -import example.springdata.geode.server.wan.event.client.WanClientConfig; -import example.springdata.geode.server.wan.event.server.WanServer; -import lombok.extern.apachecommons.CommonsLog; - -import java.io.IOException; -import java.util.concurrent.TimeUnit; - -import jakarta.annotation.Resource; - -import org.apache.geode.cache.Region; -import org.awaitility.Awaitility; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Patrick Johnson - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = WanClientConfig.class) -@CommonsLog -public class WanServerTests extends ForkingClientServerIntegrationTestsSupport { - - @Resource(name = "Customers") private Region customers; - - @BeforeClass - public static void setup() throws IOException { - startGemFireServer(WanServer.class, "-Dspring.profiles.active=SiteB"); - startGemFireServer(WanServer.class, "-Dspring.profiles.active=SiteA"); - System.getProperties().remove("spring.data.gemfire.pool.servers"); - } - - @Test - public void wanReplicationOccursCorrectly() { - - Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> customers.keySetOnServer().size() == 150); - - assertThat(customers.keySetOnServer()).hasSize(150); - - log.info(customers.keySetOnServer().size() + " entries replicated to siteA"); - - customers.getAll(customers.keySetOnServer()) - .forEach((key, value) -> assertThat(value.getLastName().length()).isEqualTo(1)); - log.info("All customers' last names changed to last initial on siteA"); - } -} diff --git a/geode/wan/src/test/java/example/springdata/geode/server/wan/event/client/WanClientConfig.java b/geode/wan/src/test/java/example/springdata/geode/server/wan/event/client/WanClientConfig.java deleted file mode 100755 index e84527f8..00000000 --- a/geode/wan/src/test/java/example/springdata/geode/server/wan/event/client/WanClientConfig.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2020-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.geode.server.wan.event.client; - -import example.springdata.geode.server.wan.event.Customer; -import example.springdata.geode.server.wan.event.CustomerRepository; - -import java.util.Collections; - -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.cache.client.ClientRegionShortcut; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.gemfire.client.ClientRegionFactoryBean; -import org.springframework.data.gemfire.config.annotation.ClientCacheApplication; -import org.springframework.data.gemfire.config.annotation.ClientCacheConfigurer; -import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories; -import org.springframework.data.gemfire.support.ConnectionEndpoint; - -/** - * Spring JavaConfig configuration class to setup a Spring container and infrastructure components. - * - * @author Udo Kohlmeyer - * @author Patrick Johnson - */ -@Configuration -@EnableGemfireRepositories(basePackageClasses = CustomerRepository.class) -@ClientCacheApplication(name = "WanClient", logLevel = "error", pingInterval = 5000L, readTimeout = 15000, - retryAttempts = 1) -public class WanClientConfig { - - @Bean("Customers") - protected ClientRegionFactoryBean configureProxyClientCustomerRegion(GemFireCache gemFireCache) { - ClientRegionFactoryBean clientRegionFactoryBean = new ClientRegionFactoryBean<>(); - clientRegionFactoryBean.setCache(gemFireCache); - clientRegionFactoryBean.setName("Customers"); - clientRegionFactoryBean.setShortcut(ClientRegionShortcut.PROXY); - return clientRegionFactoryBean; - } - - @Bean - ClientCacheConfigurer clientCacheServerConfigurer( - @Value("${spring.data.geode.locator.host:localhost}") String hostname, - @Value("${spring.data.geode.locator.port:10334}") int port) { - - return (beanName, clientCacheFactoryBean) -> clientCacheFactoryBean - .setLocators(Collections.singletonList(new ConnectionEndpoint(hostname, port))); - } -} diff --git a/geode/wan/src/test/resources/logback.xml b/geode/wan/src/test/resources/logback.xml deleted file mode 100644 index f3b82068..00000000 --- a/geode/wan/src/test/resources/logback.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - %msg%n - - - - - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index ad4a49e6..22e0bc8a 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,6 @@ couchbase cassandra elasticsearch - jdbc jpa ldap