hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r890531 - in /hadoop/mapreduce/trunk/src/test: aop/build/aop.xml aop/org/apache/hadoop/fi/FiConfig.java aop/org/apache/hadoop/fi/ProbabilityModel.java fi-site.xml
Date Mon, 14 Dec 2009 22:55:56 GMT
Author: cos
Date: Mon Dec 14 22:55:56 2009
New Revision: 890531

URL: http://svn.apache.org/viewvc?rev=890531&view=rev
Log:
MAPREDUCE-1084. Implementing aspects development and fault injeciton framework for MapReduce.
Contributed by Sreekanth Ramakrishnan.

Modified:
    hadoop/mapreduce/trunk/src/test/aop/build/aop.xml
    hadoop/mapreduce/trunk/src/test/aop/org/apache/hadoop/fi/FiConfig.java
    hadoop/mapreduce/trunk/src/test/aop/org/apache/hadoop/fi/ProbabilityModel.java
    hadoop/mapreduce/trunk/src/test/fi-site.xml

Modified: hadoop/mapreduce/trunk/src/test/aop/build/aop.xml
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/test/aop/build/aop.xml?rev=890531&r1=890530&r2=890531&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/test/aop/build/aop.xml (original)
+++ hadoop/mapreduce/trunk/src/test/aop/build/aop.xml Mon Dec 14 22:55:56 2009
@@ -130,135 +130,3 @@
 
   <!--End of Fault Injection (FI) related session-->
 </project>
-<!--
-   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
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   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.
--->
-<project name="aspects">
-  <property name="build-fi.dir" value="${basedir}/build-fi"/>
-  <property name="hadoop-fi.jar" location="${build.dir}/${final.name}-fi.jar" />
-  <property name="compile-inject.output" value="${build-fi.dir}/compile-fi.log"/>
-  <property name="aspectversion" value="1.6.5"/>
-  <property file="${basedir}/build.properties"/>
-
-  <!--All Fault Injection (FI) related targets are located in this session -->
-    
-  <target name="clean-fi">
-    <delete dir="${build-fi.dir}"/>
-  </target>
-  
-  <!-- Weaving aspects in place
-  	Later on one can run 'ant jar-fault-inject' to create
-  	Hadoop jar file with instrumented classes
-  -->
-  <!-- Target -classes-compilation has to be defined in build.xml and
-  needs to depend on classes compilation and test classes compilation
-  targets. This is a poor man parametrization for targets -->
-  <target name="compile-fault-inject" depends="-classes-compilation" >
-    <!-- AspectJ task definition -->
-    <taskdef
-      resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
-      <classpath>
-        <pathelement 
-          location="${common.ivy.lib.dir}/aspectjtools-${aspectversion}.jar"/>
-      </classpath>
-    </taskdef>
-    <echo message="Start weaving aspects in place"/>
-    <iajc
-      encoding="${build.encoding}" 
-      srcdir="${java.src.dir};${build.src};${test.src.dir}/aop" 
-      includes="org/apache/hadoop/**/*.java, org/apache/hadoop/**/*.aj"
-      excludes="org/apache/hadoop/record/**/*"
-      destDir="${build.classes}"
-      debug="${javac.debug}"
-      target="${javac.version}"
-      source="${javac.version}"
-      deprecation="${javac.deprecation}">
-      <classpath refid="test.classpath"/>
-    </iajc>
-    <loadfile property="injection.failure" srcfile="${compile-inject.output}">
-      <filterchain>
-        <linecontainsregexp>
-          <regexp pattern='iajc.*warning'/>
-        </linecontainsregexp>
-      </filterchain>
-    </loadfile>
-    <fail if="injection.failure">
-      Broken binding of advises: ${line.separator}${injection.failure}
-    </fail>
-    <echo message="Weaving of aspects is finished"/>
-  </target>
-
-  <target name="injectfaults" 
-  	description="Instrument classes with faults and other AOP advices">
-    <!--mkdir to prevent <subant> failure in case the folder has been removed-->
-    <mkdir dir="${build-fi.dir}"/>
-    <delete file="${compile-inject.output}"/>
-    <subant buildpath="${basedir}" target="compile-fault-inject"
-    	output="${compile-inject.output}">
-      <property name="build.dir" value="${build-fi.dir}"/>
-    </subant>
-  </target>
-
-  <macrodef name="macro-run-tests-fault-inject">
-    <attribute name="target.name" />
-    <attribute name="testcasesonly" />
-    <sequential>
-      <subant buildpath="build.xml" target="@{target.name}">
-        <property name="build.dir" value="${build-fi.dir}"/>
-        <property name="test.fault.inject" value="yes"/>
-        <property name="test.include" value="TestFi*"/>
-        <!-- This one is needed for the special "regression" target only -->
-        <property name="special.fi.testcasesonly" value="@{testcasesonly}"/>
-      </subant>
-    </sequential>
-  </macrodef>
-	
-  <!-- ================================================================== -->
-  <!-- Make hadoop-fi.jar including all Fault injected artifacts         -->
-  <!-- ================================================================== -->
-  <macrodef name="macro-jar-fault-inject">
-    <attribute name="target.name" />
-    <attribute name="jar.final.name" />
-    <attribute name="jar.final.value" />
-    <sequential>
-      <subant buildpath="build.xml" target="@{target.name}">
-        <property name="build.dir" value="${build-fi.dir}"/>
-        <property name="@{jar.final.name}" value="@{jar.final.value}"/>
-        <property name="jar.extra.properties.list" 
-        	  value="${test.src.dir}/fi-site.xml" />
-      </subant>
-    </sequential>
-  </macrodef>
-
-  <!-- ================================================================== -->
-  <!-- Make test jar files including all Fault Injected artifacts         -->
-  <!-- ================================================================== -->
-
-  <macrodef name="macro-jar-test-fault-inject">
-    <attribute name="target.name" />
-    <attribute name="jar.final.name" />
-    <attribute name="jar.final.value" />
-    <sequential>
-      <subant buildpath="build.xml" target="@{target.name}">
-        <property name="build.dir" value="${build-fi.dir}"/>
-        <property name="@{jar.final.name}" 
-                  value="@{jar.final.value}"/>
-      </subant>
-    </sequential>
-  </macrodef>
-
-  <!--End of Fault Injection (FI) related session-->
-</project>

