Пример #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);
        }
        private static IPEndPoint GetNNSocketAddress(BPOfferService bpos)
        {
            IList <BPServiceActor> actors = bpos.GetBPServiceActors();

            NUnit.Framework.Assert.AreEqual(1, actors.Count);
            return(actors[0].GetNNSocketAddress());
        }
 public virtual void StartCluster()
 {
     conf        = new HdfsConfiguration();
     cluster     = new MiniDFSCluster.Builder(conf).NumDataNodes(DnCount).Build();
     fs          = cluster.GetFileSystem();
     singletonNn = cluster.GetNameNode();
     singletonDn = cluster.GetDataNodes()[0];
     bpos        = singletonDn.GetAllBpOs()[0];
     actor       = bpos.GetBPServiceActors()[0];
     storageUuid = singletonDn.GetFSDataset().GetVolumes()[0].GetStorageID();
 }
Пример #4
0
        public virtual void TestBPInitErrorHandling()
        {
            DataNode mockDn = Org.Mockito.Mockito.Mock <DataNode>();

            Org.Mockito.Mockito.DoReturn(true).When(mockDn).ShouldRun();
            Configuration conf      = new Configuration();
            FilePath      dnDataDir = new FilePath(new FilePath(TestBuildData, "testBPInitErrorHandling"
                                                                ), "data");

            conf.Set(DFSConfigKeys.DfsDatanodeDataDirKey, dnDataDir.ToURI().ToString());
            Org.Mockito.Mockito.DoReturn(conf).When(mockDn).GetConf();
            Org.Mockito.Mockito.DoReturn(new DNConf(conf)).When(mockDn).GetDnConf();
            Org.Mockito.Mockito.DoReturn(DataNodeMetrics.Create(conf, "fake dn")).When(mockDn
                                                                                       ).GetMetrics();
            AtomicInteger count = new AtomicInteger();

            Org.Mockito.Mockito.DoAnswer(new _Answer_328(this, count, mockDn)).When(mockDn).InitBlockPool
                (Org.Mockito.Mockito.Any <BPOfferService>());
            // The initBlockPool is called again. Now mock init is done.
            BPOfferService         bpos   = SetupBPOSForNNs(mockDn, mockNN1, mockNN2);
            IList <BPServiceActor> actors = bpos.GetBPServiceActors();

            NUnit.Framework.Assert.AreEqual(2, actors.Count);
            bpos.Start();
            try
            {
                WaitForInitialization(bpos);
                // even if one of the actor initialization fails, the other one will be
                // finish block report.
                WaitForBlockReport(mockNN1, mockNN2);
            }
            finally
            {
                bpos.Stop();
            }
        }