You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gora.apache.org by GitBox <gi...@apache.org> on 2022/09/03 19:37:11 UTC
[GitHub] [gora] himanshuacharya95 opened a new pull request, #273: [IN-PROGRESS] GORA-698 Geode DataStore
himanshuacharya95 opened a new pull request, #273:
URL: https://github.com/apache/gora/pull/273
# Pending Items Test Cases
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@gora.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gora] kamaci commented on a diff in pull request #273: [IN-PROGRESS] GORA-698 Geode DataStore
Posted by GitBox <gi...@apache.org>.
kamaci commented on code in PR #273:
URL: https://github.com/apache/gora/pull/273#discussion_r962204714
##########
gora-geode/src/main/java/org/apache/gora/geode/store/GeodeStore.java:
##########
@@ -0,0 +1,190 @@
+package org.apache.gora.geode.store;
+
+import org.apache.geode.cache.*;
+import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.client.ClientCacheFactory;
+import org.apache.gora.geode.query.GeodeQuery;
+import org.apache.gora.geode.query.GeodeResult;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.query.PartitionQuery;
+import org.apache.gora.query.Query;
+import org.apache.gora.query.Result;
+import org.apache.gora.query.impl.PartitionQueryImpl;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.GoraException;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.ConcurrentSkipListSet;
+
+import static org.apache.geode.cache.RegionShortcut.REPLICATE;
+import static org.apache.gora.geode.store.GeodeStoreParameters.*;
+
+
+public class GeodeStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
+
+ private ClientCache clientCache;
+ private Region<K, T> region;
+ private Properties geodeProperties;
+
+
+ private CacheFactory cacheFactory;
+
+ @Override
+ public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws GoraException {
+ super.initialize(keyClass, persistentClass, properties);
+ String geodeHostName = (String) properties.get(GEODE_SERVER_HOST);
+ int portNumber = Integer.parseInt((String) properties.get(GEODE_SERVER_PORT));
+ clientCache = new ClientCacheFactory().addPoolLocator(geodeHostName, portNumber).create();
+ String userName = properties.getProperty(GEODE_USERNAME);
+ String password = properties.getProperty(GEODE_PASSWORD);
+ geodeProperties = properties;
+
+ Properties clientProperties = clientCache.getDistributedSystem().getProperties();
+ if (userName != null) {
Review Comment:
What if username is null and password is not? How about throwing an exception in that case?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@gora.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gora] himanshuacharya95 commented on a diff in pull request #273: [IN-PROGRESS] GORA-698 Geode DataStore
Posted by GitBox <gi...@apache.org>.
himanshuacharya95 commented on code in PR #273:
URL: https://github.com/apache/gora/pull/273#discussion_r963143973
##########
gora-geode/src/main/java/org/apache/gora/geode/store/GeodeStore.java:
##########
@@ -0,0 +1,190 @@
+package org.apache.gora.geode.store;
+
+import org.apache.geode.cache.*;
+import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.client.ClientCacheFactory;
+import org.apache.gora.geode.query.GeodeQuery;
+import org.apache.gora.geode.query.GeodeResult;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.query.PartitionQuery;
+import org.apache.gora.query.Query;
+import org.apache.gora.query.Result;
+import org.apache.gora.query.impl.PartitionQueryImpl;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.GoraException;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.ConcurrentSkipListSet;
+
+import static org.apache.geode.cache.RegionShortcut.REPLICATE;
+import static org.apache.gora.geode.store.GeodeStoreParameters.*;
+
+
+public class GeodeStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
+
+ private ClientCache clientCache;
+ private Region<K, T> region;
+ private Properties geodeProperties;
+
+
Review Comment:
Extra spaces removed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@gora.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gora] kamaci commented on a diff in pull request #273: [IN-PROGRESS] GORA-698 Geode DataStore
Posted by GitBox <gi...@apache.org>.
kamaci commented on code in PR #273:
URL: https://github.com/apache/gora/pull/273#discussion_r973769144
##########
gora-geode/src/test/java/store/TestGeodeStore.java:
##########
@@ -0,0 +1,161 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 store;
+
+
+
+import org.apache.avro.util.Utf8;
+import org.apache.gora.examples.WebPageDataCreator;
+import org.apache.gora.examples.generated.WebPage;
+import org.apache.gora.geode.GeodeStartupLogWaitStrategy;
+import org.apache.gora.geode.GoraGeodeTestDriver;
+import org.apache.gora.geode.query.GeodeResult;
+import org.apache.gora.query.Query;
+import org.apache.gora.store.DataStoreTestBase;
+import org.apache.gora.util.GoraException;
+import org.junit.ClassRule;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.testcontainers.containers.GenericContainer;
+
+
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.time.Duration;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests extending {@link DataStoreTestBase}
+ * which run the base JUnit test suite for Gora.
+ */
+public class TestGeodeStore extends DataStoreTestBase {
Review Comment:
Could you add more tests?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@gora.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gora] djkevincr commented on pull request #273: [IN-PROGRESS] GORA-698 Geode DataStore
Posted by "djkevincr (via GitHub)" <gi...@apache.org>.
djkevincr commented on PR #273:
URL: https://github.com/apache/gora/pull/273#issuecomment-1475455904
@himanshuacharya95 Can you please address the remaining request changes?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@gora.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gora] kamaci commented on a diff in pull request #273: [IN-PROGRESS] GORA-698 Geode DataStore
Posted by GitBox <gi...@apache.org>.
kamaci commented on code in PR #273:
URL: https://github.com/apache/gora/pull/273#discussion_r973768766
##########
gora-geode/src/main/java/org/apache/gora/geode/store/GeodeStore.java:
##########
@@ -0,0 +1,187 @@
+package org.apache.gora.geode.store;
+
+import org.apache.geode.cache.*;
Review Comment:
Please not use wildcard imports
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@gora.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gora] himanshuacharya95 commented on a diff in pull request #273: [IN-PROGRESS] GORA-698 Geode DataStore
Posted by GitBox <gi...@apache.org>.
himanshuacharya95 commented on code in PR #273:
URL: https://github.com/apache/gora/pull/273#discussion_r963144223
##########
gora-geode/src/main/java/org/apache/gora/geode/store/GeodeStore.java:
##########
@@ -0,0 +1,190 @@
+package org.apache.gora.geode.store;
+
+import org.apache.geode.cache.*;
+import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.client.ClientCacheFactory;
+import org.apache.gora.geode.query.GeodeQuery;
+import org.apache.gora.geode.query.GeodeResult;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.query.PartitionQuery;
+import org.apache.gora.query.Query;
+import org.apache.gora.query.Result;
+import org.apache.gora.query.impl.PartitionQueryImpl;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.GoraException;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.ConcurrentSkipListSet;
+
+import static org.apache.geode.cache.RegionShortcut.REPLICATE;
+import static org.apache.gora.geode.store.GeodeStoreParameters.*;
+
+
+public class GeodeStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
+
+ private ClientCache clientCache;
+ private Region<K, T> region;
+ private Properties geodeProperties;
+
+
+ private CacheFactory cacheFactory;
+
+ @Override
+ public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws GoraException {
+ super.initialize(keyClass, persistentClass, properties);
+ String geodeHostName = (String) properties.get(GEODE_SERVER_HOST);
+ int portNumber = Integer.parseInt((String) properties.get(GEODE_SERVER_PORT));
+ clientCache = new ClientCacheFactory().addPoolLocator(geodeHostName, portNumber).create();
+ String userName = properties.getProperty(GEODE_USERNAME);
+ String password = properties.getProperty(GEODE_PASSWORD);
+ geodeProperties = properties;
+
+ Properties clientProperties = clientCache.getDistributedSystem().getProperties();
+ if (userName != null) {
Review Comment:
Added some code to throw exception
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@gora.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gora] himanshuacharya95 commented on a diff in pull request #273: [IN-PROGRESS] GORA-698 Geode DataStore
Posted by GitBox <gi...@apache.org>.
himanshuacharya95 commented on code in PR #273:
URL: https://github.com/apache/gora/pull/273#discussion_r973775993
##########
gora-geode/src/main/java/org/apache/gora/geode/store/GeodeStore.java:
##########
@@ -0,0 +1,187 @@
+package org.apache.gora.geode.store;
+
+import org.apache.geode.cache.*;
Review Comment:
Replaced wildcard import statements with only required ones.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@gora.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gora] kamaci commented on a diff in pull request #273: [IN-PROGRESS] GORA-698 Geode DataStore
Posted by GitBox <gi...@apache.org>.
kamaci commented on code in PR #273:
URL: https://github.com/apache/gora/pull/273#discussion_r962204734
##########
gora-geode/src/main/java/org/apache/gora/geode/store/GeodeStore.java:
##########
@@ -0,0 +1,190 @@
+package org.apache.gora.geode.store;
+
+import org.apache.geode.cache.*;
+import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.client.ClientCacheFactory;
+import org.apache.gora.geode.query.GeodeQuery;
+import org.apache.gora.geode.query.GeodeResult;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.query.PartitionQuery;
+import org.apache.gora.query.Query;
+import org.apache.gora.query.Result;
+import org.apache.gora.query.impl.PartitionQueryImpl;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.GoraException;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.ConcurrentSkipListSet;
+
+import static org.apache.geode.cache.RegionShortcut.REPLICATE;
+import static org.apache.gora.geode.store.GeodeStoreParameters.*;
+
+
+public class GeodeStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
+
+ private ClientCache clientCache;
+ private Region<K, T> region;
+ private Properties geodeProperties;
+
+
+ private CacheFactory cacheFactory;
+
+ @Override
+ public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws GoraException {
+ super.initialize(keyClass, persistentClass, properties);
+ String geodeHostName = (String) properties.get(GEODE_SERVER_HOST);
+ int portNumber = Integer.parseInt((String) properties.get(GEODE_SERVER_PORT));
+ clientCache = new ClientCacheFactory().addPoolLocator(geodeHostName, portNumber).create();
+ String userName = properties.getProperty(GEODE_USERNAME);
+ String password = properties.getProperty(GEODE_PASSWORD);
+ geodeProperties = properties;
+
+ Properties clientProperties = clientCache.getDistributedSystem().getProperties();
+ if (userName != null) {
+ clientProperties.setProperty("security-username", userName);
+ clientProperties.setProperty("security-password", password);
+ }
+ cacheFactory = new CacheFactory(clientProperties);
+ }
+
+ @Override
+ /*
+ Schema Name can be assigned via Property file using @PREFERRED_SCHEMA_NAME, or else PersistentClass name is used as the default schema name.
+ */
+ public String getSchemaName() {
+ String preferredSchemaName = properties.getProperty(PREFERRED_SCHEMA_NAME);
+ if (preferredSchemaName == null) {
+ return persistentClass.getSimpleName();
+ }
+ return preferredSchemaName;
+ }
+
+ @Override
+ public void createSchema() throws GoraException {
+ try {
+ Cache cache = cacheFactory.create();
+ String regionShortCut = geodeProperties.getProperty(GEODE_REGION_SHORTCUT);
+ RegionFactory<K,T> regionFactory;
+ if (regionShortCut != null) {
+ regionFactory = cache.createRegionFactory(RegionShortcut.valueOf(regionShortCut));
+ } else {
+ regionFactory = cache.createRegionFactory(REPLICATE);
+ }
+ region = regionFactory.create(getSchemaName());
+ } catch (Exception e) {
+ throw new GoraException(e);
+ }
+ }
+
+ @Override
+ public void deleteSchema() {
+ region.destroyRegion();
+ }
+
+ @Override
+ public boolean schemaExists() {
+ Properties properties = clientCache.getDistributedSystem().getProperties();
+ CacheFactory factory = new CacheFactory(properties);
+ Cache cache = factory.create();
+ Region<K, T> rf = cache.getRegion(getSchemaName());
+ return rf != null;
+ }
+
+ @Override
+ public boolean exists(K key) {
+ for (K existingKey : region.getInterestList()) {
+ if (existingKey.equals(key)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public T get(K key, String[] fields) {
+ return region.get(key);
+ }
+
+ @Override
+ public void put(K key, T obj) {
+ region.put(key, obj);
+ }
+
+ @Override
+ public boolean delete(K key) {
+ region.destroy(key);
+ return true;
+ }
+
+ @Override
+ public long deleteByQuery(Query<K, T> query) throws GoraException {
+ try {
+ long deletedRows = 0;
+ Result<K, T> result = query.execute();
+ while (result.next()) {
+ if (delete(result.getKey())) {
+ deletedRows++;
+ }
+ }
+ LOG.info("Geode datastore deleted {} rows from Persistent datastore.", deletedRows);
+ return deletedRows;
+ } catch (Exception e) {
+ throw new GoraException(e);
+ }
+ }
+
+ @Override
+ public Result<K, T> execute(Query<K, T> query) {
+
Review Comment:
remove extra space
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@gora.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gora] CalvinKirs commented on pull request #273: [IN-PROGRESS] GORA-698 Geode DataStore
Posted by "CalvinKirs (via GitHub)" <gi...@apache.org>.
CalvinKirs commented on PR #273:
URL: https://github.com/apache/gora/pull/273#issuecomment-1465561868
> @CalvinKirs Do you have any input on the PR related to Geode work?
I will take a look later :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@gora.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gora] djkevincr commented on pull request #273: [IN-PROGRESS] GORA-698 Geode DataStore
Posted by "djkevincr (via GitHub)" <gi...@apache.org>.
djkevincr commented on PR #273:
URL: https://github.com/apache/gora/pull/273#issuecomment-1465352565
@CalvinKirs Do you have any input on the PR related to Geode work?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@gora.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gora] djkevincr commented on pull request #273: [IN-PROGRESS] GORA-698 Geode DataStore
Posted by "djkevincr (via GitHub)" <gi...@apache.org>.
djkevincr commented on PR #273:
URL: https://github.com/apache/gora/pull/273#issuecomment-1725866087
Theres some in complete work left in this PR, I will merge this PR for now and take things forward.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@gora.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gora] djkevincr merged pull request #273: [IN-PROGRESS] GORA-698 Geode DataStore
Posted by "djkevincr (via GitHub)" <gi...@apache.org>.
djkevincr merged PR #273:
URL: https://github.com/apache/gora/pull/273
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@gora.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gora] kamaci commented on a diff in pull request #273: [IN-PROGRESS] GORA-698 Geode DataStore
Posted by GitBox <gi...@apache.org>.
kamaci commented on code in PR #273:
URL: https://github.com/apache/gora/pull/273#discussion_r962204662
##########
gora-geode/src/main/java/org/apache/gora/geode/store/GeodeStore.java:
##########
@@ -0,0 +1,190 @@
+package org.apache.gora.geode.store;
+
+import org.apache.geode.cache.*;
+import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.client.ClientCacheFactory;
+import org.apache.gora.geode.query.GeodeQuery;
+import org.apache.gora.geode.query.GeodeResult;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.query.PartitionQuery;
+import org.apache.gora.query.Query;
+import org.apache.gora.query.Result;
+import org.apache.gora.query.impl.PartitionQueryImpl;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.GoraException;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.ConcurrentSkipListSet;
+
+import static org.apache.geode.cache.RegionShortcut.REPLICATE;
+import static org.apache.gora.geode.store.GeodeStoreParameters.*;
+
+
+public class GeodeStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
+
+ private ClientCache clientCache;
+ private Region<K, T> region;
+ private Properties geodeProperties;
+
+
Review Comment:
Please remove extra spaces
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@gora.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [gora] himanshuacharya95 commented on a diff in pull request #273: [IN-PROGRESS] GORA-698 Geode DataStore
Posted by GitBox <gi...@apache.org>.
himanshuacharya95 commented on code in PR #273:
URL: https://github.com/apache/gora/pull/273#discussion_r963144285
##########
gora-geode/src/main/java/org/apache/gora/geode/store/GeodeStore.java:
##########
@@ -0,0 +1,190 @@
+package org.apache.gora.geode.store;
+
+import org.apache.geode.cache.*;
+import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.client.ClientCacheFactory;
+import org.apache.gora.geode.query.GeodeQuery;
+import org.apache.gora.geode.query.GeodeResult;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.query.PartitionQuery;
+import org.apache.gora.query.Query;
+import org.apache.gora.query.Result;
+import org.apache.gora.query.impl.PartitionQueryImpl;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.GoraException;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.ConcurrentSkipListSet;
+
+import static org.apache.geode.cache.RegionShortcut.REPLICATE;
+import static org.apache.gora.geode.store.GeodeStoreParameters.*;
+
+
+public class GeodeStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
+
+ private ClientCache clientCache;
+ private Region<K, T> region;
+ private Properties geodeProperties;
+
+
+ private CacheFactory cacheFactory;
+
+ @Override
+ public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws GoraException {
+ super.initialize(keyClass, persistentClass, properties);
+ String geodeHostName = (String) properties.get(GEODE_SERVER_HOST);
+ int portNumber = Integer.parseInt((String) properties.get(GEODE_SERVER_PORT));
+ clientCache = new ClientCacheFactory().addPoolLocator(geodeHostName, portNumber).create();
+ String userName = properties.getProperty(GEODE_USERNAME);
+ String password = properties.getProperty(GEODE_PASSWORD);
+ geodeProperties = properties;
+
+ Properties clientProperties = clientCache.getDistributedSystem().getProperties();
+ if (userName != null) {
+ clientProperties.setProperty("security-username", userName);
+ clientProperties.setProperty("security-password", password);
+ }
+ cacheFactory = new CacheFactory(clientProperties);
+ }
+
+ @Override
+ /*
+ Schema Name can be assigned via Property file using @PREFERRED_SCHEMA_NAME, or else PersistentClass name is used as the default schema name.
+ */
+ public String getSchemaName() {
+ String preferredSchemaName = properties.getProperty(PREFERRED_SCHEMA_NAME);
+ if (preferredSchemaName == null) {
+ return persistentClass.getSimpleName();
+ }
+ return preferredSchemaName;
+ }
+
+ @Override
+ public void createSchema() throws GoraException {
+ try {
+ Cache cache = cacheFactory.create();
+ String regionShortCut = geodeProperties.getProperty(GEODE_REGION_SHORTCUT);
+ RegionFactory<K,T> regionFactory;
+ if (regionShortCut != null) {
+ regionFactory = cache.createRegionFactory(RegionShortcut.valueOf(regionShortCut));
+ } else {
+ regionFactory = cache.createRegionFactory(REPLICATE);
+ }
+ region = regionFactory.create(getSchemaName());
+ } catch (Exception e) {
+ throw new GoraException(e);
+ }
+ }
+
+ @Override
+ public void deleteSchema() {
+ region.destroyRegion();
+ }
+
+ @Override
+ public boolean schemaExists() {
+ Properties properties = clientCache.getDistributedSystem().getProperties();
+ CacheFactory factory = new CacheFactory(properties);
+ Cache cache = factory.create();
+ Region<K, T> rf = cache.getRegion(getSchemaName());
+ return rf != null;
+ }
+
+ @Override
+ public boolean exists(K key) {
+ for (K existingKey : region.getInterestList()) {
+ if (existingKey.equals(key)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public T get(K key, String[] fields) {
+ return region.get(key);
+ }
+
+ @Override
+ public void put(K key, T obj) {
+ region.put(key, obj);
+ }
+
+ @Override
+ public boolean delete(K key) {
+ region.destroy(key);
+ return true;
+ }
+
+ @Override
+ public long deleteByQuery(Query<K, T> query) throws GoraException {
+ try {
+ long deletedRows = 0;
+ Result<K, T> result = query.execute();
+ while (result.next()) {
+ if (delete(result.getKey())) {
+ deletedRows++;
+ }
+ }
+ LOG.info("Geode datastore deleted {} rows from Persistent datastore.", deletedRows);
+ return deletedRows;
+ } catch (Exception e) {
+ throw new GoraException(e);
+ }
+ }
+
+ @Override
+ public Result<K, T> execute(Query<K, T> query) {
+
Review Comment:
Extra space removed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@gora.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org