/// <exception cref="System.IO.IOException"/> public static MiniMRClientCluster Create(Type caller, string identifier, int noOfNMs , Configuration conf) { if (conf == null) { conf = new Configuration(); } FileSystem fs = FileSystem.Get(conf); Path testRootDir = new Path("target", identifier + "-tmpDir").MakeQualified(fs); Path appJar = new Path(testRootDir, "MRAppJar.jar"); // Copy MRAppJar and make it private. Path appMasterJar = new Path(MiniMRYarnCluster.Appjar); fs.CopyFromLocalFile(appMasterJar, appJar); fs.SetPermission(appJar, new FsPermission("744")); Job job = Job.GetInstance(conf); job.AddFileToClassPath(appJar); Path callerJar = new Path(JarFinder.GetJar(caller)); Path remoteCallerJar = new Path(testRootDir, callerJar.GetName()); fs.CopyFromLocalFile(callerJar, remoteCallerJar); fs.SetPermission(remoteCallerJar, new FsPermission("744")); job.AddFileToClassPath(remoteCallerJar); MiniMRYarnCluster miniMRYarnCluster = new MiniMRYarnCluster(identifier, noOfNMs); job.GetConfiguration().Set("minimrclientcluster.caller.name", identifier); job.GetConfiguration().SetInt("minimrclientcluster.nodemanagers.number", noOfNMs); miniMRYarnCluster.Init(job.GetConfiguration()); miniMRYarnCluster.Start(); return(new MiniMRYarnClusterAdapter(miniMRYarnCluster)); }
/// <exception cref="System.Exception"/> public virtual void _testDistributedCache(string jobJarPath) { if (!(new FilePath(MiniMRYarnCluster.Appjar)).Exists()) { Log.Info("MRAppJar " + MiniMRYarnCluster.Appjar + " not found. Not running test." ); return; } // Create a temporary file of length 1. Path first = CreateTempFile("distributed.first", "x"); // Create two jars with a single file inside them. Path second = MakeJar(new Path(TestRootDir, "distributed.second.jar"), 2); Path third = MakeJar(new Path(TestRootDir, "distributed.third.jar"), 3); Path fourth = MakeJar(new Path(TestRootDir, "distributed.fourth.jar"), 4); Job job = Job.GetInstance(mrCluster.GetConfig()); // Set the job jar to a new "dummy" jar so we can check that its extracted // properly job.SetJar(jobJarPath); // Because the job jar is a "dummy" jar, we need to include the jar with // DistributedCacheChecker or it won't be able to find it Path distributedCacheCheckerJar = new Path(JarFinder.GetJar(typeof(TestMRJobs.DistributedCacheChecker ))); job.AddFileToClassPath(distributedCacheCheckerJar.MakeQualified(localFs.GetUri(), distributedCacheCheckerJar.GetParent())); job.SetMapperClass(typeof(TestMRJobs.DistributedCacheChecker)); job.SetOutputFormatClass(typeof(NullOutputFormat)); FileInputFormat.SetInputPaths(job, first); // Creates the Job Configuration job.AddCacheFile(new URI(first.ToUri().ToString() + "#distributed.first.symlink") ); job.AddFileToClassPath(second); // The AppMaster jar itself job.AddFileToClassPath(AppJar.MakeQualified(localFs.GetUri(), AppJar.GetParent()) ); job.AddArchiveToClassPath(third); job.AddCacheArchive(fourth.ToUri()); job.SetMaxMapAttempts(1); // speed up failures job.Submit(); string trackingUrl = job.GetTrackingURL(); string jobId = job.GetJobID().ToString(); NUnit.Framework.Assert.IsTrue(job.WaitForCompletion(false)); NUnit.Framework.Assert.IsTrue("Tracking URL was " + trackingUrl + " but didn't Match Job ID " + jobId, trackingUrl.EndsWith(Sharpen.Runtime.Substring(jobId, jobId.LastIndexOf ("_")) + "/")); }
static void Main(string[] args) { try { Thread progressThread = new Thread(() => Application.Run(new WaitingForm())); progressThread.Start(); var javaResult = new JavaFinder(ApplicationEnvironment.TargetJavaVersion).FindJava(); if (javaResult == null || !javaResult.IsSuccess) { progressThread.Abort(); ShowNoJavaPromptForm(NoJavaPromptForm.NoJavaMessageType.NotFound); } if (javaResult.IsCompat) { if (MessageBox.Show( "检测到您的计算机是 64 位计算机,但只安装了 32 位版本的 Java.\r\n继续启动 MoeCraft 可能导致不可预料的故障,我们推荐您安装 64 位的 Java\r\n您想了解如何安装 64 位的 Java 吗?", "Java 版本不兼容", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { progressThread.Abort(); ShowNoJavaPromptForm(NoJavaPromptForm.NoJavaMessageType.Incompatible); } } string jarResult; if (args.Length >= 1 && File.Exists(args[0])) { jarResult = args[0]; } else { jarResult = new JarFinder(ApplicationEnvironment.SearchFileOrder).find(); } if (jarResult == null) { Error("未找到符合条件的 jar,请确保你已经正确解压/安装了MoeCraft"); Environment.Exit(3); } try { var process = RunJava(javaResult.JavaExePath, jarResult); process.WaitForInputIdle(); Thread.Sleep(958); if (process.HasExited && process.ExitCode != 0) { Error(string.Format("检测到 Jar {0} 没有正确启动\r\nJar 退出码: {1}\r\n这可能是由于你没有正确解压/安装 MoeCraft 导致的,请尝试重新安装 MoeCraft.\r\n\r\n若仍有问题,请在本目录打开命令提示符,输入以下命令查看错误消息 (都在一行):\r\njava -jar {2}\r\n\r\n其他参考信息: 所用 Java 路径: {3}", jarResult, process.ExitCode.ToString(), jarResult, javaResult.JavaExePath)); Environment.Exit(10); } Environment.Exit(0); } catch (Exception ex) { Error(string.Format("启动 Java 失败:\r\nJar: {0}\r\nJava: {1}\r\n{2}", jarResult, javaResult.JavaExePath, ex)); Environment.Exit(5); } } catch (Exception ex) { Error("操作失败:\r\n" + ex); Environment.Exit(1); } }