public CatalogPageJob(Config config, Storage storage, string queueName) : base(config, storage, queueName) { _packagesStorageAccount = CloudStorageAccount.Parse(config.GetProperty("PackagesStorageConnectionString")); _queueTasks = new ConcurrentQueue<Task>(); _workQueueStatus = new ConcurrentDictionary<int, bool>(); _tmpDir = new DirectoryInfo(Config.GetProperty("localtmp")); if (!_tmpDir.Exists) { _tmpDir.Create(); } }
public CantonJob(Config config, Storage storage) { if (config == null) { throw new ArgumentNullException("config"); } _storage = storage; _config = config; _runTime = new Stopwatch(); _host = Dns.GetHostName(); _run = true; }
/// <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); } } }
public CollectorJob(Config config, Storage storage, string cursorName) : base(config, storage) { _cursorName = cursorName; }
/// <summary> /// Canton jobs that can only run as single instances. /// </summary> static void Main(string[] args) { if (args.Length != 1) { Console.WriteLine(".exe <config path>"); Environment.Exit(1); } Console.CancelKeyPress += Console_CancelKeyPress; CantonUtilities.Init(); Config config = new Config(args[0]); CloudStorageAccount account = CloudStorageAccount.Parse(config.GetProperty("StorageConnectionString")); CloudStorageAccount outputAccount = CloudStorageAccount.Parse(config.GetProperty("OutputStorageConnectionString")); Uri baseAddress = new Uri(config.GetProperty("BaseAddress")); Queue<CantonJob> jobs = new Queue<CantonJob>(); // set up the storage account jobs.Enqueue(new InitStorageJob(config)); // read the gallery to find new packages // jobs.Enqueue(new QueueNewPackagesFromGallery(config, new AzureStorage(account, config.GetProperty("GalleryPageContainer")))); // this does the work of Many, just so this can all be in one .exe jobs.Enqueue(new CatalogPageJob(config, new AzureStorage(account, config.GetProperty("tmp")), CantonConstants.GalleryPagesQueue)); // commit pages to the catalog jobs.Enqueue(new CatalogPageCommitJob(config, new AzureStorage(outputAccount, config.GetProperty("CatalogContainer"), string.Empty, new Uri(baseAddress.AbsoluteUri + config.GetProperty("CatalogContainer") + "/")))); // registrations Uri regBase = new Uri(baseAddress, config.GetProperty("RegistrationContainer") + "/"); TransHttpClient httpClient = new TransHttpClient(outputAccount, config.GetProperty("BaseAddress")); jobs.Enqueue(new PartitionedRegJob(config, new AzureStorage(outputAccount, config.GetProperty("RegistrationContainer"), string.Empty, regBase), new AzureStorageFactory(outputAccount, config.GetProperty("RegistrationContainer"), null, regBase), httpClient)); Stopwatch timer = new Stopwatch(); // avoid flooding the gallery TimeSpan minWait = TimeSpan.FromMinutes(10); while (_run) { timer.Restart(); CantonUtilities.RunJobs(jobs); TimeSpan waitTime = minWait.Subtract(timer.Elapsed); Console.WriteLine("Completed jobs in: " + timer.Elapsed); // min sleep Thread.Sleep(60 * 1000); if (waitTime.TotalSeconds > 0 && _run) { Console.WriteLine("Sleeping: " + waitTime.TotalSeconds + "s"); Thread.Sleep(waitTime); } } }
public InitStorageJob(Config config) : base(config, null) { }
public QueueFedJob(Config config, Storage storage, string queueName) : base(config, storage) { _queueName = queueName; }
public CatalogPageCommitJob(Config config, Storage storage) : base(config, storage, CantonConstants.CatalogPageQueue, "catalogpagecommit") { }
public PartitionedRegJob(Config config, Storage storage, StorageFactory factory, CollectorHttpClient client) : base(config, storage, "partitionedreg") { _factory = factory; _client = client; }
public CursorQueueFedJob(Config config, Storage storage, string queueName, string cursorName) : base(config, storage, cursorName) { _queueName = queueName; }