[GitHub] [gora] carlosrmng commented on a change in pull request #177: [GORA-527] Implement a data store for redis

2019-08-09 Thread GitBox
carlosrmng commented on a change in pull request #177: [GORA-527] Implement a 
data store for redis
URL: https://github.com/apache/gora/pull/177#discussion_r312650152
 
 

 ##
 File path: gora-redis/src/main/java/org/apache/gora/redis/store/RedisStore.java
 ##
 @@ -0,0 +1,519 @@
+/**
+ * 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.redis.store;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.stream.Collectors;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.apache.avro.Schema;
+import org.apache.commons.io.IOUtils;
+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.redis.query.RedisQuery;
+import org.apache.gora.redis.query.RedisResult;
+import org.apache.gora.redis.util.DatumHandler;
+import org.apache.gora.redis.util.ServerMode;
+import org.apache.gora.redis.util.StorageMode;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.GoraException;
+import org.redisson.Redisson;
+import org.redisson.api.RBatch;
+import org.redisson.api.RBucket;
+import org.redisson.api.RBucketAsync;
+import org.redisson.api.RFuture;
+import org.redisson.api.RLexSortedSet;
+import org.redisson.api.RLexSortedSetAsync;
+import org.redisson.api.RList;
+import org.redisson.api.RListAsync;
+import org.redisson.api.RMap;
+import org.redisson.api.RMapAsync;
+import org.redisson.api.RedissonClient;
+import org.redisson.config.Config;
+import org.redisson.config.ReadMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Implementation of a Redis data store to be used by gora.
+ *
+ * @param  class to be used for the key
+ * @param  class to be persisted within the store
+ */
+public class RedisStore extends DataStoreBase {
+
+  //Redis constants
+  private static final String FIELD_SEPARATOR = ".";
+  private static final String WILDCARD = "*";
+  private static final String INDEX = "index";
+  private static final String START_TAG = "{";
+  private static final String END_TAG = "}";
+  private static final String PREFIX = "redis://";
+
+  protected static final String MOCK_PROPERTY = "redis.mock";
+  protected static final String INSTANCE_NAME_PROPERTY = "redis.instance";
+  protected static final String ZOOKEEPERS_NAME_PROPERTY = "redis.zookeepers";
+  protected static final String USERNAME_PROPERTY = "redis.user";
+  protected static final String PASSWORD_PROPERTY = "redis.password";
+  protected static final String PARSE_MAPPING_FILE_KEY = 
"gora.redis.mapping.file";
+  protected static final String DEFAULT_MAPPING_FILE = 
"gora-redis-mapping.xml";
+  protected static final String XML_MAPPING_DEFINITION = "gora.mapping";
+  private RedissonClient redisInstance;
+  private RedisMapping mapping;
+  public static final Logger LOG = LoggerFactory.getLogger(RedisStore.class);
+
+  private static final DatumHandler handler = new DatumHandler();
+  private StorageMode mode;
+
+  /**
+   * Initialize the data store by reading the credentials, setting the client's
+   * properties up and reading the mapping file. Initialize is called when then
+   * the call to {@link org.apache.gora.store.DataStoreFactory#createDataStore}
+   * is made.
+   *
+   * @param keyClass
+   * @param persistentClass
+   * @param properties
+   */
+  @Override
+  public void initialize(Class keyClass, Class persistentClass, 
Properties properties) throws GoraException {
+try {
+  super.initialize(keyClass, persistentClass, properties);
+
+  InputStream mappingStream;
+  if (properties.containsKey(XML_MAPPING_DEFINITION)) {
+if (LOG.isTraceEnabled()) {
+  LOG.trace(XML_MAPPING_DEFINITION + " = " + 

[GitHub] [gora] carlosrmng commented on a change in pull request #177: [GORA-527] Implement a data store for redis

2019-08-09 Thread GitBox
carlosrmng commented on a change in pull request #177: [GORA-527] Implement a 
data store for redis
URL: https://github.com/apache/gora/pull/177#discussion_r312648541
 
 

 ##
 File path: gora-redis/src/main/java/org/apache/gora/redis/store/RedisStore.java
 ##
 @@ -0,0 +1,519 @@
+/**
+ * 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.redis.store;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.stream.Collectors;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.apache.avro.Schema;
+import org.apache.commons.io.IOUtils;
+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.redis.query.RedisQuery;
+import org.apache.gora.redis.query.RedisResult;
+import org.apache.gora.redis.util.DatumHandler;
+import org.apache.gora.redis.util.ServerMode;
+import org.apache.gora.redis.util.StorageMode;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.GoraException;
+import org.redisson.Redisson;
+import org.redisson.api.RBatch;
+import org.redisson.api.RBucket;
+import org.redisson.api.RBucketAsync;
+import org.redisson.api.RFuture;
+import org.redisson.api.RLexSortedSet;
+import org.redisson.api.RLexSortedSetAsync;
+import org.redisson.api.RList;
+import org.redisson.api.RListAsync;
+import org.redisson.api.RMap;
+import org.redisson.api.RMapAsync;
+import org.redisson.api.RedissonClient;
+import org.redisson.config.Config;
+import org.redisson.config.ReadMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Implementation of a Redis data store to be used by gora.
+ *
+ * @param  class to be used for the key
+ * @param  class to be persisted within the store
+ */
+public class RedisStore extends DataStoreBase {
+
+  //Redis constants
+  private static final String FIELD_SEPARATOR = ".";
+  private static final String WILDCARD = "*";
+  private static final String INDEX = "index";
+  private static final String START_TAG = "{";
+  private static final String END_TAG = "}";
+  private static final String PREFIX = "redis://";
+
+  protected static final String MOCK_PROPERTY = "redis.mock";
+  protected static final String INSTANCE_NAME_PROPERTY = "redis.instance";
+  protected static final String ZOOKEEPERS_NAME_PROPERTY = "redis.zookeepers";
+  protected static final String USERNAME_PROPERTY = "redis.user";
+  protected static final String PASSWORD_PROPERTY = "redis.password";
+  protected static final String PARSE_MAPPING_FILE_KEY = 
"gora.redis.mapping.file";
+  protected static final String DEFAULT_MAPPING_FILE = 
"gora-redis-mapping.xml";
+  protected static final String XML_MAPPING_DEFINITION = "gora.mapping";
+  private RedissonClient redisInstance;
+  private RedisMapping mapping;
+  public static final Logger LOG = LoggerFactory.getLogger(RedisStore.class);
+
+  private static final DatumHandler handler = new DatumHandler();
+  private StorageMode mode;
+
+  /**
+   * Initialize the data store by reading the credentials, setting the client's
+   * properties up and reading the mapping file. Initialize is called when then
+   * the call to {@link org.apache.gora.store.DataStoreFactory#createDataStore}
+   * is made.
+   *
+   * @param keyClass
+   * @param persistentClass
+   * @param properties
+   */
+  @Override
+  public void initialize(Class keyClass, Class persistentClass, 
Properties properties) throws GoraException {
+try {
+  super.initialize(keyClass, persistentClass, properties);
+
+  InputStream mappingStream;
+  if (properties.containsKey(XML_MAPPING_DEFINITION)) {
+if (LOG.isTraceEnabled()) {
+  LOG.trace(XML_MAPPING_DEFINITION + " = " + 

[GitHub] [gora] carlosrmng commented on a change in pull request #177: [GORA-527] Implement a data store for redis

2019-08-09 Thread GitBox
carlosrmng commented on a change in pull request #177: [GORA-527] Implement a 
data store for redis
URL: https://github.com/apache/gora/pull/177#discussion_r312651216
 
 

 ##
 File path: gora-redis/src/main/java/org/apache/gora/redis/store/RedisStore.java
 ##
 @@ -0,0 +1,519 @@
+/**
+ * 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.redis.store;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.stream.Collectors;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.apache.avro.Schema;
+import org.apache.commons.io.IOUtils;
+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.redis.query.RedisQuery;
+import org.apache.gora.redis.query.RedisResult;
+import org.apache.gora.redis.util.DatumHandler;
+import org.apache.gora.redis.util.ServerMode;
+import org.apache.gora.redis.util.StorageMode;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.GoraException;
+import org.redisson.Redisson;
+import org.redisson.api.RBatch;
+import org.redisson.api.RBucket;
+import org.redisson.api.RBucketAsync;
+import org.redisson.api.RFuture;
+import org.redisson.api.RLexSortedSet;
+import org.redisson.api.RLexSortedSetAsync;
+import org.redisson.api.RList;
+import org.redisson.api.RListAsync;
+import org.redisson.api.RMap;
+import org.redisson.api.RMapAsync;
+import org.redisson.api.RedissonClient;
+import org.redisson.config.Config;
+import org.redisson.config.ReadMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Implementation of a Redis data store to be used by gora.
+ *
+ * @param  class to be used for the key
+ * @param  class to be persisted within the store
+ */
+public class RedisStore extends DataStoreBase {
+
+  //Redis constants
+  private static final String FIELD_SEPARATOR = ".";
+  private static final String WILDCARD = "*";
+  private static final String INDEX = "index";
+  private static final String START_TAG = "{";
+  private static final String END_TAG = "}";
+  private static final String PREFIX = "redis://";
+
+  protected static final String MOCK_PROPERTY = "redis.mock";
 
 Review comment:
   Are all these constants needed?


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


With regards,
Apache Git Services


[GitHub] [gora] carlosrmng commented on a change in pull request #177: [GORA-527] Implement a data store for redis

2019-08-09 Thread GitBox
carlosrmng commented on a change in pull request #177: [GORA-527] Implement a 
data store for redis
URL: https://github.com/apache/gora/pull/177#discussion_r312651463
 
 

 ##
 File path: 
gora-redis/src/main/java/org/apache/gora/redis/util/DatumHandler.java
 ##
 @@ -0,0 +1,329 @@
+/**
+ * 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.redis.util;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import org.apache.avro.Schema;
+import org.apache.avro.specific.SpecificDatumReader;
+import org.apache.avro.specific.SpecificDatumWriter;
+import org.apache.avro.util.Utf8;
+import org.apache.gora.persistency.Persistent;
+import org.apache.gora.persistency.impl.DirtyListWrapper;
+import org.apache.gora.persistency.impl.DirtyMapWrapper;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.util.AvroUtils;
+import org.apache.gora.util.IOUtils;
+import org.redisson.api.RList;
+import org.redisson.api.RMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DatumHandler {
+
+  public static final Logger LOG = LoggerFactory.getLogger(DatumHandler.class);
+
+  private final ConcurrentHashMap> readerMap = 
new ConcurrentHashMap<>();
+  private final ConcurrentHashMap> writerMap = 
new ConcurrentHashMap<>();
+
+  public DatumHandler() {
+  }
+
+  @SuppressWarnings("unchecked")
+  public Object serializeFieldValue(Schema fieldSchema, Object fieldValue) {
+Object output = fieldValue;
+switch (fieldSchema.getType()) {
+  case ARRAY:
+  case MAP:
+  case RECORD:
+byte[] data = null;
+try {
+  @SuppressWarnings("rawtypes")
+  SpecificDatumWriter writer = getDatumWriter(fieldSchema);
+  data = IOUtils.serialize(writer, fieldValue);
+} catch (IOException e) {
+  LOG.error(e.getMessage(), e);
+}
+output = data;
+break;
+  case UNION:
+if (fieldSchema.getTypes().size() == 2 && isNullable(fieldSchema)) {
+  int schemaPos = getUnionSchema(fieldValue, fieldSchema);
+  Schema unionSchema = fieldSchema.getTypes().get(schemaPos);
+  output = serializeFieldValue(unionSchema, fieldValue);
+} else {
+  data = null;
+  try {
+@SuppressWarnings("rawtypes")
+SpecificDatumWriter writer = getDatumWriter(fieldSchema);
+data = IOUtils.serialize(writer, fieldValue);
+  } catch (IOException e) {
+LOG.error(e.getMessage(), e);
+  }
+  output = data;
+}
+break;
+  case FIXED:
+break;
+  case ENUM:
+  case STRING:
+output = fieldValue.toString();
+break;
+  case BYTES:
+output = ((ByteBuffer) fieldValue).array();
+break;
+  case INT:
+  case LONG:
+  case FLOAT:
+  case DOUBLE:
+  case BOOLEAN:
+output = fieldValue;
+break;
+  case NULL:
+break;
+  default:
+throw new AssertionError(fieldSchema.getType().name());
+}
+return output;
+  }
+
+  @SuppressWarnings("unchecked")
+  public Map serializeFieldMap(Schema fieldSchema, Object 
fieldValue) {
+Map map = new HashMap();
+switch (fieldSchema.getType()) {
+  case UNION:
+for (Schema sc : fieldSchema.getTypes()) {
+  if (sc.getType() == Schema.Type.MAP) {
+map = serializeFieldMap(sc, fieldValue);
+  }
+}
+break;
+  case MAP:
+Map mp = (Map) fieldValue;
+for (Entry e : mp.entrySet()) {
+  String mapKey = e.getKey().toString();
+  Object mapValue = e.getValue();
+  mapValue = serializeFieldValue(fieldSchema.getValueType(), mapValue);
+  map.put(mapKey, mapValue);
+}
+break;
+  default:
+throw new AssertionError(fieldSchema.getType().name());
+}
+return map;
+  }
+
+  @SuppressWarnings("unchecked")
+  public List serializeFieldList(Schema fieldSchema, Object 

[GitHub] [gora] carlosrmng commented on a change in pull request #177: [GORA-527] Implement a data store for redis

2019-08-09 Thread GitBox
carlosrmng commented on a change in pull request #177: [GORA-527] Implement a 
data store for redis
URL: https://github.com/apache/gora/pull/177#discussion_r312652873
 
 

 ##
 File path: 
gora-redis/src/test/java/org/apache/gora/redis/GoraRedisTestDriver.java
 ##
 @@ -0,0 +1,105 @@
+/**
+ * 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.redis;
+
+import java.io.IOException;
+import java.time.Duration;
+import org.apache.gora.GoraTestDriver;
+import org.apache.gora.redis.store.RedisStore;
+import org.apache.gora.redis.util.RedisStartupLogWaitStrategy;
+import org.apache.gora.redis.util.ServerMode;
+import org.apache.gora.redis.util.StorageMode;
+import org.testcontainers.containers.FixedHostPortGenericContainer;
+
+/**
+ * Helper class to execute tests in a embedded instance of Redis.
+ *
+ * @author Xavier Sumba
+ */
+public class GoraRedisTestDriver extends GoraTestDriver {
+
+  private static final String DOCKER_CONTAINER_NAME = 
"grokzen/redis-cluster:latest";
+  private FixedHostPortGenericContainer redisContainer = 
((FixedHostPortGenericContainer) new 
FixedHostPortGenericContainer(DOCKER_CONTAINER_NAME)
+  .waitingFor(new RedisStartupLogWaitStrategy())
+  .withStartupTimeout(Duration.ofMinutes(3))
+  .withEnv("STANDALONE", "true")
+  .withEnv("SENTINEL", "true"))
 
 Review comment:
   Usually, exposing ports directly is not a good practice. 


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


With regards,
Apache Git Services


[GitHub] [gora] carlosrmng commented on a change in pull request #177: [GORA-527] Implement a data store for redis

2019-08-09 Thread GitBox
carlosrmng commented on a change in pull request #177: [GORA-527] Implement a 
data store for redis
URL: https://github.com/apache/gora/pull/177#discussion_r312651508
 
 

 ##
 File path: 
gora-redis/src/main/java/org/apache/gora/redis/util/DatumHandler.java
 ##
 @@ -0,0 +1,329 @@
+/**
+ * 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.redis.util;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import org.apache.avro.Schema;
+import org.apache.avro.specific.SpecificDatumReader;
+import org.apache.avro.specific.SpecificDatumWriter;
+import org.apache.avro.util.Utf8;
+import org.apache.gora.persistency.Persistent;
+import org.apache.gora.persistency.impl.DirtyListWrapper;
+import org.apache.gora.persistency.impl.DirtyMapWrapper;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.util.AvroUtils;
+import org.apache.gora.util.IOUtils;
+import org.redisson.api.RList;
+import org.redisson.api.RMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DatumHandler {
+
+  public static final Logger LOG = LoggerFactory.getLogger(DatumHandler.class);
+
+  private final ConcurrentHashMap> readerMap = 
new ConcurrentHashMap<>();
+  private final ConcurrentHashMap> writerMap = 
new ConcurrentHashMap<>();
+
+  public DatumHandler() {
+  }
+
+  @SuppressWarnings("unchecked")
+  public Object serializeFieldValue(Schema fieldSchema, Object fieldValue) {
+Object output = fieldValue;
+switch (fieldSchema.getType()) {
+  case ARRAY:
+  case MAP:
+  case RECORD:
+byte[] data = null;
+try {
+  @SuppressWarnings("rawtypes")
+  SpecificDatumWriter writer = getDatumWriter(fieldSchema);
+  data = IOUtils.serialize(writer, fieldValue);
+} catch (IOException e) {
+  LOG.error(e.getMessage(), e);
+}
+output = data;
+break;
+  case UNION:
+if (fieldSchema.getTypes().size() == 2 && isNullable(fieldSchema)) {
+  int schemaPos = getUnionSchema(fieldValue, fieldSchema);
+  Schema unionSchema = fieldSchema.getTypes().get(schemaPos);
+  output = serializeFieldValue(unionSchema, fieldValue);
+} else {
+  data = null;
+  try {
+@SuppressWarnings("rawtypes")
+SpecificDatumWriter writer = getDatumWriter(fieldSchema);
+data = IOUtils.serialize(writer, fieldValue);
+  } catch (IOException e) {
+LOG.error(e.getMessage(), e);
+  }
+  output = data;
+}
+break;
+  case FIXED:
+break;
+  case ENUM:
+  case STRING:
+output = fieldValue.toString();
+break;
+  case BYTES:
+output = ((ByteBuffer) fieldValue).array();
+break;
+  case INT:
+  case LONG:
+  case FLOAT:
+  case DOUBLE:
+  case BOOLEAN:
+output = fieldValue;
+break;
+  case NULL:
+break;
+  default:
+throw new AssertionError(fieldSchema.getType().name());
+}
+return output;
+  }
+
+  @SuppressWarnings("unchecked")
+  public Map serializeFieldMap(Schema fieldSchema, Object 
fieldValue) {
+Map map = new HashMap();
+switch (fieldSchema.getType()) {
+  case UNION:
+for (Schema sc : fieldSchema.getTypes()) {
+  if (sc.getType() == Schema.Type.MAP) {
+map = serializeFieldMap(sc, fieldValue);
+  }
+}
+break;
+  case MAP:
+Map mp = (Map) fieldValue;
+for (Entry e : mp.entrySet()) {
+  String mapKey = e.getKey().toString();
+  Object mapValue = e.getValue();
+  mapValue = serializeFieldValue(fieldSchema.getValueType(), mapValue);
+  map.put(mapKey, mapValue);
+}
+break;
+  default:
+throw new AssertionError(fieldSchema.getType().name());
+}
+return map;
+  }
+
+  @SuppressWarnings("unchecked")
+  public List serializeFieldList(Schema fieldSchema, Object 

[GitHub] [gora] carlosrmng commented on a change in pull request #177: [GORA-527] Implement a data store for redis

2019-08-09 Thread GitBox
carlosrmng commented on a change in pull request #177: [GORA-527] Implement a 
data store for redis
URL: https://github.com/apache/gora/pull/177#discussion_r312649716
 
 

 ##
 File path: gora-redis/src/main/java/org/apache/gora/redis/store/RedisStore.java
 ##
 @@ -0,0 +1,519 @@
+/**
+ * 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.redis.store;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.stream.Collectors;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.apache.avro.Schema;
+import org.apache.commons.io.IOUtils;
+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.redis.query.RedisQuery;
+import org.apache.gora.redis.query.RedisResult;
+import org.apache.gora.redis.util.DatumHandler;
+import org.apache.gora.redis.util.ServerMode;
+import org.apache.gora.redis.util.StorageMode;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.GoraException;
+import org.redisson.Redisson;
+import org.redisson.api.RBatch;
+import org.redisson.api.RBucket;
+import org.redisson.api.RBucketAsync;
+import org.redisson.api.RFuture;
+import org.redisson.api.RLexSortedSet;
+import org.redisson.api.RLexSortedSetAsync;
+import org.redisson.api.RList;
+import org.redisson.api.RListAsync;
+import org.redisson.api.RMap;
+import org.redisson.api.RMapAsync;
+import org.redisson.api.RedissonClient;
+import org.redisson.config.Config;
+import org.redisson.config.ReadMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Implementation of a Redis data store to be used by gora.
+ *
+ * @param  class to be used for the key
+ * @param  class to be persisted within the store
+ */
+public class RedisStore extends DataStoreBase {
+
+  //Redis constants
+  private static final String FIELD_SEPARATOR = ".";
+  private static final String WILDCARD = "*";
+  private static final String INDEX = "index";
+  private static final String START_TAG = "{";
+  private static final String END_TAG = "}";
+  private static final String PREFIX = "redis://";
+
+  protected static final String MOCK_PROPERTY = "redis.mock";
+  protected static final String INSTANCE_NAME_PROPERTY = "redis.instance";
+  protected static final String ZOOKEEPERS_NAME_PROPERTY = "redis.zookeepers";
+  protected static final String USERNAME_PROPERTY = "redis.user";
+  protected static final String PASSWORD_PROPERTY = "redis.password";
+  protected static final String PARSE_MAPPING_FILE_KEY = 
"gora.redis.mapping.file";
+  protected static final String DEFAULT_MAPPING_FILE = 
"gora-redis-mapping.xml";
+  protected static final String XML_MAPPING_DEFINITION = "gora.mapping";
+  private RedissonClient redisInstance;
+  private RedisMapping mapping;
+  public static final Logger LOG = LoggerFactory.getLogger(RedisStore.class);
+
+  private static final DatumHandler handler = new DatumHandler();
+  private StorageMode mode;
+
+  /**
+   * Initialize the data store by reading the credentials, setting the client's
+   * properties up and reading the mapping file. Initialize is called when then
+   * the call to {@link org.apache.gora.store.DataStoreFactory#createDataStore}
+   * is made.
+   *
+   * @param keyClass
+   * @param persistentClass
+   * @param properties
+   */
+  @Override
+  public void initialize(Class keyClass, Class persistentClass, 
Properties properties) throws GoraException {
+try {
+  super.initialize(keyClass, persistentClass, properties);
+
+  InputStream mappingStream;
+  if (properties.containsKey(XML_MAPPING_DEFINITION)) {
+if (LOG.isTraceEnabled()) {
+  LOG.trace(XML_MAPPING_DEFINITION + " = " + 

[GitHub] [gora] carlosrmng commented on a change in pull request #177: [GORA-527] Implement a data store for redis

2019-08-09 Thread GitBox
carlosrmng commented on a change in pull request #177: [GORA-527] Implement a 
data store for redis
URL: https://github.com/apache/gora/pull/177#discussion_r312651056
 
 

 ##
 File path: gora-redis/src/main/java/org/apache/gora/redis/store/RedisStore.java
 ##
 @@ -0,0 +1,519 @@
+/**
+ * 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.redis.store;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.stream.Collectors;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.apache.avro.Schema;
+import org.apache.commons.io.IOUtils;
+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.redis.query.RedisQuery;
+import org.apache.gora.redis.query.RedisResult;
+import org.apache.gora.redis.util.DatumHandler;
+import org.apache.gora.redis.util.ServerMode;
+import org.apache.gora.redis.util.StorageMode;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.GoraException;
+import org.redisson.Redisson;
+import org.redisson.api.RBatch;
+import org.redisson.api.RBucket;
+import org.redisson.api.RBucketAsync;
+import org.redisson.api.RFuture;
+import org.redisson.api.RLexSortedSet;
+import org.redisson.api.RLexSortedSetAsync;
+import org.redisson.api.RList;
+import org.redisson.api.RListAsync;
+import org.redisson.api.RMap;
+import org.redisson.api.RMapAsync;
+import org.redisson.api.RedissonClient;
+import org.redisson.config.Config;
+import org.redisson.config.ReadMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Implementation of a Redis data store to be used by gora.
+ *
+ * @param  class to be used for the key
+ * @param  class to be persisted within the store
+ */
+public class RedisStore extends DataStoreBase {
+
+  //Redis constants
+  private static final String FIELD_SEPARATOR = ".";
+  private static final String WILDCARD = "*";
+  private static final String INDEX = "index";
+  private static final String START_TAG = "{";
+  private static final String END_TAG = "}";
+  private static final String PREFIX = "redis://";
+
+  protected static final String MOCK_PROPERTY = "redis.mock";
+  protected static final String INSTANCE_NAME_PROPERTY = "redis.instance";
+  protected static final String ZOOKEEPERS_NAME_PROPERTY = "redis.zookeepers";
+  protected static final String USERNAME_PROPERTY = "redis.user";
+  protected static final String PASSWORD_PROPERTY = "redis.password";
+  protected static final String PARSE_MAPPING_FILE_KEY = 
"gora.redis.mapping.file";
+  protected static final String DEFAULT_MAPPING_FILE = 
"gora-redis-mapping.xml";
+  protected static final String XML_MAPPING_DEFINITION = "gora.mapping";
+  private RedissonClient redisInstance;
+  private RedisMapping mapping;
+  public static final Logger LOG = LoggerFactory.getLogger(RedisStore.class);
 
 Review comment:
   You can use LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());


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


With regards,
Apache Git Services


[GitHub] [gora] carlosrmng commented on a change in pull request #177: [GORA-527] Implement a data store for redis

2019-08-09 Thread GitBox
carlosrmng commented on a change in pull request #177: [GORA-527] Implement a 
data store for redis
URL: https://github.com/apache/gora/pull/177#discussion_r312650879
 
 

 ##
 File path: 
gora-redis/src/main/java/org/apache/gora/redis/util/DatumHandler.java
 ##
 @@ -0,0 +1,329 @@
+/**
+ * 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.redis.util;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import org.apache.avro.Schema;
+import org.apache.avro.specific.SpecificDatumReader;
+import org.apache.avro.specific.SpecificDatumWriter;
+import org.apache.avro.util.Utf8;
+import org.apache.gora.persistency.Persistent;
+import org.apache.gora.persistency.impl.DirtyListWrapper;
+import org.apache.gora.persistency.impl.DirtyMapWrapper;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.util.AvroUtils;
+import org.apache.gora.util.IOUtils;
+import org.redisson.api.RList;
+import org.redisson.api.RMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DatumHandler {
+
+  public static final Logger LOG = LoggerFactory.getLogger(DatumHandler.class);
 
 Review comment:
   you can use LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); 


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


With regards,
Apache Git Services


[GitHub] [gora] carlosrmng commented on a change in pull request #177: [GORA-527] Implement a data store for redis

2019-08-09 Thread GitBox
carlosrmng commented on a change in pull request #177: [GORA-527] Implement a 
data store for redis
URL: https://github.com/apache/gora/pull/177#discussion_r312649058
 
 

 ##
 File path: gora-redis/src/main/java/org/apache/gora/redis/store/RedisStore.java
 ##
 @@ -0,0 +1,519 @@
+/**
+ * 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.redis.store;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.stream.Collectors;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.apache.avro.Schema;
+import org.apache.commons.io.IOUtils;
+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.redis.query.RedisQuery;
+import org.apache.gora.redis.query.RedisResult;
+import org.apache.gora.redis.util.DatumHandler;
+import org.apache.gora.redis.util.ServerMode;
+import org.apache.gora.redis.util.StorageMode;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.GoraException;
+import org.redisson.Redisson;
+import org.redisson.api.RBatch;
+import org.redisson.api.RBucket;
+import org.redisson.api.RBucketAsync;
+import org.redisson.api.RFuture;
+import org.redisson.api.RLexSortedSet;
+import org.redisson.api.RLexSortedSetAsync;
+import org.redisson.api.RList;
+import org.redisson.api.RListAsync;
+import org.redisson.api.RMap;
+import org.redisson.api.RMapAsync;
+import org.redisson.api.RedissonClient;
+import org.redisson.config.Config;
+import org.redisson.config.ReadMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Implementation of a Redis data store to be used by gora.
+ *
+ * @param  class to be used for the key
+ * @param  class to be persisted within the store
+ */
+public class RedisStore extends DataStoreBase {
+
+  //Redis constants
+  private static final String FIELD_SEPARATOR = ".";
+  private static final String WILDCARD = "*";
+  private static final String INDEX = "index";
+  private static final String START_TAG = "{";
+  private static final String END_TAG = "}";
+  private static final String PREFIX = "redis://";
+
+  protected static final String MOCK_PROPERTY = "redis.mock";
+  protected static final String INSTANCE_NAME_PROPERTY = "redis.instance";
+  protected static final String ZOOKEEPERS_NAME_PROPERTY = "redis.zookeepers";
+  protected static final String USERNAME_PROPERTY = "redis.user";
+  protected static final String PASSWORD_PROPERTY = "redis.password";
+  protected static final String PARSE_MAPPING_FILE_KEY = 
"gora.redis.mapping.file";
+  protected static final String DEFAULT_MAPPING_FILE = 
"gora-redis-mapping.xml";
+  protected static final String XML_MAPPING_DEFINITION = "gora.mapping";
+  private RedissonClient redisInstance;
+  private RedisMapping mapping;
+  public static final Logger LOG = LoggerFactory.getLogger(RedisStore.class);
+
+  private static final DatumHandler handler = new DatumHandler();
+  private StorageMode mode;
+
+  /**
+   * Initialize the data store by reading the credentials, setting the client's
+   * properties up and reading the mapping file. Initialize is called when then
+   * the call to {@link org.apache.gora.store.DataStoreFactory#createDataStore}
+   * is made.
+   *
+   * @param keyClass
+   * @param persistentClass
+   * @param properties
+   */
+  @Override
+  public void initialize(Class keyClass, Class persistentClass, 
Properties properties) throws GoraException {
+try {
+  super.initialize(keyClass, persistentClass, properties);
+
+  InputStream mappingStream;
+  if (properties.containsKey(XML_MAPPING_DEFINITION)) {
+if (LOG.isTraceEnabled()) {
+  LOG.trace(XML_MAPPING_DEFINITION + " = " + 

[GitHub] [gora] carlosrmng commented on a change in pull request #177: [GORA-527] Implement a data store for redis

2019-08-09 Thread GitBox
carlosrmng commented on a change in pull request #177: [GORA-527] Implement a 
data store for redis
URL: https://github.com/apache/gora/pull/177#discussion_r312650318
 
 

 ##
 File path: gora-redis/src/main/java/org/apache/gora/redis/store/RedisStore.java
 ##
 @@ -0,0 +1,519 @@
+/**
+ * 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.redis.store;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.stream.Collectors;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.apache.avro.Schema;
+import org.apache.commons.io.IOUtils;
+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.redis.query.RedisQuery;
+import org.apache.gora.redis.query.RedisResult;
+import org.apache.gora.redis.util.DatumHandler;
+import org.apache.gora.redis.util.ServerMode;
+import org.apache.gora.redis.util.StorageMode;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.GoraException;
+import org.redisson.Redisson;
+import org.redisson.api.RBatch;
+import org.redisson.api.RBucket;
+import org.redisson.api.RBucketAsync;
+import org.redisson.api.RFuture;
+import org.redisson.api.RLexSortedSet;
+import org.redisson.api.RLexSortedSetAsync;
+import org.redisson.api.RList;
+import org.redisson.api.RListAsync;
+import org.redisson.api.RMap;
+import org.redisson.api.RMapAsync;
+import org.redisson.api.RedissonClient;
+import org.redisson.config.Config;
+import org.redisson.config.ReadMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Implementation of a Redis data store to be used by gora.
+ *
+ * @param  class to be used for the key
+ * @param  class to be persisted within the store
+ */
+public class RedisStore extends DataStoreBase {
+
+  //Redis constants
+  private static final String FIELD_SEPARATOR = ".";
+  private static final String WILDCARD = "*";
+  private static final String INDEX = "index";
+  private static final String START_TAG = "{";
+  private static final String END_TAG = "}";
+  private static final String PREFIX = "redis://";
+
+  protected static final String MOCK_PROPERTY = "redis.mock";
+  protected static final String INSTANCE_NAME_PROPERTY = "redis.instance";
+  protected static final String ZOOKEEPERS_NAME_PROPERTY = "redis.zookeepers";
+  protected static final String USERNAME_PROPERTY = "redis.user";
+  protected static final String PASSWORD_PROPERTY = "redis.password";
+  protected static final String PARSE_MAPPING_FILE_KEY = 
"gora.redis.mapping.file";
+  protected static final String DEFAULT_MAPPING_FILE = 
"gora-redis-mapping.xml";
+  protected static final String XML_MAPPING_DEFINITION = "gora.mapping";
+  private RedissonClient redisInstance;
+  private RedisMapping mapping;
+  public static final Logger LOG = LoggerFactory.getLogger(RedisStore.class);
+
+  private static final DatumHandler handler = new DatumHandler();
+  private StorageMode mode;
+
+  /**
+   * Initialize the data store by reading the credentials, setting the client's
+   * properties up and reading the mapping file. Initialize is called when then
+   * the call to {@link org.apache.gora.store.DataStoreFactory#createDataStore}
+   * is made.
+   *
+   * @param keyClass
+   * @param persistentClass
+   * @param properties
+   */
+  @Override
+  public void initialize(Class keyClass, Class persistentClass, 
Properties properties) throws GoraException {
+try {
+  super.initialize(keyClass, persistentClass, properties);
+
+  InputStream mappingStream;
+  if (properties.containsKey(XML_MAPPING_DEFINITION)) {
+if (LOG.isTraceEnabled()) {
+  LOG.trace(XML_MAPPING_DEFINITION + " = " +