gora-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kamaci <...@git.apache.org>
Subject [GitHub] gora pull request #111: [WIP] GORA-502 Implement Aerospike Data Store
Date Tue, 27 Jun 2017 02:27:41 GMT
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.
---

Mime
View raw message