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 2020/08/31 03:06:36 UTC

[GitHub] [gora] saviyo opened a new pull request #222: GORA-656 Add Hazelcast Imap backed datastore

saviyo opened a new pull request #222:
URL: https://github.com/apache/gora/pull/222


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] djkevincr commented on pull request #222: GORA-656 Add Hazelcast Imap backed datastore

Posted by GitBox <gi...@apache.org>.
djkevincr commented on pull request #222:
URL: https://github.com/apache/gora/pull/222#issuecomment-683989374


   @saviyo  Thank you for your hard work during the GSoC period. PR looks very good. I m going to keep PR for a while for let others to review. Good Luck with your final evaluation.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] kamaci commented on a change in pull request #222: GORA-656 Add Hazelcast Imap backed datastore

Posted by GitBox <gi...@apache.org>.
kamaci commented on a change in pull request #222:
URL: https://github.com/apache/gora/pull/222#discussion_r632660595



##########
File path: gora-hazelcast/src/main/java/org/apache/gora/hazelcast/query/HazelcastResult.java
##########
@@ -0,0 +1,91 @@
+/**
+ * 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.
+ */
+
+package org.apache.gora.hazelcast.query;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.NavigableSet;
+
+import org.apache.gora.hazelcast.store.HazelcastStore;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.query.Query;
+import org.apache.gora.query.impl.ResultBase;
+import org.apache.gora.store.DataStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * {@link HazelcastResult} is the primary class
+ * responsible for representing result set of a cache manipulation query
+ * {@link HazelcastQuery}
+ */
+public class HazelcastResult<K, T extends PersistentBase> extends ResultBase<K, T> {
+
+  private static final Logger LOG = LoggerFactory.getLogger(HazelcastResult.class);
+  private NavigableSet<K> cacheKeySet;
+  private Iterator<K> iterator;
+  private int current;
+
+  public HazelcastResult(DataStore<K, T> dataStore, Query<K, T> query) {
+    super(dataStore, query);
+  }
+
+  public HazelcastResult(DataStore<K, T> dataStore, Query<K, T> query, NavigableSet<K> cacheKeySet) {
+    super(dataStore, query);
+    this.cacheKeySet = cacheKeySet;
+    this.iterator = cacheKeySet.iterator();
+    this.current = 0;
+  }
+
+  public HazelcastStore<K, T> getDataStore() {
+    return (HazelcastStore<K, T>) super.getDataStore();
+  }
+
+  @Override
+  public float getProgress() throws IOException {
+    if (cacheKeySet.size() == 0) {
+      return 1;
+    }
+    float progress = ((float) current / (float) cacheKeySet.size());

Review comment:
       You can inline variable.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] kamaci commented on a change in pull request #222: GORA-656 Add Hazelcast Imap backed datastore

Posted by GitBox <gi...@apache.org>.
kamaci commented on a change in pull request #222:
URL: https://github.com/apache/gora/pull/222#discussion_r632661023



##########
File path: gora-hazelcast/src/main/java/org/apache/gora/hazelcast/store/HazelcastCacheEntryListenerFactory.java
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.
+ */
+
+package org.apache.gora.hazelcast.store;
+
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.cache.configuration.Factory;
+
+/**
+ * {@link HazelcastCacheEntryListenerFactory} is the primary class
+ * responsible for creating cache entry listeners which listens on {@link javax.cache.event.CacheEntryEvent}
+ * cache entry events EG:- Creation, Removal, etc of keys on caches and trigger actions as specified.
+ */
+public class HazelcastCacheEntryListenerFactory<K, T extends PersistentBase>
+        implements Factory<HazelcastCacheEntryListener<K, T>> {
+
+  public static final long serialVersionUID = 201305101634L;
+  private static final Logger LOG = LoggerFactory.getLogger(HazelcastCacheEntryListenerFactory.class);
+  private transient HazelcastCacheEntryListener<K, T> instance;
+
+  public HazelcastCacheEntryListenerFactory(HazelcastCacheEntryListener<K, T> instance) {
+    LOG.info("Hazelcast cache entry listener factory initialized successfully.");
+    this.instance = instance;
+  }
+
+  public HazelcastCacheEntryListener<K, T> create() {
+    return this.instance;
+  }
+
+  public boolean equals(Object other) {
+    if (this == other) {
+      return true;
+    } else if (other != null && this.getClass() == other.getClass()) {

Review comment:
       No need for an else if you had a if with return.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] kamaci commented on a change in pull request #222: GORA-656 Add Hazelcast Imap backed datastore

Posted by GitBox <gi...@apache.org>.
kamaci commented on a change in pull request #222:
URL: https://github.com/apache/gora/pull/222#discussion_r632664707



##########
File path: gora-hazelcast/src/test/java/org/apache/gora/hazelcast/mapreduce/HazelcastStoreMapReduceTest.java
##########
@@ -0,0 +1,63 @@
+/**
+ * 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.
+ */
+
+package org.apache.gora.hazelcast.mapreduce;
+
+import org.apache.gora.hazelcast.GoraHazelcastTestDriver;
+import org.apache.gora.mapreduce.DataStoreMapReduceTestBase;
+import org.apache.gora.examples.generated.WebPage;
+import org.apache.gora.store.DataStore;
+import org.apache.gora.store.DataStoreFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.junit.After;
+import org.junit.Before;
+
+import java.io.IOException;
+
+public class HazelcastStoreMapReduceTest extends DataStoreMapReduceTestBase {
+
+  private GoraHazelcastTestDriver driver;
+
+  public HazelcastStoreMapReduceTest() throws IOException {
+    super();
+    driver = new GoraHazelcastTestDriver();
+  }
+
+  @Override
+  @Before
+  public void setUp() throws Exception {
+    driver.setUpClass();
+    super.setUp();
+  }
+
+  @Override
+  @After
+  public void tearDown() throws Exception {
+    super.tearDown();
+    driver.tearDownClass();
+  }
+
+  @Override
+  protected DataStore<String, WebPage> createWebPageDataStore() throws IOException {
+    try {
+      return DataStoreFactory.getDataStore(String.class, WebPage.class, new Configuration(), true);
+    } catch (Exception e) {
+      throw new RuntimeException(e);

Review comment:
       What is the purpose of catching the `Exception` and re-throwing it as `RuntimeException`?




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] djkevincr edited a comment on pull request #222: GORA-656 Add Hazelcast Imap backed datastore

Posted by GitBox <gi...@apache.org>.
djkevincr edited a comment on pull request #222:
URL: https://github.com/apache/gora/pull/222#issuecomment-683989374


   @saviyo  Thank you for your hard work during the GSoC period. PR looks very good. I m going to keep PR for a while for let others to review. There are certain cases which I find can further be improved, I will do a full review on next few days. Good Luck with your final evaluation.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] lewismc closed pull request #222: GORA-656 Add Hazelcast Imap backed datastore

Posted by GitBox <gi...@apache.org>.
lewismc closed pull request #222:
URL: https://github.com/apache/gora/pull/222


   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] lewismc commented on pull request #222: GORA-656 Add Hazelcast Imap backed datastore

Posted by GitBox <gi...@apache.org>.
lewismc commented on pull request #222:
URL: https://github.com/apache/gora/pull/222#issuecomment-834654722


   @saviyo the following problem seems to be failing build
   ```
   Error:  Failed to execute goal on project gora-solr: Could not resolve dependencies for project org.apache.gora:gora-solr:bundle:1.0-SNAPSHOT: Failed to collect dependencies at org.apache.solr:solr-core:jar:8.0.0 -> org.restlet.jee:org.restlet:jar:2.3.1: Failed to read artifact descriptor for org.restlet.jee:org.restlet:jar:2.3.1: Could not transfer artifact org.restlet.jee:org.restlet:pom:2.3.1 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [maven-restlet (http://maven.restlet.org, default, releases+snapshots), apache.snapshots (http://repository.apache.org/snapshots, default, disabled)] -> [Help 1]
   ```
   Any ideas what is going on?


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [gora] kamaci commented on a change in pull request #222: GORA-656 Add Hazelcast Imap backed datastore

Posted by GitBox <gi...@apache.org>.
kamaci commented on a change in pull request #222:
URL: https://github.com/apache/gora/pull/222#discussion_r632663594



##########
File path: gora-hazelcast/src/main/java/org/apache/gora/hazelcast/store/HazelcastCacheLoaderFactory.java
##########
@@ -0,0 +1,81 @@
+/**
+ * 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.
+ */
+
+package org.apache.gora.hazelcast.store;
+
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.store.DataStoreFactory;
+import org.apache.gora.util.GoraException;
+import org.apache.hadoop.conf.Configuration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.cache.configuration.Factory;
+
+/**
+ * {@link HazelcastCacheLoaderFactory} is the primary class
+ * responsible for creating cache loader {@link javax.cache.integration.CacheLoader} instances which itself
+ * loads data beans from persistency dataStore to in memory cache.
+ */
+public class HazelcastCacheLoaderFactory<K, T extends PersistentBase>
+        implements Factory<HazelcastCacheLoader<K, T>> {
+
+  public static final long serialVersionUID = 201305101626L;
+  private static final Logger LOG = LoggerFactory.getLogger(HazelcastCacheLoaderFactory.class);
+  private transient HazelcastCacheLoader<K, T> instance;
+  private Class<K> keyClass;
+  private Class<T> persistentClass;
+
+  public HazelcastCacheLoaderFactory(HazelcastCacheLoader<K, T> instance,
+                                     Class<K> keyClass,
+                                     Class<T> persistentClass) {
+    this.keyClass = keyClass;
+    this.persistentClass = persistentClass;
+    LOG.info("JCache cache entry loader factory initialized successfully.");
+    this.instance = instance;
+  }
+
+  public HazelcastCacheLoader<K, T> create() {
+    if (this.instance != null) {
+      return (HazelcastCacheLoader<K, T>) this.instance;
+    } else {

Review comment:
       No need to write `else` after an `if` with a `return`.

##########
File path: gora-hazelcast/src/main/java/org/apache/gora/hazelcast/store/HazelcastCacheLoaderFactory.java
##########
@@ -0,0 +1,81 @@
+/**
+ * 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.
+ */
+
+package org.apache.gora.hazelcast.store;
+
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.store.DataStoreFactory;
+import org.apache.gora.util.GoraException;
+import org.apache.hadoop.conf.Configuration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.cache.configuration.Factory;
+
+/**
+ * {@link HazelcastCacheLoaderFactory} is the primary class
+ * responsible for creating cache loader {@link javax.cache.integration.CacheLoader} instances which itself
+ * loads data beans from persistency dataStore to in memory cache.
+ */
+public class HazelcastCacheLoaderFactory<K, T extends PersistentBase>
+        implements Factory<HazelcastCacheLoader<K, T>> {
+
+  public static final long serialVersionUID = 201305101626L;
+  private static final Logger LOG = LoggerFactory.getLogger(HazelcastCacheLoaderFactory.class);
+  private transient HazelcastCacheLoader<K, T> instance;
+  private Class<K> keyClass;
+  private Class<T> persistentClass;
+
+  public HazelcastCacheLoaderFactory(HazelcastCacheLoader<K, T> instance,
+                                     Class<K> keyClass,
+                                     Class<T> persistentClass) {
+    this.keyClass = keyClass;
+    this.persistentClass = persistentClass;
+    LOG.info("JCache cache entry loader factory initialized successfully.");
+    this.instance = instance;
+  }
+
+  public HazelcastCacheLoader<K, T> create() {
+    if (this.instance != null) {
+      return (HazelcastCacheLoader<K, T>) this.instance;
+    } else {
+      try {
+        this.instance = new HazelcastCacheLoader<>(DataStoreFactory
+                .getDataStore(keyClass, persistentClass, new Configuration()));
+      } catch (GoraException ex) {
+        LOG.error("Couldn't initialize persistent dataStore for cache loader.", ex);
+        return null;
+      }
+      return (HazelcastCacheLoader<K, T>) this.instance;
+    }
+  }
+
+  public boolean equals(Object other) {
+    if (this == other) {
+      return true;
+    } else if (other != null && this.getClass() == other.getClass()) {

Review comment:
       No need to write `else` after an `if` with a `return`.

##########
File path: gora-hazelcast/src/main/java/org/apache/gora/hazelcast/store/HazelcastCacheWriterFactory.java
##########
@@ -0,0 +1,80 @@
+/**
+ * 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.
+ */
+
+package org.apache.gora.hazelcast.store;
+
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.store.DataStoreFactory;
+import org.apache.gora.util.GoraException;
+import org.apache.hadoop.conf.Configuration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.cache.configuration.Factory;
+
+/**
+ * {@link HazelcastCacheWriterFactory} is the primary class
+ * responsible for creating cache writer {@link javax.cache.integration.CacheWriter} instances which itself
+ * writes data beans to persistency dataStore from in memory cache.
+ */
+public class HazelcastCacheWriterFactory<K, T extends PersistentBase> implements Factory<HazelcastCacheWriter<K, T>> {
+
+  public static final long serialVersionUID = 201205101621L;
+  private static final Logger LOG = LoggerFactory.getLogger(HazelcastCacheWriterFactory.class);
+  private transient HazelcastCacheWriter<K, T> instance;
+  private Class<K> keyClass;
+  private Class<T> persistentClass;
+
+  public HazelcastCacheWriterFactory(HazelcastCacheWriter<K, T> instance,
+                                     Class<K> keyClass,
+                                     Class<T> persistentClass) {
+    this.keyClass = keyClass;
+    this.persistentClass = persistentClass;
+    LOG.info("JCache cache writer factory initialized successfully.");
+    this.instance = instance;
+  }
+
+  public HazelcastCacheWriter<K, T> create() {
+    if (this.instance != null) {
+      return (HazelcastCacheWriter<K, T>) this.instance;
+    } else {

Review comment:
       No need to write `else` after an `if` with a `return`.

##########
File path: gora-hazelcast/src/main/java/org/apache/gora/hazelcast/store/HazelcastCacheWriterFactory.java
##########
@@ -0,0 +1,80 @@
+/**
+ * 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.
+ */
+
+package org.apache.gora.hazelcast.store;
+
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.store.DataStoreFactory;
+import org.apache.gora.util.GoraException;
+import org.apache.hadoop.conf.Configuration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.cache.configuration.Factory;
+
+/**
+ * {@link HazelcastCacheWriterFactory} is the primary class
+ * responsible for creating cache writer {@link javax.cache.integration.CacheWriter} instances which itself
+ * writes data beans to persistency dataStore from in memory cache.
+ */
+public class HazelcastCacheWriterFactory<K, T extends PersistentBase> implements Factory<HazelcastCacheWriter<K, T>> {
+
+  public static final long serialVersionUID = 201205101621L;
+  private static final Logger LOG = LoggerFactory.getLogger(HazelcastCacheWriterFactory.class);
+  private transient HazelcastCacheWriter<K, T> instance;
+  private Class<K> keyClass;
+  private Class<T> persistentClass;
+
+  public HazelcastCacheWriterFactory(HazelcastCacheWriter<K, T> instance,
+                                     Class<K> keyClass,
+                                     Class<T> persistentClass) {
+    this.keyClass = keyClass;
+    this.persistentClass = persistentClass;
+    LOG.info("JCache cache writer factory initialized successfully.");
+    this.instance = instance;
+  }
+
+  public HazelcastCacheWriter<K, T> create() {
+    if (this.instance != null) {
+      return (HazelcastCacheWriter<K, T>) this.instance;
+    } else {
+      try {
+        this.instance = new HazelcastCacheWriter<>(DataStoreFactory
+                .getDataStore(keyClass, persistentClass, new Configuration()));
+      } catch (GoraException ex) {
+        LOG.error("Couldn't initialize persistent dataStore for cache writer.", ex);
+        return null;
+      }
+      return (HazelcastCacheWriter<K, T>) this.instance;
+    }
+  }
+
+  public boolean equals(Object other) {
+    if (this == other) {
+      return true;
+    } else if (other != null && this.getClass() == other.getClass()) {

Review comment:
       No need to write `else` after an `if` with a `return`.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org