/// <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; } } }