gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lewi...@apache.org
Subject [4/6] gora git commit: fixed problem registering unnessary cache listeners, added formatting for DistributedLogManager comment
Date Mon, 15 Aug 2016 17:04:34 GMT
fixed problem registering unnessary cache listeners, added formatting for DistributedLogManager
comment


Project: http://git-wip-us.apache.org/repos/asf/gora/repo
Commit: http://git-wip-us.apache.org/repos/asf/gora/commit/2f065e86
Tree: http://git-wip-us.apache.org/repos/asf/gora/tree/2f065e86
Diff: http://git-wip-us.apache.org/repos/asf/gora/diff/2f065e86

Branch: refs/heads/master
Commit: 2f065e8669fb8699b6a08c157fb9ffc2c3254130
Parents: ba27703
Author: Kevin <djkevincr@yahoo.com>
Authored: Mon Aug 15 13:43:53 2016 +0530
Committer: Kevin <djkevincr@yahoo.com>
Committed: Mon Aug 15 13:43:53 2016 +0530

----------------------------------------------------------------------
 .../jcache/store/JCacheCacheEntryListener.java  |  24 +---
 .../store/JCacheCacheEntryListenerFactory.java  |   2 +-
 .../jcache/store/JCacheCacheFactoryBuilder.java |   8 +-
 .../gora/jcache/store/JCacheCacheLoader.java    |   8 +-
 .../jcache/store/JCacheCacheLoaderFactory.java  |  26 ++++-
 .../gora/jcache/store/JCacheCacheWriter.java    |   8 +-
 .../jcache/store/JCacheCacheWriterFactory.java  |  26 ++++-
 .../apache/gora/jcache/store/JCacheStore.java   |  38 ++----
 .../gora/jcache/GoraHazelcastTestDriver.java    |  29 ++---
 gora-jcache/src/test/resources/gora.properties  |   4 +-
 .../tutorial/log/DistributedLogManager.java     | 115 ++++++++++---------
 11 files changed, 138 insertions(+), 150 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/gora/blob/2f065e86/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheEntryListener.java
----------------------------------------------------------------------
diff --git a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheEntryListener.java
b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheEntryListener.java
index 5891048..1cc3e7c 100644
--- a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheEntryListener.java
+++ b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheEntryListener.java
@@ -37,10 +37,10 @@ import java.util.concurrent.ConcurrentSkipListSet;
 public class JCacheCacheEntryListener<K, T extends PersistentBase>
         implements CacheEntryCreatedListener<K, T>,
         CacheEntryRemovedListener<K, T>, CacheEntryUpdatedListener<K, T>,
