[jira] [Commented] (GORA-656) Hazelcast IMap backed datastore

2021-05-14 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-656?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17344717#comment-17344717
 ] 

ASF GitHub Bot commented on GORA-656:
-

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 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:
us...@infra.apache.org


> Hazelcast IMap backed datastore
> ---
>
> Key: GORA-656
> URL: https://issues.apache.org/jira/browse/GORA-656
> Project: Apache Gora
>  Issue Type: Improvement
>Reporter: Kevin Ratnasekera
>Priority: Major
>  Labels: gsoc2020
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Current implementation of JCache datastore is written in a way that it will 
> work with any JCache provider. Even though we have made explicitly available 
> Hazelcast JCache provider to the classpath. This implementation should be 
> based on the native interfaces of IMap.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GORA-656) Hazelcast IMap backed datastore

2021-05-14 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-656?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17344716#comment-17344716
 ] 

ASF GitHub Bot commented on GORA-656:
-

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
+implements Factory> {
+
+  public static final long serialVersionUID = 201305101626L;
+  private static final Logger LOG = 
LoggerFactory.getLogger(HazelcastCacheLoaderFactory.class);
+  private transient HazelcastCacheLoader instance;
+  private Class keyClass;
+  private Class persistentClass;
+
+  public HazelcastCacheLoaderFactory(HazelcastCacheLoader instance,
+ Class keyClass,
+ Class persistentClass) {
+this.keyClass = keyClass;
+this.persistentClass = persistentClass;
+LOG.info("JCache cache entry loader factory initialized successfully.");
+this.instance = instance;
+  }
+
+  public HazelcastCacheLoader create() {
+if (this.instance != null) {
+  return (HazelcastCacheLoader) 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
+implements Factory> {
+
+  public static final long serialVersionUID = 201305101626L;
+  private static final Logger LOG = 
LoggerFactory.getLogger(HazelcastCacheLoaderFactory.class);
+  private transient HazelcastCacheLoader instance;
+  private Class keyClass;
+  private Class persistentClass;
+
+  public HazelcastCacheLoaderFactory(HazelcastCacheLoader instance,
+ Class keyClass,
+ Class persistentClass) {
+this.keyClass = keyClass;
+

[jira] [Commented] (GORA-656) Hazelcast IMap backed datastore

2021-05-14 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-656?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17344712#comment-17344712
 ] 

ASF GitHub Bot commented on GORA-656:
-

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
+implements Factory> {
+
+  public static final long serialVersionUID = 201305101634L;
+  private static final Logger LOG = 
LoggerFactory.getLogger(HazelcastCacheEntryListenerFactory.class);
+  private transient HazelcastCacheEntryListener instance;
+
+  public HazelcastCacheEntryListenerFactory(HazelcastCacheEntryListener 
instance) {
+LOG.info("Hazelcast cache entry listener factory initialized 
successfully.");
+this.instance = instance;
+  }
+
+  public HazelcastCacheEntryListener 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:
us...@infra.apache.org


> Hazelcast IMap backed datastore
> ---
>
> Key: GORA-656
> URL: https://issues.apache.org/jira/browse/GORA-656
> Project: Apache Gora
>  Issue Type: Improvement
>Reporter: Kevin Ratnasekera
>Priority: Major
>  Labels: gsoc2020
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Current implementation of JCache datastore is written in a way that it will 
> work with any JCache provider. Even though we have made explicitly available 
> Hazelcast JCache provider to the classpath. This implementation should be 
> based on the native interfaces of IMap.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GORA-656) Hazelcast IMap backed datastore

2021-05-14 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-656?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17344711#comment-17344711
 ] 

ASF GitHub Bot commented on GORA-656:
-

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 extends 
ResultBase {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(HazelcastResult.class);
+  private NavigableSet cacheKeySet;
+  private Iterator iterator;
+  private int current;
+
+  public HazelcastResult(DataStore dataStore, Query query) {
+super(dataStore, query);
+  }
+
+  public HazelcastResult(DataStore dataStore, Query query, 
NavigableSet cacheKeySet) {
+super(dataStore, query);
+this.cacheKeySet = cacheKeySet;
+this.iterator = cacheKeySet.iterator();
+this.current = 0;
+  }
+
+  public HazelcastStore getDataStore() {
+return (HazelcastStore) 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:
us...@infra.apache.org


> Hazelcast IMap backed datastore
> ---
>
> Key: GORA-656
> URL: https://issues.apache.org/jira/browse/GORA-656
> Project: Apache Gora
>  Issue Type: Improvement
>Reporter: Kevin Ratnasekera
>Priority: Major
>  Labels: gsoc2020
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Current implementation of JCache datastore is written in a way that it will 
> work with any JCache provider. Even though we have made explicitly available 
> Hazelcast JCache provider to the classpath. This implementation should be 
> based on the native interfaces of IMap.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)