You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gora.apache.org by nishadi <gi...@git.apache.org> on 2017/06/20 12:08:51 UTC

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

GitHub user nishadi opened a pull request:

    https://github.com/apache/gora/pull/111

    [WIP] GORA-502 Implement Aerospike Data Store

    This is a work in progress branch

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/nishadi/gora issue-502

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/gora/pull/111.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #111
    
----
commit e796c8c511463cefdb6da785baf9373d19795995
Author: nishadi <nd...@gmail.com>
Date:   2017-06-08T15:33:29Z

    Add initial gora-aerospike module

commit 1ad1cc9c96d0e2a12612a9efa76503218a935316
Author: nishadi <nd...@gmail.com>
Date:   2017-06-17T16:56:05Z

    Add mapping reading and initialization for aerospike module

commit 5608731163dc05b7f8d66ea4071d0a1af04911f2
Author: nishadi <nd...@gmail.com>
Date:   2017-06-17T16:56:45Z

    Merge remote-tracking branch 'upstream/master' into issue-502

commit 8571ad90db93507118897e7fb51500ac4821c47c
Author: nishadi <nd...@gmail.com>
Date:   2017-06-18T08:40:27Z

    Add put functionality for aerospike module

commit 3900a41d9a517025618f346b57bd0c5a1fbe89bd
Author: nishadi <nd...@gmail.com>
Date:   2017-06-18T08:44:34Z

    Add support for aerospike in tutorial

commit b0c197744e40816bd5a1780684e9f31081949790
Author: nishadi <nd...@gmail.com>
Date:   2017-06-19T12:05:44Z

    Update mapping reading to support mappings of field names to bin values in aerospike module

commit 13f252e525e103155502953ebdad1006909747ba
Author: nishadi <nd...@gmail.com>
Date:   2017-06-19T12:07:02Z

    Update aerospike mapping file to support field to bin value mapping

