Exemplo n.º 1
0
        public virtual void TestUse_ExistingEntry_NoAppIds()
        {
            // Pre-populate the SCM with one cache entry
            store.AddResource("key1", "foo.jar");
            long hits = ClientSCMMetrics.GetInstance().GetCacheHits();
            UseSharedCacheResourceRequest request = recordFactory.NewRecordInstance <UseSharedCacheResourceRequest
                                                                                     >();

            request.SetResourceKey("key1");
            request.SetAppId(CreateAppId(2, 2L));
            // Expecting default depth of 3 and under the shared cache root dir
            string expectedPath = testDir.GetAbsolutePath() + "/k/e/y/key1/foo.jar";

            NUnit.Framework.Assert.AreEqual(expectedPath, clientSCMProxy.Use(request).GetPath
                                                ());
            NUnit.Framework.Assert.AreEqual(1, store.GetResourceReferences("key1").Count);
            NUnit.Framework.Assert.AreEqual("Client SCM metrics aren't updated.", 1, ClientSCMMetrics
                                            .GetInstance().GetCacheHits() - hits);
        }
        public virtual void TestNotify_entryExists_differentName()
        {
            long rejected = SharedCacheUploaderMetrics.GetInstance().GetRejectUploads();

            store.AddResource("key1", "foo.jar");
            SCMUploaderNotifyRequest request = recordFactory.NewRecordInstance <SCMUploaderNotifyRequest
                                                                                >();

            request.SetResourceKey("key1");
            request.SetFilename("foobar.jar");
            NUnit.Framework.Assert.IsFalse(proxy.Notify(request).GetAccepted());
            ICollection <SharedCacheResourceReference> set = store.GetResourceReferences("key1"
                                                                                         );

            NUnit.Framework.Assert.IsNotNull(set);
            NUnit.Framework.Assert.AreEqual(0, set.Count);
            NUnit.Framework.Assert.AreEqual("NM upload metrics aren't updated.", 1, SharedCacheUploaderMetrics
                                            .GetInstance().GetRejectUploads() - rejected);
        }
Exemplo n.º 3
0
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        public virtual SCMUploaderNotifyResponse Notify(SCMUploaderNotifyRequest request)
        {
            SCMUploaderNotifyResponse response = recordFactory.NewRecordInstance <SCMUploaderNotifyResponse
                                                                                  >();
            // TODO (YARN-2774): proper security/authorization needs to be implemented
            string filename = store.AddResource(request.GetResourceKey(), request.GetFileName
                                                    ());
            bool accepted = filename.Equals(request.GetFileName());

            if (accepted)
            {
                this.metrics.IncAcceptedUploads();
            }
            else
            {
                this.metrics.IncRejectedUploads();
            }
            response.SetAccepted(accepted);
            return(response);
        }