瀏覽代碼

commit d97cbd749de78bd0c8c470142bf943a1ee2abe6d
Author: Vinay Kumar Thota <vinayt@yahoo-inc.com>
Date: Fri Jun 4 08:50:52 2010 +0000

HADOOP:6788 from https://issues.apache.org/jira/secure/attachment/12446102/6788-ydist-security.patch


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1077489 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 14 年之前
父節點
當前提交
5a3eb1de54
共有 1 個文件被更改,包括 22 次插入10 次删除
  1. 22 10
      src/test/system/aop/org/apache/hadoop/test/system/DaemonProtocolAspect.aj

+ 22 - 10
src/test/system/aop/org/apache/hadoop/test/system/DaemonProtocolAspect.aj

@@ -256,19 +256,31 @@ public aspect DaemonProtocolAspect {
   public int DaemonProtocol.getNumberOfMatchesInLogFile(String pattern,
       String[] list) throws IOException {
     StringBuffer filePattern = new StringBuffer(getFilePattern());    
-    if(list != null){
-      for(int i =0; i < list.length; ++i)
-      {
-        filePattern.append(" | grep -v " + list[i] );
+    String[] cmd = null;
+    if (list != null) {
+      StringBuffer filterExpPattern = new StringBuffer();
+      int index=0;
+      for (String excludeExp : list) {
+        if (index++ < list.length -1) {
+           filterExpPattern.append("grep -v " + excludeExp + " | ");
+        } else {
+           filterExpPattern.append("grep -vc " + excludeExp);
+        }
       }
-    }  
-    String[] cmd =
-        new String[] {
-            "bash",
-            "-c",
-            "grep -c "
+      cmd = new String[] {
+                "bash",
+                "-c",
+                "grep "
+                + pattern + " " + filePattern + " | "
+                + filterExpPattern};
+    } else {
+      cmd = new String[] {
+                "bash",
+                "-c",
+                "grep -c "
                 + pattern + " " + filePattern
                 + " | awk -F: '{s+=$2} END {print s}'" };    
+    }
     ShellCommandExecutor shexec = new ShellCommandExecutor(cmd);
     shexec.execute();
     String output = shexec.getOutput();