/// <summary>Checks that the edits file has all opCodes</summary> /// <param name="filename">edits file</param> /// <returns>true is edits (filename) has all opCodes</returns> /// <exception cref="System.IO.IOException"/> private bool HasAllOpCodes(string inFilename) { string outFilename = inFilename + ".stats"; FileOutputStream fout = new FileOutputStream(outFilename); StatisticsEditsVisitor visitor = new StatisticsEditsVisitor(fout); Org.Apache.Hadoop.Hdfs.Tools.OfflineEditsViewer.OfflineEditsViewer oev = new Org.Apache.Hadoop.Hdfs.Tools.OfflineEditsViewer.OfflineEditsViewer (); if (oev.Go(inFilename, outFilename, "stats", new OfflineEditsViewer.Flags(), visitor ) != 0) { return(false); } Log.Info("Statistics for " + inFilename + "\n" + visitor.GetStatisticsString()); bool hasAllOpCodes = true; foreach (FSEditLogOpCodes opCode in FSEditLogOpCodes.Values()) { // don't need to test obsolete opCodes if (skippedOps.Contains(opCode)) { continue; } long count = visitor.GetStatistics()[opCode]; if ((count == null) || (count == 0)) { hasAllOpCodes = false; Log.Info("Opcode " + opCode + " not tested in " + inFilename); } } return(hasAllOpCodes); }
/// <summary>Run OfflineEditsViewer</summary> /// <param name="inFilename">input edits filename</param> /// <param name="outFilename">oputput edits filename</param> /// <exception cref="System.IO.IOException"/> private int RunOev(string inFilename, string outFilename, string processor, bool recovery) { Log.Info("Running oev [" + inFilename + "] [" + outFilename + "]"); Org.Apache.Hadoop.Hdfs.Tools.OfflineEditsViewer.OfflineEditsViewer oev = new Org.Apache.Hadoop.Hdfs.Tools.OfflineEditsViewer.OfflineEditsViewer (); OfflineEditsViewer.Flags flags = new OfflineEditsViewer.Flags(); flags.SetPrintToScreen(); if (recovery) { flags.SetRecoveryMode(); } return(oev.Go(inFilename, outFilename, processor, flags, null)); }