public virtual void TestNotify_noEntry() { long accepted = SharedCacheUploaderMetrics.GetInstance().GetAcceptedUploads(); SCMUploaderNotifyRequest request = recordFactory.NewRecordInstance <SCMUploaderNotifyRequest >(); request.SetResourceKey("key1"); request.SetFilename("foo.jar"); NUnit.Framework.Assert.IsTrue(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().GetAcceptedUploads() - accepted); }
public virtual void TestSuccess() { Configuration conf = new Configuration(); conf.SetBoolean(YarnConfiguration.SharedCacheEnabled, true); LocalResource resource = Org.Mockito.Mockito.Mock <LocalResource>(); Path localPath = Org.Mockito.Mockito.Mock <Path>(); Org.Mockito.Mockito.When(localPath.GetName()).ThenReturn("foo.jar"); string user = "******"; SCMUploaderProtocol scmClient = Org.Mockito.Mockito.Mock <SCMUploaderProtocol>(); SCMUploaderNotifyResponse response = Org.Mockito.Mockito.Mock <SCMUploaderNotifyResponse >(); Org.Mockito.Mockito.When(response.GetAccepted()).ThenReturn(true); Org.Mockito.Mockito.When(scmClient.Notify(Matchers.IsA <SCMUploaderNotifyRequest>( ))).ThenReturn(response); FileSystem fs = Org.Mockito.Mockito.Mock <FileSystem>(); // return false when rename is called Org.Mockito.Mockito.When(fs.Rename(Matchers.IsA <Path>(), Matchers.IsA <Path>())).ThenReturn (true); FileSystem localFs = FileSystem.GetLocal(conf); SharedCacheUploader spied = CreateSpiedUploader(resource, localPath, user, conf, scmClient, fs, localFs); // stub verifyAccess() to return true Org.Mockito.Mockito.DoReturn(true).When(spied).VerifyAccess(); // stub getActualPath() Org.Mockito.Mockito.DoReturn(localPath).When(spied).GetActualPath(); // stub computeChecksum() Org.Mockito.Mockito.DoReturn("abcdef0123456789").When(spied).ComputeChecksum(Matchers.IsA <Path>()); // stub uploadFile() to return true Org.Mockito.Mockito.DoReturn(true).When(spied).UploadFile(Matchers.IsA <Path>(), Matchers.IsA <Path>()); // stub notifySharedCacheManager to return true Org.Mockito.Mockito.DoReturn(true).When(spied).NotifySharedCacheManager(Matchers.IsA <string>(), Matchers.IsA <string>()); NUnit.Framework.Assert.IsTrue(spied.Call()); }
/// <exception cref="Com.Google.Protobuf.ServiceException"/> public virtual YarnServerCommonServiceProtos.SCMUploaderNotifyResponseProto Notify (RpcController controller, YarnServerCommonServiceProtos.SCMUploaderNotifyRequestProto proto) { SCMUploaderNotifyRequestPBImpl request = new SCMUploaderNotifyRequestPBImpl(proto ); try { SCMUploaderNotifyResponse response = real.Notify(request); return(((SCMUploaderNotifyResponsePBImpl)response).GetProto()); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } }
internal virtual bool NotifySharedCacheManager(string checksumVal, string fileName ) { try { SCMUploaderNotifyRequest request = recordFactory.NewRecordInstance <SCMUploaderNotifyRequest >(); request.SetResourceKey(checksumVal); request.SetFilename(fileName); return(scmClient.Notify(request).GetAccepted()); } catch (YarnException e) { throw new IOException(e); } catch (UndeclaredThrowableException e) { // retrieve the cause of the exception and throw it as an IOException throw new IOException(e.InnerException == null ? e : e.InnerException); } }