gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lewi...@apache.org
Subject svn commit: r1462580 - in /gora/branches/GORA_174: CHANGES.txt gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMapping.java gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMappingManager.java
Date Fri, 29 Mar 2013 18:31:25 GMT
Author: lewismc
Date: Fri Mar 29 18:31:25 2013
New Revision: 1462580

URL: http://svn.apache.org/r1462580
Log:
GORA-203 Bug in setting column field attribute qualifier in CassandraMapping

Modified:
    gora/branches/GORA_174/CHANGES.txt
    gora/branches/GORA_174/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMapping.java
    gora/branches/GORA_174/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMappingManager.java

Modified: gora/branches/GORA_174/CHANGES.txt
URL: http://svn.apache.org/viewvc/gora/branches/GORA_174/CHANGES.txt?rev=1462580&r1=1462579&r2=1462580&view=diff
==============================================================================
--- gora/branches/GORA_174/CHANGES.txt (original)
+++ gora/branches/GORA_174/CHANGES.txt Fri Mar 29 18:31:25 2013
@@ -6,6 +6,10 @@ Gora Change Log
 
 trunk (current development)
 
+* GORA-203 Bug in setting column field attribute "qualifier" in CassandraMapping (rmarroquin,
lewismc, kazk)
+
+* GORA-221 fix Cassandra configuration in gora-tutorial (lewismc)
+
 * GORA-211 thread safety: fix java.lang.NullPointerException - synchronize on mutator (rherget)
 
 * GORA-210 thread safety: fix java.util.ConcurrentModificationException (rherget)

Modified: gora/branches/GORA_174/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMapping.java
URL: http://svn.apache.org/viewvc/gora/branches/GORA_174/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMapping.java?rev=1462580&r1=1462579&r2=1462580&view=diff
==============================================================================
--- gora/branches/GORA_174/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMapping.java
(original)
+++ gora/branches/GORA_174/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMapping.java
Fri Mar 29 18:31:25 2013
@@ -100,32 +100,44 @@ public class CassandraMapping {
 
   /**
    * Primary class for loading Cassandra configuration from the 'MAPPING_FILE'.
+   * It should be noted that should the "qualifier" attribute and its associated
+   * value be absent from class field definition, it will automatically be set to 
+   * the field name value.
+   * 
    */
   @SuppressWarnings("unchecked")
   public CassandraMapping(Element keyspace, Element mapping) {
     if (keyspace == null) {
-    	LOG.error("Keyspace element should not be null!");
-        return;
+      LOG.error("Keyspace element should not be null!");
+      return;
     } else {
-      LOG.debug("Located Cassandra Keyspace");
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Located Cassandra Keyspace");
+      }
     }
     this.keyspaceName = keyspace.getAttributeValue(NAME_ATTRIBUTE);
     if (this.keyspaceName == null) {
     	LOG.error("Error locating Cassandra Keyspace name attribute!");
     } else {
-      LOG.debug("Located Cassandra Keyspace name: '" + keyspaceName + "'");
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Located Cassandra Keyspace name: '" + keyspaceName + "'");
+      }
     }
     this.clusterName = keyspace.getAttributeValue(CLUSTER_ATTRIBUTE);
     if (this.clusterName == null) {
     	LOG.error("Error locating Cassandra Keyspace cluster attribute!");
     } else {
-      LOG.debug("Located Cassandra Keyspace cluster: '" + clusterName + "'");
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Located Cassandra Keyspace cluster: '" + clusterName + "'");
+      }
     }
     this.hostName = keyspace.getAttributeValue(HOST_ATTRIBUTE);
     if (this.hostName == null) {
     	LOG.error("Error locating Cassandra Keyspace host attribute!");
     } else {
-      LOG.debug("Located Cassandra Keyspace host: '" + hostName + "'");
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Located Cassandra Keyspace host: '" + hostName + "'");
+      }  
     }
     
     // load column family definitions
