public static FileSystemWrapper get(Configuration fsConf) throws IOException { return new FileSystemWrapper(fsConf); }
public static FileSystemWrapper get(Configuration fsConf, OperatorStats stats) throws IOException { return new FileSystemWrapper(fsConf, stats, null); }
public static FileSystemWrapper get(URI uri, Configuration fsConf) throws IOException { FileSystem fs = FileSystem.get(uri, fsConf); return new FileSystemWrapper(fsConf, fs); }
public static FileSystemWrapper get(Path path, Configuration fsConf, OperatorStats stats) throws IOException { FileSystem fs = path.getFileSystem(fsConf); return new FileSystemWrapper(fsConf, fs, stats); }
public static FileSystemWrapper get(Path path, Configuration fsConf) throws IOException { FileSystem fs = path.getFileSystem(fsConf); return new FileSystemWrapper(fsConf, fs); }
public static FileSystemWrapper get(URI uri, Configuration fsConf, OperatorStats stats) throws IOException { FileSystem fs = FileSystem.get(uri, fsConf); return new FileSystemWrapper(fsConf, fs, stats); }
@Override public FileSystemWrapper run() throws Exception { logger.trace("Creating FileSystemWrapper for proxy user: " + UserGroupInformation.getCurrentUser()); return new FileSystemWrapper(fsConf, stats, connectionUniqueProps); } });
@Test public void test() throws Exception { assumeNonMaprProfile(); final IOException ioException = new IOException("test io exception"); final FSError fsError = newFSError(ioException); FileSystem underlyingFS = mock(FileSystem.class, new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { if (!invocation.getMethod().getName().equals("getScheme")) { throw fsError; } return "mockfs"; } }); Configuration conf = new Configuration(false); FileSystemWrapper fsw = new FileSystemWrapper(conf, underlyingFS, null); Object[] params = FSErrorTestUtils.getDummyArguments(method); try { method.invoke(fsw, params); } catch(InvocationTargetException e) { assertThat(e.getTargetException(), is(instanceOf(IOException.class))); assertThat((IOException) e.getTargetException(), is(sameInstance(ioException))); } } }
dfs = new FileSystemWrapper(conf, stats, null); os = dfs.create(new Path(tempFolder.getRoot().getPath(), "dremioFSWriteTest.txt"));
@Test public void testReadIOStats() throws Exception { FileSystemWrapper dfs = null; InputStream is = null; Configuration conf = new Configuration(); conf.set(FileSystem.FS_DEFAULT_NAME_KEY, "file:///"); OpProfileDef profileDef = new OpProfileDef(0 /*operatorId*/, 0 /*operatorType*/, 0 /*inputCount*/); OperatorStats stats = new OperatorStats(profileDef, null /*allocator*/); // start wait time method in OperatorStats expects the OperatorStats state to be in "processing" stats.startProcessing(); try { dfs = new FileSystemWrapper(conf, stats, null); is = dfs.open(new Path(tempFilePath)); byte[] buf = new byte[8000]; while (is.read(buf, 0, buf.length) != -1) { } } finally { stats.stopProcessing(); if (is != null) { is.close(); } if (dfs != null) { dfs.close(); } } OperatorProfile operatorProfile = stats.getProfile(); assertTrue("Expected wait time is non-zero, but got zero wait time", operatorProfile.getWaitNanos() > 0); }