-        CacheEntryExpiredListener<K, T>, java.io.Serializable {
+        CacheEntryExpiredListener<K, T> {
 
   private static final Logger LOG = LoggerFactory.getLogger(JCacheCacheEntryListener.class);
-  private transient ConcurrentSkipListSet<K> cacheEntryList;
+  private ConcurrentSkipListSet<K> cacheEntryList;
 
   public JCacheCacheEntryListener(ConcurrentSkipListSet cacheEntryList) {
     this.cacheEntryList = cacheEntryList;
@@ -49,10 +49,6 @@ public class JCacheCacheEntryListener<K, T extends PersistentBase>
   @Override
   public void onCreated(Iterable<CacheEntryEvent<? extends K, ? extends T>> cacheEntryEvents)
           throws CacheEntryListenerException {
-    //get rid execution of listener chain/executing only one initialized
-    if (cacheEntryList == null) {
-      return;
-    }
     for (CacheEntryEvent<? extends K, ? extends T> event : cacheEntryEvents) {
       cacheEntryList.add(event.getKey());
       LOG.info("Cache entry added on key {}.", event.getKey().toString());
@@ -62,10 +58,6 @@ public class JCacheCacheEntryListener<K, T extends PersistentBase>
   @Override
   public void onRemoved(Iterable<CacheEntryEvent<? extends K, ? extends T>> cacheEntryEvents)
           throws CacheEntryListenerException {
-    //get rid execution of listener chain/executing only one initialized
-    if (cacheEntryList == null) {
-      return;
-    }
     for (CacheEntryEvent<? extends K, ? extends T> event : cacheEntryEvents) {
       cacheEntryList.remove(event.getKey());
       LOG.info("Cache entry removed on key {}.", event.getKey().toString());
@@ -75,10 +67,6 @@ public class JCacheCacheEntryListener<K, T extends PersistentBase>
   @Override
   public void onUpdated(Iterable<CacheEntryEvent<? extends K, ? extends T>> cacheEntryEvents)
           throws CacheEntryListenerException {
-    //get rid execution of listener chain/executing only one initialized
-    if (cacheEntryList == null) {
-      return;
-    }
     for (CacheEntryEvent<? extends K, ? extends T> event : cacheEntryEvents) {
       LOG.info("Cache entry updated set on key {}.", event.getKey().toString());
     }
@@ -87,17 +75,9 @@ public class JCacheCacheEntryListener<K, T extends PersistentBase>
   @Override
   public void onExpired(Iterable<CacheEntryEvent<? extends K, ? extends T>> cacheEntryEvents)
           throws CacheEntryListenerException {
-    //get rid execution of listener chain/executing only one initialized
-    if (cacheEntryList == null) {
-      return;
-    }
     for (CacheEntryEvent<? extends K, ? extends T> event : cacheEntryEvents) {
       LOG.warn("Cache entry expired on key {}.", event.getKey().toString());
     }
   }
 
-  public void setCacheEntryList(ConcurrentSkipListSet<K> cacheEntryList) {
-    this.cacheEntryList = cacheEntryList;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/gora/blob/2f065e86/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheEntryListenerFactory.java
----------------------------------------------------------------------
diff --git a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheEntryListenerFactory.java
b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheEntryListenerFactory.java
index abc283d..6ecbcbc 100644
--- a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheEntryListenerFactory.java
+++ b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheEntryListenerFactory.java
@@ -33,7 +33,7 @@ public class JCacheCacheEntryListenerFactory<K, T extends PersistentBase>
 
   public static final long serialVersionUID = 201305101634L;
   private static final Logger LOG = LoggerFactory.getLogger(JCacheCacheEntryListenerFactory.class);
-  private JCacheCacheEntryListener<K, T> instance;
+  private transient JCacheCacheEntryListener<K, T> instance;
 
   public JCacheCacheEntryListenerFactory(JCacheCacheEntryListener<K, T> instance) {
     LOG.info("JCache cache entry listener factory initialized successfully.");

http://git-wip-us.apache.org/repos/asf/gora/blob/2f065e86/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheFactoryBuilder.java
----------------------------------------------------------------------
diff --git a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheFactoryBuilder.java
b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheFactoryBuilder.java
index 75c3f36..8b3b847 100644
--- a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheFactoryBuilder.java
+++ b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheFactoryBuilder.java
@@ -29,13 +29,13 @@ import javax.cache.configuration.Factory;
 public class JCacheCacheFactoryBuilder {
 
   public static <K, T extends PersistentBase> Factory<JCacheCacheLoader<K, T>>
-  factoryOfCacheLoader(DataStore<K, T> dataStore) {
-    return new JCacheCacheLoaderFactory<>(new JCacheCacheLoader<>(dataStore));
+  factoryOfCacheLoader(DataStore<K, T> dataStore, Class<K> keyClass, Class<T>
persistentClass) {
+    return new JCacheCacheLoaderFactory<>(new JCacheCacheLoader<>(dataStore),
keyClass, persistentClass);
   }
 
   public static <K, T extends PersistentBase> Factory<JCacheCacheWriter<K, T>>
-  factoryOfCacheWriter(DataStore<K, T> dataStore) {
-    return new JCacheCacheWriterFactory<>(new JCacheCacheWriter<>(dataStore));
+  factoryOfCacheWriter(DataStore<K, T> dataStore, Class<K> keyClass, Class<T>
persistentClass) {
+    return new JCacheCacheWriterFactory<>(new JCacheCacheWriter<>(dataStore),
keyClass, persistentClass);
   }
 
   public static <K, T extends PersistentBase> Factory<JCacheCacheEntryListener<K,
T>>

http://git-wip-us.apache.org/repos/asf/gora/blob/2f065e86/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheLoader.java
----------------------------------------------------------------------
diff --git a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheLoader.java
b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheLoader.java
index fed2ba2..72915d0 100644
--- a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheLoader.java
+++ b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheLoader.java
@@ -31,10 +31,10 @@ import java.util.Map;
  * {@link org.apache.gora.jcache.store.JCacheCacheLoader} is the primary class
  * responsible for loading data beans from persistency dataStore to in memory cache.
  */
-public class JCacheCacheLoader<K, T extends PersistentBase> implements CacheLoader<K,
T>, java.io.Serializable {
+public class JCacheCacheLoader<K, T extends PersistentBase> implements CacheLoader<K,
T> {
 
   private static final Logger LOG = LoggerFactory.getLogger(JCacheCacheLoader.class);
-  private transient DataStore<K, T> dataStore;
+  private DataStore<K, T> dataStore;
 
   public JCacheCacheLoader(DataStore<K, T> dataStore) {
     this.dataStore = dataStore;
@@ -65,8 +65,4 @@ public class JCacheCacheLoader<K, T extends PersistentBase> implements
CacheLoad
     return loaded;
   }
 
-  public void setDataStore(DataStore<K, T> dataStore) {
-    this.dataStore = dataStore;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/gora/blob/2f065e86/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheLoaderFactory.java
----------------------------------------------------------------------
diff --git a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheLoaderFactory.java
b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheLoaderFactory.java
index 2b82f1f..6b08e01 100644
--- a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheLoaderFactory.java
+++ b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheLoaderFactory.java
@@ -18,6 +18,9 @@
 package org.apache.gora.jcache.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;
 
@@ -33,15 +36,32 @@ public class JCacheCacheLoaderFactory<K, T extends PersistentBase>
 
   public static final long serialVersionUID = 201305101626L;
   private static final Logger LOG = LoggerFactory.getLogger(JCacheCacheLoaderFactory.class);
-  private JCacheCacheLoader<K, T> instance;
+  private transient JCacheCacheLoader<K, T> instance;
+  private Class<K> keyClass;
+  private Class<T> persistentClass;
 
-  public JCacheCacheLoaderFactory(JCacheCacheLoader<K, T> instance) {
+  public JCacheCacheLoaderFactory(JCacheCacheLoader<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 JCacheCacheLoader<K, T> create() {
-    return (JCacheCacheLoader<K, T>) this.instance;
+    if (this.instance != null) {
+      return (JCacheCacheLoader<K, T>) this.instance;
+    } else {
+      try {
+        this.instance = new JCacheCacheLoader<>(DataStoreFactory
+                .getDataStore(keyClass, persistentClass, new Configuration()));
+      } catch (GoraException ex) {
+        LOG.error("Couldn't initialize persistent dataStore for cache loader.", ex);
+        return null;
+      }
+      return (JCacheCacheLoader<K, T>) this.instance;
+    }
   }
 
   public boolean equals(Object other) {

http://git-wip-us.apache.org/repos/asf/gora/blob/2f065e86/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheWriter.java
----------------------------------------------------------------------
diff --git a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheWriter.java
b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheWriter.java
index b7a95c3..e1e5ae8 100644
--- a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheWriter.java
+++ b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheWriter.java
@@ -32,10 +32,10 @@ import java.util.Iterator;
  * {@link org.apache.gora.jcache.store.JCacheCacheWriter} is the primary class
  * responsible for writing data beans to persistency dataStore from in memory cache.
  */
-public class JCacheCacheWriter<K, T extends PersistentBase> implements CacheWriter<K,
T>, java.io.Serializable {
+public class JCacheCacheWriter<K, T extends PersistentBase> implements CacheWriter<K,
T> {
 
   private static final Logger LOG = LoggerFactory.getLogger(JCacheCacheWriter.class);
-  private transient DataStore<K, T> dataStore;
+  private DataStore<K, T> dataStore;
 
   public JCacheCacheWriter(DataStore<K, T> dataStore) {
     this.dataStore = dataStore;
@@ -73,8 +73,4 @@ public class JCacheCacheWriter<K, T extends PersistentBase> implements
CacheWrit
     }
   }
 
-  public void setDataStore(DataStore<K, T> dataStore) {
-    this.dataStore = dataStore;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/gora/blob/2f065e86/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheWriterFactory.java
----------------------------------------------------------------------
diff --git a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheWriterFactory.java
b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheWriterFactory.java
index 33c2fbb..d824529 100644
--- a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheWriterFactory.java
+++ b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheCacheWriterFactory.java
@@ -18,6 +18,9 @@
 package org.apache.gora.jcache.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;
 
@@ -32,15 +35,32 @@ public class JCacheCacheWriterFactory<K, T extends PersistentBase>
implements Fa
 
   public static final long serialVersionUID = 201205101621L;
   private static final Logger LOG = LoggerFactory.getLogger(JCacheCacheWriterFactory.class);
-  private JCacheCacheWriter<K, T> instance;
+  private transient JCacheCacheWriter<K, T> instance;
+  private Class<K> keyClass;
+  private Class<T> persistentClass;
 
-  public JCacheCacheWriterFactory(JCacheCacheWriter<K, T> instance) {
+  public JCacheCacheWriterFactory(JCacheCacheWriter<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 JCacheCacheWriter<K, T> create() {
-    return (JCacheCacheWriter<K, T>) this.instance;
+    if (this.instance != null) {
+      return (JCacheCacheWriter<K, T>) this.instance;
+    } else {
+      try {
+        this.instance = new JCacheCacheWriter<>(DataStoreFactory
+                .getDataStore(keyClass, persistentClass, new Configuration()));
+      } catch (GoraException ex) {
+        LOG.error("Couldn't initialize persistent dataStore for cache writer.", ex);
+        return null;
+      }
+      return (JCacheCacheWriter<K, T>) this.instance;
+    }
   }
 
   public boolean equals(Object other) {

http://git-wip-us.apache.org/repos/asf/gora/blob/2f065e86/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheStore.java
----------------------------------------------------------------------
diff --git a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheStore.java b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheStore.java
index f0c9c27..126c07a 100644
--- a/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheStore.java
+++ b/gora-jcache/src/main/java/org/apache/gora/jcache/store/JCacheStore.java
@@ -250,22 +250,20 @@ public class JCacheStore<K, T extends PersistentBase> extends
DataStoreBase<K, T
         }
       }
       cacheConfig.setCacheLoaderFactory(JCacheCacheFactoryBuilder
-              .factoryOfCacheLoader(this.persistentDataStore));
+              .factoryOfCacheLoader(this.persistentDataStore, keyClass, persistentClass));
       cacheConfig.setCacheWriterFactory(JCacheCacheFactoryBuilder
-              .factoryOfCacheWriter(this.persistentDataStore));
-      cacheConfig.addCacheEntryListenerConfiguration(
-              new MutableCacheEntryListenerConfiguration<>(
-                      JCacheCacheFactoryBuilder
-                              .factoryOfEntryListener(new JCacheCacheEntryListener<K,
T>(cacheEntryList)),
-                      null, true, true));
+              .factoryOfCacheWriter(this.persistentDataStore, keyClass, persistentClass));
       cache = manager.createCache(persistentClass.getSimpleName(),
               cacheConfig).unwrap(ICache.class);
     } else {
       cache = manager.getCache(super.getPersistentClass().getSimpleName(),
               keyClass, persistentClass).unwrap(ICache.class);
       this.populateLocalCacheEntrySet(cache);
-      this.populateLocalCacheConfig(cache);
     }
+    cache.registerCacheEntryListener(new MutableCacheEntryListenerConfiguration<>(
+            JCacheCacheFactoryBuilder
+                    .factoryOfEntryListener(new JCacheCacheEntryListener<K, T>(cacheEntryList)),
+            null, true, true));
     LOG.info("JCache Gora datastore initialized successfully.");
   }
 
@@ -281,6 +279,10 @@ public class JCacheStore<K, T extends PersistentBase> extends DataStoreBase<K,
T
       cache = manager.createCache(persistentClass.getSimpleName(),
               cacheConfig).unwrap(ICache.class);
     }
+    cache.registerCacheEntryListener(new MutableCacheEntryListenerConfiguration<>(
+            JCacheCacheFactoryBuilder
+                    .factoryOfEntryListener(new JCacheCacheEntryListener<K, T>(cacheEntryList)),
+            null, true, true));
     persistentDataStore.createSchema();
     LOG.info("Created schema on persistent store and initialized cache for persistent bean
{}."
             , super.getPersistentClass().getSimpleName());
@@ -446,27 +448,7 @@ public class JCacheStore<K, T extends PersistentBase> extends DataStoreBase<K,
T
       cacheEntryList.add(cacheEntryIterator.next().getKey());
     }
     cacheConfig = cache.getConfiguration(CacheConfig.class);
-    Iterator<CacheEntryListenerConfiguration<K, T>> itr =
-            cacheConfig.getCacheEntryListenerConfigurations().iterator();
-    while (itr.hasNext()) {
-      JCacheCacheEntryListenerFactory<K, T> listenerFac = (JCacheCacheEntryListenerFactory<K,
T>)
-              ((MutableCacheEntryListenerConfiguration) itr.next()).getCacheEntryListenerFactory();
-      //populate transient field in Cache Entry Listener
-      listenerFac.create().setCacheEntryList(cacheEntryList);
-      //register exactly one listener on each local node either client/server
-      break;
-    }
     LOG.info("Populated local cache entry set with respect to remote cache provider.");
   }
 
-  private void populateLocalCacheConfig(ICache<K, T> cache) {
-    cacheConfig = cache.getConfiguration(CacheConfig.class);
-    //populate transient fields in Cache Loader/Cache Listener
-    ((JCacheCacheLoaderFactory) cacheConfig.getCacheLoaderFactory())
-            .create().setDataStore(this.persistentDataStore);
-    ((JCacheCacheWriterFactory) cacheConfig.getCacheWriterFactory())
-            .create().setDataStore(this.persistentDataStore);
-    LOG.info("Populated transient cache loader/writer in local cache configuration.");
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/gora/blob/2f065e86/gora-jcache/src/test/java/org/apache/gora/jcache/GoraHazelcastTestDriver.java
----------------------------------------------------------------------
diff --git a/gora-jcache/src/test/java/org/apache/gora/jcache/GoraHazelcastTestDriver.java
b/gora-jcache/src/test/java/org/apache/gora/jcache/GoraHazelcastTestDriver.java
index ebe04bd..e245557 100644
--- a/gora-jcache/src/test/java/org/apache/gora/jcache/GoraHazelcastTestDriver.java
+++ b/gora-jcache/src/test/java/org/apache/gora/jcache/GoraHazelcastTestDriver.java
@@ -18,8 +18,11 @@
 
 package org.apache.gora.jcache;
 
+import com.hazelcast.config.ClasspathXmlConfig;
+import com.hazelcast.config.Config;
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.HazelcastInstance;
 import org.apache.gora.GoraTestDriver;
-import org.apache.gora.examples.generated.WebPage;
 import org.apache.gora.jcache.store.JCacheStore;
 import org.apache.gora.persistency.Persistent;
 import org.apache.gora.store.DataStore;
@@ -27,21 +30,11 @@ import org.apache.gora.util.GoraException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Properties;
-
 public class GoraHazelcastTestDriver extends GoraTestDriver {
 
   private static Logger log = LoggerFactory.getLogger(GoraHazelcastTestDriver.class);
-  private JCacheStore<String, WebPage> serverCacheProvider;
-  private static final String GORA_DEFAULT_JCACHE_PROVIDER_KEY = "gora.datastore.jcache.provider";
-  private static final String PROVIDER = "com.hazelcast.cache.impl.HazelcastServerCachingProvider";
-  private static final String GORA_DEFAULT_JCACHE_HAZELCAST_CONFIG_KEY = "gora.datastore.jcache.hazelcast.config";
   private static final String CONFIG = "hazelcast.xml";
-  public static final String GORA_DEFAULT_DATASTORE_KEY = "gora.datastore.default";
-  public static final String MEMSTORE = "org.apache.gora.memory.store.MemStore";
-  private static final String JCACHE_READ_THROUGH_PROPERTY_KEY = "jcache.read.through.enable";
-  private static final String JCACHE_WRITE_THROUGH_PROPERTY_KEY = "jcache.write.through.enable";
-  private static final String FALSE = "false";
+  private HazelcastInstance hazelcastInstance;
 
   public GoraHazelcastTestDriver() {
     super(JCacheStore.class);
@@ -51,21 +44,15 @@ public class GoraHazelcastTestDriver extends GoraTestDriver {
   public void setUpClass() throws Exception {
     super.setUpClass();
     log.info("Starting Hazelcast server side cache provider.");
-    Properties properties = new Properties();
-    properties.setProperty(GORA_DEFAULT_JCACHE_PROVIDER_KEY, PROVIDER);
-    properties.setProperty(GORA_DEFAULT_JCACHE_HAZELCAST_CONFIG_KEY, CONFIG);
-    properties.setProperty(GORA_DEFAULT_DATASTORE_KEY, MEMSTORE);
-    properties.setProperty(JCACHE_READ_THROUGH_PROPERTY_KEY, FALSE);
-    properties.setProperty(JCACHE_WRITE_THROUGH_PROPERTY_KEY, FALSE);
-    serverCacheProvider = new JCacheStore();
-    serverCacheProvider.initialize(String.class, WebPage.class, properties);
+    Config config = new ClasspathXmlConfig(CONFIG);
+    hazelcastInstance = Hazelcast.newHazelcastInstance(config);
   }
 
   @Override
   public void tearDownClass() throws Exception {
     super.tearDownClass();
     log.info("Stopping Hazelcast server side cache provider.");
-    serverCacheProvider.close();
+    hazelcastInstance.shutdown();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/gora/blob/2f065e86/gora-jcache/src/test/resources/gora.properties
----------------------------------------------------------------------
diff --git a/gora-jcache/src/test/resources/gora.properties b/gora-jcache/src/test/resources/gora.properties
index 625faab..6dc150d 100644
--- a/gora-jcache/src/test/resources/gora.properties
+++ b/gora-jcache/src/test/resources/gora.properties
@@ -17,6 +17,6 @@ gora.cache.datastore.default=org.apache.gora.jcache.store.JCacheStore
 gora.datastore.jcache.provider=com.hazelcast.client.cache.impl.HazelcastClientCachingProvider
 gora.datastore.jcache.hazelcast.config=hazelcast-client.xml
 gora.datastore.default=org.apache.gora.memory.store.MemStore
-jcache.read.through.enable=false
-jcache.write.through.enable=false
+#jcache.read.through.enable=false
+#jcache.write.through.enable=false
 

http://git-wip-us.apache.org/repos/asf/gora/blob/2f065e86/gora-tutorial/src/main/java/org/apache/gora/tutorial/log/DistributedLogManager.java
----------------------------------------------------------------------
diff --git a/gora-tutorial/src/main/java/org/apache/gora/tutorial/log/DistributedLogManager.java
b/gora-tutorial/src/main/java/org/apache/gora/tutorial/log/DistributedLogManager.java
index 4ef9231..0f3be5c 100644
--- a/gora-tutorial/src/main/java/org/apache/gora/tutorial/log/DistributedLogManager.java
+++ b/gora-tutorial/src/main/java/org/apache/gora/tutorial/log/DistributedLogManager.java
@@ -46,106 +46,113 @@ import java.util.StringTokenizer;
  * illustrate the basic distributed features that can be gained when persistent dataStore
is used together with
  * cache dataStore similar to {@link org.apache.gora.jcache.store.JCacheStore}. Since Hazelcast
provides cache as
  * a service approach, Apache Gora data stores can now be exposed as a data SERVICE when
persistent data store is
- * exposed over the JCache store.
- *
+ * exposed over the JCache store/distributed caching layer.
+ * <p>
  * JCache data store has two modes.
- *
- * 1. Server mode - Participate in Hazelcast cluster as a member. ( Data grid ) and communicates
directly
+ * <p>
+ * 1. Server mode - Participate in Hazelcast cluster as a member. ( DATA GRID ) and communicates
directly
  * with persistent store to full fill cache read/write operations.
- *
+ * <p>
  * Add following properties gora.properties file to start JCache store in server mode.
- *
- * gora.cache.datastore.default=org.apache.gora.jcache.store.JCacheStore
- * gora.datastore.jcache.provider=com.hazelcast.cache.impl.HazelcastServerCachingProvider
- * gora.datastore.jcache.hazelcast.config=hazelcast.xml
- *
+ * <p>
+ * <b>gora.cache.datastore.default=org.apache.gora.jcache.store.JCacheStore</b>
+ * <br><b>gora.datastore.jcache.provider=com.hazelcast.cache.impl.HazelcastServerCachingProvider</b>
+ * <br><b>gora.datastore.jcache.hazelcast.config=hazelcast.xml</b>
+ * <p>
  * For cluster member network configuration use hazelcast.xml.
  * <p>See Network Configuration on
  * <a href="http://docs.hazelcast.org/docs/3.5/manual/html/networkconfiguration.html">
- * web site</a>for more information.</p>
- *
- * 2. Client mode - DOES not participate in Hazelcast cluster as a member. ( Data grid )
and For cache
+ * official documentation</a> for more information.</p>
+ * <p>
+ * 2. Client mode - DOES not participate in Hazelcast cluster as a member. ( DATA GRID )
and For cache
  * read/write operations client forwards the requests to hazelcast cluster members which
run in SERVER mode.
- *
+ * <p>
  * Add following properties gora.properties file to start JCache store in client mode.
- *
- * gora.cache.datastore.default=org.apache.gora.jcache.store.JCacheStore
- * gora.datastore.jcache.provider=com.hazelcast.client.cache.impl.HazelcastClientCachingProvider
- * gora.datastore.jcache.hazelcast.config=hazelcast-client.xml
- *
+ * <p>
+ * <b>gora.cache.datastore.default=org.apache.gora.jcache.store.JCacheStore</b>
+ * <br><b>gora.datastore.jcache.provider=com.hazelcast.client.cache.impl.HazelcastClientCachingProvider</b>
+ * <br><b>gora.datastore.jcache.hazelcast.config=hazelcast-client.xml</b>
+ * <p>
  * For Hazelcast client configuration use hazelcast-client.xml.
  * <p>See Java Client Configuration on
  * <a href="http://docs.hazelcast.org/docs/3.5/manual/html/javaclientconfiguration.html#java-client-configuration">
- * web site</a>for more information.</p>
- *
+ * official documentation</a> for more information.</p>
+ * <p>
  * Sample
  * ------
- * 1. Start DistributedLogManager in SERVER for two or higher instances. ( separate JVMs
).
+ * <p>
+ * 1. Start DistributedLogManager in SERVER mode for two or higher instances. ( separate
JVMs )
  * Notice the Hazelcast cluster is well formed by following Hazelcast logs.
- * Members [2] {
+ * <br><b>Members [2] {
  *     Member [127.0.0.1]:5701
  *     Member [127.0.0.1]:5702 this
- * }
- *
- * 2. Start DistributedLogManager in CLIENT mode for one instances.
+ * }</b>
+ * <p>
+ * 2. Start DistributedLogManager in CLIENT mode for one instance.
  * Notice the client correctly connected to the cluster by following Hazelcast logs.
- * Members [2] {
+ * <br><b>Members [2] {
  *     Member [127.0.0.1]:5701
  *     Member [127.0.0.1]:5702
- * }
- * INFO: HazelcastClient[hz.client_0_dev][3.6.4] is CLIENT_CONNECTED
- *
+ * }</b>
+ * <br><b>INFO: HazelcastClient[hz.client_0_dev][3.6.4] is CLIENT_CONNECTED</b>
+ * <p>
  * 3. Now use CLIENT's command line console to forward cache queries to cluster.
- *
- *  (a) -parse cache <input_log_file> - This will parse logs from logs file and put
Pageview data beans to
- *      persistent store via the cache.
- *      Notice following logs
- *      INFO 19:46:34,833 Written data bean to persistent datastore on key 45.
- *      on SERVER instance of DistributedLogManager. Notice the persistent data bean writes
are LOAD BALANCED
- *      among SERVER instances.
- *  (b) -parse persistent <input_log_file> - This will write parsed log data beans
directly to persistent store.
+ * <p>
+ *  (a) <b>-parse cache <-input_log_file-></b> - This will parse logs from
logs file and put Pageview data beans to
+ *      persistent store via the cache. Notice following logs
+ *      <br><b>INFO 19:46:34,833 Written data bean to persistent datastore on
key 45.</b>
+ *      <br>on SERVER instance of DistributedLogManager.
+ *      <br>Notice the persistent data bean writes are LOAD BALANCED among SERVER instances.
+ * <p>
+ *  (b) <b>-parse persistent <-input_log_file-></b> - This will write parsed
log data beans directly to persistent store.
  *      NOT via cache.
+ * <p>
  *  (c) Executing with (a) will create cache entry per each data bean key on each SERVER
and CLIENT instances. Since
  *      now data bean ( key/value ) is now loaded to Hazelcast DATA GRID, entries created
data beans
  *      are now available to all the SERVER and CLIENT instances. Data beans which were loaded
to Hazelcast
  *      DATA Grid can be retrieved from cache so that the latency is reduced compared to
when data bean is
  *      direct retrieved from persistent data store.
+ * <p>
  *  (d) Executing with (b) will not create cache entries on keys since the data beans were
directly put into
  *      to persistent store.
  *      Executing following command
- *      -get <lineNum>
- *      Data will be first loaded from persistent store to cache from one of SERVER instances.
Then cache
+ *      <br><b>get <-lineNum-></b>
+ *      <br>Data will be first loaded from persistent store to cache from one of SERVER
instances. Then cache
  *      entry on given key will be created on all SERVER/CLIENT instances.
  *      Notice the persistent data bean load on SINGLE SERVER instance. Only one SERVER instance
will handle this work.
- *      INFO 17:13:22,652 Loaded data bean from persistent datastore on key 4.
- *      Notice the cache entry creation on ALL SERVER/CLIENT instances
- *      INFO 17:13:22,656 Cache entry added on key 4.
- *      Once the cache entry is created, data bean is now available to be retrieved from
cache without reaching the
+ *      <br><b>INFO 17:13:22,652 Loaded data bean from persistent datastore on
key 4.</b>
+ *      <br>Notice the cache entry creation on ALL SERVER/CLIENT instances
+ *      <br><b>INFO 17:13:22,656 Cache entry added on key 4.</b>
+ *      <br>Once the cache entry is created, data bean is now available to be retrieved
from cache without reaching the
  *      persistent store.
  *      Execute the above command consecutively for several times.
- *      -get <lineNum>
+ *      <br><b>-get <-lineNum-></b>
  *      Notice there will be NO log entry similar to below
- *      INFO 17:13:22,652 Loaded data bean from persistent datastore on key 4.
- *      Since there will be no data bean load from persistent data store and the data bean
is now loaded from
+ *      <br><b>INFO 17:13:22,652 Loaded data bean from persistent datastore on
key 4.</b>
+ *      <br>Since there will be no data bean load from persistent data store and the
data bean is now loaded from
  *      cache.
+ * <p>
  *  (e) DistributedLogManager has two Apache Gora data stores instances.
  *      dataStore - which call directly underline persistent data store.
  *      cacheStore - which call same persistent data store via the caching layer.
  *      Simple benchmarking purposes use
- *      -benchmark <startLineNum> <endLineNum> <iterations>
- *      to compare data beans read for two cases. ( Cache layer is present and Not present
when executing
+ *      <br><b>-benchmark <-startLineNum-> <-endLineNum-> <-iterations-></b>
+ *      <br>to compare data beans read for two cases. ( Cache layer is present and
Not present when executing
  *      consecutive data reads for same data items in nearby intervals )
  *      It generates LOG entries similar to below which indicates time spent for two cases
in milliseconds
- *      INFO 17:13:22,652 Direct Backend took 1973 ms
- *      INFO 17:18:49,252 Via Cache took 1923 ms
- *
- * <p>In the data model, keys are the line numbers in the log file,
+ *      <br><b>INFO 17:13:22,652 Direct Backend took 1973 ms</b>
+ *      <br><b>INFO 17:18:49,252 Via Cache took 1923 ms</b>
+ * <p>
+ *  (f) For standalone/single node DistributedLogManager usage, Start the DistributedLogManager
in SERVER mode.
+ *      Follow the the commands over the command line console of SERVER instance.
+ * <p>
+ * In the data model, keys are the line numbers in the log file,
  * and the values are Pageview objects, generated from
  * <code>gora-tutorial/src/main/avro/pageview.json</code>.
  *
  * <p>See the tutorial.html file in docs or go to the
  * <a href="http://gora.apache.org/docs/current/tutorial.html">
- * web site</a>for more information.</p>
+ * web site</a> for more information.</p>
  */
 
 public class DistributedLogManager {


Mime
View raw message