gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lewi...@apache.org
Subject svn commit: r1444435 - in /gora/trunk: 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 Sat, 09 Feb 2013 21:12:20 GMT
Author: lewismc
Date: Sat Feb  9 21:12:19 2013
New Revision: 1444435

URL: http://svn.apache.org/r1444435
Log:
GORA-169 Implement correct logging for KeySpaces and attributes in CassandraMappingManager

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

Modified: gora/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/gora/trunk/CHANGES.txt?rev=1444435&r1=1444434&r2=1444435&view=diff
==============================================================================
--- gora/trunk/CHANGES.txt (original)
+++ gora/trunk/CHANGES.txt Sat Feb  9 21:12:19 2013
@@ -6,6 +6,8 @@ Gora Change Log
 
 trunk (current development)
 
+* GORA-169 Implement correct logging for KeySpaces and attributes in CassandraMappingManager
(lewismc)
+
 * GORA-27 Optionally add license headers to generated files (lewismc + rmarroquin)
 
 * GORA-181 Replace tab characters with correct Gora coding style (rmarroquin)

Modified: gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMapping.java
URL: http://svn.apache.org/viewvc/gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMapping.java?rev=1444435&r1=1444434&r2=1444435&view=diff
==============================================================================
--- gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMapping.java
(original)
+++ gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMapping.java
Sat Feb  9 21:12:19 2013
@@ -18,7 +18,6 @@
 
 package org.apache.gora.cassandra.store;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -30,10 +29,7 @@ import me.prettyprint.hector.api.ddl.Col
 import me.prettyprint.hector.api.ddl.ColumnType;
 import me.prettyprint.hector.api.ddl.ComparatorType;
 
