/// <exception cref="System.Exception"/> public virtual void TestSerializedExceptionDeSer() { // without cause YarnException yarnEx = new YarnException("Yarn_Exception"); SerializedException serEx = SerializedException.NewInstance(yarnEx); Exception throwable = serEx.DeSerialize(); NUnit.Framework.Assert.AreEqual(yarnEx.GetType(), throwable.GetType()); NUnit.Framework.Assert.AreEqual(yarnEx.Message, throwable.Message); // with cause IOException ioe = new IOException("Test_IOException"); RuntimeException runtimeException = new RuntimeException("Test_RuntimeException", ioe); YarnException yarnEx2 = new YarnException("Test_YarnException", runtimeException); SerializedException serEx2 = SerializedException.NewInstance(yarnEx2); Exception throwable2 = serEx2.DeSerialize(); Sharpen.Runtime.PrintStackTrace(throwable2); NUnit.Framework.Assert.AreEqual(yarnEx2.GetType(), throwable2.GetType()); NUnit.Framework.Assert.AreEqual(yarnEx2.Message, throwable2.Message); NUnit.Framework.Assert.AreEqual(runtimeException.GetType(), throwable2.InnerException .GetType()); NUnit.Framework.Assert.AreEqual(runtimeException.Message, throwable2.InnerException .Message); NUnit.Framework.Assert.AreEqual(ioe.GetType(), throwable2.InnerException.InnerException .GetType()); NUnit.Framework.Assert.AreEqual(ioe.Message, throwable2.InnerException.InnerException .Message); }
/// <summary>Create the payload for the HeartBeat.</summary> /// <remarks> /// Create the payload for the HeartBeat. Mainly the list of /// <see cref="Org.Apache.Hadoop.Yarn.Server.Nodemanager.Api.Protocolrecords.LocalResourceStatus /// "/> /// es /// </remarks> /// <returns> /// a /// <see cref="Org.Apache.Hadoop.Yarn.Server.Nodemanager.Api.Protocolrecords.LocalizerStatus /// "/> /// that can be sent via heartbeat. /// </returns> /// <exception cref="System.Exception"/> private LocalizerStatus CreateStatus() { IList <LocalResourceStatus> currentResources = new AList <LocalResourceStatus>(); // TODO: Synchronization?? for (IEnumerator <LocalResource> i = pendingResources.Keys.GetEnumerator(); i.HasNext ();) { LocalResource rsrc = i.Next(); LocalResourceStatus stat = recordFactory.NewRecordInstance <LocalResourceStatus>(); stat.SetResource(rsrc); Future <Path> fPath = pendingResources[rsrc]; if (fPath.IsDone()) { try { Path localPath = fPath.Get(); stat.SetLocalPath(ConverterUtils.GetYarnUrlFromPath(localPath)); stat.SetLocalSize(FileUtil.GetDU(new FilePath(localPath.GetParent().ToUri()))); stat.SetStatus(ResourceStatusType.FetchSuccess); } catch (ExecutionException e) { stat.SetStatus(ResourceStatusType.FetchFailure); stat.SetException(SerializedException.NewInstance(e.InnerException)); } catch (CancellationException e) { stat.SetStatus(ResourceStatusType.FetchFailure); stat.SetException(SerializedException.NewInstance(e)); } // TODO shouldn't remove until ACK i.Remove(); } else { stat.SetStatus(ResourceStatusType.FetchPending); } currentResources.AddItem(stat); } LocalizerStatus status = recordFactory.NewRecordInstance <LocalizerStatus>(); status.SetLocalizerId(localizerId); status.AddAllResources(currentResources); return(status); }
internal static LocalResourceStatus CreateLocalResourceStatus() { LocalResourceStatus ret = recordFactory.NewRecordInstance <LocalResourceStatus>(); NUnit.Framework.Assert.IsTrue(ret is LocalResourceStatusPBImpl); ret.SetResource(CreateResource()); ret.SetLocalPath(ConverterUtils.GetYarnUrlFromPath(new Path("file:///local/foo/bar" ))); ret.SetStatus(ResourceStatusType.FetchSuccess); ret.SetLocalSize(4443L); Exception e = new Exception("Dingos."); e.SetStackTrace(new StackTraceElement[] { new StackTraceElement("foo", "bar", "baz" , 10), new StackTraceElement("sbb", "one", "onm", 10) }); ret.SetException(SerializedException.NewInstance(e)); return(ret); }