Author: [email protected]
Date: Wed Feb 15 14:33:44 2012
New Revision: 2089

Log:
[AMDATUCASSANDRA-160] Fixed by catching NumberFormatException and removing the 
';' from the default config

Modified:
   
trunk/amdatu-cassandra/cassandra-client/src/main/java/org/amdatu/cassandra/client/util/ConfigurationUtil.java
   
trunk/amdatu-cassandra/cassandra-persistencemanager-hector/src/main/java/org/amdatu/cassandra/persistencemanager/hector/util/ConfigurationUtil.java
   
trunk/amdatu-cassandra/config/src/main/resources/org.amdatu.cassandra.persistencemanager.hector.cfg
   
trunk/amdatu-cassandra/config/src/main/resources/org.amdatu.core.cassandra.client.cfg

Modified: 
trunk/amdatu-cassandra/cassandra-client/src/main/java/org/amdatu/cassandra/client/util/ConfigurationUtil.java
==============================================================================
--- 
trunk/amdatu-cassandra/cassandra-client/src/main/java/org/amdatu/cassandra/client/util/ConfigurationUtil.java
       (original)
+++ 
trunk/amdatu-cassandra/cassandra-client/src/main/java/org/amdatu/cassandra/client/util/ConfigurationUtil.java
       Wed Feb 15 14:33:44 2012
@@ -96,7 +96,14 @@
             m_logService.log(LogService.LOG_INFO, msg);
             return defaultValue;
         }
-        return Integer.parseInt(value.toString().trim());
+        try {
+            return Integer.parseInt(value.toString().trim());
+        } catch (NumberFormatException e) {
+            String msg = "Invalid value set for property '" + key + "' ('" + 
value.toString() 
+                            + "'), switching to default value '" + 
defaultValue + "'";
+            m_logService.log(LogService.LOG_ERROR, msg);
+            return defaultValue;
+        }
     }
 
     private long getLongProperty(final String key, final long defaultValue) {
@@ -106,7 +113,14 @@
             m_logService.log(LogService.LOG_INFO, msg);
             return defaultValue;
         }
