Exemple #1
0
 internal void Update()
 {
     Log.V(Log.TagQuery, "%s: update() called.", this);
     if (GetView() == null)
     {
         throw new InvalidOperationException("Cannot start LiveQuery when view is null");
     }
     if (runningState.Get() == false)
     {
         Log.D(Log.TagQuery, "%s: update() called, but running state == false.  Ignoring."
               , this);
         return;
     }
     if (queryFuture != null && !queryFuture.IsCancelled() && !queryFuture.IsDone())
     {
         // There is a already a query in flight, so leave it alone except to schedule something
         // to run update() again once it finishes.
         Log.D(Log.TagQuery, "%s: already a query in flight, scheduling call to update() once it's done"
               , this);
         if (rerunUpdateFuture != null && !rerunUpdateFuture.IsCancelled() && !rerunUpdateFuture
             .IsDone())
         {
             bool cancelResult = rerunUpdateFuture.Cancel(true);
             Log.D(Log.TagQuery, "%s: cancelled %s result: %s", this, rerunUpdateFuture, cancelResult
                   );
         }
         rerunUpdateFuture = RerunUpdateAfterQueryFinishes(queryFuture);
         Log.D(Log.TagQuery, "%s: created new rerunUpdateFuture: %s", this, rerunUpdateFuture
               );
         return;
     }
     // No query in flight, so kick one off
     queryFuture = RunAsyncInternal(new _QueryCompleteListener_281(this));
     Log.D(Log.TagQuery, "%s: update() created queryFuture: %s", this, queryFuture);
 }
        /// <exception cref="System.Exception"/>
        public virtual void TestUniqueDestinationPath()
        {
            Configuration conf    = new Configuration();
            FileContext   files   = FileContext.GetLocalFSFileContext(conf);
            Path          basedir = files.MakeQualified(new Path("target", typeof(TestFSDownload).Name
                                                                 ));

            files.Mkdir(basedir, null, true);
            conf.SetStrings(typeof(TestFSDownload).FullName, basedir.ToString());
            ExecutorService   singleThreadedExec = Executors.NewSingleThreadExecutor();
            LocalDirAllocator dirs = new LocalDirAllocator(typeof(TestFSDownload).FullName);
            Path destPath          = dirs.GetLocalPathForWrite(basedir.ToString(), conf);

            destPath = new Path(destPath, System.Convert.ToString(uniqueNumberGenerator.IncrementAndGet
                                                                      ()));
            Path p = new Path(basedir, "dir" + 0 + ".jar");
            LocalResourceVisibility vis  = LocalResourceVisibility.Private;
            LocalResource           rsrc = CreateJar(files, p, vis);
            FSDownload fsd = new FSDownload(files, UserGroupInformation.GetCurrentUser(), conf
                                            , destPath, rsrc);
            Future <Path> rPath = singleThreadedExec.Submit(fsd);

            singleThreadedExec.Shutdown();
            while (!singleThreadedExec.AwaitTermination(1000, TimeUnit.Milliseconds))
            {
            }
            NUnit.Framework.Assert.IsTrue(rPath.IsDone());
            // Now FSDownload will not create a random directory to localize the
            // resource. Therefore the final localizedPath for the resource should be
            // destination directory (passed as an argument) + file name.
            NUnit.Framework.Assert.AreEqual(destPath, rPath.Get().GetParent());
        }
Exemple #3
0
            /// <exception cref="System.Exception"/>
            public Future <Path> Answer(InvocationOnMock invoc)
            {
                Future <Path> done = Org.Mockito.Mockito.Mock <Future>();

                Org.Mockito.Mockito.When(done.IsDone()).ThenReturn(true);
                TestContainerLocalizer.FakeDownload d = (TestContainerLocalizer.FakeDownload)invoc
                                                        .GetArguments()[0];
                Org.Mockito.Mockito.When(done.Get()).ThenReturn(d.Call());
                return(done);
            }
        /// <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);
        }