/** * return a hadoop path from a given url * This method is deprecated, use {@link URL#toPath()} instead. * * @param url * url to convert * @return path from {@link URL} * @throws URISyntaxException */ @Public @Deprecated public static Path getPathFromYarnURL(URL url) throws URISyntaxException { return url.toPath(); }
remotePath = resource.getResource().toPath(); } catch (URISyntaxException e) { throw new IOException("Invalid resource", e);
remotePath = resource.getResource().toPath(); } catch (URISyntaxException e) { throw new IOException("Invalid resource", e);
/** * Localize files. * @param destination destination directory * @throws IOException cannot read or write file * @throws YarnException subcommand returned an error */ private void verifyAndCopy(Path destination) throws IOException, YarnException { final Path sCopy; try { sCopy = resource.getResource().toPath(); } catch (URISyntaxException e) { throw new IOException("Invalid resource", e); } FileSystem sourceFs = sCopy.getFileSystem(conf); FileStatus sStat = sourceFs.getFileStatus(sCopy); if (sStat.getModificationTime() != resource.getTimestamp()) { throw new IOException("Resource " + sCopy + " changed on src filesystem (expected " + resource.getTimestamp() + ", was " + sStat.getModificationTime()); } if (resource.getVisibility() == LocalResourceVisibility.PUBLIC) { if (!isPublic(sourceFs, sCopy, sStat, statCache)) { throw new IOException("Resource " + sCopy + " is not publicly accessible and as such cannot be part of the" + " public cache."); } } downloadAndUnpack(sCopy, destination); }
resourcePath = resource.getResource().toPath(); } catch (URISyntaxException e) { throw new IOException(e);
resourcePath = resource.getResource().toPath(); } catch (URISyntaxException e) { throw new IOException(e);
final Path sCopy; try { sCopy = resource.getResource().toPath(); } catch (URISyntaxException e) { throw new IOException("Invalid resource", e);
@Test public void testConversion() throws Exception { Configuration conf = new Configuration(); conf.set(YarnConfiguration.IPC_RECORD_FACTORY_CLASS, RecordFactoryForTest.class.getName()); String[] pathStrs = new String[] {"/", ".", "foo/bar", "foo", "/foo/bar/baz", "moo://bar/baz", "moo://bar:123/baz", "moo:///foo", "moo://foo@bar:123/baz/foo", "moo://foo@bar/baz/foo", "moo://foo@bar", "moo://foo:123"}; for (String s : pathStrs) { Path path = new Path(s); assertEquals(path, URL.fromPath(path, conf).toPath()); } Path p = new Path("/foo/bar#baz"); assertEquals(p, URL.fromPath(p, conf).toPath()); }
@Test public void testConversion() throws Exception { Configuration conf = new Configuration(); conf.set(YarnConfiguration.IPC_RECORD_FACTORY_CLASS, RecordFactoryForTest.class.getName()); String[] pathStrs = new String[] {"/", ".", "foo/bar", "foo", "/foo/bar/baz", "moo://bar/baz", "moo://bar:123/baz", "moo:///foo", "moo://foo@bar:123/baz/foo", "moo://foo@bar/baz/foo", "moo://foo@bar", "moo://foo:123"}; for (String s : pathStrs) { Path path = new Path(s); assertEquals(path, URL.fromPath(path, conf).toPath()); } Path p = new Path("/foo/bar#baz"); assertEquals(p, URL.fromPath(p, conf).toPath()); }
/** * Wrap API resource to match against cache of localized resources. * @param resource Resource requested by container * @throws URISyntaxException If the path is malformed */ public LocalResourceRequest(LocalResource resource) throws URISyntaxException { this(resource.getResource().toPath(), resource.getTimestamp(), resource.getType(), resource.getVisibility(), resource.getPattern()); }
/** * Wrap API resource to match against cache of localized resources. * @param resource Resource requested by container * @throws URISyntaxException If the path is malformed */ public LocalResourceRequest(LocalResource resource) throws URISyntaxException { this(resource.getResource().toPath(), resource.getTimestamp(), resource.getType(), resource.getVisibility(), resource.getPattern()); }
@Test public void testConvertUrlWithNoPort() throws URISyntaxException { Path expectedPath = new Path("hdfs://foo.com"); URL url = URL.fromPath(expectedPath); Path actualPath = url.toPath(); assertEquals(expectedPath, actualPath); }
@Test public void testConvertUrlWithUserinfo() throws URISyntaxException { Path expectedPath = new Path("foo://username:password@example.com:8042"); URL url = URL.fromPath(expectedPath); Path actualPath = url.toPath(); assertEquals(expectedPath, actualPath); }
@Test public void testConvertUrlWithNoPort() throws URISyntaxException { Path expectedPath = new Path("hdfs://foo.com"); URL url = URL.fromPath(expectedPath); Path actualPath = url.toPath(); assertEquals(expectedPath, actualPath); }
@Test public void testConvertUrlWithUserinfo() throws URISyntaxException { Path expectedPath = new Path("foo://username:password@example.com:8042"); URL url = URL.fromPath(expectedPath); Path actualPath = url.toPath(); assertEquals(expectedPath, actualPath); }
stat.getLocalPath().toPath(), stat.getLocalSize())); } catch (URISyntaxException e) { }
stat.getLocalPath().toPath(), stat.getLocalSize())); } catch (URISyntaxException e) { }