public override void Run() { var chopDate = DateTime.Now - new TimeSpan(Config.ChangeRetentionHours, 0, 0); IEnumerable <long> CTIDs; if (Config.MasterType == SqlFlavor.MySQL) { var temp = (MSSQLDataUtils)destDataUtils; CTIDs = temp.GetOldStopSyncMaster(Config.RelayDB, chopDate); } else { CTIDs = destDataUtils.GetOldCTIDsMaster(Config.RelayDB, chopDate); } var tables = sourceDataUtils.GetTables(Config.MasterCTDB); if (tables.Count() > 0) { logger.Log("Deleting {" + string.Join(",", CTIDs) + "} from { " + string.Join(",", tables.Select(t => t.name)) + "}", LogLevel.Debug); MaintenanceHelper.DeleteOldTables(CTIDs, tables, sourceDataUtils, Config.MasterCTDB); } else { logger.Log("No tables to delete", LogLevel.Info); } if (Config.MasterType == SqlFlavor.MySQL) { foreach (var table in Config.Tables) { var temp = (MySQLDataUtils)sourceDataUtils; temp.CleanupTriggerTable(Config.MasterDB, table.Name, chopDate); } } }
public override void Run() { var chopDate = DateTime.Now - new TimeSpan(Config.ChangeRetentionHours, 0, 0); var rowChopDate = DateTime.Now - new TimeSpan(Config.batchRecordRetentionDays, 0, 0, 0); IEnumerable <long> CTIDs = relayDataUtils.GetOldCTIDsRelay(Config.RelayDB, chopDate); IEnumerable <string> allDbs = new List <string> { Config.RelayDB }; if (Config.ShardDatabases != null) { allDbs = allDbs.Concat(Config.ShardDatabases); } foreach (string db in allDbs) { var tables = relayDataUtils.GetTables(db); if (tables.Count() > 0) { logger.Log("Deleting {" + string.Join(",", CTIDs) + "} from { " + string.Join(",", tables.Select(t => t.name)) + "}", LogLevel.Debug); MaintenanceHelper.DeleteOldTables(CTIDs, tables, relayDataUtils, db); } else { logger.Log("No tables to delete for database " + db, LogLevel.Info); } relayDataUtils.DeleteOldCTVersions(db, rowChopDate); } relayDataUtils.DeleteOldCTSlaveVersions(Config.RelayDB, rowChopDate); }
public override void Run() { var chopDate = DateTime.Now - new TimeSpan(Config.ChangeRetentionHours, 0, 0); IEnumerable <long> CTIDs = relayDataUtils.GetOldCTIDsSlave(Config.RelayDB, chopDate, Config.Slave); var tables = slaveDataUtils.GetTables(Config.SlaveCTDB); if (tables.Count() > 0) { logger.Log("Deleting {" + string.Join(",", CTIDs) + "} from { " + string.Join(",", tables.Select(t => t.name)) + "}", LogLevel.Debug); MaintenanceHelper.DeleteOldTables(CTIDs, tables, slaveDataUtils, Config.SlaveCTDB); } else { logger.Log("No tables to delete", LogLevel.Info); } if (Config.BcpPath != null && Config.BcpPath.Length > 0) { DeleteOldFiles(CTIDs, Config.SlaveCTDB, Config.BcpPath); } }