Esempio n. 1
0
        public virtual void SetupCluster()
        {
            Configuration conf = SetupCommonConfig();

            // Dial down the retention of extra edits and checkpoints. This is to
            // help catch regressions of HDFS-4238 (SBN should not purge shared edits)
            conf.SetInt(DFSConfigKeys.DfsNamenodeNumCheckpointsRetainedKey, 1);
            conf.SetInt(DFSConfigKeys.DfsNamenodeNumExtraEditsRetainedKey, 0);
            int retryCount = 0;

            while (true)
            {
                try
                {
                    int basePort = 10060 + random.Next(100) * 2;
                    MiniDFSNNTopology topology = new MiniDFSNNTopology().AddNameservice(new MiniDFSNNTopology.NSConf
                                                                                            ("ns1").AddNN(new MiniDFSNNTopology.NNConf("nn1").SetHttpPort(basePort)).AddNN(new
                                                                                                                                                                           MiniDFSNNTopology.NNConf("nn2").SetHttpPort(basePort + 1)));
                    cluster = new MiniDFSCluster.Builder(conf).NnTopology(topology).NumDataNodes(1).Build
                                  ();
                    cluster.WaitActive();
                    nn0 = cluster.GetNameNode(0);
                    nn1 = cluster.GetNameNode(1);
                    fs  = HATestUtil.ConfigureFailoverFs(cluster, conf);
                    cluster.TransitionToActive(0);
                    ++retryCount;
                    break;
                }
                catch (BindException)
                {
                    Log.Info("Set up MiniDFSCluster failed due to port conflicts, retry " + retryCount
                             + " times");
                }
            }
        }
        public virtual void SetupCluster()
        {
            conf = new Configuration();
            conf.SetInt(DFSConfigKeys.DfsHaTaileditsPeriodKey, 1);
            HAUtil.SetAllowStandbyReads(conf, true);
            fsHelper = new FileSystemTestHelper();
            string testRoot = fsHelper.GetTestRootDir();

            testRootDir = new FilePath(testRoot).GetAbsoluteFile();
            conf.Set(DFSConfigKeys.DfsEncryptionKeyProviderUri, JavaKeyStoreProvider.SchemeName
                     + "://file" + new Path(testRootDir.ToString(), "test.jks").ToUri());
            cluster = new MiniDFSCluster.Builder(conf).NnTopology(MiniDFSNNTopology.SimpleHATopology
                                                                      ()).NumDataNodes(1).Build();
            cluster.WaitActive();
            cluster.TransitionToActive(0);
            fs = (DistributedFileSystem)HATestUtil.ConfigureFailoverFs(cluster, conf);
            DFSTestUtil.CreateKey(TestKey, cluster, 0, conf);
            DFSTestUtil.CreateKey(TestKey, cluster, 1, conf);
            nn0       = cluster.GetNameNode(0);
            nn1       = cluster.GetNameNode(1);
            dfsAdmin0 = new HdfsAdmin(cluster.GetURI(0), conf);
            dfsAdmin1 = new HdfsAdmin(cluster.GetURI(1), conf);
            KeyProviderCryptoExtension nn0Provider = cluster.GetNameNode(0).GetNamesystem().GetProvider
                                                         ();

            fs.GetClient().SetKeyProvider(nn0Provider);
        }