commit eae36f4752f0e22465df552b1c8da1cb5db347fb
Author: nishadi <nd...@gmail.com>
Date:   2017-06-19T16:25:15Z

    Update put method to support field mapping in aerospike module

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora issue #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by djkevincr <gi...@git.apache.org>.
Github user djkevincr commented on the issue:

    https://github.com/apache/gora/pull/111
  
    Build passes without any issue.
    
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO] 
    [INFO] Apache Gora ....................................... SUCCESS [1.370s]
    [INFO] Apache Gora :: Compiler ........................... SUCCESS [2.063s]
    [INFO] Apache Gora :: Compiler-CLI ....................... SUCCESS [1.380s]
    [INFO] Apache Gora :: Core ............................... SUCCESS [1:17.004s]
    [INFO] Apache Gora :: Accumulo ........................... SUCCESS [1:33.638s]
    [INFO] Apache Gora :: Cassandra .......................... SUCCESS [53.152s]
    [INFO] Apache Gora :: GoraCI ............................. SUCCESS [3.377s]
    [INFO] Apache Gora :: HBase .............................. SUCCESS [2:38.696s]
    [INFO] Apache Gora :: Infinispan ......................... SUCCESS [1:19.227s]
    [INFO] Apache Gora :: JCache ............................. SUCCESS [1:11.505s]
    [INFO] Apache Gora :: Dynamodb ........................... SUCCESS [4.452s]
    [INFO] Apache Gora :: CouchDB ............................ SUCCESS [3.742s]
    [INFO] Apache Gora :: Maven Plugin ....................... SUCCESS [3.379s]
    [INFO] Apache Gora :: MongoDB ............................ SUCCESS [1:29.381s]
    [INFO] Apache Gora :: Solr ............................... SUCCESS [3:00.093s]
    [INFO] Apache Gora :: Aerospike .......................... SUCCESS [3.017s]
    [INFO] Apache Gora :: Tutorial ........................... SUCCESS [7.266s]
    [INFO] Apache Gora :: Sources-Dist ....................... SUCCESS [0.501s]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 13:54.015s
    [INFO] Finished at: Thu Jul 27 23:40:39 IST 2017
    [INFO] Final Memory: 80M/710M
    [INFO] ------------------------------------------------------------------------



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: GORA-502 Implement Aerospike Data Store

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/gora/pull/111


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by nishadi <gi...@git.apache.org>.
Github user nishadi commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124704093
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeMappingBuilder.java ---
    @@ -0,0 +1,303 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.gora.aerospike.store;
    +
    +import com.aerospike.client.policy.GenerationPolicy;
    +import com.aerospike.client.policy.Policy;
    +import com.aerospike.client.policy.RecordExistsAction;
    +import com.aerospike.client.policy.WritePolicy;
    +import org.jdom.Document;
    +import org.jdom.Element;
    +import org.jdom.input.SAXBuilder;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.jdom.JDOMException;
    +
    +import javax.naming.ConfigurationException;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.util.List;
    +import java.util.Locale;
    +import java.util.Map;
    +import java.util.HashMap;
    +
    +public class AerospikeMappingBuilder {
    +
    +  private static final Logger LOG = LoggerFactory.getLogger(AerospikeMappingBuilder.class);
    +
    +  private AerospikeMapping aerospikeMapping;
    +
    +  public AerospikeMappingBuilder() {
    +    this.aerospikeMapping = new AerospikeMapping();
    +  }
    +
    +  public AerospikeMapping getAerospikeMapping() {
    +    return this.aerospikeMapping;
    +  }
    +
    +  /**
    +   * Reads the gora aerospike mapping file
    +   *
    +   * @param mappingFile     mapping file path
    +   * @param keyClass        key class
    +   * @param persistentClass persistent class
    +   */
    +  public void readMappingFile(String mappingFile, Class<?> keyClass, Class<?> persistentClass) {
    +
    +    try {
    +      SAXBuilder saxBuilder = new SAXBuilder();
    +      InputStream inputStream = getClass().getClassLoader().getResourceAsStream(mappingFile);
    +      if (inputStream == null) {
    +        LOG.error("Mapping file '{}' could not be found!", mappingFile);
    +        throw new IOException("Mapping file '" + mappingFile + "' could not be found!");
    +      }
    +      Document document = saxBuilder.build(inputStream);
    +      if (document == null) {
    +        LOG.error("Mapping file '{}' could not be found!", mappingFile);
    +        throw new IOException("Mapping file '" + mappingFile + "' could not be found!");
    +      }
    +
    +      Element root = document.getRootElement();
    +
    +      List<Element> policyElements = root.getChildren("policy");
    +
    +      for (Element policyElement : policyElements) {
    +
    +        String policy = policyElement.getAttributeValue("name");
    +        if (policy != null) {
    +          if (policy.equals("write")) {
    --- End diff --
    
    There is no ENUM for policy names at this level (write policies or read policies). But when defining values for each policy, there are ENUMs which I have used in below sections while assigning the policy values. 
    
    > [](url)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124163020
  
    --- Diff: gora-aerospike/src/test/java/org/apache/gora/aerospike/GoraAerospikeTestDriver.java ---
    @@ -0,0 +1,78 @@
    +/*
    + * 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.aerospike;
    +
    +import org.apache.gora.GoraTestDriver;
    +import org.apache.gora.aerospike.store.AerospikeStore;
    +import org.apache.gora.persistency.Persistent;
    +import org.apache.gora.store.DataStore;
    +import org.apache.gora.store.DataStoreFactory;
    +import org.apache.gora.util.GoraException;
    +import org.testcontainers.containers.GenericContainer;
    +
    +import java.util.Properties;
    +
    +/**
    + * Helper class for third part tests using gora-aerospike backend.
    + * @see GoraTestDriver
    + */
    +public class GoraAerospikeTestDriver extends GoraTestDriver {
    +
    +  private GenericContainer aerospikeContainer;
    --- End diff --
    
    final variable?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124165935
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeParameters.java ---
    @@ -0,0 +1,182 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.gora.aerospike.store;
    +
    +import com.aerospike.client.AerospikeClient;
    +import com.aerospike.client.Info;
    +import com.aerospike.client.cluster.Node;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.lang.reflect.Field;
    +import java.util.Properties;
    +
    +public class AerospikeParameters {
    +  private String host;
    +
    +  private int port;
    +
    +  private String user;
    +
    +  private String password;
    +
    +  private AerospikeMapping aerospikeMapping;
    +
    +  private boolean isSingleBinEnabled;
    +
    +  // Property names
    +  private static final String AS_SERVER_IP = "server.ip";
    +
    +  private static final String AS_SERVER_port = "server.port";
    --- End diff --
    
    AS_SERVER_port -> AS_SERVER_PORT?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by lewismc <gi...@git.apache.org>.
Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r122998877
  
    --- Diff: gora-aerospike/pom.xml ---
    @@ -0,0 +1,147 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<!--
    +  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.
    +-->
    +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    +  <modelVersion>4.0.0</modelVersion>
    +
    +  <parent>
    +    <groupId>org.apache.gora</groupId>
    +    <artifactId>gora</artifactId>
    +    <version>0.8-SNAPSHOT</version>
    +    <relativePath>../</relativePath>
    +  </parent>
    +  <artifactId>gora-aerospike</artifactId>
    +  <packaging>bundle</packaging>
    +
    +  <name>Apache Gora :: Aerospike</name>
    +  <url>http://gora.apache.org</url>
    +  <description>The Apache Gora open source framework provides an in-memory data model and
    +    persistence for big data. Gora supports persisting to column stores, key value stores,
    +    document stores and RDBMSs, and analyzing the data with extensive Apache Hadoop MapReduce
    +    support.</description>
    +  <inceptionYear>2010</inceptionYear>
    +  <organization>
    +    <name>The Apache Software Foundation</name>
    +    <url>http://www.apache.org/</url>
    +  </organization>
    +  <issueManagement>
    +    <system>JIRA</system>
    +    <url>https://issues.apache.org/jira/browse/GORA</url>
    +  </issueManagement>
    +  <ciManagement>
    +    <system>Jenkins</system>
    +    <url>https://builds.apache.org/job/Gora-trunk/</url>
    +  </ciManagement>
    +
    +  <properties>
    +    <aerospike.version>3.3.2</aerospike.version>
    --- End diff --
    
    There's no need to include ```aerospike.version``` here if you have already included in within parent pom.xml.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124167624
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java ---
    @@ -0,0 +1,473 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.gora.aerospike.store;
    +
    +import java.io.IOException;
    +import java.nio.ByteBuffer;
    +import java.util.HashMap;
    +import java.util.List;
    +import java.util.ArrayList;
    +import java.util.Map;
    +import java.util.Properties;
    +
    +import com.aerospike.client.Key;
    +import com.aerospike.client.Value;
    +import com.aerospike.client.Bin;
    +import com.aerospike.client.Record;
    +import com.aerospike.client.AerospikeClient;
    +import com.aerospike.client.policy.ClientPolicy;
    +import org.apache.avro.Schema;
    +import org.apache.avro.Schema.Field;
    +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.query.PartitionQuery;
    +import org.apache.gora.query.Query;
    +import org.apache.gora.query.Result;
    +import org.apache.gora.store.impl.DataStoreBase;
    +import org.apache.gora.util.AvroUtils;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +/**
    + * Implementation of a Aerospike data store to be used by gora.
    + *
    + * @param <K> class to be used for the key
    + * @param <T> class to be persisted within the store
    + */
    +public class AerospikeStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
    +
    +  private static final Logger LOG = LoggerFactory.getLogger(AerospikeStore.class);
    +
    +  private static final String PARSE_MAPPING_FILE_KEY = "gora.aerospike.mapping.file";
    +
    +  private static final String DEFAULT_MAPPING_FILE = "gora-aerospike-mapping.xml";
    +
    +  private AerospikeClient aerospikeClient;
    +
    +  private AerospikeParameters aerospikeParameters;
    +
    +  /**
    +   * {@inheritDoc}
    +   * In initializing the aerospike datastore, read the mapping file, sets the basic
    +   * aerospike specific parameters and creates the client with the user defined policies
    +   *
    +   * @param keyClass        key class
    +   * @param persistentClass persistent class
    +   * @param properties      properties
    +   */
    +  @Override
    +  public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) {
    +    super.initialize(keyClass, persistentClass, properties);
    +
    +    AerospikeMappingBuilder aerospikeMappingBuilder = new AerospikeMappingBuilder();
    +    aerospikeMappingBuilder
    +            .readMappingFile(getConf().get(PARSE_MAPPING_FILE_KEY, DEFAULT_MAPPING_FILE), keyClass,
    +                    persistentClass);
    +    aerospikeParameters = new AerospikeParameters(aerospikeMappingBuilder.getAerospikeMapping(),
    +            properties);
    +    ClientPolicy policy = new ClientPolicy();
    +    policy.writePolicyDefault = aerospikeParameters.getAerospikeMapping().getWritePolicy();
    +    policy.readPolicyDefault = aerospikeParameters.getAerospikeMapping().getReadPolicy();
    +
    +    aerospikeClient = new AerospikeClient(aerospikeParameters.getHost(),
    +            aerospikeParameters.getPort());
    +    aerospikeParameters.setServerSpecificParameters(aerospikeClient);
    +    aerospikeParameters.validateServerBinConfiguration(persistentClass.getFields());
    +    LOG.info("Aerospike Gora datastore initialized successfully.");
    +  }
    +
    +  /**
    +   * Aerospike, being a schemaless database does not support explicit schema creation through the
    +   * provided java client. When the records are added to the database, the schema is created on
    +   * the fly. Thus, schema related functionality is unavailable in gora-aerospike module.
    +   *
    +   * @return null
    +   */
    +  @Override
    +  public String getSchemaName() {
    +    return null;
    +  }
    +
    +  /**
    +   * Aerospike, being a schemaless database does not support explicit schema creation through the
    +   * provided java client. When the records are added to the database, the schema is created on
    +   * the fly. Thus, schema creation functionality is unavailable in gora-aerospike module.
    +   */
    +  @Override
    +  public void createSchema() {
    +  }
    +
    +  /**
    +   * Aerospike, being a schemaless database does not support explicit schema creation through the
    +   * provided java client. When the records are added to the database, the schema is created on
    +   * the fly. Thus, schema deletion functionality is unavailable in gora-aerospike module.
    +   */
    +  @Override
    +  public void deleteSchema() {
    +  }
    +
    +  /**
    +   * Aerospike, being a schemaless database does not support explicit schema creation through the
    +   * provided java client. When the records are added to the database, the schema is created on
    +   * the fly. Thus, schema exists functionality is unavailable in gora-aerospike module.
    +   */
    +  @Override
    +  public boolean schemaExists() {
    +    return true;
    +  }
    +
    +  /**
    +   * {@inheritDoc}
    +   *
    +   * @param key    the key of the object
    +   * @param fields the fields required in the object. Pass null, to retrieve all fields
    +   * @return the Object corresponding to the key or null if it cannot be found
    +   */
    +  @Override
    +  public T get(K key, String[] fields) {
    +
    +    Key recordKey = getAerospikeKey(key);
    +    fields = getFieldsToQuery(fields);
    +
    +    Record record = aerospikeClient
    +            .get(aerospikeParameters.getAerospikeMapping().getReadPolicy(), recordKey, fields);
    +    if (record == null) {
    +      return null;
    +    }
    +    return createPersistentInstance(record, fields);
    +  }
    +
    +  /**
    +   * Method to insert the persistent objects with the given key to the aerospike database server.
    +   * In writing the records, the policy defined in the mapping file is used to decide on the
    +   * behaviour of transaction handling.
    +   *
    +   * @param key        key of the object
    +   * @param persistent object to be persisted
    +   */
    +  @Override
    +  public void put(K key, T persistent) {
    +
    +    Key recordKey = getAerospikeKey(key);
    +
    +    List<Field> fields = persistent.getSchema().getFields();
    +    for (int i = 0; i < fields.size(); i++) {
    +      Object persistentValue = persistent.get(i);
    +      if (persistentValue != null) {
    +        String mappingBinName = aerospikeParameters.getAerospikeMapping().getBinMapping()
    +                .get(fields.get(i).name());
    +        if (mappingBinName == null) {
    +          LOG.error(
    +                  "Aerospike mapping for field {}#{} not found. Wrong gora-aerospike-mapping.xml?",
    +                  persistent.getClass().getName(), fields.get(i).name());
    +          throw new RuntimeException(
    +                  "Aerospike mapping for field [" + persistent.getClass().getName() + "#" + fields
    +                          .get(i).name() + "] not found. Wrong gora-aerospike-mapping.xml?");
    +        }
    +        Bin bin = new Bin(mappingBinName,
    +                getSerializableValue(persistentValue, fields.get(i).schema()));
    +        aerospikeClient
    +                .put(aerospikeParameters.getAerospikeMapping().getWritePolicy(), recordKey, bin);
    +      }
    +    }
    +  }
    +
    +  /**
    +   * {@inheritDoc}
    +   *
    +   * @param key the key of the object
    +   * @return whether the object was successfully deleted
    +   */
    +  @Override
    +  public boolean delete(K key) {
    +    Key recordKey = getAerospikeKey(key);
    +    return aerospikeClient
    +            .delete(aerospikeParameters.getAerospikeMapping().getWritePolicy(), recordKey);
    +  }
    +
    +  @Override
    +  public long deleteByQuery(Query<K, T> query) {
    +    return 0;
    +  }
    +
    +  @Override
    +  public Result<K, T> execute(Query<K, T> query) {
    +    return null;
    +  }
    +
    +  @Override
    +  public Query<K, T> newQuery() {
    +    return null;
    +  }
    +
    +  @Override
    +  public List<PartitionQuery<K, T>> getPartitions(Query<K, T> query) throws IOException {
    +    return null;
    +  }
    +
    +  @Override
    +  public void flush() {
    +  }
    +
    +  /**
    +   * Method to close aerospike client connections to database server nodes
    +   */
    +  @Override
    +  public void close() {
    +    aerospikeClient.close();
    +    LOG.info("Aerospike Gora datastore destroyed successfully.");
    +  }
    +
    +  /**
    +   * Method to get the aerospike key from the provided K
    +   *
    +   * @param key persistent key
    +   * @return aerospike key for the record
    +   */
    +  public Key getAerospikeKey(K key) {
    +    Value keyValue;
    +    if (keyClass.getSimpleName().equalsIgnoreCase("string")) {
    +      keyValue = Value.get(key.toString());
    +    } else {
    +      keyValue = Value.get(key);
    +    }
    +
    +    return new Key(aerospikeParameters.getAerospikeMapping().getNamespace(),
    +            aerospikeParameters.getAerospikeMapping().getSet(), keyValue);
    +  }
    +
    +  /**
    +   * Method to get the value serializable in database from the Avro persistent object
    +   *
    +   * @param object persistent object
    +   * @param schema schema of the persistent object
    +   * @return serializable value
    +   */
    +  private Value getSerializableValue(Object object, Schema schema) {
    +
    +    Value value = null;
    +    switch (schema.getType()) {
    +      case UNION:
    +        if (object != null) {
    +          int schemaPos = getUnionSchema(object, schema);
    +          Schema unionSchema = schema.getTypes().get(schemaPos);
    +          value = getSerializableValue(object, unionSchema);
    +        }
    +        break;
    +      case STRING:
    +        value = Value.get(object.toString());
    +        break;
    +      case BYTES:
    +        value = Value.get(((ByteBuffer) object).array());
    +        break;
    +      case MAP:
    +        Map<Object, Object> newMap = new HashMap<>();
    +        Map<?, ?> fieldMap = (Map<?, ?>) object;
    +        for (Object key : fieldMap.keySet()) {
    --- End diff --
    
    You can iterate over the `entrySet`. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora issue #111: GORA-502 Implement Aerospike Data Store

Posted by nishadi <gi...@git.apache.org>.
Github user nishadi commented on the issue:

    https://github.com/apache/gora/pull/111
  
    I will update the client to the latest.
    
    [https://issues.apache.org/jira/browse/GORA-515](url)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124163233
  
    --- Diff: gora-aerospike/src/test/java/org/apache/gora/aerospike/GoraAerospikeTestDriver.java ---
    @@ -0,0 +1,78 @@
    +/*
    + * 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.aerospike;
    +
    +import org.apache.gora.GoraTestDriver;
    +import org.apache.gora.aerospike.store.AerospikeStore;
    +import org.apache.gora.persistency.Persistent;
    +import org.apache.gora.store.DataStore;
    +import org.apache.gora.store.DataStoreFactory;
    +import org.apache.gora.util.GoraException;
    +import org.testcontainers.containers.GenericContainer;
    +
    +import java.util.Properties;
    +
    +/**
    + * Helper class for third part tests using gora-aerospike backend.
    + * @see GoraTestDriver
    + */
    +public class GoraAerospikeTestDriver extends GoraTestDriver {
    +
    +  private GenericContainer aerospikeContainer;
    +  private Properties properties = DataStoreFactory.createProps();
    +
    +  public GoraAerospikeTestDriver(GenericContainer aerospikeContainer) {
    +    super(AerospikeStore.class);
    +    this.aerospikeContainer = aerospikeContainer;
    +  }
    +
    +  @Override
    +  public void setUpClass() throws Exception {
    +
    +    // Wait for the aerospike server to be started in the container
    +    Thread.sleep(5000);
    +
    +    properties.setProperty("server.ip", "localhost");
    +    properties.setProperty("server.port", aerospikeContainer.getMappedPort(3000).toString());
    +  }
    +
    +  @Override
    +  public void tearDownClass() throws Exception {
    +  }
    +
    +  /**
    +   * Instantiate a new {@link DataStore}. Uses 'null' schema.
    +   *
    +   * @param keyClass The key class.
    +   * @param persistentClass The value class.
    +   * @return A new store instance.
    +   * @throws GoraException
    --- End diff --
    
    @throws -> throws


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by nishadi <gi...@git.apache.org>.
Github user nishadi commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124073946
  
    --- Diff: gora-aerospike/src/test/java/org/apache/gora/aerospike/GoraAerospikeTestDriver.java ---
    @@ -0,0 +1,78 @@
    +/*
    + * 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.aerospike;
    +
    +import org.apache.gora.GoraTestDriver;
    +import org.apache.gora.aerospike.store.AerospikeStore;
    +import org.apache.gora.persistency.Persistent;
    +import org.apache.gora.store.DataStore;
    +import org.apache.gora.store.DataStoreFactory;
    +import org.apache.gora.util.GoraException;
    +import org.testcontainers.containers.GenericContainer;
    +
    +import java.util.Properties;
    +
    +/**
    + * Helper class for third part tests using gora-aerospike backend.
    + * @see GoraTestDriver
    + */
    +public class GoraAerospikeTestDriver extends GoraTestDriver {
    +
    +  private GenericContainer aerospikeContainer;
    --- End diff --
    
    For the GoraTestDriver class we can add this field( GenericContaine), and in the instances when we need to use the docker based setup environment, we can provide a separate constructor to handle the container. I will look further into generalizing this further to create the docker instance at the DataStoreTestBase level. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by nishadi <gi...@git.apache.org>.
Github user nishadi commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124074066
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeParameters.java ---
    @@ -0,0 +1,127 @@
    +package org.apache.gora.aerospike.store;
    --- End diff --
    
    Added the header 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora issue #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by nishadi <gi...@git.apache.org>.
Github user nishadi commented on the issue:

    https://github.com/apache/gora/pull/111
  
    @kamaci thank you for reviewing. Added changes as suggested


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124163028
  
    --- Diff: gora-aerospike/src/test/java/org/apache/gora/aerospike/GoraAerospikeTestDriver.java ---
    @@ -0,0 +1,78 @@
    +/*
    + * 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.aerospike;
    +
    +import org.apache.gora.GoraTestDriver;
    +import org.apache.gora.aerospike.store.AerospikeStore;
    +import org.apache.gora.persistency.Persistent;
    +import org.apache.gora.store.DataStore;
    +import org.apache.gora.store.DataStoreFactory;
    +import org.apache.gora.util.GoraException;
    +import org.testcontainers.containers.GenericContainer;
    +
    +import java.util.Properties;
    +
    +/**
    + * Helper class for third part tests using gora-aerospike backend.
    + * @see GoraTestDriver
    + */
    +public class GoraAerospikeTestDriver extends GoraTestDriver {
    +
    +  private GenericContainer aerospikeContainer;
    +  private Properties properties = DataStoreFactory.createProps();
    --- End diff --
    
    final variable?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124163187
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/package-info.java ---
    @@ -0,0 +1,20 @@
    +/**
    --- End diff --
    
    /** -> /*


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by nishadi <gi...@git.apache.org>.
Github user nishadi commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r129641694
  
    --- Diff: gora-aerospike/pom.xml ---
    @@ -71,6 +71,14 @@
         </testResources>
         <plugins>
           <plugin>
    +        <groupId>org.apache.maven.plugins</groupId>
    +        <artifactId>maven-surefire-plugin</artifactId>
    +        <version>2.4.2</version>
    +        <configuration>
    +          <skipTests>true</skipTests>
    --- End diff --
    
    Hi Lewis, This was done basically as I have used Docker to start up the Aerospike server for the test cases. If the build environment does not have Docker environment, the test cases get failed due to the absence of the server. That is the reason why the test cases are made skipped by default as it is done in the couchdb store.
    [https://lists.apache.org/thread.html/d9816c1e3f3a73fe07a3bc19035c532ffde2163aca5cc43e6d854158@%3Cdev.gora.apache.org%3E](url)
    
    I have added a profile to activate the test cases when we need to run the test cases. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora issue #111: GORA-502 Implement Aerospike Data Store

Posted by djkevincr <gi...@git.apache.org>.
Github user djkevincr commented on the issue:

    https://github.com/apache/gora/pull/111
  
    Locally tested Aerospike datastore tests with activating maven profile -  mvn clean install -P aerospike-with-test
    
    Results :
    
    Tests run: 33, Failures: 0, Errors: 0, Skipped: 8
    



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by djkevincr <gi...@git.apache.org>.
Github user djkevincr commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124043213
  
    --- Diff: gora-aerospike/src/test/java/org/apache/gora/aerospike/GoraAerospikeTestDriver.java ---
    @@ -0,0 +1,78 @@
    +/*
    + * 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.aerospike;
    +
    +import org.apache.gora.GoraTestDriver;
    +import org.apache.gora.aerospike.store.AerospikeStore;
    +import org.apache.gora.persistency.Persistent;
    +import org.apache.gora.store.DataStore;
    +import org.apache.gora.store.DataStoreFactory;
    +import org.apache.gora.util.GoraException;
    +import org.testcontainers.containers.GenericContainer;
    +
    +import java.util.Properties;
    +
    +/**
    + * Helper class for third part tests using gora-aerospike backend.
    + * @see GoraTestDriver
    + */
    +public class GoraAerospikeTestDriver extends GoraTestDriver {
    +
    +  private GenericContainer aerospikeContainer;
    --- End diff --
    
    Check whether you can make this test-containers code generic, this can be reused for other datastore which doesn't have java based embedded server.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by lewismc <gi...@git.apache.org>.
Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r122998610
  
    --- Diff: pom.xml ---
    @@ -932,6 +934,11 @@
             <version>${project.version}</version>
             <type>test-jar</type>
           </dependency>
    +      <dependency>
    +        <groupId>org.apache.gora</groupId>
    +        <artifactId>gora-aerospike</artifactId>
    +        <version>${project.version}</version>
    +      </dependency>
    --- End diff --
    
    You should also include the test artifact e.g.
    ```
    +      <dependency>
    +        <groupId>org.apache.gora</groupId>
    +        <artifactId>gora-aerospike</artifactId>
    +        <version>${project.version}</version>
    +        <type>test-jar</type>
    +      </dependency>
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by lewismc <gi...@git.apache.org>.
Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r122998074
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java ---
    @@ -0,0 +1,169 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.gora.aerospike.store;
    +
    +import java.io.IOException;
    +import java.util.List;
    +import java.util.Properties;
    +
    +import com.aerospike.client.*;
    +import com.aerospike.client.policy.ClientPolicy;
    +import org.apache.avro.Schema;
    +import org.apache.avro.Schema.Field;
    +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.store.DataStoreFactory;
    +import org.apache.gora.store.impl.DataStoreBase;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +/**
    + * Implementation of a Aerospike data store to be used by gora.
    + *
    + * @param <K> class to be used for the key
    + * @param <T> class to be persisted within the store
    + */
    +public class AerospikeStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
    +
    +  public static final Logger LOG = LoggerFactory.getLogger(AerospikeStore.class);
    +
    +  private static final String PARSE_MAPPING_FILE_KEY = "gora.aerospike.mapping.file";
    +
    +  private static final String DEFAULT_MAPPING_FILE = "gora-aerospike-mapping.xml";
    +
    +  private AerospikeClient aerospikeClient;
    +
    +  private AerospikeParameters aerospikeParameters;
    +
    +  @Override public void initialize(Class<K> keyClass, Class<T> persistentClass,
    +          Properties properties) {
    +    super.initialize(keyClass, persistentClass, properties);
    +
    +    try {
    +      AerospikeMappingBuilder aerospikeMappingBuilder = new AerospikeMappingBuilder();
    +      aerospikeMappingBuilder
    +              .readMappingFile(getConf().get(PARSE_MAPPING_FILE_KEY, DEFAULT_MAPPING_FILE),
    +                      keyClass, persistentClass);
    +      aerospikeParameters = new AerospikeParameters(aerospikeMappingBuilder.getAerospikeMapping(),
    +              properties);
    +      ClientPolicy policy = new ClientPolicy();
    +      policy.writePolicyDefault = aerospikeParameters.getAerospikeMapping().getWritePolicy();
    +      policy.readPolicyDefault = aerospikeParameters.getAerospikeMapping().getReadPolicy();
    +      aerospikeClient = new AerospikeClient(aerospikeParameters.getHost(),
    +              aerospikeParameters.getPort());
    +      aerospikeParameters.setServerSpecificParameters(aerospikeClient);
    +    } catch (Exception e) {
    +      throw new RuntimeException(e);
    +    }
    +  }
    +
    +  @Override public String getSchemaName() {
    +    return null;
    +  }
    +
    +  @Override public void createSchema() {
    +  }
    +
    +  @Override public void deleteSchema() {
    +  }
    +
    +  @Override public boolean schemaExists() {
    +    return true;
    +  }
    +
    +  @Override public T get(K key, String[] fields) {
    +    return null;
    +  }
    +
    +  @Override public void put(K key, T persistent) {
    +
    +    Key recordKey = new Key(aerospikeParameters.getAerospikeMapping().getNamespace(),
    +            aerospikeParameters.getAerospikeMapping().getSet(), Value.get(key));
    +
    +    List<Field> fields = persistent.getSchema().getFields();
    +    for (int i = 0; i < fields.size(); i++) {
    +      String mappingBinName = aerospikeParameters.getAerospikeMapping().getBinMapping()
    +              .get(fields.get(i).name());
    +      if (mappingBinName == null) {
    +        throw new RuntimeException(
    +                "Aerospike mapping for field [" + persistent.getClass().getName() + "#" + fields
    +                        .get(i).name() + "] not found. Wrong gora-aerospike-mapping.xml?");
    +      }
    +      Bin bin = getBin(mappingBinName, persistent.get(i), fields.get(i));
    +      aerospikeClient
    +              .put(aerospikeParameters.getAerospikeMapping().getWritePolicy(), recordKey, bin);
    +    }
    +  }
    +
    +  @Override public boolean delete(K key) {
    +    return true;
    +  }
    +
    +  @Override public long deleteByQuery(Query<K, T> query) {
    +    return 0;
    +  }
    +
    +  @Override public Result<K, T> execute(Query<K, T> query) {
    +    return null;
    +  }
    +
    +  @Override public Query<K, T> newQuery() {
    +    return null;
    +  }
    +
    +  @Override public List<PartitionQuery<K, T>> getPartitions(Query<K, T> query) throws IOException {
    +    return null;
    +  }
    +
    +  public void flush() {
    +  }
    +
    +  @Override public void close() {
    +    aerospikeClient.close();
    +  }
    +
    +  /**
    +   * Aerospike does not support Utf8 format returned from Avro.
    --- End diff --
    
    What is **bin**? Can you elaborate and make it clearer?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124165992
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeParameters.java ---
    @@ -0,0 +1,182 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.gora.aerospike.store;
    +
    +import com.aerospike.client.AerospikeClient;
    +import com.aerospike.client.Info;
    +import com.aerospike.client.cluster.Node;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.lang.reflect.Field;
    +import java.util.Properties;
    +
    +public class AerospikeParameters {
    +  private String host;
    +
    +  private int port;
    +
    +  private String user;
    +
    +  private String password;
    +
    +  private AerospikeMapping aerospikeMapping;
    +
    +  private boolean isSingleBinEnabled;
    +
    +  // Property names
    +  private static final String AS_SERVER_IP = "server.ip";
    +
    +  private static final String AS_SERVER_port = "server.port";
    +
    +  // Default property values
    +  private static final String DEFAULT_SERVER_IP = "localhost";
    +
    +  private static final String DEFAULT_SERVER_PORT = "3000";
    +
    +  private static final Logger LOG = LoggerFactory.getLogger(AerospikeParameters.class);
    +
    +  /**
    +   * Constructor to create AerospikeParameters object with the given mapping and properties
    +   *
    +   * @param aerospikeMapping aerospike mapping initialized from the mapping file
    +   * @param properties       property details
    +   */
    +  public AerospikeParameters(AerospikeMapping aerospikeMapping, Properties properties) {
    +    this.aerospikeMapping = aerospikeMapping;
    +    this.host = properties.getProperty(AS_SERVER_IP, DEFAULT_SERVER_IP);
    +    this.port = Integer.parseInt(properties.getProperty(AS_SERVER_port, DEFAULT_SERVER_PORT));
    +  }
    +
    +  public String getHost() {
    +    return host;
    +  }
    +
    +  public void setHost(String host) {
    +    this.host = host;
    +  }
    +
    +  public int getPort() {
    +    return port;
    +  }
    +
    +  public void setPort(int port) {
    +    this.port = port;
    +  }
    +
    +  public String getUser() {
    +    return user;
    +  }
    +
    +  public void setUser(String user) {
    +    this.user = user;
    +  }
    +
    +  public String getPassword() {
    +    return password;
    +  }
    +
    +  public void setPassword(String password) {
    +    this.password = password;
    +  }
    +
    +  public AerospikeMapping getAerospikeMapping() {
    +    return aerospikeMapping;
    +  }
    +
    +  public void setAerospikeMapping(AerospikeMapping aerospikeMapping) {
    +    this.aerospikeMapping = aerospikeMapping;
    +  }
    +
    +  public boolean isSingleBinEnabled() {
    +    return isSingleBinEnabled;
    +  }
    +
    +  public void setSingleBinEnabled(boolean singleBinEnabled) {
    +    this.isSingleBinEnabled = singleBinEnabled;
    +  }
    +
    +  /**
    +   * Retrieves and sets the server specific parameters
    +   * Validates the existence of user provided namespace and validates for single binned
    +   * namespaces
    +   *
    +   * @param client aerospike client used to connect with the server
    +   */
    +  public void setServerSpecificParameters(AerospikeClient client) {
    +
    +    String namespaceTokens = null;
    +    for (Node node : client.getNodes()) {
    +      String namespaceFilter = "namespace/" + aerospikeMapping.getNamespace();
    +      namespaceTokens = Info.request(null, node, namespaceFilter);
    +
    +      if (namespaceTokens != null) {
    +        isSingleBinEnabled = parseBoolean(namespaceTokens, "single-bin");
    +        break;
    +      }
    +    }
    +    if (namespaceTokens == null) {
    +      LOG.error("Failed to get namespace info from Aerospike");
    +      throw new RuntimeException("Failed to get namespace info from Aerospike");
    +    }
    +  }
    +
    +  /**
    +   * Parse the namespace tokens and retrieve the corresponding boolean value for the
    +   * provided parameter name
    +   *
    +   * @param namespaceTokens namespace tokens
    +   * @param name            name of the parameter
    +   * @return boolean value in the namespace corresponding to the provided parameter
    +   */
    +  private boolean parseBoolean(String namespaceTokens, String name) {
    +    String search = name + '=';
    +    int begin = namespaceTokens.indexOf(search);
    +
    +    if (begin < 0) {
    +      return false;
    +    }
    +
    +    begin += search.length();
    +    int end = namespaceTokens.indexOf(';', begin);
    +
    +    if (end < 0) {
    +      end = namespaceTokens.length();
    +    }
    +    String value = namespaceTokens.substring(begin, end);
    +    return Boolean.parseBoolean(value);
    +  }
    +
    +  /**
    +   * Method is used to validate server bin configuration. In Aerospike, it is possible to enable
    +   * single bin (column) for the namespace which will disallow multiple bins (columns) for a
    +   * record. Thus if the namespace is single bin enabled and the data bean contains more than one
    +   * field, that namespace cannot be used to mutiple bin operations.
    +   *
    +   * @param fields fields of the persistent class
    +   */
    +  public void validateServerBinConfiguration(Field[] fields) {
    +    if (isSingleBinEnabled) {
    --- End diff --
    
    This and below lines of if statements can be merged.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora issue #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci commented on the issue:

    https://github.com/apache/gora/pull/111
  
    Apart from this commit, do we need .gitignore file under gora-accumulo/src/examples/java folder?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by lewismc <gi...@git.apache.org>.
Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r129631962
  
    --- Diff: gora-aerospike/pom.xml ---
    @@ -71,6 +71,14 @@
         </testResources>
         <plugins>
           <plugin>
    +        <groupId>org.apache.maven.plugins</groupId>
    +        <artifactId>maven-surefire-plugin</artifactId>
    +        <version>2.4.2</version>
    +        <configuration>
    +          <skipTests>true</skipTests>
    --- End diff --
    
    Please don't do this. Instead use the @ Ignore syntax for JUnit. Please see http://junit.sourceforge.net/javadoc/org/junit/Ignore.html



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora issue #111: GORA-502 Implement Aerospike Data Store

Posted by djkevincr <gi...@git.apache.org>.
Github user djkevincr commented on the issue:

    https://github.com/apache/gora/pull/111
  
    @nishadi This is really awesome work :) I am really happy to merge your work to the master. As we discussed please create tickets for any remaining work. Once again we are really thankful for your awesome contributions. 
    Thanks all for reviewing the PR. @lewismc @kamaci @renato2099 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124165711
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeMappingBuilder.java ---
    @@ -0,0 +1,303 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.gora.aerospike.store;
    +
    +import com.aerospike.client.policy.GenerationPolicy;
    +import com.aerospike.client.policy.Policy;
    +import com.aerospike.client.policy.RecordExistsAction;
    +import com.aerospike.client.policy.WritePolicy;
    +import org.jdom.Document;
    +import org.jdom.Element;
    +import org.jdom.input.SAXBuilder;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.jdom.JDOMException;
    +
    +import javax.naming.ConfigurationException;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.util.List;
    +import java.util.Locale;
    +import java.util.Map;
    +import java.util.HashMap;
    +
    +public class AerospikeMappingBuilder {
    +
    +  private static final Logger LOG = LoggerFactory.getLogger(AerospikeMappingBuilder.class);
    +
    +  private AerospikeMapping aerospikeMapping;
    +
    +  public AerospikeMappingBuilder() {
    +    this.aerospikeMapping = new AerospikeMapping();
    +  }
    +
    +  public AerospikeMapping getAerospikeMapping() {
    +    return this.aerospikeMapping;
    +  }
    +
    +  /**
    +   * Reads the gora aerospike mapping file
    +   *
    +   * @param mappingFile     mapping file path
    +   * @param keyClass        key class
    +   * @param persistentClass persistent class
    +   */
    +  public void readMappingFile(String mappingFile, Class<?> keyClass, Class<?> persistentClass) {
    +
    +    try {
    +      SAXBuilder saxBuilder = new SAXBuilder();
    +      InputStream inputStream = getClass().getClassLoader().getResourceAsStream(mappingFile);
    +      if (inputStream == null) {
    +        LOG.error("Mapping file '{}' could not be found!", mappingFile);
    +        throw new IOException("Mapping file '" + mappingFile + "' could not be found!");
    +      }
    +      Document document = saxBuilder.build(inputStream);
    +      if (document == null) {
    +        LOG.error("Mapping file '{}' could not be found!", mappingFile);
    +        throw new IOException("Mapping file '" + mappingFile + "' could not be found!");
    +      }
    +
    +      Element root = document.getRootElement();
    +
    +      List<Element> policyElements = root.getChildren("policy");
    +
    +      for (Element policyElement : policyElements) {
    +
    +        String policy = policyElement.getAttributeValue("name");
    +        if (policy != null) {
    +          if (policy.equals("write")) {
    +            WritePolicy writePolicy = new WritePolicy();
    +            if (policyElement.getAttributeValue("gen") != null)
    +              writePolicy.generationPolicy = getGenerationPolicyMapping(
    +                      policyElement.getAttributeValue("gen").toUpperCase(Locale.getDefault()));
    +            if (policyElement.getAttributeValue("exists") != null)
    +              writePolicy.recordExistsAction = getRecordExistsAction(
    +                      policyElement.getAttributeValue("exists").toUpperCase(Locale.getDefault()));
    +            if (policyElement.getAttributeValue("key") != null)
    +              writePolicy.sendKey = getKeyUsagePolicy(
    +                      policyElement.getAttributeValue("key").toUpperCase(Locale.getDefault()));
    +            if (policyElement.getAttributeValue("retry") != null)
    +              writePolicy.retryOnTimeout = getRetryOnTimeoutPolicy(
    +                      policyElement.getAttributeValue("retry").toUpperCase(Locale.getDefault()));
    +            if (policyElement.getAttributeValue("timeout") != null)
    +              writePolicy.timeout = getTimeoutValue(policyElement.getAttributeValue("timeout"));
    +            aerospikeMapping.setWritePolicy(writePolicy);
    +          } else if (policy.equals("read")) {
    +            Policy readPolicy = new Policy();
    +            if (policyElement.getAttributeValue("key") != null)
    +              readPolicy.sendKey = getKeyUsagePolicy(
    +                      policyElement.getAttributeValue("key").toUpperCase(Locale.getDefault()));
    +            if (policyElement.getAttributeValue("timeout") != null)
    +              readPolicy.timeout = getTimeoutValue(policyElement.getAttributeValue("timeout"));
    +            aerospikeMapping.setReadPolicy(readPolicy);
    +          }
    +        }
    +      }
    +
    +      List<Element> classElements = root.getChildren("class");
    +
    +      boolean persistentClassAndKeyClassMatches = false;
    +      for (Element classElement : classElements) {
    +
    +        String mappingKeyClass = classElement.getAttributeValue("keyClass");
    +        String mappingClassName = classElement.getAttributeValue("name");
    +
    +        if (mappingKeyClass != null && mappingClassName != null) {
    --- End diff --
    
    This and below lines of if statements can be merged.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124165139
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java ---
    @@ -0,0 +1,473 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.gora.aerospike.store;
    +
    +import java.io.IOException;
    +import java.nio.ByteBuffer;
    +import java.util.HashMap;
    +import java.util.List;
    +import java.util.ArrayList;
    +import java.util.Map;
    +import java.util.Properties;
    +
    +import com.aerospike.client.Key;
    +import com.aerospike.client.Value;
    +import com.aerospike.client.Bin;
    +import com.aerospike.client.Record;
    +import com.aerospike.client.AerospikeClient;
    +import com.aerospike.client.policy.ClientPolicy;
    +import org.apache.avro.Schema;
    +import org.apache.avro.Schema.Field;
    +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.query.PartitionQuery;
    +import org.apache.gora.query.Query;
    +import org.apache.gora.query.Result;
    +import org.apache.gora.store.impl.DataStoreBase;
    +import org.apache.gora.util.AvroUtils;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +/**
    + * Implementation of a Aerospike data store to be used by gora.
    + *
    + * @param <K> class to be used for the key
    + * @param <T> class to be persisted within the store
    + */
    +public class AerospikeStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
    +
    +  private static final Logger LOG = LoggerFactory.getLogger(AerospikeStore.class);
    +
    +  private static final String PARSE_MAPPING_FILE_KEY = "gora.aerospike.mapping.file";
    +
    +  private static final String DEFAULT_MAPPING_FILE = "gora-aerospike-mapping.xml";
    +
    +  private AerospikeClient aerospikeClient;
    +
    +  private AerospikeParameters aerospikeParameters;
    +
    +  /**
    +   * {@inheritDoc}
    +   * In initializing the aerospike datastore, read the mapping file, sets the basic
    +   * aerospike specific parameters and creates the client with the user defined policies
    +   *
    +   * @param keyClass        key class
    +   * @param persistentClass persistent class
    +   * @param properties      properties
    +   */
    +  @Override
    +  public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) {
    +    super.initialize(keyClass, persistentClass, properties);
    +
    +    AerospikeMappingBuilder aerospikeMappingBuilder = new AerospikeMappingBuilder();
    +    aerospikeMappingBuilder
    +            .readMappingFile(getConf().get(PARSE_MAPPING_FILE_KEY, DEFAULT_MAPPING_FILE), keyClass,
    +                    persistentClass);
    +    aerospikeParameters = new AerospikeParameters(aerospikeMappingBuilder.getAerospikeMapping(),
    +            properties);
    +    ClientPolicy policy = new ClientPolicy();
    +    policy.writePolicyDefault = aerospikeParameters.getAerospikeMapping().getWritePolicy();
    +    policy.readPolicyDefault = aerospikeParameters.getAerospikeMapping().getReadPolicy();
    +
    +    aerospikeClient = new AerospikeClient(aerospikeParameters.getHost(),
    +            aerospikeParameters.getPort());
    +    aerospikeParameters.setServerSpecificParameters(aerospikeClient);
    +    aerospikeParameters.validateServerBinConfiguration(persistentClass.getFields());
    +    LOG.info("Aerospike Gora datastore initialized successfully.");
    +  }
    +
    +  /**
    +   * Aerospike, being a schemaless database does not support explicit schema creation through the
    +   * provided java client. When the records are added to the database, the schema is created on
    +   * the fly. Thus, schema related functionality is unavailable in gora-aerospike module.
    +   *
    +   * @return null
    +   */
    +  @Override
    +  public String getSchemaName() {
    +    return null;
    +  }
    +
    +  /**
    +   * Aerospike, being a schemaless database does not support explicit schema creation through the
    +   * provided java client. When the records are added to the database, the schema is created on
    +   * the fly. Thus, schema creation functionality is unavailable in gora-aerospike module.
    +   */
    +  @Override
    +  public void createSchema() {
    +  }
    +
    +  /**
    +   * Aerospike, being a schemaless database does not support explicit schema creation through the
    +   * provided java client. When the records are added to the database, the schema is created on
    +   * the fly. Thus, schema deletion functionality is unavailable in gora-aerospike module.
    +   */
    +  @Override
    +  public void deleteSchema() {
    +  }
    +
    +  /**
    +   * Aerospike, being a schemaless database does not support explicit schema creation through the
    +   * provided java client. When the records are added to the database, the schema is created on
    +   * the fly. Thus, schema exists functionality is unavailable in gora-aerospike module.
    +   */
    +  @Override
    +  public boolean schemaExists() {
    +    return true;
    +  }
    +
    +  /**
    +   * {@inheritDoc}
    +   *
    +   * @param key    the key of the object
    +   * @param fields the fields required in the object. Pass null, to retrieve all fields
    +   * @return the Object corresponding to the key or null if it cannot be found
    +   */
    +  @Override
    +  public T get(K key, String[] fields) {
    +
    +    Key recordKey = getAerospikeKey(key);
    +    fields = getFieldsToQuery(fields);
    +
    +    Record record = aerospikeClient
    +            .get(aerospikeParameters.getAerospikeMapping().getReadPolicy(), recordKey, fields);
    +    if (record == null) {
    +      return null;
    +    }
    +    return createPersistentInstance(record, fields);
    +  }
    +
    +  /**
    +   * Method to insert the persistent objects with the given key to the aerospike database server.
    +   * In writing the records, the policy defined in the mapping file is used to decide on the
    +   * behaviour of transaction handling.
    +   *
    +   * @param key        key of the object
    +   * @param persistent object to be persisted
    +   */
    +  @Override
    +  public void put(K key, T persistent) {
    +
    +    Key recordKey = getAerospikeKey(key);
    +
    +    List<Field> fields = persistent.getSchema().getFields();
    +    for (int i = 0; i < fields.size(); i++) {
    +      Object persistentValue = persistent.get(i);
    +      if (persistentValue != null) {
    +        String mappingBinName = aerospikeParameters.getAerospikeMapping().getBinMapping()
    +                .get(fields.get(i).name());
    +        if (mappingBinName == null) {
    +          LOG.error(
    +                  "Aerospike mapping for field {}#{} not found. Wrong gora-aerospike-mapping.xml?",
    +                  persistent.getClass().getName(), fields.get(i).name());
    +          throw new RuntimeException(
    +                  "Aerospike mapping for field [" + persistent.getClass().getName() + "#" + fields
    +                          .get(i).name() + "] not found. Wrong gora-aerospike-mapping.xml?");
    +        }
    +        Bin bin = new Bin(mappingBinName,
    +                getSerializableValue(persistentValue, fields.get(i).schema()));
    +        aerospikeClient
    +                .put(aerospikeParameters.getAerospikeMapping().getWritePolicy(), recordKey, bin);
    +      }
    +    }
    +  }
    +
    +  /**
    +   * {@inheritDoc}
    +   *
    +   * @param key the key of the object
    +   * @return whether the object was successfully deleted
    +   */
    +  @Override
    +  public boolean delete(K key) {
    +    Key recordKey = getAerospikeKey(key);
    +    return aerospikeClient
    +            .delete(aerospikeParameters.getAerospikeMapping().getWritePolicy(), recordKey);
    +  }
    +
    +  @Override
    +  public long deleteByQuery(Query<K, T> query) {
    +    return 0;
    +  }
    +
    +  @Override
    +  public Result<K, T> execute(Query<K, T> query) {
    +    return null;
    +  }
    +
    +  @Override
    +  public Query<K, T> newQuery() {
    +    return null;
    +  }
    +
    +  @Override
    +  public List<PartitionQuery<K, T>> getPartitions(Query<K, T> query) throws IOException {
    +    return null;
    +  }
    +
    +  @Override
    +  public void flush() {
    +  }
    +
    +  /**
    +   * Method to close aerospike client connections to database server nodes
    +   */
    +  @Override
    +  public void close() {
    +    aerospikeClient.close();
    +    LOG.info("Aerospike Gora datastore destroyed successfully.");
    +  }
    +
    +  /**
    +   * Method to get the aerospike key from the provided K
    +   *
    +   * @param key persistent key
    +   * @return aerospike key for the record
    +   */
    +  public Key getAerospikeKey(K key) {
    +    Value keyValue;
    +    if (keyClass.getSimpleName().equalsIgnoreCase("string")) {
    +      keyValue = Value.get(key.toString());
    +    } else {
    +      keyValue = Value.get(key);
    +    }
    +
    +    return new Key(aerospikeParameters.getAerospikeMapping().getNamespace(),
    +            aerospikeParameters.getAerospikeMapping().getSet(), keyValue);
    +  }
    +
    +  /**
    +   * Method to get the value serializable in database from the Avro persistent object
    +   *
    +   * @param object persistent object
    +   * @param schema schema of the persistent object
    +   * @return serializable value
    +   */
    +  private Value getSerializableValue(Object object, Schema schema) {
    +
    +    Value value = null;
    +    switch (schema.getType()) {
    +      case UNION:
    +        if (object != null) {
    +          int schemaPos = getUnionSchema(object, schema);
    +          Schema unionSchema = schema.getTypes().get(schemaPos);
    +          value = getSerializableValue(object, unionSchema);
    +        }
    +        break;
    +      case STRING:
    +        value = Value.get(object.toString());
    +        break;
    +      case BYTES:
    +        value = Value.get(((ByteBuffer) object).array());
    +        break;
    +      case MAP:
    +        Map<Object, Object> newMap = new HashMap<>();
    +        Map<?, ?> fieldMap = (Map<?, ?>) object;
    +        for (Object key : fieldMap.keySet()) {
    +          newMap.put(key.toString(),
    +                  getSerializableValue(fieldMap.get(key), schema.getValueType()));
    +        }
    +        value = Value.get(newMap);
    +        break;
    +      case ARRAY:
    +        List<Object> objectList = new ArrayList<>();
    +        for (Object obj : (List<Object>) object) {
    +          objectList.add(getSerializableValue(obj, schema.getElementType()));
    +        }
    +        value = Value.get(objectList);
    +        break;
    +      default:
    +        value = Value.get(object);
    +        break;
    +    }
    +    return value;
    +  }
    +
    +  /**
    +   * Method to create a persistent object given the retrieved record
    +   * from Aerospike database
    +   *
    +   * @param record record retrieved from database
    +   * @param fields fields
    +   * @return persistent object created
    +   */
    +  private T createPersistentInstance(Record record, String[] fields) {
    +
    +    T persistent = newPersistent();
    +    for (String field : fields) {
    +      setPersistentField(field, record, persistent);
    +    }
    +    return persistent;
    +  }
    +
    +  /**
    +   * Method to set a field in the persistent object
    +   *
    +   * @param fieldName  field name
    +   * @param record     record retrieved from database
    +   * @param persistent persistent object for the field to be set
    +   */
    +  private void setPersistentField(String fieldName, Record record, T persistent) {
    +
    +    String binName = aerospikeParameters.getAerospikeMapping().getBinName(fieldName);
    +    if (binName == null) {
    +      LOG.error("Aerospike mapping for field {} not found. Wrong gora-aerospike-mapping.xml",
    +              fieldName);
    +      throw new RuntimeException("Aerospike mapping for field [" + fieldName + "] not found. "
    +              + "Wrong gora-aerospike-mapping.xml?");
    +    }
    +    if (record.bins.get(fieldName) == null) {
    +      return;
    +    }
    +    String binDataType = record.bins.get(fieldName).getClass().getSimpleName();
    +    Object binValue = record.bins.get(binName);
    +
    +    persistent.put(fieldName,
    +            getDeserializedObject(binValue, binDataType, fieldMap.get(fieldName).schema()));
    +  }
    +
    +  /**
    +   * Method to get Avro mapped persistent object from the record retrieved from the database
    +   *
    +   * @param binValue    value retrieved from database
    +   * @param binDataType data type of the database value
    +   * @param schema      corresponding schema in the persistent class
    +   * @return persistent object
    +   */
    +  private Object getDeserializedObject(Object binValue, String binDataType, Schema schema) {
    +
    +    Object result;
    +    switch (schema.getType()) {
    +
    +      case MAP:
    +        Map<String, Object> rawMap = (Map<String, Object>) binValue;
    +        Map<Utf8, Object> deserializableMap = new HashMap<>();
    +        if (rawMap == null) {
    +          result = new DirtyMapWrapper(deserializableMap);
    +          break;
    +        }
    +        for (Map.Entry<?, ?> e : rawMap.entrySet()) {
    +          Schema innerSchema = schema.getValueType();
    +          Object obj = getDeserializedObject(e.getValue(), e.getValue().getClass().getSimpleName(),
    +                  innerSchema);
    +          if (e.getKey().getClass().getSimpleName().equalsIgnoreCase("Utf8")) {
    +            deserializableMap.put((Utf8) e.getKey(), obj);
    +          } else {
    +            deserializableMap.put(new Utf8((String) e.getKey()), obj);
    +          }
    +        }
    +        result = new DirtyMapWrapper<>(deserializableMap);
    +        break;
    +
    +      case ARRAY:
    +        List<Object> rawList = (List<Object>) binValue;
    +        List<Object> deserializableList = new ArrayList<>();
    +        if (rawList == null) {
    +          return new DirtyListWrapper(deserializableList);
    +        }
    +        for (Object item : rawList) {
    +          Object obj = getDeserializedObject(item, item.getClass().getSimpleName(),
    +                  schema.getElementType());
    +          deserializableList.add(obj);
    +        }
    +        result = new DirtyListWrapper<>(deserializableList);
    +        break;
    +
    +      case RECORD:
    +        result = (PersistentBase) binValue;
    +        break;
    +
    +      case UNION:
    +        int index = getUnionSchema(binValue, schema);
    +        Schema resolvedSchema = schema.getTypes().get(index);
    +        result = getDeserializedObject(binValue, binDataType, resolvedSchema);
    +        break;
    +
    +      case ENUM:
    +        result = AvroUtils.getEnumValue(schema, (String) binValue);
    +        break;
    +
    +      case BYTES:
    +        result = ByteBuffer.wrap((byte[]) binValue);
    +        break;
    +
    +      case STRING:
    +        if (binValue instanceof org.apache.avro.util.Utf8)
    +          result = binValue;
    +        else
    +          result = new Utf8((String) binValue);
    +        break;
    +
    +      case INT:
    +        if (binDataType.equalsIgnoreCase("long")) {
    +          result = Math.toIntExact((Long) binValue);
    +        } else {
    +          result = binValue;
    +        }
    +        break;
    +
    +      default:
    +        result = binValue;
    +    }
    +    return result;
    +  }
    +
    +  /**
    +   * Method to retrieve the corresponding schema type index of a particular object having UNION
    +   * schema. As UNION type can have one or more types and at a given instance, it holds an object
    +   * of only one type of the defined types, this method is used to figure out the corresponding
    +   * instance's
    +   * schema type index.
    +   *
    +   * @param instanceValue value that the object holds
    +   * @param unionSchema   union schema containing all of the data types
    +   * @return the unionSchemaPosition corresponding schema position
    +   */
    +  private int getUnionSchema(Object instanceValue, Schema unionSchema) {
    +    int unionSchemaPos = 0;
    +    for (Schema currentSchema : unionSchema.getTypes()) {
    +      Schema.Type schemaType = currentSchema.getType();
    +      if (instanceValue instanceof CharSequence && schemaType.equals(Schema.Type.STRING))
    +        return unionSchemaPos;
    +      else if (instanceValue instanceof ByteBuffer && schemaType.equals(Schema.Type.BYTES))
    --- End diff --
    
    `else` after a `return` statement?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124162952
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeMappingBuilder.java ---
    @@ -0,0 +1,303 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.gora.aerospike.store;
    +
    +import com.aerospike.client.policy.GenerationPolicy;
    +import com.aerospike.client.policy.Policy;
    +import com.aerospike.client.policy.RecordExistsAction;
    +import com.aerospike.client.policy.WritePolicy;
    +import org.jdom.Document;
    +import org.jdom.Element;
    +import org.jdom.input.SAXBuilder;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.jdom.JDOMException;
    +
    +import javax.naming.ConfigurationException;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.util.List;
    +import java.util.Locale;
    +import java.util.Map;
    +import java.util.HashMap;
    +
    +public class AerospikeMappingBuilder {
    +
    +  private static final Logger LOG = LoggerFactory.getLogger(AerospikeMappingBuilder.class);
    +
    +  private AerospikeMapping aerospikeMapping;
    --- End diff --
    
    final variable?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by lewismc <gi...@git.apache.org>.
Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r122998327
  
    --- Diff: gora-tutorial/conf/gora.properties ---
    @@ -16,7 +16,8 @@
     
     ##gora.datastore.default is the default detastore implementation to use 
     ##if it is not passed to the DataStoreFactory#createDataStore() method.
    -gora.datastore.default=org.apache.gora.hbase.store.HBaseStore
    +gora.datastore.default=org.apache.gora.aerospike.store.AerospikeStore
    --- End diff --
    
    Please retain HBaseStore are default and merely add AerospikeStore to end of list.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by djkevincr <gi...@git.apache.org>.
Github user djkevincr commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r129768438
  
    --- Diff: gora-aerospike/pom.xml ---
    @@ -0,0 +1,174 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<!--
    +  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.
    +-->
    +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    +  <modelVersion>4.0.0</modelVersion>
    +
    +  <parent>
    +    <groupId>org.apache.gora</groupId>
    +    <artifactId>gora</artifactId>
    +    <version>0.8-SNAPSHOT</version>
    +    <relativePath>../</relativePath>
    +  </parent>
    +  <artifactId>gora-aerospike</artifactId>
    +  <packaging>bundle</packaging>
    +
    +  <name>Apache Gora :: Aerospike</name>
    +  <url>http://gora.apache.org</url>
    +  <description>The Apache Gora open source framework provides an in-memory data model and
    +    persistence for big data. Gora supports persisting to column stores, key value stores,
    +    document stores and RDBMSs, and analyzing the data with extensive Apache Hadoop MapReduce
    +    support.</description>
    +  <inceptionYear>2010</inceptionYear>
    +  <organization>
    +    <name>The Apache Software Foundation</name>
    +    <url>http://www.apache.org/</url>
    +  </organization>
    +  <issueManagement>
    +    <system>JIRA</system>
    +    <url>https://issues.apache.org/jira/browse/GORA</url>
    +  </issueManagement>
    +  <ciManagement>
    +    <system>Jenkins</system>
    +    <url>https://builds.apache.org/job/Gora-trunk/</url>
    +  </ciManagement>
    +
    +  <properties>
    +    <osgi.import>*</osgi.import>
    +    <osgi.export>org.apache.gora.aerospike*;version="${project.version}";-noimport:=true</osgi.export>
    +  </properties>
    +
    +  <profiles>
    +    <profile>
    +      <id>aerospike-with-test</id>
    +      <build>
    +        <plugins>
    +          <plugin>
    +            <groupId>org.apache.maven.plugins</groupId>
    +            <artifactId>maven-surefire-plugin</artifactId>
    +            <version>2.4.2</version>
    +            <configuration>
    +              <skipTests>false</skipTests>
    +            </configuration>
    +          </plugin>
    +        </plugins>
    +      </build>
    +    </profile>
    +  </profiles>
    +
    +  <build>
    +    <directory>target</directory>
    +    <outputDirectory>target/classes</outputDirectory>
    +    <finalName>${project.artifactId}-${project.version}</finalName>
    +    <testOutputDirectory>target/test-classes</testOutputDirectory>
    +    <testSourceDirectory>src/test/java</testSourceDirectory>
    +    <sourceDirectory>src/main/java</sourceDirectory>
    +    <testResources>
    +      <testResource>
    +        <directory>${project.basedir}/src/test/conf</directory>
    +        <includes>
    +          <include>**/*</include>
    +        </includes>
    +      </testResource>
    +    </testResources>
    +    <plugins>
    +      <plugin>
    +        <groupId>org.apache.maven.plugins</groupId>
    +        <artifactId>maven-surefire-plugin</artifactId>
    +        <version>2.4.2</version>
    +        <configuration>
    +          <skipTests>true</skipTests>
    +        </configuration>
    +      </plugin>
    +      <plugin>
    +        <groupId>org.codehaus.mojo</groupId>
    +        <artifactId>build-helper-maven-plugin</artifactId>
    +        <version>${build-helper-maven-plugin.version}</version>
    +        <executions>
    +          <execution>
    +            <phase>generate-sources</phase>
    +            <goals>
    +              <goal>add-source</goal>
    +            </goals>
    +            <configuration>
    +              <sources>
    +                <source>src/examples/java</source>
    +              </sources>
    +            </configuration>
    +          </execution>
    +        </executions>
    +      </plugin>
    +    </plugins>
    +  </build>
    +
    +  <dependencies>
    +    <!-- Gora Internal Dependencies -->
    +    <dependency>
    +      <groupId>org.apache.gora</groupId>
    +      <artifactId>gora-core</artifactId>
    +    </dependency>
    +
    +    <dependency>
    +      <groupId>org.apache.gora</groupId>
    +      <artifactId>gora-core</artifactId>
    +      <type>test-jar</type>
    +      <scope>test</scope>
    +    </dependency>
    +
    +    <!--Aerospike Dependency -->
    +    <dependency>
    +      <groupId>com.aerospike</groupId>
    +      <artifactId>aerospike-client</artifactId>
    +      <version>${aerospike.version}</version>
    +    </dependency>
    +
    +    <dependency>
    +      <groupId>org.apache.avro</groupId>
    +      <artifactId>avro</artifactId>
    +    </dependency>
    +
    +    <!-- Hadoop Dependencies -->
    +    <dependency>
    +      <groupId>org.apache.hadoop</groupId>
    +      <artifactId>hadoop-client</artifactId>
    +    </dependency>
    +
    +    <dependency>
    +      <groupId>org.jdom</groupId>
    +      <artifactId>jdom</artifactId>
    +      <scope>compile</scope>
    +    </dependency>
    +
    +    <!-- Logging Dependencies -->
    +    <dependency>
    +      <groupId>org.slf4j</groupId>
    +      <artifactId>slf4j-log4j12</artifactId>
    +    </dependency>
    +
    +    <!-- Testing Dependencies -->
    +    <dependency>
    +      <groupId>org.testcontainers</groupId>
    +      <artifactId>testcontainers</artifactId>
    +      <version>1.1.0</version>
    +      <scope>test</scope>
    --- End diff --
    
    Please define the version separately in parent pom.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by lewismc <gi...@git.apache.org>.
Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r122997087
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeMappingBuilder.java ---
    @@ -0,0 +1,255 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.gora.aerospike.store;
    +
    +import com.aerospike.client.policy.GenerationPolicy;
    +import com.aerospike.client.policy.Policy;
    +import com.aerospike.client.policy.RecordExistsAction;
    +import com.aerospike.client.policy.WritePolicy;
    +import org.jdom.Document;
    +import org.jdom.Element;
    +import org.jdom.input.SAXBuilder;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.jdom.JDOMException;
    +import javax.naming.ConfigurationException;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.util.List;
    +import java.util.Locale;
    +import java.util.Map;
    +import java.util.HashMap;
    +
    +public class AerospikeMappingBuilder {
    +
    +  public static final Logger LOG = LoggerFactory.getLogger(AerospikeMappingBuilder.class);
    +
    +  private AerospikeMapping aerospikeMapping;
    +
    +  public AerospikeMappingBuilder() throws IOException {
    +    this.aerospikeMapping = new AerospikeMapping();
    +  }
    +
    +  public AerospikeMapping getAerospikeMapping() {
    +    return this.aerospikeMapping;
    +  }
    +
    +  public void readMappingFile(String mappingFile, Class<?> keyClass, Class<?> persistentClass)
    +          throws IOException, JDOMException, ConfigurationException {
    +
    +    SAXBuilder saxBuilder = new SAXBuilder();
    +    InputStream inputStream = getClass().getClassLoader().getResourceAsStream(mappingFile);
    +    if (inputStream == null) {
    +      LOG.warn("Mapping file '" + mappingFile + "' could not be found!");
    +      throw new IOException("Mapping file '" + mappingFile + "' could not be found!");
    +    }
    +    Document document = saxBuilder.build(inputStream);
    +    if (document == null) {
    +      LOG.warn("Mapping file '" + mappingFile + "' could not be found!");
    --- End diff --
    
    Please use parameterized logging.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124165578
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeMappingBuilder.java ---
    @@ -0,0 +1,303 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.gora.aerospike.store;
    +
    +import com.aerospike.client.policy.GenerationPolicy;
    +import com.aerospike.client.policy.Policy;
    +import com.aerospike.client.policy.RecordExistsAction;
    +import com.aerospike.client.policy.WritePolicy;
    +import org.jdom.Document;
    +import org.jdom.Element;
    +import org.jdom.input.SAXBuilder;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.jdom.JDOMException;
    +
    +import javax.naming.ConfigurationException;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.util.List;
    +import java.util.Locale;
    +import java.util.Map;
    +import java.util.HashMap;
    +
    +public class AerospikeMappingBuilder {
    +
    +  private static final Logger LOG = LoggerFactory.getLogger(AerospikeMappingBuilder.class);
    +
    +  private AerospikeMapping aerospikeMapping;
    +
    +  public AerospikeMappingBuilder() {
    +    this.aerospikeMapping = new AerospikeMapping();
    +  }
    +
    +  public AerospikeMapping getAerospikeMapping() {
    +    return this.aerospikeMapping;
    +  }
    +
    +  /**
    +   * Reads the gora aerospike mapping file
    +   *
    +   * @param mappingFile     mapping file path
    +   * @param keyClass        key class
    +   * @param persistentClass persistent class
    +   */
    +  public void readMappingFile(String mappingFile, Class<?> keyClass, Class<?> persistentClass) {
    +
    +    try {
    +      SAXBuilder saxBuilder = new SAXBuilder();
    +      InputStream inputStream = getClass().getClassLoader().getResourceAsStream(mappingFile);
    +      if (inputStream == null) {
    +        LOG.error("Mapping file '{}' could not be found!", mappingFile);
    +        throw new IOException("Mapping file '" + mappingFile + "' could not be found!");
    +      }
    +      Document document = saxBuilder.build(inputStream);
    +      if (document == null) {
    +        LOG.error("Mapping file '{}' could not be found!", mappingFile);
    +        throw new IOException("Mapping file '" + mappingFile + "' could not be found!");
    +      }
    +
    +      Element root = document.getRootElement();
    +
    +      List<Element> policyElements = root.getChildren("policy");
    +
    +      for (Element policyElement : policyElements) {
    +
    +        String policy = policyElement.getAttributeValue("name");
    +        if (policy != null) {
    +          if (policy.equals("write")) {
    --- End diff --
    
    Is there an enum for such policies?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora issue #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by nishadi <gi...@git.apache.org>.
Github user nishadi commented on the issue:

    https://github.com/apache/gora/pull/111
  
    @lewismc  @djkevincr  Thank you for reviewing. Updated the code base as per the given feedback :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by djkevincr <gi...@git.apache.org>.
Github user djkevincr commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r129876180
  
    --- Diff: gora-aerospike/pom.xml ---
    @@ -71,6 +71,14 @@
         </testResources>
         <plugins>
           <plugin>
    +        <groupId>org.apache.maven.plugins</groupId>
    +        <artifactId>maven-surefire-plugin</artifactId>
    +        <version>2.4.2</version>
    +        <configuration>
    +          <skipTests>true</skipTests>
    --- End diff --
    
    @lewismc Shall I proceed merging the PR to master? Are you done with reviewing/happy with the changes?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by nishadi <gi...@git.apache.org>.
Github user nishadi commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124719586
  
    --- Diff: gora-aerospike/src/test/java/org/apache/gora/aerospike/GoraAerospikeTestDriver.java ---
    @@ -0,0 +1,78 @@
    +/*
    + * 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.aerospike;
    +
    +import org.apache.gora.GoraTestDriver;
    +import org.apache.gora.aerospike.store.AerospikeStore;
    +import org.apache.gora.persistency.Persistent;
    +import org.apache.gora.store.DataStore;
    +import org.apache.gora.store.DataStoreFactory;
    +import org.apache.gora.util.GoraException;
    +import org.testcontainers.containers.GenericContainer;
    +
    +import java.util.Properties;
    +
    +/**
    + * Helper class for third part tests using gora-aerospike backend.
    + * @see GoraTestDriver
    + */
    +public class GoraAerospikeTestDriver extends GoraTestDriver {
    +
    +  private GenericContainer aerospikeContainer;
    +  private Properties properties = DataStoreFactory.createProps();
    +
    +  public GoraAerospikeTestDriver(GenericContainer aerospikeContainer) {
    +    super(AerospikeStore.class);
    +    this.aerospikeContainer = aerospikeContainer;
    +  }
    +
    +  @Override
    +  public void setUpClass() throws Exception {
    +
    +    // Wait for the aerospike server to be started in the container
    +    Thread.sleep(5000);
    +
    +    properties.setProperty("server.ip", "localhost");
    +    properties.setProperty("server.port", aerospikeContainer.getMappedPort(3000).toString());
    +  }
    +
    +  @Override
    +  public void tearDownClass() throws Exception {
    +  }
    +
    +  /**
    +   * Instantiate a new {@link DataStore}. Uses 'null' schema.
    +   *
    +   * @param keyClass The key class.
    +   * @param persistentClass The value class.
    +   * @return A new store instance.
    +   * @throws GoraException
    --- End diff --
    
    Added the exception description



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: GORA-502 Implement Aerospike Data Store

Posted by renato2099 <gi...@git.apache.org>.
Github user renato2099 commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r129933133
  
    --- Diff: gora-aerospike/pom.xml ---
    @@ -71,6 +71,14 @@
         </testResources>
         <plugins>
           <plugin>
    +        <groupId>org.apache.maven.plugins</groupId>
    +        <artifactId>maven-surefire-plugin</artifactId>
    +        <version>2.4.2</version>
    +        <configuration>
    +          <skipTests>true</skipTests>
    --- End diff --
    
    I am happy with this +1 from me


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora issue #111: GORA-502 Implement Aerospike Data Store

Posted by djkevincr <gi...@git.apache.org>.
Github user djkevincr commented on the issue:

    https://github.com/apache/gora/pull/111
  
    +1


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124160109
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeMappingBuilder.java ---
    @@ -0,0 +1,303 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.gora.aerospike.store;
    +
    +import com.aerospike.client.policy.GenerationPolicy;
    +import com.aerospike.client.policy.Policy;
    +import com.aerospike.client.policy.RecordExistsAction;
    +import com.aerospike.client.policy.WritePolicy;
    +import org.jdom.Document;
    +import org.jdom.Element;
    +import org.jdom.input.SAXBuilder;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.jdom.JDOMException;
    +
    +import javax.naming.ConfigurationException;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.util.List;
    +import java.util.Locale;
    +import java.util.Map;
    +import java.util.HashMap;
    +
    +public class AerospikeMappingBuilder {
    +
    +  private static final Logger LOG = LoggerFactory.getLogger(AerospikeMappingBuilder.class);
    +
    +  private AerospikeMapping aerospikeMapping;
    +
    +  public AerospikeMappingBuilder() {
    +    this.aerospikeMapping = new AerospikeMapping();
    +  }
    +
    +  public AerospikeMapping getAerospikeMapping() {
    +    return this.aerospikeMapping;
    +  }
    +
    +  /**
    +   * Reads the gora aerospike mapping file
    +   *
    +   * @param mappingFile     mapping file path
    +   * @param keyClass        key class
    +   * @param persistentClass persistent class
    +   */
    +  public void readMappingFile(String mappingFile, Class<?> keyClass, Class<?> persistentClass) {
    +
    +    try {
    +      SAXBuilder saxBuilder = new SAXBuilder();
    +      InputStream inputStream = getClass().getClassLoader().getResourceAsStream(mappingFile);
    +      if (inputStream == null) {
    +        LOG.error("Mapping file '{}' could not be found!", mappingFile);
    +        throw new IOException("Mapping file '" + mappingFile + "' could not be found!");
    +      }
    +      Document document = saxBuilder.build(inputStream);
    +      if (document == null) {
    +        LOG.error("Mapping file '{}' could not be found!", mappingFile);
    +        throw new IOException("Mapping file '" + mappingFile + "' could not be found!");
    +      }
    +
    +      Element root = document.getRootElement();
    +
    +      List<Element> policyElements = root.getChildren("policy");
    +
    +      for (Element policyElement : policyElements) {
    +
    +        String policy = policyElement.getAttributeValue("name");
    +        if (policy != null) {
    +          if (policy.equals("write")) {
    +            WritePolicy writePolicy = new WritePolicy();
    +            if (policyElement.getAttributeValue("gen") != null)
    --- End diff --
    
    Seems that my comment is not placed when I wrote it. I wrote about that: 
    Could you check this Apple bug: https://www.imperialviolet.org/2014/02/22/applebug.html
    
    Please put curly braces even they are single line of if statements at your PR.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by nishadi <gi...@git.apache.org>.
Github user nishadi commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124718390
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/package-info.java ---
    @@ -0,0 +1,20 @@
    +/**
    --- End diff --
    
    Updated the doc comment


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by nishadi <gi...@git.apache.org>.
Github user nishadi commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124718683
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/package-info.java ---
    @@ -0,0 +1,20 @@
    +/**
    --- End diff --
    
    Updated the doc comment


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora issue #111: GORA-502 Implement Aerospike Data Store

Posted by nishadi <gi...@git.apache.org>.
Github user nishadi commented on the issue:

    https://github.com/apache/gora/pull/111
  
    I have sent the PR on the aerospike client update. Thanks a lot @djkevincr for merging to the master. Thanks a lot to the great the support given. :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by lewismc <gi...@git.apache.org>.
Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r122997802
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeStore.java ---
    @@ -0,0 +1,169 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.gora.aerospike.store;
    +
    +import java.io.IOException;
    +import java.util.List;
    +import java.util.Properties;
    +
    +import com.aerospike.client.*;
    --- End diff --
    
    Remove wildcard imports please. Use explicit imports. Thank you.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by djkevincr <gi...@git.apache.org>.
Github user djkevincr commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124040382
  
    --- Diff: gora-aerospike/pom.xml ---
    @@ -0,0 +1,153 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<!--
    +  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.
    +-->
    +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    +  <modelVersion>4.0.0</modelVersion>
    +
    +  <parent>
    +    <groupId>org.apache.gora</groupId>
    +    <artifactId>gora</artifactId>
    +    <version>0.8-SNAPSHOT</version>
    +    <relativePath>../</relativePath>
    +  </parent>
    +  <artifactId>gora-aerospike</artifactId>
    +  <packaging>bundle</packaging>
    +
    +  <name>Apache Gora :: Aerospike</name>
    +  <url>http://gora.apache.org</url>
    +  <description>The Apache Gora open source framework provides an in-memory data model and
    +    persistence for big data. Gora supports persisting to column stores, key value stores,
    +    document stores and RDBMSs, and analyzing the data with extensive Apache Hadoop MapReduce
    +    support.</description>
    +  <inceptionYear>2010</inceptionYear>
    +  <organization>
    +    <name>The Apache Software Foundation</name>
    +    <url>http://www.apache.org/</url>
    +  </organization>
    +  <issueManagement>
    +    <system>JIRA</system>
    +    <url>https://issues.apache.org/jira/browse/GORA</url>
    +  </issueManagement>
    +  <ciManagement>
    +    <system>Jenkins</system>
    +    <url>https://builds.apache.org/job/Gora-trunk/</url>
    +  </ciManagement>
    +
    +  <properties>
    +    <osgi.import>*</osgi.import>
    +    <osgi.export>org.apache.gora.aerospike*;version="${project.version}";-noimport:=true</osgi.export>
    +  </properties>
    +
    +  <build>
    +    <directory>target</directory>
    +    <outputDirectory>target/classes</outputDirectory>
    +    <finalName>${project.artifactId}-${project.version}</finalName>
    +    <testOutputDirectory>target/test-classes</testOutputDirectory>
    +    <testSourceDirectory>src/test/java</testSourceDirectory>
    +    <sourceDirectory>src/main/java</sourceDirectory>
    +    <testResources>
    +      <testResource>
    +        <directory>${project.basedir}/src/test/conf</directory>
    +        <includes>
    +          <include>**/*</include>
    +        </includes>
    +      </testResource>
    +    </testResources>
    +    <plugins>
    +      <plugin>
    +        <groupId>org.codehaus.mojo</groupId>
    +        <artifactId>build-helper-maven-plugin</artifactId>
    +        <version>${build-helper-maven-plugin.version}</version>
    +        <executions>
    +          <execution>
    +            <phase>generate-sources</phase>
    +            <goals>
    +              <goal>add-source</goal>
    +            </goals>
    +            <configuration>
    +              <sources>
    +                <source>src/examples/java</source>
    +              </sources>
    +            </configuration>
    +          </execution>
    +        </executions>
    +      </plugin>
    +    </plugins>
    +  </build>
    +
    +  <dependencies>
    +    <!-- Gora Internal Dependencies -->
    +    <dependency>
    +      <groupId>org.apache.gora</groupId>
    +      <artifactId>gora-core</artifactId>
    +    </dependency>
    +
    +    <dependency>
    +      <groupId>org.apache.gora</groupId>
    +      <artifactId>gora-core</artifactId>
    +      <type>test-jar</type>
    +      <scope>test</scope>
    +    </dependency>
    +
    +    <!--Aerospike Dependency -->
    +    <dependency>
    +      <groupId>com.aerospike</groupId>
    +      <artifactId>aerospike-client</artifactId>
    +      <version>${aerospike.version}</version>
    +    </dependency>
    +
    +    <dependency>
    +      <groupId>org.apache.avro</groupId>
    +      <artifactId>avro</artifactId>
    +    </dependency>
    +
    +    <!-- Hadoop Dependencies -->
    +    <dependency>
    +      <groupId>org.apache.hadoop</groupId>
    +      <artifactId>hadoop-client</artifactId>
    +    </dependency>
    +
    +    <dependency>
    +      <groupId>org.jdom</groupId>
    +      <artifactId>jdom</artifactId>
    +      <scope>compile</scope>
    +    </dependency>
    +
    +    <!-- Logging Dependencies -->
    +    <dependency>
    +      <groupId>org.slf4j</groupId>
    +      <artifactId>slf4j-log4j12</artifactId>
    +    </dependency>
    +
    +    <!-- Testing Dependencies -->
    +    <dependency>
    +      <groupId>junit</groupId>
    +      <artifactId>junit</artifactId>
    +    </dependency>
    +
    +    <dependency>
    --- End diff --
    
    Move this dependency to parent pom and define version separately. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora issue #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by djkevincr <gi...@git.apache.org>.
Github user djkevincr commented on the issue:

    https://github.com/apache/gora/pull/111
  
    @nishadi  very good work, heading in right direction :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124168409
  
    --- Diff: gora-aerospike/src/test/java/org/apache/gora/aerospike/GoraAerospikeTestDriver.java ---
    @@ -0,0 +1,78 @@
    +/*
    + * 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.aerospike;
    +
    +import org.apache.gora.GoraTestDriver;
    +import org.apache.gora.aerospike.store.AerospikeStore;
    +import org.apache.gora.persistency.Persistent;
    +import org.apache.gora.store.DataStore;
    +import org.apache.gora.store.DataStoreFactory;
    +import org.apache.gora.util.GoraException;
    +import org.testcontainers.containers.GenericContainer;
    +
    +import java.util.Properties;
    +
    +/**
    + * Helper class for third part tests using gora-aerospike backend.
    + * @see GoraTestDriver
    + */
    +public class GoraAerospikeTestDriver extends GoraTestDriver {
    +
    +  private GenericContainer aerospikeContainer;
    +  private Properties properties = DataStoreFactory.createProps();
    +
    +  public GoraAerospikeTestDriver(GenericContainer aerospikeContainer) {
    +    super(AerospikeStore.class);
    +    this.aerospikeContainer = aerospikeContainer;
    +  }
    +
    +  @Override
    +  public void setUpClass() throws Exception {
    +
    +    // Wait for the aerospike server to be started in the container
    +    Thread.sleep(5000);
    --- End diff --
    
    Can we check this condition with a framework like Awaitility?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by nishadi <gi...@git.apache.org>.
Github user nishadi commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124072360
  
    --- Diff: pom.xml ---
    @@ -932,6 +934,11 @@
             <version>${project.version}</version>
             <type>test-jar</type>
           </dependency>
    +      <dependency>
    +        <groupId>org.apache.gora</groupId>
    +        <artifactId>gora-aerospike</artifactId>
    +        <version>${project.version}</version>
    +      </dependency>
    --- End diff --
    
    Added the test artifact


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by nishadi <gi...@git.apache.org>.
Github user nishadi commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124718526
  
    --- Diff: gora-aerospike/src/test/java/org/apache/gora/aerospike/GoraAerospikeTestDriver.java ---
    @@ -0,0 +1,78 @@
    +/*
    + * 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.aerospike;
    +
    +import org.apache.gora.GoraTestDriver;
    +import org.apache.gora.aerospike.store.AerospikeStore;
    +import org.apache.gora.persistency.Persistent;
    +import org.apache.gora.store.DataStore;
    +import org.apache.gora.store.DataStoreFactory;
    +import org.apache.gora.util.GoraException;
    +import org.testcontainers.containers.GenericContainer;
    +
    +import java.util.Properties;
    +
    +/**
    + * Helper class for third part tests using gora-aerospike backend.
    + * @see GoraTestDriver
    + */
    +public class GoraAerospikeTestDriver extends GoraTestDriver {
    +
    +  private GenericContainer aerospikeContainer;
    +  private Properties properties = DataStoreFactory.createProps();
    +
    +  public GoraAerospikeTestDriver(GenericContainer aerospikeContainer) {
    +    super(AerospikeStore.class);
    +    this.aerospikeContainer = aerospikeContainer;
    +  }
    +
    +  @Override
    +  public void setUpClass() throws Exception {
    +
    +    // Wait for the aerospike server to be started in the container
    +    Thread.sleep(5000);
    --- End diff --
    
    I will check for a method to find out whether the server has been started in the docker container, so that we can use this framework in waiting for the status of the server


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by lewismc <gi...@git.apache.org>.
Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r122997020
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/store/AerospikeMappingBuilder.java ---
    @@ -0,0 +1,255 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.gora.aerospike.store;
    +
    +import com.aerospike.client.policy.GenerationPolicy;
    +import com.aerospike.client.policy.Policy;
    +import com.aerospike.client.policy.RecordExistsAction;
    +import com.aerospike.client.policy.WritePolicy;
    +import org.jdom.Document;
    +import org.jdom.Element;
    +import org.jdom.input.SAXBuilder;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.jdom.JDOMException;
    +import javax.naming.ConfigurationException;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.util.List;
    +import java.util.Locale;
    +import java.util.Map;
    +import java.util.HashMap;
    +
    +public class AerospikeMappingBuilder {
    +
    +  public static final Logger LOG = LoggerFactory.getLogger(AerospikeMappingBuilder.class);
    +
    +  private AerospikeMapping aerospikeMapping;
    +
    +  public AerospikeMappingBuilder() throws IOException {
    +    this.aerospikeMapping = new AerospikeMapping();
    +  }
    +
    +  public AerospikeMapping getAerospikeMapping() {
    +    return this.aerospikeMapping;
    +  }
    +
    +  public void readMappingFile(String mappingFile, Class<?> keyClass, Class<?> persistentClass)
    +          throws IOException, JDOMException, ConfigurationException {
    +
    +    SAXBuilder saxBuilder = new SAXBuilder();
    +    InputStream inputStream = getClass().getClassLoader().getResourceAsStream(mappingFile);
    +    if (inputStream == null) {
    +      LOG.warn("Mapping file '" + mappingFile + "' could not be found!");
    --- End diff --
    
    Please use parameterized logging.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store

Posted by kamaci <gi...@git.apache.org>.
Github user kamaci commented on a diff in the pull request:

    https://github.com/apache/gora/pull/111#discussion_r124163124
  
    --- Diff: gora-aerospike/src/main/java/org/apache/gora/aerospike/package-info.java ---
    @@ -0,0 +1,20 @@
    +/**
    --- End diff --
    
    /** -> /*


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] gora issue #111: GORA-502 Implement Aerospike Data Store

Posted by lewismc <gi...@git.apache.org>.
Github user lewismc commented on the issue:

    https://github.com/apache/gora/pull/111
  
    Can you guys possibly upgrade aerospike-client to most recent?
    http://search.maven.org/#artifactdetails|com.aerospike|aerospike-client|4.0.6|jar


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---