-        return Long.parseLong(value.toString().trim());
+        try {
+            return Long.parseLong(value.toString().trim());
+        } catch (NumberFormatException e) {
+            String msg = "Invalid value set for property '" + key + "' ('" + 
value.toString() 
+                            + "'), switching to default value '" + 
defaultValue + "'";
+            m_logService.log(LogService.LOG_ERROR, msg);
+            return defaultValue;
+        }
     }
 
     private boolean getBooleanProperty(final String key, final boolean 
defaultValue) {

Modified: 
trunk/amdatu-cassandra/cassandra-persistencemanager-hector/src/main/java/org/amdatu/cassandra/persistencemanager/hector/util/ConfigurationUtil.java
==============================================================================
--- 
trunk/amdatu-cassandra/cassandra-persistencemanager-hector/src/main/java/org/amdatu/cassandra/persistencemanager/hector/util/ConfigurationUtil.java
 (original)
+++ 
trunk/amdatu-cassandra/cassandra-persistencemanager-hector/src/main/java/org/amdatu/cassandra/persistencemanager/hector/util/ConfigurationUtil.java
 Wed Feb 15 14:33:44 2012
@@ -68,6 +68,7 @@
 
     /**
      * Returns a property from the configuration.
+     * 
      * @param key The key of the property to retrieve.
      * @param class The type of the property value to retrieve
      * @return The value of this property as type T
@@ -100,7 +101,15 @@
             m_logService.log(LogService.LOG_INFO, msg);
             return defaultValue;
         }
-        return Integer.parseInt(value.toString().trim());
+        try {
+            return Integer.parseInt(value.toString().trim());
+        }
+        catch (NumberFormatException e) {
+            String msg = "Invalid value set for property '" + key + "' ('" + 
value.toString()
+                + "'), switching to default value '" + defaultValue + "'";
+            m_logService.log(LogService.LOG_ERROR, msg);
+            return defaultValue;
+        }
     }
 
     private long getLongProperty(final String key, final long defaultValue) {
@@ -110,7 +119,15 @@
             m_logService.log(LogService.LOG_INFO, msg);
             return defaultValue;
         }
-        return Long.parseLong(value.toString().trim());
+        try {
+            return Long.parseLong(value.toString().trim());
+        }
+        catch (NumberFormatException e) {
+            String msg = "Invalid value set for property '" + key + "' ('" + 
value.toString()
+                + "'), switching to default value '" + defaultValue + "'";
+            m_logService.log(LogService.LOG_ERROR, msg);
+            return defaultValue;
+        }
     }
 
     private boolean getBooleanProperty(final String key, final boolean 
defaultValue) {
@@ -130,7 +147,7 @@
             m_logService.log(LogService.LOG_INFO, msg);
             return defaultValue;
         }
-        
+
         try {
             return ConsistencyLevel.valueOf(value.toString());
         }

Modified: 
trunk/amdatu-cassandra/config/src/main/resources/org.amdatu.cassandra.persistencemanager.hector.cfg
==============================================================================
--- 
trunk/amdatu-cassandra/config/src/main/resources/org.amdatu.cassandra.persistencemanager.hector.cfg
 (original)
+++ 
trunk/amdatu-cassandra/config/src/main/resources/org.amdatu.cassandra.persistencemanager.hector.cfg
 Wed Feb 15 14:33:44 2012
@@ -44,12 +44,11 @@
 # available host, this prevents concurrent schema modification conflicts.
 hector.hosts=${cassandra.rpc_address}
 
-# The port on which the cassandra hosts are running (all hosts must run on the 
same
-# port)
+# The port on which the cassandra hosts are running (all hosts must run on the 
same port)
 hector.port=${cassandra.rpc_port}
 
 # The maximum size of the Hector connection pool (so maximum amount of open 
connections)
-hector.maxActive = 50;
+hector.maxActive = 50
 
 # The maximum wait time for a succesffull connection to a particular host 
until that
 # host is marked as exhausted. The default value is negative, which means it 
will

Modified: 
trunk/amdatu-cassandra/config/src/main/resources/org.amdatu.core.cassandra.client.cfg
==============================================================================
--- 
trunk/amdatu-cassandra/config/src/main/resources/org.amdatu.core.cassandra.client.cfg
       (original)
+++ 
trunk/amdatu-cassandra/config/src/main/resources/org.amdatu.core.cassandra.client.cfg
       Wed Feb 15 14:33:44 2012
@@ -47,34 +47,6 @@
 # the replication factor upon first boot is always 1, to be increased at 
runtime.
 default_replication_factor=${cassandra.default_replication_factor}
 
-# The read consistency level to apply. The read consistencly level determines 
the
-# amount of nodes in the cluster that must reply on a request for providing 
the latest
-# version of some row before the result is returned. Note that if the read 
consistency
-# level is ALL, all nodes in the cluster are effectively down as soon as one 
node in
-# the cluster goes down, as cassandra will block until it received an answer 
from
-# this (unavailable) node before returning the result.
-consistency_level_read=${cassandra.consistency_level_read}
-
-# The write consistency level to apply. The write consistencly level 
determines the
-# amount of nodes in the cluster that should have received the write request 
operation
-# before the call is returned. Note that if the write consistency level is 
ALL, all
-# nodes in the cluster are effectively down as soon as one node in the cluster 
goes
-# down, as cassandra will block each write operation until this (unavailable) 
node
-# answered.
-consistency_level_write=${cassandra.consistency_level_write}
-
-
-
-
-
-
-
-
-
-
-
-
-
 # All configuration properties below configure the Hector connection manager 
and
 # are input for the me.prettyprint.cassandra.service.CassandraHostConfigurator 
class
 
@@ -85,12 +57,11 @@
 # available host, this prevents concurrent schema modification conflicts.
 hector.hosts=${cassandra.rpc_address}
 
-# The port on which the cassandra hosts are running (all hosts must run on the 
same
-# port)
+# The port on which the cassandra hosts are running (all hosts must run on the 
same port)
 hector.port=${cassandra.rpc_port}
 
 # The maximum size of the Hector connection pool (so maximum amount of open 
connections)
-hector.maxActive = 50;
+hector.maxActive = 50
 
 # The maximum wait time for a succesffull connection to a particular host 
until that
 # host is marked as exhausted. The default value is negative, which means it 
will
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits

Reply via email to