@Test public void testWithSafetyNet() throws Exception { final String entropyKey = "__ekey__"; final String entropyValue = "abc"; final File folder = TMP_FOLDER.newFolder(); final Path path = new Path(Path.fromLocalFile(folder), entropyKey + "/path/"); final Path pathWithEntropy = new Path(Path.fromLocalFile(folder), entropyValue + "/path/"); TestEntropyInjectingFs efs = new TestEntropyInjectingFs(entropyKey, entropyValue); FSDataOutputStream out; FileSystemSafetyNet.initializeSafetyNetForThread(); FileSystem fs = FileSystemSafetyNet.wrapWithSafetyNetWhenActivated(efs); try { OutputStreamAndPath streamAndPath = EntropyInjector.createEntropyAware( fs, path, WriteMode.NO_OVERWRITE); out = streamAndPath.stream(); assertEquals(pathWithEntropy, streamAndPath.path()); } finally { FileSystemSafetyNet.closeSafetyNetAndGuardedResourcesForThread(); } try { out.write(42); out.flush(); fail("stream should be already close and hence fail with an exception"); } catch (IOException ignored) {} }
public static OutputStreamAndPath createEntropyAware( FileSystem fs, Path path, WriteMode writeMode) throws IOException { final EntropyInjectingFileSystem efs = getEntropyFs(fs); final Path processedPath = efs == null ? path : resolveEntropy(path, efs, true); final FSDataOutputStream out = fs.create(processedPath, writeMode); return new OutputStreamAndPath(out, processedPath); }
EntropyInjector { public static OutputStreamAndPath createEntropyAware( FileSystem fs, Path path, WriteMode writeMode) throws IOException { final EntropyInjectingFileSystem efs = getEntropyFs(fs); final Path processedPath = efs == null ? path : resolveEntropy(path, efs, true); final FSDataOutputStream out = fs.create(processedPath, writeMode); return new OutputStreamAndPath(out, processedPath); } }
EntropyInjector { public static OutputStreamAndPath createEntropyAware( FileSystem fs, Path path, WriteMode writeMode) throws IOException { final EntropyInjectingFileSystem efs = getEntropyFs(fs); final Path processedPath = efs == null ? path : resolveEntropy(path, efs, true); final FSDataOutputStream out = fs.create(processedPath, writeMode); return new OutputStreamAndPath(out, processedPath); } private  EntropyInjector(); }
EntropyInjector { public static OutputStreamAndPath createEntropyAware( FileSystem fs, Path path, WriteMode writeMode) throws IOException { final EntropyInjectingFileSystem efs = getEntropyFs(fs); final Path processedPath = efs == null ? path : resolveEntropy(path, efs, true); final FSDataOutputStream out = fs.create(processedPath, writeMode); return new OutputStreamAndPath(out, processedPath); } private  EntropyInjector(); static OutputStreamAndPath createEntropyAware(
			FileSystem fs,
			Path path,
			WriteMode writeMode); static Path removeEntropyMarkerIfPresent(FileSystem fs, Path path); }
EntropyInjector { public static OutputStreamAndPath createEntropyAware( FileSystem fs, Path path, WriteMode writeMode) throws IOException { final EntropyInjectingFileSystem efs = getEntropyFs(fs); final Path processedPath = efs == null ? path : resolveEntropy(path, efs, true); final FSDataOutputStream out = fs.create(processedPath, writeMode); return new OutputStreamAndPath(out, processedPath); } private  EntropyInjector(); static OutputStreamAndPath createEntropyAware(
			FileSystem fs,
			Path path,
			WriteMode writeMode); static Path removeEntropyMarkerIfPresent(FileSystem fs, Path path);  }