Esempio n. 3
0
        /// <exception cref="Org.Apache.Hadoop.HA.ServiceFailedException"/>
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="Sharpen.URISyntaxException"/>
        /// <exception cref="System.Exception"/>
        private void AssertCanStartHANameNodes(MiniDFSCluster cluster, Configuration conf
                                               , string path)
        {
            // Now should be able to start both NNs. Pass "false" here so that we don't
            // try to waitActive on all NNs, since the second NN doesn't exist yet.
            cluster.RestartNameNode(0, false);
            cluster.RestartNameNode(1, true);
            // Make sure HA is working.
            cluster.GetNameNode(0).GetRpcServer().TransitionToActive(new HAServiceProtocol.StateChangeRequestInfo
                                                                         (HAServiceProtocol.RequestSource.RequestByUser));
            FileSystem fs = null;

            try
            {
                Path newPath = new Path(path);
                fs = HATestUtil.ConfigureFailoverFs(cluster, conf);
                NUnit.Framework.Assert.IsTrue(fs.Mkdirs(newPath));
                HATestUtil.WaitForStandbyToCatchUp(cluster.GetNameNode(0), cluster.GetNameNode(1)
                                                   );
                NUnit.Framework.Assert.IsTrue(NameNodeAdapter.GetFileInfo(cluster.GetNameNode(1),
                                                                          newPath.ToString(), false).IsDir());
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }
Esempio n. 4
0
        /// <summary>Sets the required configurations for performing failover.</summary>
        public static void SetFailoverConfigurations(MiniDFSCluster cluster, Configuration
                                                     conf, string logicalName, int nsIndex)
        {
            IPEndPoint nnAddr1 = cluster.GetNameNode(2 * nsIndex).GetNameNodeAddress();
            IPEndPoint nnAddr2 = cluster.GetNameNode(2 * nsIndex + 1).GetNameNodeAddress();

            SetFailoverConfigurations(conf, logicalName, nnAddr1, nnAddr2);
        }
 public virtual void TestSingleFailedEditsDirOnFlush()
 {
     NUnit.Framework.Assert.IsTrue(DoAnEdit());
     // Invalidate one edits journal.
     InvalidateEditsDirAtIndex(0, true, false);
     // The NN has not terminated (no ExitException thrown)
     NUnit.Framework.Assert.IsTrue(DoAnEdit());
     // A single journal failure should not result in a call to terminate
     NUnit.Framework.Assert.IsFalse(cluster.GetNameNode().IsInSafeMode());
 }
Esempio n. 6
0
        /// <summary>
        /// Test that, if there are no blocks in the filesystem,
        /// the NameNode doesn't enter the "safemode extension" period.
        /// </summary>
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestNoExtensionIfNoBlocks()
        {
            cluster.GetConfiguration(0).SetInt(DFSConfigKeys.DfsNamenodeSafemodeExtensionKey,
                                               60000);
            cluster.RestartNameNode();
            // Even though we have safemode extension set high, we should immediately
            // exit safemode on startup because there are no blocks in the namespace.
            string status = cluster.GetNameNode().GetNamesystem().GetSafemode();

            NUnit.Framework.Assert.AreEqual(string.Empty, status);
        }
Esempio n. 7
0
 /// <exception cref="System.IO.IOException"/>
 private void StartCluster()
 {
     conf = new HdfsConfiguration();
     conf.SetInt("dfs.blocksize", 1024 * 1024);
     cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(ReplFactor).Build();
     cluster.WaitActive();
     fs = cluster.GetFileSystem();
     nn = cluster.GetNameNode(0);
     NUnit.Framework.Assert.IsNotNull(nn);
     dn0 = cluster.GetDataNodes()[0];
     NUnit.Framework.Assert.IsNotNull(dn0);
     blockPoolId = cluster.GetNameNode(0).GetNamesystem().GetBlockPoolId();
 }
Esempio n. 8
0
 /// <exception cref="System.IO.IOException"/>
 private void RestartStandby()
 {
     cluster.ShutdownNameNode(1);
     // Set the safemode extension to be lengthy, so that the tests
     // can check the safemode message after the safemode conditions
     // have been achieved, without being racy.
     cluster.GetConfiguration(1).SetInt(DFSConfigKeys.DfsNamenodeSafemodeExtensionKey,
                                        30000);
     cluster.GetConfiguration(1).SetInt(DFSConfigKeys.DfsHaTaileditsPeriodKey, 1);
     cluster.RestartNameNode(1);
     nn1 = cluster.GetNameNode(1);
     NUnit.Framework.Assert.AreEqual(nn1.GetNamesystem().GetTransactionsSinceLastLogRoll
                                         (), 0L);
 }
Esempio n. 9
0
 /// <summary>Signal the maps/reduces to start.</summary>
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="Sharpen.TimeoutException"/>
 internal static void SignalTasks(MiniDFSCluster dfs, FileSystem fileSys, string mapSignalFile
                                  , string reduceSignalFile, int replication)
 {
     try
     {
         WriteFile(dfs.GetNameNode(), fileSys.GetConf(), new Path(mapSignalFile), (short)replication
                   );
         WriteFile(dfs.GetNameNode(), fileSys.GetConf(), new Path(reduceSignalFile), (short
                                                                                      )replication);
     }
     catch (Exception)
     {
     }
 }
Esempio n. 10
0
        public virtual void SetupCluster()
        {
            Configuration conf = new Configuration();

            conf.SetInt(DFSConfigKeys.DfsHaTaileditsPeriodKey, 1);
            HAUtil.SetAllowStandbyReads(conf, true);
            cluster = new MiniDFSCluster.Builder(conf).NnTopology(MiniDFSNNTopology.SimpleHATopology
                                                                      ()).NumDataNodes(1).WaitSafeMode(false).Build();
            cluster.WaitActive();
            nn0 = cluster.GetNameNode(0);
            nn1 = cluster.GetNameNode(1);
            fs  = HATestUtil.ConfigureFailoverFs(cluster, conf);
            cluster.TransitionToActive(0);
        }
Esempio n. 11
0
        /// <exception cref="System.Exception"/>
        private void TestUpgrade(TestBootstrapStandbyWithQJM.UpgradeState state)
        {
            cluster.TransitionToActive(0);
            Configuration confNN1 = cluster.GetConfiguration(1);
            FilePath      current = cluster.GetNameNode(1).GetFSImage().GetStorage().GetStorageDir
                                        (0).GetCurrentDir();
            FilePath tmp = cluster.GetNameNode(1).GetFSImage().GetStorage().GetStorageDir(0).
                           GetPreviousTmp();

            // shut down nn1
            cluster.ShutdownNameNode(1);
            // make NN0 in upgrade state
            FSImage fsImage0 = cluster.GetNameNode(0).GetNamesystem().GetFSImage();

            Whitebox.SetInternalState(fsImage0, "isUpgradeFinalized", false);
            switch (state)
            {
            case TestBootstrapStandbyWithQJM.UpgradeState.Recover:
            {
                // rename the current directory to previous.tmp in nn1
                NNStorage.Rename(current, tmp);
                break;
            }

            case TestBootstrapStandbyWithQJM.UpgradeState.Format:
            {
                // rename the current directory to a random name so it's not formatted
                FilePath wrongPath = new FilePath(current.GetParentFile(), "wrong");
                NNStorage.Rename(current, wrongPath);
                break;
            }

            default:
            {
                break;
            }
            }
            int rc = BootstrapStandby.Run(new string[] { "-force" }, confNN1);

            NUnit.Framework.Assert.AreEqual(0, rc);
            // Should have copied over the namespace from the standby
            FSImageTestUtil.AssertNNHasCheckpoints(cluster, 1, ImmutableList.Of(0));
            FSImageTestUtil.AssertNNFilesMatch(cluster);
            // make sure the NN1 is in upgrade state, i.e., the previous directory has
            // been successfully created
            cluster.RestartNameNode(1);
            NUnit.Framework.Assert.IsFalse(cluster.GetNameNode(1).GetNamesystem().IsUpgradeFinalized
                                               ());
        }
Esempio n. 12
0
 public virtual void SetUp()
 {
     cluster = new MiniDFSCluster.Builder(Conf).Build();
     cluster.WaitActive();
     cluster.GetNameNode();
     fs = cluster.GetFileSystem();
 }
Esempio n. 13
0
        public virtual void TestStorageReportHasStorageTypeAndState()
        {
            // Make sure we are not testing with the default type, that would not
            // be a very good test.
            NUnit.Framework.Assert.AreNotSame(storageType, StorageType.Default);
            NameNode nn = cluster.GetNameNode();
            DataNode dn = cluster.GetDataNodes()[0];
            // Insert a spy object for the NN RPC.
            DatanodeProtocolClientSideTranslatorPB nnSpy = DataNodeTestUtils.SpyOnBposToNN(dn
                                                                                           , nn);

            // Trigger a heartbeat so there is an interaction with the spy
            // object.
            DataNodeTestUtils.TriggerHeartbeat(dn);
            // Verify that the callback passed in the expected parameters.
            ArgumentCaptor <StorageReport[]> captor = ArgumentCaptor.ForClass <StorageReport[]>
                                                          ();

            Org.Mockito.Mockito.Verify(nnSpy).SendHeartbeat(Matchers.Any <DatanodeRegistration
                                                                          >(), captor.Capture(), Matchers.AnyLong(), Matchers.AnyLong(), Matchers.AnyInt()
                                                            , Matchers.AnyInt(), Matchers.AnyInt(), Org.Mockito.Mockito.Any <VolumeFailureSummary
                                                                                                                             >());
            StorageReport[] reports = captor.GetValue();
            foreach (StorageReport report in reports)
            {
                Assert.AssertThat(report.GetStorage().GetStorageType(), IS.Is(storageType));
                Assert.AssertThat(report.GetStorage().GetState(), IS.Is(DatanodeStorage.State.Normal
                                                                        ));
            }
        }
Esempio n. 14
0
        public virtual void Test()
        {
            // make sure JT starts
            Configuration jobConf = new JobConf(mrCluster.GetConfig());
            // provide namenodes names for the job to get the delegation tokens for
            //String nnUri = dfsCluster.getNameNode().getUri(namenode).toString();
            NameNode nn    = dfsCluster.GetNameNode();
            URI      nnUri = NameNode.GetUri(nn.GetNameNodeAddress());

            jobConf.Set(JobContext.JobNamenodes, nnUri + "," + nnUri.ToString());
            jobConf.Set("mapreduce.job.credentials.json", "keys.json");
            // using argument to pass the file name
            string[] args = new string[] { "-m", "1", "-r", "1", "-mt", "1", "-rt", "1" };
            int      res  = -1;

            try
            {
                res = ToolRunner.Run(jobConf, new CredentialsTestJob(), args);
            }
            catch (Exception e)
            {
                System.Console.Out.WriteLine("Job failed with" + e.GetLocalizedMessage());
                Sharpen.Runtime.PrintStackTrace(e, System.Console.Out);
                NUnit.Framework.Assert.Fail("Job failed");
            }
            NUnit.Framework.Assert.AreEqual("dist job res is not 0", res, 0);
        }
Esempio n. 15
0
        public static void Setup()
        {
            string currentUser = Runtime.GetProperty("user.name");

            config.Set(DefaultImpersonationProvider.GetTestProvider().GetProxySuperuserGroupConfKey
                           (currentUser), "*");
            config.Set(DefaultImpersonationProvider.GetTestProvider().GetProxySuperuserIpConfKey
                           (currentUser), "*");
            ProxyUsers.RefreshSuperUserGroupsConfiguration(config);
            cluster = new MiniDFSCluster.Builder(config).NumDataNodes(1).Build();
            cluster.WaitActive();
            hdfs = cluster.GetFileSystem();
            nn   = cluster.GetNameNode();
            // Use emphral port in case tests are running in parallel
            config.SetInt("nfs3.mountd.port", 0);
            config.SetInt("nfs3.server.port", 0);
            // Start nfs
            Org.Apache.Hadoop.Hdfs.Nfs.Nfs3.Nfs3 nfs3 = new Org.Apache.Hadoop.Hdfs.Nfs.Nfs3.Nfs3
                                                            (config);
            nfs3.StartServiceInternal(false);
            nfsd            = (RpcProgramNfs3)nfs3.GetRpcProgram();
            securityHandler = Org.Mockito.Mockito.Mock <SecurityHandler>();
            Org.Mockito.Mockito.When(securityHandler.GetUser()).ThenReturn(Runtime.GetProperty
                                                                               ("user.name"));
        }
Esempio n. 16
0
        public static void SetUp()
        {
            conf = new Configuration();
            conf.SetBoolean(DFSConfigKeys.DfsWebhdfsEnabledKey, true);
            conf.Set(DFSConfigKeys.DfsHttpPolicyKey, HttpConfig.Policy.HttpsOnly.ToString());
            conf.Set(DFSConfigKeys.DfsNamenodeHttpsAddressKey, "localhost:0");
            conf.Set(DFSConfigKeys.DfsDatanodeHttpsAddressKey, "localhost:0");
            FilePath @base = new FilePath(Basedir);

            FileUtil.FullyDelete(@base);
            @base.Mkdirs();
            keystoresDir = new FilePath(Basedir).GetAbsolutePath();
            sslConfDir   = KeyStoreTestUtil.GetClasspathDir(typeof(TestHttpsFileSystem));
            KeyStoreTestUtil.SetupSSLConfig(keystoresDir, sslConfDir, conf, false);
            cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(1).Build();
            cluster.WaitActive();
            OutputStream os = cluster.GetFileSystem().Create(new Path("/test"));

            os.Write(23);
            os.Close();
            IPEndPoint addr = cluster.GetNameNode().GetHttpsAddress();

            nnAddr = NetUtils.GetHostPortString(addr);
            conf.Set(DFSConfigKeys.DfsNamenodeHttpsAddressKey, nnAddr);
        }
Esempio n. 17
0
        /* Helper function to create a key in the Key Provider. */
        /// <exception cref="Sharpen.NoSuchAlgorithmException"/>
        /// <exception cref="System.IO.IOException"/>
        private void CreateAKey(string keyName, Configuration conf)
        {
            KeyProvider provider = dfsCluster.GetNameNode().GetNamesystem().GetProvider();

            KeyProvider.Options options = KeyProvider.Options(conf);
            provider.CreateKey(keyName, options);
            provider.Flush();
        }
Esempio n. 18
0
        public static void SetUp()
        {
            cluster   = (new MiniDFSCluster.Builder(conf)).NumDataNodes(1).Build();
            nnAddress = cluster.GetNameNode().GetNameNodeAddress();
            DataNode dn = cluster.GetDataNodes()[0];

            dnAddress = new IPEndPoint(dn.GetDatanodeId().GetIpAddr(), dn.GetIpcPort());
        }
Esempio n. 19
0
        /// <exception cref="System.IO.IOException"/>
        internal static void CheckPath(MiniDFSCluster cluster, FileSystem fileSys)
        {
            IPEndPoint add = cluster.GetNameNode().GetNameNodeAddress();

            // Test upper/lower case
            fileSys.CheckPath(new Path("hdfs://" + StringUtils.ToUpperCase(add.GetHostName())
                                       + ":" + add.Port));
        }
        public virtual void SetupCluster()
        {
            SecurityUtilTestHelper.SetTokenServiceUseIp(true);
            conf.SetBoolean(DFSConfigKeys.DfsNamenodeDelegationTokenAlwaysUseKey, true);
            conf.Set(CommonConfigurationKeysPublic.HadoopSecurityAuthToLocal, "RULE:[2:$1@$0](JobTracker@.*FOO.COM)s/@.*//"
                     + "DEFAULT");
            cluster = new MiniDFSCluster.Builder(conf).NnTopology(MiniDFSNNTopology.SimpleHATopology
                                                                      ()).NumDataNodes(0).Build();
            cluster.WaitActive();
            string logicalName = HATestUtil.GetLogicalHostname(cluster);

            HATestUtil.SetFailoverConfigurations(cluster, conf, logicalName, 0);
            nn0 = cluster.GetNameNode(0);
            nn1 = cluster.GetNameNode(1);
            fs  = HATestUtil.ConfigureFailoverFs(cluster, conf);
            dfs = (DistributedFileSystem)fs;
            cluster.TransitionToActive(0);
            dtSecretManager = NameNodeAdapter.GetDtSecretManager(nn0.GetNamesystem());
        }
 /// <exception cref="System.IO.IOException"/>
 internal Suite(MiniDFSCluster cluster, int nNameNodes, int nDataNodes)
 {
     this.cluster = cluster;
     clients      = new ClientProtocol[nNameNodes];
     for (int i = 0; i < nNameNodes; i++)
     {
         clients[i] = cluster.GetNameNode(i).GetRpcServer();
     }
     replication = (short)Math.Max(1, nDataNodes - 1);
 }
Esempio n. 22
0
        public virtual void TestReplicationError()
        {
            // create a file of replication factor of 1
            Path fileName = new Path("/test.txt");
            int  fileLen  = 1;

            DFSTestUtil.CreateFile(fs, fileName, 1, (short)1, 1L);
            DFSTestUtil.WaitReplication(fs, fileName, (short)1);
            // get the block belonged to the created file
            LocatedBlocks blocks = NameNodeAdapter.GetBlockLocations(cluster.GetNameNode(), fileName
                                                                     .ToString(), 0, (long)fileLen);

            NUnit.Framework.Assert.AreEqual("Should only find 1 block", blocks.LocatedBlockCount
                                                (), 1);
            LocatedBlock block = blocks.Get(0);

            // bring up a second datanode
            cluster.StartDataNodes(conf, 1, true, null, null);
            cluster.WaitActive();
            int      sndNode  = 1;
            DataNode datanode = cluster.GetDataNodes()[sndNode];
            // replicate the block to the second datanode
            IPEndPoint target = datanode.GetXferAddress();
            Socket     s      = Sharpen.Extensions.CreateSocket(target.Address, target.Port);
            // write the header.
            DataOutputStream @out     = new DataOutputStream(s.GetOutputStream());
            DataChecksum     checksum = DataChecksum.NewDataChecksum(DataChecksum.Type.Crc32, 512
                                                                     );

            new Sender(@out).WriteBlock(block.GetBlock(), StorageType.Default, BlockTokenSecretManager
                                        .DummyToken, string.Empty, new DatanodeInfo[0], new StorageType[0], null, BlockConstructionStage
                                        .PipelineSetupCreate, 1, 0L, 0L, 0L, checksum, CachingStrategy.NewDefaultStrategy
                                            (), false, false, null);
            @out.Flush();
            // close the connection before sending the content of the block
            @out.Close();
            // the temporary block & meta files should be deleted
            string   bpid       = cluster.GetNamesystem().GetBlockPoolId();
            FilePath storageDir = cluster.GetInstanceStorageDir(sndNode, 0);
            FilePath dir1       = MiniDFSCluster.GetRbwDir(storageDir, bpid);

            storageDir = cluster.GetInstanceStorageDir(sndNode, 1);
            FilePath dir2 = MiniDFSCluster.GetRbwDir(storageDir, bpid);

            while (dir1.ListFiles().Length != 0 || dir2.ListFiles().Length != 0)
            {
                Sharpen.Thread.Sleep(100);
            }
            // then increase the file's replication factor
            fs.SetReplication(fileName, (short)2);
            // replication should succeed
            DFSTestUtil.WaitReplication(fs, fileName, (short)1);
            // clean up the file
            fs.Delete(fileName, false);
        }
 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();
 }
 public virtual void Setup()
 {
     conf = new HdfsConfiguration();
     conf.SetLong(DFSConfigKeys.DfsBlockSizeKey, BlockSize);
     conf.SetBoolean(DFSConfigKeys.DfsNamenodeEnableRetryCacheKey, true);
     conf.SetBoolean(DFSConfigKeys.DfsNamenodeAclsEnabledKey, true);
     cluster = new MiniDFSCluster.Builder(conf).Build();
     cluster.WaitActive();
     nnRpc      = cluster.GetNameNode().GetRpcServer();
     filesystem = cluster.GetFileSystem();
 }
        private int GetBlockCount()
        {
            NUnit.Framework.Assert.IsNotNull("Null cluster", mc);
            NUnit.Framework.Assert.IsNotNull("No Namenode in cluster", mc.GetNameNode());
            FSNamesystem namesystem = mc.GetNamesystem();

            NUnit.Framework.Assert.IsNotNull("Null Namesystem in cluster", namesystem);
            NUnit.Framework.Assert.IsNotNull("Null Namesystem.blockmanager", namesystem.GetBlockManager
                                                 ());
            return((int)namesystem.GetBlocksTotal());
        }
