Exemplo n.º 1
0
        /// <summary>
        /// Insert a Mockito spy object between the given DataNode and
        /// the given NameNode.
        /// </summary>
        /// <remarks>
        /// Insert a Mockito spy object between the given DataNode and
        /// the given NameNode. This can be used to delay or wait for
        /// RPC calls on the datanode-&gt;NN path.
        /// </remarks>
        public static DatanodeProtocolClientSideTranslatorPB SpyOnBposToNN(DataNode dn, NameNode
                                                                           nn)
        {
            string         bpid = nn.GetNamesystem().GetBlockPoolId();
            BPOfferService bpos = null;

            foreach (BPOfferService thisBpos in dn.GetAllBpOs())
            {
                if (thisBpos.GetBlockPoolId().Equals(bpid))
                {
                    bpos = thisBpos;
                    break;
                }
            }
            Preconditions.CheckArgument(bpos != null, "No such bpid: %s", bpid);
            BPServiceActor bpsa = null;

            foreach (BPServiceActor thisBpsa in bpos.GetBPServiceActors())
            {
                if (thisBpsa.GetNNSocketAddress().Equals(nn.GetServiceRpcAddress()))
                {
                    bpsa = thisBpsa;
                    break;
                }
            }
            Preconditions.CheckArgument(bpsa != null, "No service actor to NN at %s", nn.GetServiceRpcAddress
                                            ());
            DatanodeProtocolClientSideTranslatorPB origNN = bpsa.GetNameNodeProxy();
            DatanodeProtocolClientSideTranslatorPB spy    = Org.Mockito.Mockito.Spy(origNN);

            bpsa.SetNameNode(spy);
            return(spy);
        }
Exemplo n.º 2
0
        public virtual void SetUp()
        {
            mockDnConf = Org.Mockito.Mockito.Mock <DNConf>();
            Org.Mockito.Mockito.DoReturn(VersionInfo.GetVersion()).When(mockDnConf).GetMinimumNameNodeVersion
                ();
            DataNode mockDN = Org.Mockito.Mockito.Mock <DataNode>();

            Org.Mockito.Mockito.DoReturn(true).When(mockDN).ShouldRun();
            Org.Mockito.Mockito.DoReturn(mockDnConf).When(mockDN).GetDnConf();
            BPOfferService mockBPOS = Org.Mockito.Mockito.Mock <BPOfferService>();

            Org.Mockito.Mockito.DoReturn(mockDN).When(mockBPOS).GetDataNode();
            actor      = new BPServiceActor(InvalidAddr, mockBPOS);
            fakeNsInfo = Org.Mockito.Mockito.Mock <NamespaceInfo>();
            // Return a a good software version.
            Org.Mockito.Mockito.DoReturn(VersionInfo.GetVersion()).When(fakeNsInfo).GetSoftwareVersion
                ();
            // Return a good layout version for now.
            Org.Mockito.Mockito.DoReturn(HdfsConstants.NamenodeLayoutVersion).When(fakeNsInfo
                                                                                   ).GetLayoutVersion();
            DatanodeProtocolClientSideTranslatorPB fakeDnProt = Org.Mockito.Mockito.Mock <DatanodeProtocolClientSideTranslatorPB
                                                                                          >();

            Org.Mockito.Mockito.When(fakeDnProt.VersionRequest()).ThenReturn(fakeNsInfo);
            actor.SetNameNode(fakeDnProt);
        }