private Path setupTempDirWithSingleOutputFile(Configuration hconf) throws IOException { Path tempDirPath = new Path("file://" + temporaryFolder.newFolder().getAbsolutePath()); Path taskOutputPath = new Path(tempDirPath, Utilities.getTaskId(hconf)); FileSystem.getLocal(hconf).create(taskOutputPath).close(); return tempDirPath; }
out = FileSystem.getLocal(hconf).create(hConfFilePath); tempConf.writeXml(out); } finally {
out = FileSystem.getLocal(hconf).create(hConfFilePath); tempConf.writeXml(out); } finally {
out = FileSystem.getLocal(conf).create(planPath); SerializationUtilities.serializePlan(plan, out); out.close();
out = FileSystem.getLocal(conf).create(planPath); SerializationUtilities.serializePlan(plan, out); out.close();
@Test public void testCloseForErroneousRCFile() throws IOException { Configuration conf = new Configuration(); LocalFileSystem fs = FileSystem.getLocal(conf); // create an empty file (which is not a valid rcfile) Path path = new Path(System.getProperty("test.tmp.dir", ".") + "/broken.rcfile"); fs.create(path).close(); // try to create RCFile.Reader final TestFSDataInputStream[] openedFile = new TestFSDataInputStream[1]; try { new RCFile.Reader(fs, path, conf) { // this method is called by the RCFile.Reader constructor, overwritten, // so we can access the opened file @Override protected FSDataInputStream openFile(FileSystem fs, Path file, int bufferSize, long length) throws IOException { final InputStream in = super.openFile(fs, file, bufferSize, length); openedFile[0] = new TestFSDataInputStream(in); return openedFile[0]; } }; fail("IOException expected."); } catch (IOException expected) { } assertNotNull(path + " should have been opened.", openedFile[0]); assertTrue("InputStream for " + path + " should have been closed.", openedFile[0].isClosed()); }
out = FileSystem.getLocal(conf).create(planPath); SerializationUtilities.serializePlan(plan, out); out.close();
out = FileSystem.getLocal(conf).create(planPath); SerializationUtilities.serializePlan(plan, out); out.close();
localFileSystem.create(fileNotDirectory); localFileSystem.deleteOnExit(fileNotDirectory);
dataSegmentWithLoadspect = DataSegment.builder(dataSegment).loadSpec(ImmutableMap.of("path", indexPath)).build(); OutputStream outputStream = localFileSystem.create(indexPath, true); outputStream.close(); Assert.assertTrue("index file is not created ??", localFileSystem.exists(indexPath));
Path tmpPath = new Path(TEST_DIR + "/testBytesWrittenLimit-tmpFile-" + new Random(System.currentTimeMillis()).nextInt()); FSDataOutputStream out = localFS.create(tmpPath, true); out.write(new byte[LOCAL_BYTES_WRITTEN]); out.close();
private void createFile(Path ... paths) throws IOException { for (Path path : paths) { FSDataOutputStream out = lfs.create(path); out.write(path.getName().getBytes()); out.close(); } }
private void createFile(Path ... paths) throws IOException { for (Path path : paths) { FSDataOutputStream out = lfs.create(path); out.write(path.getName().getBytes()); out.close(); } }
@Override protected OutputStream getOutputStream(int bufferSize, byte[] key, byte[] iv) throws IOException { return new CryptoOutputStream(fileSys.create(file), codec, bufferSize, key, iv); }
@Override protected OutputStream getOutputStream(int bufferSize, byte[] key, byte[] iv) throws IOException { return new CryptoOutputStream(fileSys.create(file), codec, bufferSize, key, iv); }
@Test public void testCopyFileFromLocal() throws Exception { Path testRoot = new Path(testRootDir, "testPutFile"); lfs.delete(testRoot, true); lfs.mkdirs(testRoot); Path targetDir = new Path(testRoot, "target"); Path filePath = new Path(testRoot, new Path("srcFile")); lfs.create(filePath).close(); checkPut(filePath, targetDir, false); }
@Test public void testCopyDirFromLocal() throws Exception { Path testRoot = new Path(testRootDir, "testPutDir"); lfs.delete(testRoot, true); lfs.mkdirs(testRoot); Path targetDir = new Path(testRoot, "target"); Path dirPath = new Path(testRoot, new Path("srcDir")); lfs.mkdirs(dirPath); lfs.create(new Path(dirPath, "srcFile")).close(); checkPut(dirPath, targetDir, false); }
@Test public void testCopyDirFromLocal() throws Exception { Path testRoot = new Path(testRootDir, "testPutDir"); lfs.delete(testRoot, true); lfs.mkdirs(testRoot); Path targetDir = new Path(testRoot, "target"); Path dirPath = new Path(testRoot, new Path("srcDir")); lfs.mkdirs(dirPath); lfs.create(new Path(dirPath, "srcFile")).close(); checkPut(dirPath, targetDir, false); }
@Before public void prepFiles() throws Exception { lfs.setVerifyChecksum(true); lfs.setWriteChecksum(true); lfs.delete(srcPath, true); lfs.delete(dstPath, true); FSDataOutputStream out = lfs.create(srcPath); out.writeChars("hi"); out.close(); assertTrue(lfs.exists(lfs.getChecksumFile(srcPath))); }
@Before public void prepFiles() throws Exception { lfs.setVerifyChecksum(true); lfs.setWriteChecksum(true); lfs.delete(srcPath, true); lfs.delete(dstPath, true); FSDataOutputStream out = lfs.create(srcPath); out.writeChars("hi"); out.close(); assertTrue(lfs.exists(lfs.getChecksumFile(srcPath))); }