Modified: hadoop/mapreduce/trunk/src/test/aop/org/apache/hadoop/fi/FiConfig.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/test/aop/org/apache/hadoop/fi/FiConfig.java?rev=890531&r1=890530&r2=890531&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/test/aop/org/apache/hadoop/fi/FiConfig.java (original)
+++ hadoop/mapreduce/trunk/src/test/aop/org/apache/hadoop/fi/FiConfig.java Mon Dec 14 22:55:56
2009
@@ -53,58 +53,3 @@
     return conf;
   }
 }
-/*
- * 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
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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.hadoop.fi;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hdfs.HdfsConfiguration;
-
-/**
- * This class wraps the logic around fault injection configuration file
- * Default file is expected to be found in src/test/fi-site.xml
- * This default file should be copied by JUnit Ant's tasks to 
- * build/test/extraconf folder before tests are ran
- * An alternative location can be set through
- *   -Dfi.config=<file_name>
- */
-public class FiConfig {
-  private static final String CONFIG_PARAMETER = ProbabilityModel.FPROB_NAME + "config";
-  private static final String DEFAULT_CONFIG = "fi-site.xml";
-  private static Configuration conf;
-  static {
-    init();
-  }
-  
-  protected static void init () {
-    if (conf == null) {
-      conf = new HdfsConfiguration(false);
-      String configName = System.getProperty(CONFIG_PARAMETER, DEFAULT_CONFIG);
-      conf.addResource(configName);
-    }
-  }
-  
-  /**
-   * Method provides access to local Configuration 
-   * 
-   * @return Configuration initialized with fault injection's parameters
-   */
-  public static Configuration getConfig() {
-    return conf;
-  }
-}

Modified: hadoop/mapreduce/trunk/src/test/aop/org/apache/hadoop/fi/ProbabilityModel.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/test/aop/org/apache/hadoop/fi/ProbabilityModel.java?rev=890531&r1=890530&r2=890531&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/test/aop/org/apache/hadoop/fi/ProbabilityModel.java (original)
+++ hadoop/mapreduce/trunk/src/test/aop/org/apache/hadoop/fi/ProbabilityModel.java Mon Dec
14 22:55:56 2009
@@ -103,108 +103,3 @@
     return ret;
   }
 }
-/*
- * 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
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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.hadoop.fi;
-
-import java.util.Random;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.conf.Configuration;
-
-/**
- * This class is responsible for the decision of when a fault 
- * has to be triggered within a class of Hadoop
- * 
- *  Default probability of injection is set to 0%. To change it
- *  one can set the sys. prop. -Dfi.*=<new probability level>
- *  Another way to do so is to set this level through FI config file,
- *  located under src/test/fi-site.conf
- *  
- *  To change the level one has to specify the following sys,prop.:
- *  -Dfi.<name of fault location>=<probability level> in the runtime
- *  Probability level is specified by a float between 0.0 and 1.0
- *  
- *  <name of fault location> might be represented by a short classname
- *  or otherwise. This decision is left up to the discretion of aspects
- *  developer, but has to be consistent through the code 
- */
-public class ProbabilityModel {
-  private static Random generator = new Random();
-  private static final Log LOG = LogFactory.getLog(ProbabilityModel.class);
-
-  static final String FPROB_NAME = "fi.";
-  private static final String ALL_PROBABILITIES = FPROB_NAME + "*";
-  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();
-
-  static {
-    // Set new default probability if specified through a system.property
-    // If neither is specified set default probability to DEFAULT_PROB 
-    conf.set(ALL_PROBABILITIES, 
-        System.getProperty(ALL_PROBABILITIES, 
-            conf.get(ALL_PROBABILITIES, Float.toString(DEFAULT_PROB))));
-
-    LOG.info(ALL_PROBABILITIES + "=" + conf.get(ALL_PROBABILITIES));
-  }
-
-  /**
-   * 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!!!
-    if (generator.nextFloat() < getProbability(klassName)) {
-      trigger = true;
-    }
-    return trigger;
-  }
-
-  /**
-   * 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;
-
-    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 < DEFAULT_PROB || ret > MAX_PROB) 
-      ret = conf.getFloat(ALL_PROBABILITIES, DEFAULT_PROB);
-    
-    return ret;
-  }
-}

Modified: hadoop/mapreduce/trunk/src/test/fi-site.xml
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/test/fi-site.xml?rev=890531&r1=890530&r2=890531&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/test/fi-site.xml (original)
+++ hadoop/mapreduce/trunk/src/test/fi-site.xml Mon Dec 14 22:55:56 2009
@@ -13,18 +13,3 @@
     </description>
   </property>
 </configuration>
-<?xml version="1.0"?>
-<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-
-<!-- Put fault injection specific property overrides in this file. -->
-
-<configuration>
-  <property>
-    <name>fi.*</name>
-    <value>0.00</value>
-    <description>
-    	Default probability level for all injected faults specified 
-    	as a floating number between 0 and 1.00
-    </description>
-  </property>
-</configuration>



Mime
View raw message