Skip to content

Commit

Permalink
add patch folder to support PR from CS527 students
Browse files Browse the repository at this point in the history
  • Loading branch information
xylian86 committed Dec 2, 2022
1 parent a435231 commit 57708a1
Show file tree
Hide file tree
Showing 2 changed files with 163 additions and 0 deletions.
55 changes: 55 additions & 0 deletions core/patch/hadoop/interception.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
diff --git a/hadoop-common-project/hadoop-common/pom.xml b/hadoop-common-project/hadoop-common/pom.xml
index 8a9ba175..470126c0 100644
--- a/hadoop-common-project/hadoop-common/pom.xml
+++ b/hadoop-common-project/hadoop-common/pom.xml
@@ -513,6 +513,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
+ <version>3.0.0-M4</version>
<configuration>
<systemPropertyVariables>
<runningWithNative>${runningWithNative}</runningWithNative>
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
index aedde6b5..24df9481 100755
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
@@ -786,6 +786,7 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
// Add default resources
addDefaultResource("core-default.xml");
addDefaultResource("core-site.xml");
+ addDefaultResource("core-ctest.xml"); //CTEST

// print deprecation warning if hadoop-site.xml is found in classpath
ClassLoader cL = Thread.currentThread().getContextClassLoader();
diff --git a/hadoop-common-project/hadoop-common/src/main/resources/core-ctest.xml b/hadoop-common-project/hadoop-common/src/main/resources/core-ctest.xml
new file mode 100644
index 00000000..d0ff3399
--- /dev/null
+++ b/hadoop-common-project/hadoop-common/src/main/resources/core-ctest.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+
+<configuration>
+
+</configuration>
diff --git a/pom.xml b/pom.xml
index 74a036e3..bedccf28 100644
--- a/pom.xml
+++ b/pom.xml
@@ -142,6 +142,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/x
<build>
<pluginManagement>
<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <reportFormat>plain</reportFormat>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>

108 changes: 108 additions & 0 deletions core/patch/hadoop/logging.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
index 24df9481..6451a97d 100755
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
@@ -1196,6 +1196,14 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
+ MAX_SUBST + " " + expr);
}

+ private String getStackTrace() {
+ String stacktrace = " ";
+ for (StackTraceElement element : Thread.currentThread().getStackTrace()) {
+ stacktrace = stacktrace.concat(element.getClassName() + "\t");
+ }
+ return stacktrace;
+ }
+
String getenv(String name) {
return System.getenv(name);
}
@@ -1220,11 +1228,14 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
* or null if no such property exists.
*/
public String get(String name) {
+ String ctestParam = name; //CTEST
String[] names = handleDeprecation(deprecationContext.get(), name);
String result = null;
for(String n : names) {
+ ctestParam = n; //CTEST
result = substituteVars(getProps().getProperty(n));
}
+ LOG.warn("[CTEST][GET-PARAM] " + ctestParam); //CTEST
return result;
}

@@ -1312,11 +1323,14 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
* its replacing property and null if no such property exists.
*/
public String getRaw(String name) {
+ String ctestParam = name; //CTEST
String[] names = handleDeprecation(deprecationContext.get(), name);
String result = null;
for(String n : names) {
+ ctestParam = n; //CTEST
result = getProps().getProperty(n);
}
+ LOG.warn("[CTEST][GET-PARAM] " + ctestParam); //CTEST
return result;
}

@@ -1364,6 +1378,10 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
set(name, value, null);
}

+ public void set(String name, String value, String source) {
+ set(name, value, source, true);
+ }
+
/**
* Set the <code>value</code> of the <code>name</code> property. If
* <code>name</code> is deprecated, it also sets the <code>value</code> to
@@ -1376,7 +1394,7 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
* (For debugging).
* @throws IllegalArgumentException when the value or name is null.
*/
- public void set(String name, String value, String source) {
+ public void set(String name, String value, String source, boolean log_enabled) {
Preconditions.checkArgument(
name != null,
"Property name must not be null");
@@ -1388,6 +1406,7 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
if (deprecations.getDeprecatedKeyMap().isEmpty()) {
getProps();
}
+ if(log_enabled) LOG.warn("[CTEST][SET-PARAM] " + name + getStackTrace()); //CTEST
getOverlay().setProperty(name, value);
getProps().setProperty(name, value);
String newSource = (source == null ? "programmatically" : source);
@@ -1398,6 +1417,7 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
if(altNames != null) {
for(String n: altNames) {
if(!n.equals(name)) {
+ if(log_enabled) LOG.warn("[CTEST][SET-PARAM] " + n + getStackTrace()); //CTEST
getOverlay().setProperty(n, value);
getProps().setProperty(n, value);
putIntoUpdatingResource(n, new String[] {newSource});
@@ -1409,6 +1429,7 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
String[] names = handleDeprecation(deprecationContext.get(), name);
String altSource = "because " + name + " is deprecated";
for(String n : names) {
+ if(log_enabled) LOG.warn("[CTEST][SET-PARAM] " + n + getStackTrace()); //CTEST
getOverlay().setProperty(n, value);
getProps().setProperty(n, value);
putIntoUpdatingResource(n, new String[] {altSource});
@@ -1481,11 +1502,14 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
* doesn't exist.
*/
public String get(String name, String defaultValue) {
+ String ctestParam = name; //CTEST
String[] names = handleDeprecation(deprecationContext.get(), name);
String result = null;
for(String n : names) {
+ ctestParam = n; //CTEST
result = substituteVars(getProps().getProperty(n, defaultValue));
}
+ LOG.warn("[CTEST][GET-PARAM] " + ctestParam); //CTEST
return result;
}

0 comments on commit 57708a1

Please sign in to comment.