|
1 | | -package com.searchcode.app.jobs.enqueue; |
2 | | - |
3 | | -import com.searchcode.app.dao.IRepo; |
4 | | -import com.searchcode.app.service.Singleton; |
5 | | -import com.searchcode.app.service.index.IIndexService; |
6 | | -import com.searchcode.app.util.Helpers; |
7 | | -import com.searchcode.app.util.LoggerWrapper; |
8 | | -import org.quartz.DisallowConcurrentExecution; |
9 | | -import org.quartz.Job; |
10 | | -import org.quartz.JobExecutionContext; |
11 | | -import org.quartz.PersistJobDataAfterExecution; |
12 | | - |
13 | | -/** |
14 | | - * Responsible for adding all of the repositories inside the database into the queues. There will be a queue |
15 | | - * for GIT and SVN or any other repository added. |
16 | | - * TODO add logic to test that the right queue has things added to it |
17 | | - */ |
18 | | -@PersistJobDataAfterExecution |
19 | | -@DisallowConcurrentExecution |
20 | | -public class EnqueueSearchcodeRepositoryJob implements Job { |
21 | | - private final IIndexService indexService; |
22 | | - private final LoggerWrapper logger; |
23 | | - private final IRepo repo; |
24 | | - private final Helpers helpers; |
25 | | - |
26 | | - public EnqueueSearchcodeRepositoryJob() { |
27 | | - this.indexService = Singleton.getIndexService(); |
28 | | - this.repo = Singleton.getRepo(); |
29 | | - this.logger = Singleton.getLogger(); |
30 | | - this.helpers = Singleton.getHelpers(); |
31 | | - } |
32 | | - |
33 | | - public void execute(JobExecutionContext context) { |
34 | | - this.logger.info("fe39b962::starting enqueue job"); |
35 | | - Thread.currentThread().setPriority(Thread.MIN_PRIORITY); |
36 | | - |
37 | | - // TODO this never returns false, should probably implement back-pressure |
38 | | - if (this.indexService.shouldPause(IIndexService.JobType.REPO_ADDER)) { |
39 | | - return; |
40 | | - } |
41 | | - |
42 | | - try { |
43 | | - Thread.currentThread().setPriority(Thread.MIN_PRIORITY); |
44 | | - |
45 | | - var repoGitQueue = Singleton.getUniqueGitRepoQueue(); |
46 | | - var repoSvnQueue = Singleton.getUniqueSvnRepoQueue(); |
47 | | - |
48 | | - // Determine where we have started from a repo collection |
49 | | - // determine where that ends |
50 | | - // update the point |
51 | | - // Get the batch of repositories from the database |
52 | | - // add them to the queue |
53 | | - } catch (Exception ex) { |
54 | | - this.logger.severe(String.format("8675db36::error in class %s exception %s", ex.getClass(), ex.getMessage())); |
55 | | - } |
56 | | - } |
57 | | -} |
| 1 | +package com.searchcode.app.jobs.enqueue; |
| 2 | + |
| 3 | +import com.searchcode.app.dao.Data; |
| 4 | +import com.searchcode.app.dao.IRepo; |
| 5 | +import com.searchcode.app.service.Singleton; |
| 6 | +import com.searchcode.app.service.index.IIndexService; |
| 7 | +import com.searchcode.app.util.Helpers; |
| 8 | +import com.searchcode.app.util.LoggerWrapper; |
| 9 | +import org.quartz.DisallowConcurrentExecution; |
| 10 | +import org.quartz.Job; |
| 11 | +import org.quartz.JobExecutionContext; |
| 12 | +import org.quartz.PersistJobDataAfterExecution; |
| 13 | + |
| 14 | +/** |
| 15 | + * Responsible for adding all of the repositories inside the database into the queues. There will be a queue |
| 16 | + * for GIT and SVN or any other repository added. |
| 17 | + * TODO add logic to test that the right queue has things added to it |
| 18 | + */ |
| 19 | +@PersistJobDataAfterExecution |
| 20 | +@DisallowConcurrentExecution |
| 21 | +public class EnqueueSearchcodeRepositoryJob implements Job { |
| 22 | + private final IIndexService indexService; |
| 23 | + private final LoggerWrapper logger; |
| 24 | + private final IRepo repo; |
| 25 | + private final Helpers helpers; |
| 26 | + private final Data data; |
| 27 | + |
| 28 | + public EnqueueSearchcodeRepositoryJob() { |
| 29 | + this.indexService = Singleton.getIndexService(); |
| 30 | + this.repo = Singleton.getRepo(); |
| 31 | + this.logger = Singleton.getLogger(); |
| 32 | + this.helpers = Singleton.getHelpers(); |
| 33 | + this.data = Singleton.getData(); |
| 34 | + } |
| 35 | + |
| 36 | + public void execute(JobExecutionContext context) { |
| 37 | + this.logger.info("fe39b962::starting enqueue job"); |
| 38 | + Thread.currentThread().setPriority(Thread.MIN_PRIORITY); |
| 39 | + |
| 40 | + // TODO this never returns false, should probably implement back-pressure |
| 41 | + if (this.indexService.shouldPause(IIndexService.JobType.REPO_ADDER)) { |
| 42 | + return; |
| 43 | + } |
| 44 | + |
| 45 | + try { |
| 46 | + Thread.currentThread().setPriority(Thread.MIN_PRIORITY); |
| 47 | + |
| 48 | + var repoGitQueue = Singleton.getUniqueGitRepoQueue(); |
| 49 | + var repoSvnQueue = Singleton.getUniqueSvnRepoQueue(); |
| 50 | + |
| 51 | +// this.repo.getAllRepo(); |
| 52 | + |
| 53 | +// for (var r : this.repo.getAllRepo()) { |
| 54 | +// repoGitQueue.add(r); |
| 55 | +// } |
| 56 | + |
| 57 | + repoGitQueue.add(this.repo.getRepoById(1).get()); |
| 58 | + |
| 59 | + // Determine where we have started from a repo collection |
| 60 | + // determine where that ends |
| 61 | + // update the point |
| 62 | + // Get the batch of repositories from the database |
| 63 | + // add them to the queue |
| 64 | + } catch (Exception ex) { |
| 65 | + this.logger.severe(String.format("8675db36::error in class %s exception %s", ex.getClass(), ex.getMessage())); |
| 66 | + } |
| 67 | + } |
| 68 | +} |
0 commit comments