internal static LocalizerHeartbeatResponse DieHBResponse() { LocalizerHeartbeatResponse response = recordFactory.NewRecordInstance <LocalizerHeartbeatResponse >(); response.SetLocalizerAction(LocalizerAction.Die); return(response); }
/// <exception cref="System.IO.IOException"/> protected internal virtual void LocalizeFiles(LocalizationProtocol nodemanager, CompletionService <Path> cs, UserGroupInformation ugi) { while (true) { try { LocalizerStatus status = CreateStatus(); LocalizerHeartbeatResponse response = nodemanager.Heartbeat(status); switch (response.GetLocalizerAction()) { case LocalizerAction.Live: { IList <ResourceLocalizationSpec> newRsrcs = response.GetResourceSpecs(); foreach (ResourceLocalizationSpec newRsrc in newRsrcs) { if (!pendingResources.Contains(newRsrc.GetResource())) { pendingResources[newRsrc.GetResource()] = cs.Submit(Download(new Path(newRsrc.GetDestinationDirectory ().GetFile()), newRsrc.GetResource(), ugi)); } } break; } case LocalizerAction.Die: { // killall running localizations foreach (Future <Path> pending in pendingResources.Values) { pending.Cancel(true); } status = CreateStatus(); // ignore response try { nodemanager.Heartbeat(status); } catch (YarnException) { } return; } } cs.Poll(1000, TimeUnit.Milliseconds); } catch (Exception) { return; } catch (YarnException) { // TODO cleanup return; } } }
public virtual void TestPbRecordFactory() { RecordFactory pbRecordFactory = RecordFactoryPBImpl.Get(); try { LocalizerHeartbeatResponse response = pbRecordFactory.NewRecordInstance <LocalizerHeartbeatResponse >(); NUnit.Framework.Assert.AreEqual(typeof(LocalizerHeartbeatResponsePBImpl), response .GetType()); } catch (YarnRuntimeException e) { Sharpen.Runtime.PrintStackTrace(e); NUnit.Framework.Assert.Fail("Failed to crete record"); } }
Heartbeat(RpcController controller, YarnServerNodemanagerServiceProtos.LocalizerStatusProto proto) { LocalizerStatusPBImpl request = new LocalizerStatusPBImpl(proto); try { LocalizerHeartbeatResponse response = real.Heartbeat(request); return(((LocalizerHeartbeatResponsePBImpl)response).GetProto()); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } }
/// <exception cref="Sharpen.URISyntaxException"/> internal static LocalizerHeartbeatResponse CreateLocalizerHeartbeatResponse() { LocalizerHeartbeatResponse ret = recordFactory.NewRecordInstance <LocalizerHeartbeatResponse >(); NUnit.Framework.Assert.IsTrue(ret is LocalizerHeartbeatResponsePBImpl); ret.SetLocalizerAction(LocalizerAction.Live); LocalResource rsrc = CreateResource(); AList <ResourceLocalizationSpec> rsrcs = new AList <ResourceLocalizationSpec>(); ResourceLocalizationSpec resource = recordFactory.NewRecordInstance <ResourceLocalizationSpec >(); resource.SetResource(rsrc); resource.SetDestinationDirectory(ConverterUtils.GetYarnUrlFromPath(new Path("/tmp" + Runtime.CurrentTimeMillis()))); rsrcs.AddItem(resource); ret.SetResourceSpecs(rsrcs); System.Console.Out.WriteLine(resource); return(ret); }
/// <exception cref="System.Exception"/> public virtual void TestLocalizerHeartbeatResponseSerDe() { LocalizerHeartbeatResponse rsrcS = CreateLocalizerHeartbeatResponse(); NUnit.Framework.Assert.IsTrue(rsrcS is LocalizerHeartbeatResponsePBImpl); LocalizerHeartbeatResponsePBImpl rsrcPb = (LocalizerHeartbeatResponsePBImpl)rsrcS; DataOutputBuffer @out = new DataOutputBuffer(); rsrcPb.GetProto().WriteDelimitedTo(@out); DataInputBuffer @in = new DataInputBuffer(); @in.Reset(@out.GetData(), 0, @out.GetLength()); YarnServerNodemanagerServiceProtos.LocalizerHeartbeatResponseProto rsrcPbD = YarnServerNodemanagerServiceProtos.LocalizerHeartbeatResponseProto .ParseDelimitedFrom(@in); NUnit.Framework.Assert.IsNotNull(rsrcPbD); LocalizerHeartbeatResponse rsrcD = new LocalizerHeartbeatResponsePBImpl(rsrcPbD); NUnit.Framework.Assert.AreEqual(rsrcS, rsrcD); NUnit.Framework.Assert.AreEqual(CreateResource(), rsrcS.GetResourceSpecs()[0].GetResource ()); NUnit.Framework.Assert.AreEqual(CreateResource(), rsrcD.GetResourceSpecs()[0].GetResource ()); }
public virtual void TestLocalizerRPC() { IPEndPoint locAddr = new IPEndPoint("0.0.0.0", 8040); TestPBLocalizerRPC.LocalizerService server = new TestPBLocalizerRPC.LocalizerService (locAddr); try { server.Start(); Configuration conf = new Configuration(); YarnRPC rpc = YarnRPC.Create(conf); LocalizationProtocol client = (LocalizationProtocol)rpc.GetProxy(typeof(LocalizationProtocol ), locAddr, conf); LocalizerStatus status = recordFactory.NewRecordInstance <LocalizerStatus>(); status.SetLocalizerId("localizer0"); LocalizerHeartbeatResponse response = client.Heartbeat(status); NUnit.Framework.Assert.AreEqual(DieHBResponse(), response); } finally { server.Stop(); } NUnit.Framework.Assert.IsTrue(true); }