protected void Log(string message)
 {
     lock (this)
     {
         CantonUtilities.Log(message, "canton-log.txt");
     }
 }
 protected void LogError(string message)
 {
     lock (this)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         CantonUtilities.Log(message, "canton-error.txt");
         Console.ResetColor();
     }
 }
        public override IGraph CreateContentGraph(CatalogContext context)
        {
            if (!_graphUriFixed)
            {
                _graphUriFixed = true;

                INode  rdfTypePredicate = _graph.CreateUriNode(Schema.Predicates.Type);
                Triple resource         = _graph.GetTriplesWithPredicateObject(rdfTypePredicate, _graph.CreateUriNode(GetItemType())).First();

                Uri oldUri = ((IUriNode)resource.Subject).Uri;
                Uri newUri = GetItemAddress();

                CantonUtilities.ReplaceIRI(_graph, oldUri, newUri);
            }

            return(_graph);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Canton jobs that can run many instances.
        /// </summary>
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine(".exe <config path> <thread count>");
                Environment.Exit(1);
            }

            Console.CancelKeyPress += Console_CancelKeyPress;

            CantonUtilities.Init();

            Config config      = new Config(args[0]);
            int    threadCount = 1;

            Int32.TryParse(args[1], out threadCount);

            CloudStorageAccount account = CloudStorageAccount.Parse(config.GetProperty("StorageConnectionString"));

            Queue <Func <CantonJob> > jobs = new Queue <Func <CantonJob> >();

            // process gallery pages and nupkgs into catalog pages
            jobs.Enqueue(() => new CatalogPageJob(config, new AzureStorage(account, config.GetProperty("tmp")), CantonConstants.GalleryPagesQueue));

            Stopwatch timer = new Stopwatch();

            // avoid flooding storage
            TimeSpan minWait = TimeSpan.FromMinutes(2);

            while (_run)
            {
                timer.Restart();
                CantonUtilities.RunManyJobs(jobs, threadCount);

                TimeSpan waitTime = minWait.Subtract(timer.Elapsed);

                Console.WriteLine("Completed jobs in: " + timer.Elapsed);

                if (waitTime.TotalMilliseconds > 0 && _run)
                {
                    Console.WriteLine("Sleeping: " + waitTime.TotalSeconds + "s");
                    Thread.Sleep(waitTime);
                }
            }
        }