public RedFSPersistantStorage(string name, string clog) { dfile = new FileStream(CONFIG.GetBasePath() + name, FileMode.OpenOrCreate, FileAccess.ReadWrite); clogfile = new FileStream(CONFIG.GetBasePath() + clog, FileMode.OpenOrCreate, FileAccess.ReadWrite); initialized = true; }
public void swap_clog() { flush_clog(); lock (fpcache_buf) { clogfile.Flush(); clogfile.Close(); File.Move(CONFIG.GetBasePath() + "clog", CONFIG.GetBasePath() + "clog1"); clogfile = new FileStream(CONFIG.GetBasePath() + "clog", FileMode.OpenOrCreate, FileAccess.ReadWrite); } }
//private int start_dbn_bulk; public Map256M(string name) { mfile = new FileStream(CONFIG.GetBasePath() + name, FileMode.OpenOrCreate, FileAccess.ReadWrite); xfile = new FileStream(CONFIG.GetBasePath() + name + ".x", FileMode.OpenOrCreate, FileAccess.ReadWrite); initialized = true; byte[] buf = new byte[4]; xfile.Read(buf, 0, 4); USED_BLK_COUNT = OPS.get_dbn(buf, 0); DEFS.DEBUGYELLOW("REF", "Found used block count = " + USED_BLK_COUNT); }
public static void INIT_LOGGING() { string t = get_time_formatted(); DEFS.DEBUG("IFSD", "Setting INIT_LOGGING()" + t); if (log == null) { string fname = CONFIG.GetBasePath() + "log_" + t + ".txt"; Console.WriteLine("Setting INIT_LOGGING()" + fname); log = new StreamWriter(fname); DEFS.DEBUG("IFSD", "Setting INIT_LOGGING()" + t); } DEFS.DEBUG("IFSD", "Done INIT_LOGGING()"); }
private void start_operation() { string input_clog = CONFIG.GetBasePath() + "clog1"; string clog_inofbn = CONFIG.GetBasePath() + "clog.inofbn"; string clog_inofbnclean = CONFIG.GetBasePath() + "clog.inofbn.clean"; string clog_dbn = CONFIG.GetBasePath() + "clog.dbn"; string clog_dbnclean = CONFIG.GetBasePath() + "clog.dbn.clean"; string clog_fporder = CONFIG.GetBasePath() + "clog.fporder"; string fpdb_input = CONFIG.GetBasePath() + "fpdb1"; string fpdb_dbncleaned = CONFIG.GetBasePath() + "fpdb.dbn.clean"; string fpdb_fporder = CONFIG.GetBasePath() + "fpdb.fporder"; string fpdb_temp = CONFIG.GetBasePath() + "fpdb.temp"; string dedupeScript_a = CONFIG.GetBasePath() + "script.dedupeop.temp"; string dedupeScript = CONFIG.GetBasePath() + "script.dedupeop"; REDDY.ptrRedFS.dedupe_swap_changelog(); if (File.Exists(input_clog) == false) { DEFS.DEBUG("DE", "Input clog does not exist, so no dedupe op now!"); return; } /* * Prepare the changelog. */ print_file(RECORD_TYPE.FINGERPRINT_RECORD_CLOG, DEDUP_SORT_ORDER.DBN_BASED, input_clog, input_clog + ".txt"); m_stage = DEDUP_ENGINE_STAGE.SORT_CLOG_INOFBN; sort_dedupe_file(RECORD_TYPE.FINGERPRINT_RECORD_CLOG, input_clog, clog_inofbn, DEDUP_SORT_ORDER.INO_FBN_BASED); ui.Update_DedupeUI(DEDUP_ENGINE_STAGE.SORT_CLOG_INOFBN, 100); print_file(RECORD_TYPE.FINGERPRINT_RECORD_CLOG, DEDUP_SORT_ORDER.INO_FBN_BASED, clog_inofbn, clog_inofbn + ".txt"); m_stage = DEDUP_ENGINE_STAGE.CLEAN_CLOG_INOFBNSTALES; clean_clog_file_P1(clog_inofbn, clog_inofbnclean); ui.Update_DedupeUI(DEDUP_ENGINE_STAGE.CLEAN_CLOG_INOFBNSTALES, 100); print_file(RECORD_TYPE.FINGERPRINT_RECORD_CLOG, DEDUP_SORT_ORDER.INO_FBN_BASED, clog_inofbnclean, clog_inofbnclean + ".txt"); m_stage = DEDUP_ENGINE_STAGE.SORT_CLOG_DBN; sort_dedupe_file(RECORD_TYPE.FINGERPRINT_RECORD_CLOG, clog_inofbnclean, clog_dbn, DEDUP_SORT_ORDER.DBN_BASED); ui.Update_DedupeUI(DEDUP_ENGINE_STAGE.SORT_CLOG_DBN, 100); //commenting this off for now. print_file(RECORD_TYPE.FINGERPRINT_RECORD_CLOG, DEDUP_SORT_ORDER.DBN_BASED, clog_dbn, clog_dbn + ".txt"); m_stage = DEDUP_ENGINE_STAGE.CLEAN_CLOG_DBNSTALES; clean_clog_file_P2(clog_dbn, clog_dbnclean); ui.Update_DedupeUI(DEDUP_ENGINE_STAGE.CLEAN_CLOG_DBNSTALES, 100); print_file(RECORD_TYPE.FINGERPRINT_RECORD_CLOG, DEDUP_SORT_ORDER.DBN_BASED, clog_dbnclean, clog_dbnclean + ".txt"); m_stage = DEDUP_ENGINE_STAGE.SORT_CLOG_FPORDER; sort_dedupe_file(RECORD_TYPE.FINGERPRINT_RECORD_CLOG, clog_dbnclean, clog_fporder, DEDUP_SORT_ORDER.FINGERPRINT_BASED); print_file(RECORD_TYPE.FINGERPRINT_RECORD_CLOG, DEDUP_SORT_ORDER.FINGERPRINT_BASED, clog_fporder, clog_fporder + ".txt"); ui.Update_DedupeUI(DEDUP_ENGINE_STAGE.SORT_CLOG_FPORDER, 100); remove_file(input_clog); remove_file(clog_inofbn); remove_file(clog_inofbnclean); remove_file(clog_dbn); remove_file(clog_dbnclean); /* * Prepare the fpdb. we have 'clog_fporder' from above steps * We must have a delete log that should be applied to clean the FPDB, */ if (File.Exists(fpdb_input)) { print_file(RECORD_TYPE.FINGERPRINT_RECORD_FPDB, DEDUP_SORT_ORDER.DBN_BASED, fpdb_input, fpdb_input + ".old.txt"); m_stage = DEDUP_ENGINE_STAGE.CLEAN_FPDB_DBNSTALES; clean_fpdb_P1(fpdb_input, fpdb_dbncleaned); remove_file(fpdb_input); ui.Update_DedupeUI(DEDUP_ENGINE_STAGE.CLEAN_FPDB_DBNSTALES, 100); print_file(RECORD_TYPE.FINGERPRINT_RECORD_FPDB, DEDUP_SORT_ORDER.DBN_BASED, fpdb_dbncleaned, fpdb_dbncleaned + ".txt"); m_stage = DEDUP_ENGINE_STAGE.SORT_FPDB_FPORDER; sort_dedupe_file(RECORD_TYPE.FINGERPRINT_RECORD_FPDB, fpdb_dbncleaned, fpdb_fporder, DEDUP_SORT_ORDER.FINGERPRINT_BASED); remove_file(fpdb_dbncleaned); print_file(RECORD_TYPE.FINGERPRINT_RECORD_FPDB, DEDUP_SORT_ORDER.FINGERPRINT_BASED, fpdb_fporder, fpdb_fporder + ".txt"); ui.Update_DedupeUI(DEDUP_ENGINE_STAGE.SORT_FPDB_FPORDER, 100); } /* * Do the dedupe operation. we have 'fpdb_fporder' from above steps. */ m_stage = DEDUP_ENGINE_STAGE.GENERATE_DEDUPE_SCRIPT; GenDedupeScript(fpdb_fporder, clog_fporder, fpdb_temp, dedupeScript_a); print_file(RECORD_TYPE.FINGERPRINT_RECORD_MSG, DEDUP_SORT_ORDER.FINGERPRINT_BASED, dedupeScript_a, dedupeScript_a + ".txt"); print_file(RECORD_TYPE.FINGERPRINT_RECORD_FPDB, DEDUP_SORT_ORDER.FINGERPRINT_BASED, fpdb_temp, fpdb_temp + ".txt"); remove_file(fpdb_fporder); remove_file(clog_fporder); ui.Update_DedupeUI(DEDUP_ENGINE_STAGE.GENERATE_DEDUPE_SCRIPT, 100); /* * Create the new fpdb. */ m_stage = DEDUP_ENGINE_STAGE.SORT_FPDBT_DBN; sort_dedupe_file(RECORD_TYPE.FINGERPRINT_RECORD_FPDB, fpdb_temp, fpdb_input, DEDUP_SORT_ORDER.DBN_BASED); print_file(RECORD_TYPE.FINGERPRINT_RECORD_FPDB, DEDUP_SORT_ORDER.DBN_BASED, fpdb_input, fpdb_input + ".txt"); remove_file(fpdb_temp); ui.Update_DedupeUI(DEDUP_ENGINE_STAGE.SORT_FPDBT_DBN, 100); m_stage = DEDUP_ENGINE_STAGE.SORT_SCRIPT_INOFBN; sort_dedupe_file(RECORD_TYPE.FINGERPRINT_RECORD_MSG, dedupeScript_a, dedupeScript, DEDUP_SORT_ORDER.INO_FBN_BASED); print_file(RECORD_TYPE.FINGERPRINT_RECORD_MSG, DEDUP_SORT_ORDER.INO_FBN_BASED, dedupeScript, dedupeScript + ".txt"); ui.Update_DedupeUI(DEDUP_ENGINE_STAGE.SORT_SCRIPT_INOFBN, 100); //rename the file and get over with it. m_stage = DEDUP_ENGINE_STAGE.DEDUPE_MESSAGES; ACTUAL_DEDUPE(dedupeScript); remove_file(dedupeScript); remove_file(dedupeScript_a); ui.Update_DedupeUI(DEDUP_ENGINE_STAGE.DEDUPE_MESSAGES, 100); m_stage = DEDUP_ENGINE_STAGE.DEDUPE_DONE; System.Threading.Thread.Sleep(2000); ui.Update_DedupeUI(DEDUP_ENGINE_STAGE.DEDUPE_DONE, 100); }