From 06d20805230b79024980138a3daa63305f51b502 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 12 Jun 2020 12:12:04 +0530 Subject: [PATCH] JAVA-1848: Moved apache-geode to apache-libraries --- apache-geode/README.md | 7 -- apache-geode/pom.xml | 29 ----- .../java/com/baeldung/geode/Customer.java | 78 ------------- .../java/com/baeldung/geode/CustomerKey.java | 57 --------- .../geode/functions/UpperCaseNames.java | 34 ------ .../baeldung/geode/GeodeSamplesLiveTest.java | 110 ------------------ 6 files changed, 315 deletions(-) delete mode 100644 apache-geode/README.md delete mode 100644 apache-geode/pom.xml delete mode 100644 apache-geode/src/main/java/com/baeldung/geode/Customer.java delete mode 100644 apache-geode/src/main/java/com/baeldung/geode/CustomerKey.java delete mode 100644 apache-geode/src/main/java/com/baeldung/geode/functions/UpperCaseNames.java delete mode 100644 apache-geode/src/test/java/com/baeldung/geode/GeodeSamplesLiveTest.java diff --git a/apache-geode/README.md b/apache-geode/README.md deleted file mode 100644 index 86629f7a82..0000000000 --- a/apache-geode/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Apache Geode - -This module contains articles about Apache Geode - -### Relevant Articles: - -- [A Quick Guide to Apache Geode](https://www.baeldung.com/apache-geode) diff --git a/apache-geode/pom.xml b/apache-geode/pom.xml deleted file mode 100644 index fc5b253c01..0000000000 --- a/apache-geode/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - apache-geode - 1.0-SNAPSHOT - apache-geode - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - - - - - org.apache.geode - geode-core - ${geode.core} - - - - - 1.6.0 - - - \ No newline at end of file diff --git a/apache-geode/src/main/java/com/baeldung/geode/Customer.java b/apache-geode/src/main/java/com/baeldung/geode/Customer.java deleted file mode 100644 index 82ee5ecaeb..0000000000 --- a/apache-geode/src/main/java/com/baeldung/geode/Customer.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.baeldung.geode; - -import java.io.Serializable; -import java.util.Objects; - -public class Customer implements Serializable { - - private static final long serialVersionUID = -7482516011038799900L; - - private CustomerKey key; - private String firstName; - private String lastName; - private Integer age; - - public Customer() { - } - - public Customer(String firstName, String lastName, int age) { - this.firstName = firstName; - this.lastName = lastName; - this.age = age; - } - - public Customer(CustomerKey key, String firstName, String lastName, int age) { - this(firstName, lastName, age); - this.key = key; - } - - // setters and getters - - public static long getSerialVersionUID() { - return serialVersionUID; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public Integer getAge() { - return age; - } - - public void setAge(Integer age) { - this.age = age; - } - - @Override - public String toString() { - return "Customer{" + "firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + ", age=" + age + '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - Customer customer = (Customer) o; - return Objects.equals(firstName, customer.firstName) && Objects.equals(lastName, customer.lastName) && Objects.equals(age, customer.age); - } - - @Override - public int hashCode() { - return Objects.hash(firstName, lastName, age); - } -} diff --git a/apache-geode/src/main/java/com/baeldung/geode/CustomerKey.java b/apache-geode/src/main/java/com/baeldung/geode/CustomerKey.java deleted file mode 100644 index bfa64870c0..0000000000 --- a/apache-geode/src/main/java/com/baeldung/geode/CustomerKey.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.baeldung.geode; - -import java.io.Serializable; - -public class CustomerKey implements Serializable { - - private static final long serialVersionUID = -3529253035303792458L; - private long id; - private String country; - - public CustomerKey(long id) { - this.id = id; - this.country = "USA"; - } - - public CustomerKey(long id, String country) { - this.id = id; - this.country = country; - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - CustomerKey that = (CustomerKey) o; - - if (id != that.id) - return false; - return country != null ? country.equals(that.country) : that.country == null; - } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (country != null ? country.hashCode() : 0); - return result; - } -} diff --git a/apache-geode/src/main/java/com/baeldung/geode/functions/UpperCaseNames.java b/apache-geode/src/main/java/com/baeldung/geode/functions/UpperCaseNames.java deleted file mode 100644 index 5ff8e53da8..0000000000 --- a/apache-geode/src/main/java/com/baeldung/geode/functions/UpperCaseNames.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.baeldung.geode.functions; - -import com.baeldung.geode.Customer; -import com.baeldung.geode.CustomerKey; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.execute.Function; -import org.apache.geode.cache.execute.FunctionContext; -import org.apache.geode.cache.execute.RegionFunctionContext; - -import java.util.Map; - -public class UpperCaseNames implements Function { - private static final long serialVersionUID = -8946294032165677602L; - - @Override - public void execute(FunctionContext context) { - RegionFunctionContext regionContext = (RegionFunctionContext) context; - Region region = regionContext.getDataSet(); - - for (Map.Entry entry : region.entrySet()) { - Customer customer = entry.getValue(); - customer.setFirstName(customer.getFirstName() - .toUpperCase()); - } - - context.getResultSender() - .lastResult(true); - } - - @Override - public String getId() { - return getClass().getName(); - } -} diff --git a/apache-geode/src/test/java/com/baeldung/geode/GeodeSamplesLiveTest.java b/apache-geode/src/test/java/com/baeldung/geode/GeodeSamplesLiveTest.java deleted file mode 100644 index 359568db98..0000000000 --- a/apache-geode/src/test/java/com/baeldung/geode/GeodeSamplesLiveTest.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.baeldung.geode; - -import com.baeldung.geode.functions.UpperCaseNames; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.client.ClientCache; -import org.apache.geode.cache.client.ClientCacheFactory; -import org.apache.geode.cache.client.ClientRegionShortcut; -import org.apache.geode.cache.execute.Execution; -import org.apache.geode.cache.execute.FunctionService; -import org.apache.geode.cache.query.*; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static org.junit.Assert.assertEquals; - -public class GeodeSamplesLiveTest { - - ClientCache cache = null; - Region region = null; - Region queryRegion = null; - Region customerRegion = null; - - @Before - public void connect() { - this.cache = new ClientCacheFactory().addPoolLocator("localhost", 10334) - .create(); - this.region = this.cache. createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY) - .create("baeldung"); - this.customerRegion = this.cache. createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY) - .create("baeldung-customers"); - } - - @After - public void cleanup() { - this.cache.close(); - } - - @Test - public void whenSendMessageToRegion_thenMessageSavedSuccessfully() { - - this.region.put("1", "Hello"); - this.region.put("2", "Baeldung"); - - assertEquals("Hello", region.get("1")); - assertEquals("Baeldung", region.get("2")); - - } - - @Test - public void whenPutMultipleValuesAtOnce_thenValuesSavedSuccessfully() { - - Supplier> keys = () -> Stream.of("A", "B", "C", "D", "E"); - Map values = keys.get() - .collect(Collectors.toMap(Function.identity(), String::toLowerCase)); - - this.region.putAll(values); - - keys.get() - .forEach(k -> assertEquals(k.toLowerCase(), this.region.get(k))); - - } - - @Test - public void whenPutCustomKey_thenValuesSavedSuccessfully() { - CustomerKey key = new CustomerKey(123); - Customer customer = new Customer(key, "William", "Russell", 35); - - Map customerInfo = new HashMap<>(); - customerInfo.put(key, customer); - - this.customerRegion.putAll(customerInfo); - - Customer storedCustomer = this.customerRegion.get(key); - assertEquals("William", storedCustomer.getFirstName()); - assertEquals("Russell", storedCustomer.getLastName()); - - } - - @Test - public void whenFindACustomerUsingOQL_thenCorrectCustomerObject() throws NameResolutionException, TypeMismatchException, QueryInvocationTargetException, FunctionDomainException { - - Map data = new HashMap<>(); - data.put(new CustomerKey(1), new Customer("Gheorge", "Manuc", 36)); - data.put(new CustomerKey(2), new Customer("Allan", "McDowell", 43)); - this.customerRegion.putAll(data); - - QueryService queryService = this.cache.getQueryService(); - String query = "select * from /baeldung-customers c where c.firstName = 'Allan'"; - SelectResults queryResults = (SelectResults) queryService.newQuery(query) - .execute(); - assertEquals(1, queryResults.size()); - - } - - @Test - public void whenExecuteUppercaseNames_thenCustomerNamesAreUppercased() { - Execution execution = FunctionService.onRegion(this.customerRegion); - execution.execute(UpperCaseNames.class.getName()); - Customer customer = this.customerRegion.get(new CustomerKey(1)); - assertEquals("GHEORGE", customer.getFirstName()); - } -}