hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r788513 - in /hadoop/hdfs/trunk: CHANGES.txt src/test/aop/org/apache/hadoop/fi/FiConfig.java src/test/aop/org/apache/hadoop/fi/ProbabilityModel.java
Date Thu, 25 Jun 2009 21:10:54 GMT
Author: szetszwo
Date: Thu Jun 25 21:10:53 2009
New Revision: 788513

URL: http://svn.apache.org/viewvc?rev=788513&view=rev
Log:
HDFS-444. Allow to change probability levels dynamically in the fault injection framework.
 Contributed by Konstantin Boudnik

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/test/aop/org/apache/hadoop/fi/FiConfig.java
    hadoop/hdfs/trunk/src/test/aop/org/apache/hadoop/fi/ProbabilityModel.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=788513&r1=788512&r2=788513&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Thu Jun 25 21:10:53 2009
@@ -15,6 +15,9 @@
     HDFS-396. NameNode image and edits directories are specified as URIs.
     (Luca Telloli via rangadi)
 
+    HDFS-444. Allow to change probability levels dynamically in the fault
+    injection framework.  (Konstantin Boudnik via szetszwo)
+
   BUG FIXES
     HDFS-76. Better error message to users when commands fail because of 
     lack of quota. Allow quota to be set even if the limit is lower than

Modified: hadoop/hdfs/trunk/src/test/aop/org/apache/hadoop/fi/FiConfig.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/aop/org/apache/hadoop/fi/FiConfig.java?rev=788513&r1=788512&r2=788513&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/aop/org/apache/hadoop/fi/FiConfig.java (original)
+++ hadoop/hdfs/trunk/src/test/aop/org/apache/hadoop/fi/FiConfig.java Thu Jun 25 21:10:53
2009
@@ -38,7 +38,6 @@
   protected static void init () {
     if (conf == null) {
       conf = new Configuration(false);
-      System.out.println(System.getProperties());
       String configName = System.getProperty(CONFIG_PARAMETER, DEFAULT_CONFIG);
       conf.addResource(configName);
     }

Modified: hadoop/hdfs/trunk/src/test/aop/org/apache/hadoop/fi/ProbabilityModel.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/aop/org/apache/hadoop/fi/ProbabilityModel.java?rev=788513&r1=788512&r2=788513&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/aop/org/apache/hadoop/fi/ProbabilityModel.java (original)
+++ hadoop/hdfs/trunk/src/test/aop/org/apache/hadoop/fi/ProbabilityModel.java Thu Jun 25 21:10:53
2009
@@ -46,7 +46,8 @@
 
   static final String FPROB_NAME = "fi.";
   private static final String ALL_PROBABILITIES = FPROB_NAME + "*";
-  private static final float DEFAULT_PROB = 0.00f; // Default probability rate is 0%
+  private static final float DEFAULT_PROB = 0.00f; //Default probability is 0%
+  private static final float MAX_PROB = 1.00f; // Max probability is 100%
 
   private static Configuration conf = FiConfig.getConfig();
 
@@ -60,7 +61,14 @@
     LOG.info(ALL_PROBABILITIES + "=" + conf.get(ALL_PROBABILITIES));
   }
 
-  // Simplistic method to check if we have reached the point of injection
+  /**
+   * Simplistic method to check if we have reached the point of injection
+   * @param klassName is the name of the probability level to check. 
+   *  If a configuration has been set for "fi.myClass" then you can check if the
+   *  inject criteria has been reached by calling this method with "myClass"
+   *  string as its parameter
+   * @return true if the probability threshold has been reached; false otherwise
+   */
   public static boolean injectCriteria(String klassName) {
     boolean trigger = false;
     // TODO fix this: make it more sophisticated!!!
@@ -70,17 +78,26 @@
     return trigger;
   }
 
-  // This primitive checks for arbitrary set of desired probability and
-  // uses default setting if it wasn't
-  // The probability expected to be set as an float between 0 and 100
+  /**
+   * This primitive checks for arbitrary set of desired probability. If the 
+   * level hasn't been set method will return default setting.
+   * The probability expected to be set as an float between 0.0 and 1.0
+   * @param klass is the name of the resource
+   * @return float representation of configured probability level of 
+   *  the requested resource or default value if hasn't been set
+   */
   protected static float getProbability(final String klass) {
     String newProbName = FPROB_NAME + klass;
 
-    conf.setIfUnset(newProbName, System.getProperty(newProbName, conf.get(ALL_PROBABILITIES)));
-    float ret = conf.getFloat(newProbName, conf.getFloat(ALL_PROBABILITIES, DEFAULT_PROB));
+    String newValue = System.getProperty(newProbName, conf.get(ALL_PROBABILITIES));
+    if (newValue != null && !newValue.equals(conf.get(newProbName)))
+      conf.set(newProbName, newValue);
+
+    float ret = conf.getFloat(newProbName,
+        conf.getFloat(ALL_PROBABILITIES, DEFAULT_PROB));
     LOG.debug("Request for " + newProbName + " returns=" + ret);
     // Make sure that probability level is valid.
-    if (ret < 0.00 || ret > 1.00) 
+    if (ret < DEFAULT_PROB || ret > MAX_PROB) 
       ret = conf.getFloat(ALL_PROBABILITIES, DEFAULT_PROB);
     
     return ret;



Mime
View raw message