@@ -138,13 +150,19 @@ public class CassandraMapping {
       	LOG.error("Error locating column family name attribute!");
       	continue;
       } else {
-        LOG.debug("Located column family: '" + familyName + "'" );
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Located column family: '" + familyName + "'" );
+        }
       }
       String superAttribute = element.getAttributeValue(SUPER_ATTRIBUTE);
       if (superAttribute != null) {
-      LOG.debug("Located super column family");
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Located super column family");
+        }
         this.superFamilies.add(familyName);
-        LOG.debug("Added super column family: '" + familyName + "'");
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Added super column family: '" + familyName + "'");
+        }
         cfDef.setColumnType(ColumnType.SUPER);
         cfDef.setSubComparatorType(ComparatorType.BYTESTYPE);
       }
@@ -164,6 +182,19 @@ public class CassandraMapping {
       String fieldName = element.getAttributeValue(NAME_ATTRIBUTE);
       String familyName = element.getAttributeValue(FAMILY_ATTRIBUTE);
       String columnName = element.getAttributeValue(COLUMN_ATTRIBUTE);
+      if (fieldName == null) {
+       LOG.error("Field name is not declared.");
+        continue;
+      }
+      if (familyName == null) {
+        LOG.error("Family name is not declared for \"" + fieldName + "\" field.");
+        continue;
+      }
+      if (columnName == null) {
+        LOG.warn("Column name (qualifier) is not declared for \"" + fieldName + "\" field.");
+        columnName = fieldName;
+      }
+
       BasicColumnFamilyDefinition columnFamilyDefinition = this.columnFamilyDefinitions.get(familyName);
       if (columnFamilyDefinition == null) {
         LOG.warn("Family " + familyName + " was not declared in the keyspace.");

Modified: gora/branches/GORA_174/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMappingManager.java
URL: http://svn.apache.org/viewvc/gora/branches/GORA_174/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMappingManager.java?rev=1462580&r1=1462579&r2=1462580&view=diff
==============================================================================
--- gora/branches/GORA_174/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMappingManager.java
(original)
+++ gora/branches/GORA_174/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMappingManager.java
Fri Mar 29 18:31:25 2013
@@ -74,7 +74,9 @@ public class CassandraMappingManager {
       return null;
     }
     String keyspaceName = mappingElement.getAttributeValue(KEYSPACE_ELEMENT);
+    if (LOG.isDebugEnabled()) {
       LOG.debug("className=" + className + " -> keyspaceName=" + keyspaceName);
+    }
     Element keyspaceElement = keyspaceMap.get(keyspaceName);
     if (keyspaceElement == null) {
       LOG.error("Keyspace element does not exist for keyspaceName=" + keyspaceName);
@@ -109,8 +111,10 @@ public class CassandraMappingManager {
         String keyspaceName = keyspace.getAttributeValue(NAME_ATTRIBUTE);
         String clusterName = keyspace.getAttributeValue(CLUSTER_ATTRIBUTE);
         String hostName = keyspace.getAttributeValue(HOST_ATTRIBUTE);
-        LOG.debug("Located Cassandra Keyspace: '" + keyspaceName + "' in cluster '" + clusterName
+ 
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Located Cassandra Keyspace: '" + keyspaceName + "' in cluster '" + clusterName
+ 
           "' on host '" + hostName + "'.");
+        }
         if (keyspaceName == null) {
           LOG.error("Error locating Cassandra Keyspace name attribute!");
           continue;
@@ -130,8 +134,10 @@ public class CassandraMappingManager {
         String className = mapping.getAttributeValue(NAME_ATTRIBUTE);
         String keyClassName = mapping.getAttributeValue(KEYCLASS_ATTRIBUTE);
         String keyspaceName = mapping.getAttributeValue(KEYSPACE_ELEMENT);
+        if (LOG.isDebugEnabled()) {
         LOG.debug("Located Cassandra Mapping: keyClass: '" + keyClassName + "' in storage
class '" 
           + className + "' for Keyspace '" + keyspaceName + "'.");
+        }
         if (className == null) {
           LOG.error("Error locating Cassandra Mapping class name attribute!");
           continue;



Mime
View raw message