示例#1
0
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="Sharpen.URISyntaxException"/>
        internal static LocalResource CreateZipFile(FileContext files, Path p, int len, Random
                                                    r, LocalResourceVisibility vis)
        {
            byte[] bytes = new byte[len];
            r.NextBytes(bytes);
            FilePath archiveFile = new FilePath(p.ToUri().GetPath() + ".ZIP");

            archiveFile.CreateNewFile();
            ZipOutputStream @out = new ZipOutputStream(new FileOutputStream(archiveFile));

            @out.PutNextEntry(new ZipEntry(p.GetName()));
            @out.Write(bytes);
            @out.CloseEntry();
            @out.Close();
            LocalResource ret = recordFactory.NewRecordInstance <LocalResource>();

            ret.SetResource(ConverterUtils.GetYarnUrlFromPath(new Path(p.ToString() + ".ZIP")
                                                              ));
            ret.SetSize(len);
            ret.SetType(LocalResourceType.Archive);
            ret.SetVisibility(vis);
            ret.SetTimestamp(files.GetFileStatus(new Path(p.ToString() + ".ZIP")).GetModificationTime
                                 ());
            return(ret);
        }
示例#2
0
        public virtual void TestConvertUrlWithUserinfo()
        {
            Path expectedPath = new Path("foo://*****:*****@example.com:8042");
            URL  url          = ConverterUtils.GetYarnUrlFromPath(expectedPath);
            Path actualPath   = ConverterUtils.GetPathFromYarnURL(url);

            NUnit.Framework.Assert.AreEqual(expectedPath, actualPath);
        }
示例#3
0
        public virtual void TestConvertUrlWithNoPort()
        {
            Path expectedPath = new Path("hdfs://foo.com");
            URL  url          = ConverterUtils.GetYarnUrlFromPath(expectedPath);
            Path actualPath   = ConverterUtils.GetPathFromYarnURL(url);

            NUnit.Framework.Assert.AreEqual(expectedPath, actualPath);
        }
示例#4
0
        /// <exception cref="System.IO.IOException"/>
        internal static LocalResource CreateFile(FileContext files, Path p, int len, Random
                                                 r, LocalResourceVisibility vis)
        {
            CreateFile(files, p, len, r);
            LocalResource ret = recordFactory.NewRecordInstance <LocalResource>();

            ret.SetResource(ConverterUtils.GetYarnUrlFromPath(p));
            ret.SetSize(len);
            ret.SetType(LocalResourceType.File);
            ret.SetVisibility(vis);
            ret.SetTimestamp(files.GetFileStatus(p).GetModificationTime());
            return(ret);
        }
示例#5
0
        /// <exception cref="System.IO.IOException"/>
        internal static LocalResource CreateJar(FileContext files, Path p, LocalResourceVisibility
                                                vis)
        {
            Log.Info("Create jar file " + p);
            FilePath         jarFile = new FilePath((files.MakeQualified(p)).ToUri());
            FileOutputStream stream  = new FileOutputStream(jarFile);

            Log.Info("Create jar out stream ");
            JarOutputStream @out = new JarOutputStream(stream, new Manifest());

            Log.Info("Done writing jar stream ");
            @out.Close();
            LocalResource ret = recordFactory.NewRecordInstance <LocalResource>();

            ret.SetResource(ConverterUtils.GetYarnUrlFromPath(p));
            FileStatus status = files.GetFileStatus(p);

            ret.SetSize(status.GetLen());
            ret.SetTimestamp(status.GetModificationTime());
            ret.SetType(LocalResourceType.Pattern);
            ret.SetVisibility(vis);
            ret.SetPattern("classes/.*");
            return(ret);
        }