Пример #1
0
        /// <exception cref="System.Exception"/>
        public virtual void TestSetupDistributedCacheConflictsFiles()
        {
            Configuration conf = new Configuration();

            conf.SetClass("fs.mockfs.impl", typeof(TestMRApps.MockFileSystem), typeof(FileSystem
                                                                                      ));
            URI        mockUri = URI.Create("mockfs://mock/");
            FileSystem mockFs  = ((FilterFileSystem)FileSystem.Get(mockUri, conf)).GetRawFileSystem
                                     ();
            URI  file      = new URI("mockfs://mock/tmp/something.zip#something");
            Path filePath  = new Path(file);
            URI  file2     = new URI("mockfs://mock/tmp/something.txt#something");
            Path file2Path = new Path(file2);

            Org.Mockito.Mockito.When(mockFs.ResolvePath(filePath)).ThenReturn(filePath);
            Org.Mockito.Mockito.When(mockFs.ResolvePath(file2Path)).ThenReturn(file2Path);
            DistributedCache.AddCacheFile(file, conf);
            DistributedCache.AddCacheFile(file2, conf);
            conf.Set(MRJobConfig.CacheFileTimestamps, "10,11");
            conf.Set(MRJobConfig.CacheFilesSizes, "10,11");
            conf.Set(MRJobConfig.CacheFileVisibilities, "true,true");
            IDictionary <string, LocalResource> localResources = new Dictionary <string, LocalResource
                                                                                 >();

            MRApps.SetupDistributedCache(conf, localResources);
            NUnit.Framework.Assert.AreEqual(1, localResources.Count);
            LocalResource lr = localResources["something"];

            //First one wins
            NUnit.Framework.Assert.IsNotNull(lr);
            NUnit.Framework.Assert.AreEqual(10l, lr.GetSize());
            NUnit.Framework.Assert.AreEqual(10l, lr.GetTimestamp());
            NUnit.Framework.Assert.AreEqual(LocalResourceType.File, lr.GetType());
        }
Пример #2
0
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestSetupDistributedCacheEmpty()
        {
            Configuration conf = new Configuration();
            IDictionary <string, LocalResource> localResources = new Dictionary <string, LocalResource
                                                                                 >();

            MRApps.SetupDistributedCache(conf, localResources);
            NUnit.Framework.Assert.IsTrue("Empty Config did not produce an empty list of resources"
                                          , localResources.IsEmpty());
        }