Esempio n. 26
0
        /// <summary>Restart the cluster, optionally saving a new checkpoint.</summary>
        /// <param name="checkpoint">boolean true to save a new checkpoint</param>
        /// <param name="aclsEnabled">if true, ACL support is enabled</param>
        /// <exception cref="System.Exception">if restart fails</exception>
        private void Restart(bool checkpoint, bool aclsEnabled)
        {
            NameNode nameNode = cluster.GetNameNode();

            if (checkpoint)
            {
                NameNodeAdapter.EnterSafeMode(nameNode, false);
                NameNodeAdapter.SaveNamespace(nameNode);
            }
            Shutdown();
            InitCluster(false, aclsEnabled);
        }
Esempio n. 27
0
 public virtual void TestStaleNodes()
 {
     // Set two datanodes as stale
     for (int i = 0; i < 2; i++)
     {
         DataNode dn = cluster.GetDataNodes()[i];
         DataNodeTestUtils.SetHeartbeatsDisabledForTests(dn, true);
         long staleInterval = Conf.GetLong(DFSConfigKeys.DfsNamenodeStaleDatanodeIntervalKey
                                           , DFSConfigKeys.DfsNamenodeStaleDatanodeIntervalDefault);
         DatanodeDescriptor dnDes = cluster.GetNameNode().GetNamesystem().GetBlockManager(
             ).GetDatanodeManager().GetDatanode(dn.GetDatanodeId());
         DFSTestUtil.ResetLastUpdatesWithOffset(dnDes, -(staleInterval + 1));
     }
     // Let HeartbeatManager to check heartbeat
     BlockManagerTestUtil.CheckHeartbeat(cluster.GetNameNode().GetNamesystem().GetBlockManager
                                             ());
     MetricsAsserts.AssertGauge("StaleDataNodes", 2, MetricsAsserts.GetMetrics(NsMetrics
                                                                               ));
     // Reset stale datanodes
     for (int i_1 = 0; i_1 < 2; i_1++)
     {
         DataNode dn = cluster.GetDataNodes()[i_1];
         DataNodeTestUtils.SetHeartbeatsDisabledForTests(dn, false);
         DatanodeDescriptor dnDes = cluster.GetNameNode().GetNamesystem().GetBlockManager(
             ).GetDatanodeManager().GetDatanode(dn.GetDatanodeId());
         DFSTestUtil.ResetLastUpdatesWithOffset(dnDes, 0);
     }
     // Let HeartbeatManager to refresh
     BlockManagerTestUtil.CheckHeartbeat(cluster.GetNameNode().GetNamesystem().GetBlockManager
                                             ());
     MetricsAsserts.AssertGauge("StaleDataNodes", 0, MetricsAsserts.GetMetrics(NsMetrics
                                                                               ));
 }
        /// <summary>Get edits filename</summary>
        /// <returns>edits file name for cluster</returns>
        /// <exception cref="System.IO.IOException"/>
        private string GetEditsFilename(CheckpointSignature sig)
        {
            FSImage image = cluster.GetNameNode().GetFSImage();
            // it was set up to only have ONE StorageDirectory
            IEnumerator <Storage.StorageDirectory> it = image.GetStorage().DirIterator(NNStorage.NameNodeDirType
                                                                                       .Edits);

            Storage.StorageDirectory sd = it.Next();
            FilePath ret = NNStorage.GetFinalizedEditsFile(sd, 1, sig.curSegmentTxId - 1);

            System.Diagnostics.Debug.Assert(ret.Exists(), "expected " + ret + " exists");
            return(ret.GetAbsolutePath());
        }
 private void AddCrmThreads(MiniDFSCluster cluster, List <Sharpen.Thread> crmThreads
                            )
 {
     for (int nn = 0; nn <= 1; nn++)
     {
         Sharpen.Thread thread = cluster.GetNameNode(nn).GetNamesystem().GetCacheManager()
                                 .GetCacheReplicationMonitor();
         if (thread != null)
         {
             crmThreads.AddItem(thread);
         }
     }
 }
        public virtual void TestWithCheckpoint()
        {
            Path path = new Path("/test");

            DoWriteAndAbort(fs, path);
            fs.Delete(new Path("/test/test"), true);
            NameNode nameNode = cluster.GetNameNode();

            NameNodeAdapter.EnterSafeMode(nameNode, false);
            NameNodeAdapter.SaveNamespace(nameNode);
            NameNodeAdapter.LeaveSafeMode(nameNode);
            cluster.RestartNameNode(true);
            // read snapshot file after restart
            string test2snapshotPath = Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot
                                       .GetSnapshotPath(path.ToString(), "s1/test/test2");

            DFSTestUtil.ReadFile(fs, new Path(test2snapshotPath));
            string test3snapshotPath = Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot
                                       .GetSnapshotPath(path.ToString(), "s1/test/test3");

            DFSTestUtil.ReadFile(fs, new Path(test3snapshotPath));
        }