Author: edwardyoon
Date: Mon Sep 24 02:01:51 2012
New Revision: 1389181

URL: http://svn.apache.org/viewvc?rev=1389181&view=rev
Log:
Add deleting temporary files method in TestSubmitGraphJob 

Modified:
    hama/trunk/CHANGES.txt
    hama/trunk/graph/src/test/java/org/apache/hama/graph/TestSubmitGraphJob.java

Modified: hama/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hama/trunk/CHANGES.txt?rev=1389181&r1=1389180&r2=1389181&view=diff
==============================================================================
--- hama/trunk/CHANGES.txt (original)
+++ hama/trunk/CHANGES.txt Mon Sep 24 02:01:51 2012
@@ -15,6 +15,7 @@ Release 0.6 (unreleased changes)
 
   IMPROVEMENTS
 
+   HAMA-646: Add deleting temporary files method in TestSubmitGraphJob 
(Yuesheng Hu via edwardyoon)
    HAMA-597: Split a GraphJobRunner into multiple classes (edwardyoon & 
tjungblut) 
    HAMA-557: Implement Checkpointing service in Hama (surajmenon)
    HAMA-587: Synchronization Client should provide API's to store and retrieve 
information among peers and BSPMaster (surajmenon)

Modified: 
hama/trunk/graph/src/test/java/org/apache/hama/graph/TestSubmitGraphJob.java
URL: 
http://svn.apache.org/viewvc/hama/trunk/graph/src/test/java/org/apache/hama/graph/TestSubmitGraphJob.java?rev=1389181&r1=1389180&r2=1389181&view=diff
==============================================================================
--- 
hama/trunk/graph/src/test/java/org/apache/hama/graph/TestSubmitGraphJob.java 
(original)
+++ 
hama/trunk/graph/src/test/java/org/apache/hama/graph/TestSubmitGraphJob.java 
Mon Sep 24 02:01:51 2012
@@ -55,10 +55,10 @@ public class TestSubmitGraphJob extends 
   public void testSubmitJob() throws Exception {
 
     generateTestData();
-    
+
     // Set multi-step partitioning interval to 30 bytes
     configuration.setInt("hama.graph.multi.step.partitioning.interval", 30);
-    
+
     GraphJob bsp = new GraphJob(configuration, PageRank.class);
     bsp.setInputPath(new Path(INPUT));
     bsp.setOutputPath(new Path(OUTPUT));
@@ -91,12 +91,16 @@ public class TestSubmitGraphJob extends 
     bsp.setOutputValueClass(DoubleWritable.class);
 
     long startTime = System.currentTimeMillis();
-    if (bsp.waitForCompletion(true)) {
-      verifyResult();
-      LOG.info("Job Finished in " + (System.currentTimeMillis() - startTime)
-          / 1000.0 + " seconds");
-    } else {
-      fail();
+    try {
+      if (bsp.waitForCompletion(true)) {
+        verifyResult();
+        LOG.info("Job Finished in " + (System.currentTimeMillis() - startTime)
+            / 1000.0 + " seconds");
+      } else {
+        fail();
+      }
+    } finally {
+      deleteTempDirs();
     }
   }
 
@@ -131,14 +135,25 @@ public class TestSubmitGraphJob extends 
       if (bw != null) {
         try {
           bw.close();
-          
+
           File file = new File(INPUT);
           LOG.info("Temp file length: " + file.length());
-          
+
         } catch (IOException e) {
           e.printStackTrace();
         }
       }
     }
   }
+
+  private void deleteTempDirs() {
+    try {
+      if (fs.exists(new Path(INPUT)))
+        fs.delete(new Path(INPUT), true);
+      if (fs.exists(new Path(OUTPUT)))
+        fs.delete(new Path(OUTPUT), true);
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+  }
 }


Reply via email to