Exemplo n.º 1
0
 private static void RunTests(List<ITestRuleSupplier> testTypesList)
 {
     foreach (ITestRuleSupplier ts in testTypesList)
     {
         Logger.TraceWriteLine(string.Format("Running cleaning for {0} tests", ts.Name));
         Logger.TraceIndent();
         CleansingManager cm = new CleansingManager(ts);
         cm.cleanData(null);
         if (ts.TestCurrentState())
         {
             Logger.TraceWriteLine("The test suceeded.");
         }
         else
         {
             Logger.TraceWriteLine("The test failed.");
         }
         Logger.TraceUnindent();
     }
 }
Exemplo n.º 2
0
        public void thread_main()
        {
            try
            {
                DateTime timestamp = DateTime.MinValue;
                DatabaseCleaningManager dcm = new DatabaseCleaningManager();
                dcm.ParseArgs(m_args.Skip(1).ToArray());
                dcm.InitFlow();
                int iteration = 0;
                CleansingManager offline =
                    new CleansingManager(new OfflineCleaningRuleProvider(dcm.SqlUtils));
                while (m_exit_thread == false)
                {
                    Logger.DebugWrite(string.Format("Thread is going to sleep at {0}...",
                        DateTime.Now.ToLongTimeString()));
                    Thread.Sleep(1000);
                    Logger.DebugWriteLine(string.Format("back at {0}", DateTime.Now.ToLongTimeString()));
                    if (m_exit_thread) break;

                    DateTime cur = DateTime.Now;
            #if (!FREQUENT)
                    object res = dcm.SqlUtils.ExecuteScalar(string.Format(
                        "select count(*) from itemsmentions where time > timestamp('{0}')",
                        timestamp.ToString("s")));
                    long num = (long)res;
                    if (num > 0)
            #endif
                    {
                        if (0 == iteration++ % 10) // 2 minutes
                        { // full cleanup
                            timestamp = DateTime.Now;
                            Logger.DebugWriteLine("Full cleaning");
                            offline.cleanData(null);
                        }
                        else
                        { // incremental cleanup

            #if (FREQUENT)
                            // test code
                            object res = dcm.SqlUtils.ExecuteScalar(string.Format(
                                "select count(*) from itemsmentions where time > timestamp('{0}')",
                                timestamp.ToString("s")));
                            long num = (long)res;
                            if (num == 0) continue;
            #endif

                            Logger.TraceWriteLine("Incremental cleaning");
                            timestamp = cur;
                            CleansingManager online =
                                new CleansingManager(new OnlineCleaningRuleProvider(dcm.SqlUtils));
                            online.cleanData(null);
                            //offline.cleanData(null);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DCF.Common.Logger.TraceWriteLine("Caught exception " + ex.Message);
            }
        }