static void Main(string[] args) { var couchbaseConfig = new Couchbase.Configuration.CouchbaseClientConfiguration(); couchbaseConfig.Bucket = "larm"; couchbaseConfig.Urls.Add(new Uri("http://10.0.252.63:8091/pools")); var cache = new Cache(new Couchbase.CouchbaseClient(couchbaseConfig)); var portalRepository = new PortalRepository().WithConfiguration("user id=larm-app;password=0n44Fx4f4m2jNtuLuA6ym88mr3h40D;server=mysql01.cpwvkgghf9fg.eu-west-1.rds.amazonaws.com;persist security info=True;database=larm-portal;Allow User Variables=True;CharSet=utf8;"); var portal = new PortalApplication(cache, new ViewManager(new Dictionary<string, IView>(), cache), portalRepository, new DatabaseLoggerFactory(portalRepository)); var mcm = new McmModule(); mcm.Load(portal); const uint PageSize = 100; var indexedCount = 0; for (uint i = 0; ; i++) { var objects = mcm.McmRepository.ObjectGet(null, i, PageSize, true, true, true, true, true, null); portal.ViewManager.GetView("Search").Index(objects); portal.ViewManager.GetView("Object").Index(objects); Console.SetCursorPosition(0,Console.CursorTop); Console.Write("Objects indexed: {0}", ++indexedCount); if (objects.Count != PageSize) break; } }
private static void Index() { Console.Clear(); var cache = new Cache(new Couchbase.CouchbaseClient()); var portalRepository = new PortalRepository().WithConfiguration( System.Configuration.ConfigurationManager.ConnectionStrings["Portal"].ConnectionString); var portal = new PortalApplication(cache, new ViewManager(new Dictionary<string, IView>(), cache), portalRepository, new DatabaseLoggerFactory(portalRepository)); var mcm = new McmModule(); var larm = new LarmModule(); portal.AddModule(mcm); portal.AddModule(larm); Thread.Sleep(10000); const uint PageSize = 100; var indexedCount = 0; var retrievedCount = 0; uint folderId = 0; Console.WriteLine("Enter folderId (leave blank for all):"); uint.TryParse(Console.ReadLine(), out folderId); var t1 = new Stopwatch(); for (uint i = 0; ; i++) { t1.Reset(); t1.Start(); IList<Chaos.Mcm.Data.Dto.Object> objects = new List<Object>(); if(folderId == 0) objects = mcm.McmRepository.ObjectGet(null, i, PageSize, true, true, true, true, true).ToList(); if(folderId > 0) objects = mcm.McmRepository.ObjectGet(folderId, i, PageSize, true, true, true, true, true).ToList(); Write(0, 1, String.Format("ObjectGet time: {0}", t1.Elapsed)); retrievedCount += objects.Count; new Thread(() => { var objs = objects; var t2 = new Stopwatch(); t2.Start(); try { portal.ViewManager.Index(objs); } catch (Exception) { Thread.Sleep(30000); portal.ViewManager.Index(objs); } Write(0, 2, String.Format("Index time: {0}", t2.Elapsed)); t2.Restart(); indexedCount += 100; Write(0, 5, String.Format("Objects indexed: {0}", indexedCount)); }).Start(); Write(0, 4, String.Format("Objects retrieved: {0}", retrievedCount)); if (objects.Count != PageSize) break; } }