001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.util;
019
020import static org.junit.Assert.assertEquals;
021import static org.junit.Assert.assertFalse;
022import static org.junit.Assert.assertNotEquals;
023import static org.junit.Assert.assertNotNull;
024import static org.junit.Assert.assertNull;
025import static org.junit.Assert.assertTrue;
026
027import java.io.File;
028import java.io.IOException;
029import java.util.Random;
030import java.util.UUID;
031import org.apache.hadoop.conf.Configuration;
032import org.apache.hadoop.fs.FSDataInputStream;
033import org.apache.hadoop.fs.FSDataOutputStream;
034import org.apache.hadoop.fs.FileStatus;
035import org.apache.hadoop.fs.FileSystem;
036import org.apache.hadoop.fs.Path;
037import org.apache.hadoop.fs.permission.FsPermission;
038import org.apache.hadoop.hbase.HBaseClassTestRule;
039import org.apache.hadoop.hbase.HBaseTestingUtility;
040import org.apache.hadoop.hbase.HConstants;
041import org.apache.hadoop.hbase.HDFSBlocksDistribution;
042import org.apache.hadoop.hbase.exceptions.DeserializationException;
043import org.apache.hadoop.hbase.testclassification.MediumTests;
044import org.apache.hadoop.hbase.testclassification.MiscTests;
045import org.apache.hadoop.hdfs.DFSConfigKeys;
046import org.apache.hadoop.hdfs.DFSHedgedReadMetrics;
047import org.apache.hadoop.hdfs.DFSTestUtil;
048import org.apache.hadoop.hdfs.MiniDFSCluster;
049import org.junit.Before;
050import org.junit.ClassRule;
051import org.junit.Test;
052import org.junit.experimental.categories.Category;
053import org.slf4j.Logger;
054import org.slf4j.LoggerFactory;
055
056/**
057 * Test {@link FSUtils}.
058 */
059@Category({MiscTests.class, MediumTests.class})
060public class TestFSUtils {
061
062  @ClassRule
063  public static final HBaseClassTestRule CLASS_RULE =
064      HBaseClassTestRule.forClass(TestFSUtils.class);
065
066  private static final Logger LOG = LoggerFactory.getLogger(TestFSUtils.class);
067
068  private HBaseTestingUtility htu;
069  private FileSystem fs;
070  private Configuration conf;
071
072  @Before
073  public void setUp() throws IOException {
074    htu = new HBaseTestingUtility();
075    fs = htu.getTestFileSystem();
076    conf = htu.getConfiguration();
077  }
078
079  @Test public void testIsHDFS() throws Exception {
080    assertFalse(FSUtils.isHDFS(conf));
081    MiniDFSCluster cluster = null;
082    try {
083      cluster = htu.startMiniDFSCluster(1);
084      assertTrue(FSUtils.isHDFS(conf));
085    } finally {
086      if (cluster != null) cluster.shutdown();
087    }
088  }
089
090  private void WriteDataToHDFS(FileSystem fs, Path file, int dataSize)
091    throws Exception {
092    FSDataOutputStream out = fs.create(file);
093    byte [] data = new byte[dataSize];
094    out.write(data, 0, dataSize);
095    out.close();
096  }
097
098  @Test public void testcomputeHDFSBlocksDistribution() throws Exception {
099    final int DEFAULT_BLOCK_SIZE = 1024;
100    conf.setLong("dfs.blocksize", DEFAULT_BLOCK_SIZE);
101    MiniDFSCluster cluster = null;
102    Path testFile = null;
103
104    try {
105      // set up a cluster with 3 nodes
106      String hosts[] = new String[] { "host1", "host2", "host3" };
107      cluster = htu.startMiniDFSCluster(hosts);
108      cluster.waitActive();
109      FileSystem fs = cluster.getFileSystem();
110
111      // create a file with two blocks
112      testFile = new Path("/test1.txt");
113      WriteDataToHDFS(fs, testFile, 2*DEFAULT_BLOCK_SIZE);
114
115      // given the default replication factor is 3, the same as the number of
116      // datanodes; the locality index for each host should be 100%,
117      // or getWeight for each host should be the same as getUniqueBlocksWeights
118      final long maxTime = System.currentTimeMillis() + 2000;
119      boolean ok;
120      do {
121        ok = true;
122        FileStatus status = fs.getFileStatus(testFile);
123        HDFSBlocksDistribution blocksDistribution =
124          FSUtils.computeHDFSBlocksDistribution(fs, status, 0, status.getLen());
125        long uniqueBlocksTotalWeight =
126          blocksDistribution.getUniqueBlocksTotalWeight();
127        for (String host : hosts) {
128          long weight = blocksDistribution.getWeight(host);
129          ok = (ok && uniqueBlocksTotalWeight == weight);
130        }
131      } while (!ok && System.currentTimeMillis() < maxTime);
132      assertTrue(ok);
133      } finally {
134      htu.shutdownMiniDFSCluster();
135    }
136
137
138    try {
139      // set up a cluster with 4 nodes
140      String hosts[] = new String[] { "host1", "host2", "host3", "host4" };
141      cluster = htu.startMiniDFSCluster(hosts);
142      cluster.waitActive();
143      FileSystem fs = cluster.getFileSystem();
144
145      // create a file with three blocks
146      testFile = new Path("/test2.txt");
147      WriteDataToHDFS(fs, testFile, 3*DEFAULT_BLOCK_SIZE);
148
149      // given the default replication factor is 3, we will have total of 9
150      // replica of blocks; thus the host with the highest weight should have
151      // weight == 3 * DEFAULT_BLOCK_SIZE
152      final long maxTime = System.currentTimeMillis() + 2000;
153      long weight;
154      long uniqueBlocksTotalWeight;
155      do {
156        FileStatus status = fs.getFileStatus(testFile);
157        HDFSBlocksDistribution blocksDistribution =
158          FSUtils.computeHDFSBlocksDistribution(fs, status, 0, status.getLen());
159        uniqueBlocksTotalWeight = blocksDistribution.getUniqueBlocksTotalWeight();
160
161        String tophost = blocksDistribution.getTopHosts().get(0);
162        weight = blocksDistribution.getWeight(tophost);
163
164        // NameNode is informed asynchronously, so we may have a delay. See HBASE-6175
165      } while (uniqueBlocksTotalWeight != weight && System.currentTimeMillis() < maxTime);
166      assertTrue(uniqueBlocksTotalWeight == weight);
167
168    } finally {
169      htu.shutdownMiniDFSCluster();
170    }
171
172
173    try {
174      // set up a cluster with 4 nodes
175      String hosts[] = new String[] { "host1", "host2", "host3", "host4" };
176      cluster = htu.startMiniDFSCluster(hosts);
177      cluster.waitActive();
178      FileSystem fs = cluster.getFileSystem();
179
180      // create a file with one block
181      testFile = new Path("/test3.txt");
182      WriteDataToHDFS(fs, testFile, DEFAULT_BLOCK_SIZE);
183
184      // given the default replication factor is 3, we will have total of 3
185      // replica of blocks; thus there is one host without weight
186      final long maxTime = System.currentTimeMillis() + 2000;
187      HDFSBlocksDistribution blocksDistribution;
188      do {
189        FileStatus status = fs.getFileStatus(testFile);
190        blocksDistribution = FSUtils.computeHDFSBlocksDistribution(fs, status, 0, status.getLen());
191        // NameNode is informed asynchronously, so we may have a delay. See HBASE-6175
192      }
193      while (blocksDistribution.getTopHosts().size() != 3 && System.currentTimeMillis() < maxTime);
194      assertEquals("Wrong number of hosts distributing blocks.", 3,
195        blocksDistribution.getTopHosts().size());
196    } finally {
197      htu.shutdownMiniDFSCluster();
198    }
199  }
200
201  @Test
202  public void testVersion() throws DeserializationException, IOException {
203    final Path rootdir = htu.getDataTestDir();
204    final FileSystem fs = rootdir.getFileSystem(conf);
205    assertNull(FSUtils.getVersion(fs, rootdir));
206    // Write out old format version file.  See if we can read it in and convert.
207    Path versionFile = new Path(rootdir, HConstants.VERSION_FILE_NAME);
208    FSDataOutputStream s = fs.create(versionFile);
209    final String version = HConstants.FILE_SYSTEM_VERSION;
210    s.writeUTF(version);
211    s.close();
212    assertTrue(fs.exists(versionFile));
213    FileStatus [] status = fs.listStatus(versionFile);
214    assertNotNull(status);
215    assertTrue(status.length > 0);
216    String newVersion = FSUtils.getVersion(fs, rootdir);
217    assertEquals(version.length(), newVersion.length());
218    assertEquals(version, newVersion);
219    // File will have been converted. Exercise the pb format
220    assertEquals(version, FSUtils.getVersion(fs, rootdir));
221    FSUtils.checkVersion(fs, rootdir, true);
222  }
223
224  @Test
225  public void testPermMask() throws Exception {
226    final Path rootdir = htu.getDataTestDir();
227    final FileSystem fs = rootdir.getFileSystem(conf);
228    // default fs permission
229    FsPermission defaultFsPerm = FSUtils.getFilePermissions(fs, conf,
230        HConstants.DATA_FILE_UMASK_KEY);
231    // 'hbase.data.umask.enable' is false. We will get default fs permission.
232    assertEquals(FsPermission.getFileDefault(), defaultFsPerm);
233
234    conf.setBoolean(HConstants.ENABLE_DATA_FILE_UMASK, true);
235    // first check that we don't crash if we don't have perms set
236    FsPermission defaultStartPerm = FSUtils.getFilePermissions(fs, conf,
237        HConstants.DATA_FILE_UMASK_KEY);
238    // default 'hbase.data.umask'is 000, and this umask will be used when
239    // 'hbase.data.umask.enable' is true.
240    // Therefore we will not get the real fs default in this case.
241    // Instead we will get the starting point FULL_RWX_PERMISSIONS
242    assertEquals(new FsPermission(FSUtils.FULL_RWX_PERMISSIONS), defaultStartPerm);
243
244    conf.setStrings(HConstants.DATA_FILE_UMASK_KEY, "077");
245    // now check that we get the right perms
246    FsPermission filePerm = FSUtils.getFilePermissions(fs, conf,
247        HConstants.DATA_FILE_UMASK_KEY);
248    assertEquals(new FsPermission("700"), filePerm);
249
250    // then that the correct file is created
251    Path p = new Path("target" + File.separator + UUID.randomUUID().toString());
252    try {
253      FSDataOutputStream out = FSUtils.create(conf, fs, p, filePerm, null);
254      out.close();
255      FileStatus stat = fs.getFileStatus(p);
256      assertEquals(new FsPermission("700"), stat.getPermission());
257      // and then cleanup
258    } finally {
259      fs.delete(p, true);
260    }
261  }
262
263  @Test
264  public void testDeleteAndExists() throws Exception {
265    final Path rootdir = htu.getDataTestDir();
266    final FileSystem fs = rootdir.getFileSystem(conf);
267    conf.setBoolean(HConstants.ENABLE_DATA_FILE_UMASK, true);
268    FsPermission perms = FSUtils.getFilePermissions(fs, conf, HConstants.DATA_FILE_UMASK_KEY);
269    // then that the correct file is created
270    String file = UUID.randomUUID().toString();
271    Path p = new Path(htu.getDataTestDir(), "temptarget" + File.separator + file);
272    Path p1 = new Path(htu.getDataTestDir(), "temppath" + File.separator + file);
273    try {
274      FSDataOutputStream out = FSUtils.create(conf, fs, p, perms, null);
275      out.close();
276      assertTrue("The created file should be present", FSUtils.isExists(fs, p));
277      // delete the file with recursion as false. Only the file will be deleted.
278      FSUtils.delete(fs, p, false);
279      // Create another file
280      FSDataOutputStream out1 = FSUtils.create(conf, fs, p1, perms, null);
281      out1.close();
282      // delete the file with recursion as false. Still the file only will be deleted
283      FSUtils.delete(fs, p1, true);
284      assertFalse("The created file should be present", FSUtils.isExists(fs, p1));
285      // and then cleanup
286    } finally {
287      FSUtils.delete(fs, p, true);
288      FSUtils.delete(fs, p1, true);
289    }
290  }
291
292  @Test
293  public void testFilteredStatusDoesNotThrowOnNotFound() throws Exception {
294    MiniDFSCluster cluster = htu.startMiniDFSCluster(1);
295    try {
296      assertNull(FSUtils.listStatusWithStatusFilter(cluster.getFileSystem(), new Path("definitely/doesn't/exist"), null));
297    } finally {
298      cluster.shutdown();
299    }
300
301  }
302
303  @Test
304  public void testRenameAndSetModifyTime() throws Exception {
305    MiniDFSCluster cluster = htu.startMiniDFSCluster(1);
306    assertTrue(FSUtils.isHDFS(conf));
307
308    FileSystem fs = FileSystem.get(conf);
309    Path testDir = htu.getDataTestDirOnTestFS("testArchiveFile");
310
311    String file = UUID.randomUUID().toString();
312    Path p = new Path(testDir, file);
313
314    FSDataOutputStream out = fs.create(p);
315    out.close();
316    assertTrue("The created file should be present", FSUtils.isExists(fs, p));
317
318    long expect = System.currentTimeMillis() + 1000;
319    assertNotEquals(expect, fs.getFileStatus(p).getModificationTime());
320
321    ManualEnvironmentEdge mockEnv = new ManualEnvironmentEdge();
322    mockEnv.setValue(expect);
323    EnvironmentEdgeManager.injectEdge(mockEnv);
324    try {
325      String dstFile = UUID.randomUUID().toString();
326      Path dst = new Path(testDir , dstFile);
327
328      assertTrue(FSUtils.renameAndSetModifyTime(fs, p, dst));
329      assertFalse("The moved file should not be present", FSUtils.isExists(fs, p));
330      assertTrue("The dst file should be present", FSUtils.isExists(fs, dst));
331
332      assertEquals(expect, fs.getFileStatus(dst).getModificationTime());
333      cluster.shutdown();
334    } finally {
335      EnvironmentEdgeManager.reset();
336    }
337  }
338
339  @Test
340  public void testSetStoragePolicyDefault() throws Exception {
341    verifyFileInDirWithStoragePolicy(HConstants.DEFAULT_WAL_STORAGE_POLICY);
342  }
343
344  /* might log a warning, but still work. (always warning on Hadoop < 2.6.0) */
345  @Test
346  public void testSetStoragePolicyValidButMaybeNotPresent() throws Exception {
347    verifyFileInDirWithStoragePolicy("ALL_SSD");
348  }
349
350  /* should log a warning, but still work. (different warning on Hadoop < 2.6.0) */
351  @Test
352  public void testSetStoragePolicyInvalid() throws Exception {
353    verifyFileInDirWithStoragePolicy("1772");
354  }
355
356  // Here instead of TestCommonFSUtils because we need a minicluster
357  private void verifyFileInDirWithStoragePolicy(final String policy) throws Exception {
358    conf.set(HConstants.WAL_STORAGE_POLICY, policy);
359
360    MiniDFSCluster cluster = htu.startMiniDFSCluster(1);
361    try {
362      assertTrue(FSUtils.isHDFS(conf));
363
364      FileSystem fs = FileSystem.get(conf);
365      Path testDir = htu.getDataTestDirOnTestFS("testArchiveFile");
366      fs.mkdirs(testDir);
367
368      FSUtils.setStoragePolicy(fs, conf, testDir, HConstants.WAL_STORAGE_POLICY,
369          HConstants.DEFAULT_WAL_STORAGE_POLICY);
370
371      String file = UUID.randomUUID().toString();
372      Path p = new Path(testDir, file);
373      WriteDataToHDFS(fs, p, 4096);
374      // will assert existance before deleting.
375      cleanupFile(fs, testDir);
376    } finally {
377      cluster.shutdown();
378    }
379  }
380
381  /**
382   * Ugly test that ensures we can get at the hedged read counters in dfsclient.
383   * Does a bit of preading with hedged reads enabled using code taken from hdfs TestPread.
384   * @throws Exception
385   */
386  @Test public void testDFSHedgedReadMetrics() throws Exception {
387    // Enable hedged reads and set it so the threshold is really low.
388    // Most of this test is taken from HDFS, from TestPread.
389    conf.setInt(DFSConfigKeys.DFS_DFSCLIENT_HEDGED_READ_THREADPOOL_SIZE, 5);
390    conf.setLong(DFSConfigKeys.DFS_DFSCLIENT_HEDGED_READ_THRESHOLD_MILLIS, 0);
391    conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, 4096);
392    conf.setLong(DFSConfigKeys.DFS_CLIENT_READ_PREFETCH_SIZE_KEY, 4096);
393    // Set short retry timeouts so this test runs faster
394    conf.setInt(DFSConfigKeys.DFS_CLIENT_RETRY_WINDOW_BASE, 0);
395    conf.setBoolean("dfs.datanode.transferTo.allowed", false);
396    MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(3).build();
397    // Get the metrics.  Should be empty.
398    DFSHedgedReadMetrics metrics = FSUtils.getDFSHedgedReadMetrics(conf);
399    assertEquals(0, metrics.getHedgedReadOps());
400    FileSystem fileSys = cluster.getFileSystem();
401    try {
402      Path p = new Path("preadtest.dat");
403      // We need > 1 blocks to test out the hedged reads.
404      DFSTestUtil.createFile(fileSys, p, 12 * blockSize, 12 * blockSize,
405        blockSize, (short) 3, seed);
406      pReadFile(fileSys, p);
407      cleanupFile(fileSys, p);
408      assertTrue(metrics.getHedgedReadOps() > 0);
409    } finally {
410      fileSys.close();
411      cluster.shutdown();
412    }
413  }
414
415  // Below is taken from TestPread over in HDFS.
416  static final int blockSize = 4096;
417  static final long seed = 0xDEADBEEFL;
418
419  private void pReadFile(FileSystem fileSys, Path name) throws IOException {
420    FSDataInputStream stm = fileSys.open(name);
421    byte[] expected = new byte[12 * blockSize];
422    Random rand = new Random(seed);
423    rand.nextBytes(expected);
424    // do a sanity check. Read first 4K bytes
425    byte[] actual = new byte[4096];
426    stm.readFully(actual);
427    checkAndEraseData(actual, 0, expected, "Read Sanity Test");
428    // now do a pread for the first 8K bytes
429    actual = new byte[8192];
430    doPread(stm, 0L, actual, 0, 8192);
431    checkAndEraseData(actual, 0, expected, "Pread Test 1");
432    // Now check to see if the normal read returns 4K-8K byte range
433    actual = new byte[4096];
434    stm.readFully(actual);
435    checkAndEraseData(actual, 4096, expected, "Pread Test 2");
436    // Now see if we can cross a single block boundary successfully
437    // read 4K bytes from blockSize - 2K offset
438    stm.readFully(blockSize - 2048, actual, 0, 4096);
439    checkAndEraseData(actual, (blockSize - 2048), expected, "Pread Test 3");
440    // now see if we can cross two block boundaries successfully
441    // read blockSize + 4K bytes from blockSize - 2K offset
442    actual = new byte[blockSize + 4096];
443    stm.readFully(blockSize - 2048, actual);
444    checkAndEraseData(actual, (blockSize - 2048), expected, "Pread Test 4");
445    // now see if we can cross two block boundaries that are not cached
446    // read blockSize + 4K bytes from 10*blockSize - 2K offset
447    actual = new byte[blockSize + 4096];
448    stm.readFully(10 * blockSize - 2048, actual);
449    checkAndEraseData(actual, (10 * blockSize - 2048), expected, "Pread Test 5");
450    // now check that even after all these preads, we can still read
451    // bytes 8K-12K
452    actual = new byte[4096];
453    stm.readFully(actual);
454    checkAndEraseData(actual, 8192, expected, "Pread Test 6");
455    // done
456    stm.close();
457    // check block location caching
458    stm = fileSys.open(name);
459    stm.readFully(1, actual, 0, 4096);
460    stm.readFully(4*blockSize, actual, 0, 4096);
461    stm.readFully(7*blockSize, actual, 0, 4096);
462    actual = new byte[3*4096];
463    stm.readFully(0*blockSize, actual, 0, 3*4096);
464    checkAndEraseData(actual, 0, expected, "Pread Test 7");
465    actual = new byte[8*4096];
466    stm.readFully(3*blockSize, actual, 0, 8*4096);
467    checkAndEraseData(actual, 3*blockSize, expected, "Pread Test 8");
468    // read the tail
469    stm.readFully(11*blockSize+blockSize/2, actual, 0, blockSize/2);
470    IOException res = null;
471    try { // read beyond the end of the file
472      stm.readFully(11*blockSize+blockSize/2, actual, 0, blockSize);
473    } catch (IOException e) {
474      // should throw an exception
475      res = e;
476    }
477    assertTrue("Error reading beyond file boundary.", res != null);
478
479    stm.close();
480  }
481
482  private void checkAndEraseData(byte[] actual, int from, byte[] expected, String message) {
483    for (int idx = 0; idx < actual.length; idx++) {
484      assertEquals(message+" byte "+(from+idx)+" differs. expected "+
485                        expected[from+idx]+" actual "+actual[idx],
486                        actual[idx], expected[from+idx]);
487      actual[idx] = 0;
488    }
489  }
490
491  private void doPread(FSDataInputStream stm, long position, byte[] buffer,
492      int offset, int length) throws IOException {
493    int nread = 0;
494    // long totalRead = 0;
495    // DFSInputStream dfstm = null;
496
497    /* Disable. This counts do not add up. Some issue in original hdfs tests?
498    if (stm.getWrappedStream() instanceof DFSInputStream) {
499      dfstm = (DFSInputStream) (stm.getWrappedStream());
500      totalRead = dfstm.getReadStatistics().getTotalBytesRead();
501    } */
502
503    while (nread < length) {
504      int nbytes =
505          stm.read(position + nread, buffer, offset + nread, length - nread);
506      assertTrue("Error in pread", nbytes > 0);
507      nread += nbytes;
508    }
509
510    /* Disable. This counts do not add up. Some issue in original hdfs tests?
511    if (dfstm != null) {
512      if (isHedgedRead) {
513        assertTrue("Expected read statistic to be incremented",
514          length <= dfstm.getReadStatistics().getTotalBytesRead() - totalRead);
515      } else {
516        assertEquals("Expected read statistic to be incremented", length, dfstm
517            .getReadStatistics().getTotalBytesRead() - totalRead);
518      }
519    }*/
520  }
521
522  private void cleanupFile(FileSystem fileSys, Path name) throws IOException {
523    assertTrue(fileSys.exists(name));
524    assertTrue(fileSys.delete(name, true));
525    assertTrue(!fileSys.exists(name));
526  }
527
528
529  private static final boolean STREAM_CAPABILITIES_IS_PRESENT;
530  static {
531    boolean tmp = false;
532    try {
533      Class.forName("org.apache.hadoop.fs.StreamCapabilities");
534      tmp = true;
535      LOG.debug("Test thought StreamCapabilities class was present.");
536    } catch (ClassNotFoundException exception) {
537      LOG.debug("Test didn't think StreamCapabilities class was present.");
538    } finally {
539      STREAM_CAPABILITIES_IS_PRESENT = tmp;
540    }
541  }
542
543  // Here instead of TestCommonFSUtils because we need a minicluster
544  @Test
545  public void checkStreamCapabilitiesOnHdfsDataOutputStream() throws Exception {
546    MiniDFSCluster cluster = htu.startMiniDFSCluster(1);
547    try (FileSystem filesystem = cluster.getFileSystem()) {
548      FSDataOutputStream stream = filesystem.create(new Path("/tmp/foobar"));
549      assertTrue(FSUtils.hasCapability(stream, "hsync"));
550      assertTrue(FSUtils.hasCapability(stream, "hflush"));
551      assertNotEquals("We expect HdfsDataOutputStream to say it has a dummy capability iff the " +
552          "StreamCapabilities class is not defined.",
553          STREAM_CAPABILITIES_IS_PRESENT,
554          FSUtils.hasCapability(stream, "a capability that hopefully HDFS doesn't add."));
555    } finally {
556      cluster.shutdown();
557    }
558  }
559
560}