-import org.jdom.Document;
 import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,10 +37,7 @@ public class CassandraMapping {
   
   public static final Logger LOG = LoggerFactory.getLogger(CassandraMapping.class);
   
-  private static final String MAPPING_FILE = "gora-cassandra-mapping.xml";
-  private static final String KEYSPACE_ELEMENT = "keyspace";
   private static final String NAME_ATTRIBUTE = "name";
-  private static final String MAPPING_ELEMENT = "class";
   private static final String COLUMN_ATTRIBUTE = "qualifier";
   private static final String FAMILY_ATTRIBUTE = "family";
   private static final String SUPER_ATTRIBUTE = "type";
@@ -108,30 +101,31 @@ public class CassandraMapping {
   /**
    * Primary class for loading Cassandra configuration from the 'MAPPING_FILE'.
    */
+  @SuppressWarnings("unchecked")
   public CassandraMapping(Element keyspace, Element mapping) {
     if (keyspace == null) {
     	LOG.error("Keyspace element should not be null!");
         return;
     } else {
-    	// LOG.info("Located Cassandra Keyspace: '" + KEYSPACE_ELEMENT + "'");
+      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.info("Located Cassandra Keyspace name: '" + NAME_ATTRIBUTE + "' -> " + keyspaceName);
+      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.info("Located Cassandra Keyspace cluster: '" + CLUSTER_ATTRIBUTE + "' -> "
+ clusterName);
+      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.info("Located Cassandra Keyspace host: '" + HOST_ATTRIBUTE + "' -> " + hostName);
+      LOG.debug("Located Cassandra Keyspace host: '" + hostName + "'");
     }
     
     // load column family definitions
@@ -144,13 +138,13 @@ public class CassandraMapping {
       	LOG.error("Error locating column family name attribute!");
       	continue;
       } else {
-      	// LOG.info("Located column family name: '" + NAME_ATTRIBUTE + "' -> " + familyName);
+        LOG.debug("Located column family: '" + familyName + "'" );
       }
       String superAttribute = element.getAttributeValue(SUPER_ATTRIBUTE);
       if (superAttribute != null) {
-    	// LOG.info("Located super column family");
+      LOG.debug("Located super column family");
         this.superFamilies.add(familyName);
-        // LOG.info("Added super column family: '" + familyName + "'");
+        LOG.debug("Added super column family: '" + familyName + "'");
         cfDef.setColumnType(ColumnType.SUPER);
         cfDef.setSubComparatorType(ComparatorType.BYTESTYPE);
       }

Modified: gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMappingManager.java
URL: http://svn.apache.org/viewvc/gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMappingManager.java?rev=1444435&r1=1444434&r2=1444435&view=diff
==============================================================================
--- gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMappingManager.java
(original)
+++ gora/trunk/gora-cassandra/src/main/java/org/apache/gora/cassandra/store/CassandraMappingManager.java
Sat Feb  9 21:12:19 2013
@@ -19,17 +19,10 @@
 package org.apache.gora.cassandra.store;
 
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import me.prettyprint.cassandra.model.BasicColumnFamilyDefinition;
-import me.prettyprint.cassandra.service.ThriftCfDef;
-import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition;
-import me.prettyprint.hector.api.ddl.ColumnType;
-import me.prettyprint.hector.api.ddl.ComparatorType;
-
 import org.jdom.Document;
 import org.jdom.Element;
 import org.jdom.JDOMException;
@@ -45,12 +38,9 @@ public class CassandraMappingManager {
   private static final String KEYSPACE_ELEMENT = "keyspace";
   private static final String NAME_ATTRIBUTE = "name";
   private static final String MAPPING_ELEMENT = "class";
-  private static final String COLUMN_ATTRIBUTE = "qualifier";
-  private static final String FAMILY_ATTRIBUTE = "family";
-  private static final String SUPER_ATTRIBUTE = "type";
-  private static final String CLUSTER_ATTRIBUTE = "cluster";
+  private static final String KEYCLASS_ATTRIBUTE = "keyClass";
   private static final String HOST_ATTRIBUTE = "host";
-
+  private static final String CLUSTER_ATTRIBUTE = "cluster";
   // singleton
   private static CassandraMappingManager manager = new CassandraMappingManager();
 
@@ -76,7 +66,7 @@ public class CassandraMappingManager {
     }
   }
 
-  public CassandraMapping get(Class persistentClass) {
+  public CassandraMapping get(Class<?> persistentClass) {
     String className = persistentClass.getName();
     Element mappingElement = mappingMap.get(className);
     if (mappingElement == null) {
@@ -84,7 +74,7 @@ public class CassandraMappingManager {
       return null;
     }
     String keyspaceName = mappingElement.getAttributeValue(KEYSPACE_ELEMENT);
-    // LOG.info("className=" + className + " -> keyspaceName=" + keyspaceName);
+      LOG.debug("className=" + className + " -> keyspaceName=" + keyspaceName);
     Element keyspaceElement = keyspaceMap.get(keyspaceName);
     if (keyspaceElement == null) {
       LOG.error("Keyspace element does not exist for keyspaceName=" + keyspaceName);
@@ -102,26 +92,28 @@ public class CassandraMappingManager {
   @SuppressWarnings("unchecked")
   public void loadConfiguration() throws JDOMException, IOException {
     SAXBuilder saxBuilder = new SAXBuilder();
+    // get mapping file
     Document document = saxBuilder.build(getClass().getClassLoader().getResourceAsStream(MAPPING_FILE));
     if (document == null) {
       LOG.warn("Mapping file '" + MAPPING_FILE + "' could not be found!");
     }
     Element root = document.getRootElement();
-    
+    // find cassandra keyspace element
     List<Element> keyspaces = root.getChildren(KEYSPACE_ELEMENT);
     if (keyspaces == null || keyspaces.size() == 0) {
       LOG.error("Error locating Cassandra Keyspace element!");
     }
     else {
-      // LOG.info("Located Cassandra Keyspace: '" + KEYSPACE_ELEMENT + "'");
       for (Element keyspace : keyspaces) {
+        // log name, cluster and host for given keyspace(s)
         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
+ 
+          "' on host '" + hostName + "'.");
         if (keyspaceName == null) {
-    	    LOG.error("Error locating Cassandra Keyspace name attribute!");
-    	    continue;
-        }
-        else {
-    	    // LOG.info("Located Cassandra Keyspace name: '" + NAME_ATTRIBUTE + "' -> " +
keyspaceName);
+          LOG.error("Error locating Cassandra Keyspace name attribute!");
+          continue;
         }
         keyspaceMap.put(keyspaceName, keyspace);
       }
@@ -133,15 +125,16 @@ public class CassandraMappingManager {
       LOG.error("Error locating Cassandra Mapping class element!");
     }
     else {
-      // LOG.info("Located Cassandra Mapping: '" + MAPPING_ELEMENT + "'");
       for (Element mapping : mappings) {
+        // associate persistent and class names for keyspace(s)
         String className = mapping.getAttributeValue(NAME_ATTRIBUTE);
+        String keyClassName = mapping.getAttributeValue(KEYCLASS_ATTRIBUTE);
+        String keyspaceName = mapping.getAttributeValue(KEYSPACE_ELEMENT);
+        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;
-        }
-        else {
-    	    // LOG.info("Located Cassandra Mapping class name: '" + NAME_ATTRIBUTE + "' ->
" + className);
+          LOG.error("Error locating Cassandra Mapping class name attribute!");
+          continue;
         }
         mappingMap.put(className, mapping);
       }



Mime
View raw message