Esempio n. 1
0
 private static void CreateDatabaseWithReplication(string databaseName, IDocumentStore store)
 {
     store.DatabaseCommands.GlobalAdmin.CreateDatabase(new DatabaseDocument
     {
         Id = databaseName,
         Settings = new Dictionary<string, string>
         {
             {
                 "Raven/ActiveBundles", "Replication"
             },
             {
                 "Raven/DataDir", "~/" + databaseName
             }
         }
     });
     using (var newStore = new DocumentStore
     {
         Url = store.Url,
         DefaultDatabase = databaseName
     }.Initialize())
     {
         newStore.ExecuteIndex(new RavenDocumentsByEntityName());
     }
 }
        static void Main(string[] args)
        {
            var store = new DocumentStore
            {
                Url = (args.Length == 1 ? args[0] : "http://localhost:33333/storage"),
            };

            store.Initialize();
            store.Conventions.MaxNumberOfRequestsPerSession = 2048;

            Console.WriteLine("This tool is going to examine ServiceControl for potential messages affected by issue  https://github.com/Particular/ServiceControl/pull/558\n");
            
            Console.WriteLine("Creating Temp Index (this may take some time)...");

            var index = new MessageHistories();

            try
            {
                store.ExecuteIndex(index);

                while (store.DatabaseCommands.GetStatistics().StaleIndexes.Length != 0)
                {
                    Thread.Sleep(10);
                }

                Console.WriteLine(" DONE");
                Console.WriteLine("\nScanning for messages that were sent for reprocessing and require your attention.\n");

                var dangerLevel = CheckForMessagesAffectedByIssue(store);

                var noralColor = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Cyan;

                switch (dangerLevel)
                {
                    case 0: // Not affected
                        Console.WriteLine("You are NOT affected by issue https://github.com/Particular/ServiceControl/pull/558");
                        Console.WriteLine("However, we ask all users of ServiceControl using 1.6.x to update to the latest version immediately.");
                        Console.WriteLine("Latest release:  https://github.com/Particular/ServiceControl/releases");
                        break;
                    case 1: // Maybe affected
                        Console.WriteLine("You may be affected by issue https://github.com/Particular/ServiceControl/pull/558");
                        Console.WriteLine("Please upgrade ServiceControl to the latest version immediately.");
                        Console.WriteLine("Latest release:  https://github.com/Particular/ServiceControl/releases");
                        Console.WriteLine("Contact us via support (http://particular.net/support) and we will work with you to get your situation sorted out.");
                        break;
                    case 2: // Definitely affected
                        Console.WriteLine("You are affected by issue https://github.com/Particular/ServiceControl/pull/558");
                        Console.WriteLine("Please upgrade ServiceControl to the latest version immediately.");
                        Console.WriteLine("Latest release:  https://github.com/Particular/ServiceControl/releases");
                        Console.WriteLine("Contact us via support (http://particular.net/support) and we will work with you to get your situation sorted out.");
                        break;
                }

                Console.ForegroundColor = noralColor;
            }
            finally
            {
                Console.WriteLine("\nRemoving Temp Index...");
                Console.WriteLine(" DONE");
                store.DatabaseCommands.DeleteIndex(index.IndexName);
            }
        }