public virtual void TestSharedEditsMissingLogs()
        {
            RemoveStandbyNameDirs();
            CheckpointSignature sig = nn0.GetRpcServer().RollEditLog();

            NUnit.Framework.Assert.AreEqual(3, sig.GetCurSegmentTxId());
            // Should have created edits_1-2 in shared edits dir
            URI      editsUri     = cluster.GetSharedEditsDir(0, 1);
            FilePath editsDir     = new FilePath(editsUri);
            FilePath editsSegment = new FilePath(new FilePath(editsDir, "current"), NNStorage
                                                 .GetFinalizedEditsFileName(1, 2));

            GenericTestUtils.AssertExists(editsSegment);
            // Delete the segment.
            NUnit.Framework.Assert.IsTrue(editsSegment.Delete());
            // Trying to bootstrap standby should now fail since the edit
            // logs aren't available in the shared dir.
            GenericTestUtils.LogCapturer logs = GenericTestUtils.LogCapturer.CaptureLogs(LogFactory
                                                                                         .GetLog(typeof(BootstrapStandby)));
            try
            {
                int rc = BootstrapStandby.Run(new string[] { "-force" }, cluster.GetConfiguration
                                                  (1));
                NUnit.Framework.Assert.AreEqual(BootstrapStandby.ErrCodeLogsUnavailable, rc);
            }
            finally
            {
                logs.StopCapturing();
            }
            GenericTestUtils.AssertMatches(logs.GetOutput(), "FATAL.*Unable to read transaction ids 1-3 from the configured shared"
                                           );
        }
Exemple #2
0
        /// <exception cref="System.IO.IOException"/>
        private void ShutdownClusterAndRemoveSharedEditsDir()
        {
            cluster.ShutdownNameNode(0);
            cluster.ShutdownNameNode(1);
            FilePath sharedEditsDir = new FilePath(cluster.GetSharedEditsDir(0, 1));

            NUnit.Framework.Assert.IsTrue(FileUtil.FullyDelete(sharedEditsDir));
        }
        /// <exception cref="System.Exception"/>
        private static void WaitForLogRollInSharedDir(MiniDFSCluster cluster, long startTxId
                                                      )
        {
            URI      sharedUri   = cluster.GetSharedEditsDir(0, 1);
            FilePath sharedDir   = new FilePath(sharedUri.GetPath(), "current");
            FilePath expectedLog = new FilePath(sharedDir, NNStorage.GetInProgressEditsFileName
                                                    (startTxId));

            GenericTestUtils.WaitFor(new _Supplier_153(expectedLog), 100, 10000);
        }
        /// <exception cref="System.IO.IOException"/>
        private static void CreateEmptyInProgressEditLog(MiniDFSCluster cluster, NameNode
                                                         nn, bool writeHeader)
        {
            long     txid           = nn.GetNamesystem().GetEditLog().GetLastWrittenTxId();
            URI      sharedEditsUri = cluster.GetSharedEditsDir(0, 1);
            FilePath sharedEditsDir = new FilePath(sharedEditsUri.GetPath());

            Storage.StorageDirectory storageDir = new Storage.StorageDirectory(sharedEditsDir
                                                                               );
            FilePath inProgressFile = NameNodeAdapter.GetInProgressEditsFile(storageDir, txid
                                                                             + 1);

            NUnit.Framework.Assert.IsTrue("Failed to create in-progress edits file", inProgressFile
                                          .CreateNewFile());
            if (writeHeader)
            {
                DataOutputStream @out = new DataOutputStream(new FileOutputStream(inProgressFile)
                                                             );
                EditLogFileOutputStream.WriteHeader(NameNodeLayoutVersion.CurrentLayoutVersion, @out
                                                    );
                @out.Close();
            }
        }