You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2015/03/22 18:12:07 UTC

svn commit: r1668412 - /lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsTestUtil.java

Author: markrmiller
Date: Sun Mar 22 17:12:07 2015
New Revision: 1668412

URL: http://svn.apache.org/r1668412
Log:
SOLR-7092: Do a little better at clean up in new test code.

Modified:
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsTestUtil.java

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsTestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsTestUtil.java?rev=1668412&r1=1668411&r2=1668412&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsTestUtil.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsTestUtil.java Sun Mar 22 17:12:07 2015
@@ -44,6 +44,8 @@ public class HdfsTestUtil {
 
   private static FSDataOutputStream badTlogOutStream;
 
+  private static FileSystem badTlogOutStreamFs;
+
   public static MiniDFSCluster setupClass(String dir) throws Exception {
     return setupClass(dir, true);
   }
@@ -94,12 +96,13 @@ public class HdfsTestUtil {
       
       timers.put(dfsCluster, timer);
     } else {
+      // TODO: we could do much better at testing this
       // force a lease recovery by creating a tlog file and not closing it
       URI uri = dfsCluster.getURI();
       Path hdfsDirPath = new Path(uri.toString() + "/solr/collection1/core_node1/data/tlog/tlog.0000000000000000000");
       // tran log already being created testing
-      FileSystem fs = FileSystem.newInstance(hdfsDirPath.toUri(), conf);
-      badTlogOutStream = fs.create(hdfsDirPath);
+      badTlogOutStreamFs = FileSystem.get(hdfsDirPath.toUri(), conf);
+      badTlogOutStream = badTlogOutStreamFs.create(hdfsDirPath);
     }
     
     SolrTestCaseJ4.useFactory("org.apache.solr.core.HdfsDirectoryFactory");
@@ -113,6 +116,10 @@ public class HdfsTestUtil {
       IOUtils.closeQuietly(badTlogOutStream);
     }
     
+    if (badTlogOutStreamFs != null) {
+      IOUtils.closeQuietly(badTlogOutStreamFs);
+    }
+    
     SolrTestCaseJ4.resetFactory();
     System.clearProperty("solr.lock.type");
     System.clearProperty("test.build.data");
@@ -120,7 +127,10 @@ public class HdfsTestUtil {
     System.clearProperty("solr.hdfs.home");
     System.clearProperty("solr.hdfs.blockcache.global");
     if (dfsCluster != null) {
-      timers.remove(dfsCluster);
+      Timer timer = timers.remove(dfsCluster);
+      if (timer != null) {
+        timer.cancel();
+      }
       dfsCluster.shutdown();
     }