Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/wsplgen/Scheduler.java @ 8202:e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 05 Sep 2014 12:58:17 +0200 |
parents | af13ceeba52a |
children | 0a5239a1e46e |
comparison
equal
deleted
inserted
replaced
8201:4b8c5a08de04 | 8202:e4606eae8ea5 |
---|---|
48 protected Map<String, FutureJob> jobs; | 48 protected Map<String, FutureJob> jobs; |
49 | 49 |
50 | 50 |
51 private static Scheduler INSTANCE; | 51 private static Scheduler INSTANCE; |
52 | 52 |
53 private static final Logger logger = Logger.getLogger(Scheduler.class); | 53 private static final Logger log = Logger.getLogger(Scheduler.class); |
54 | 54 |
55 | 55 |
56 | 56 |
57 private Scheduler() { | 57 private Scheduler() { |
58 jobs = new HashMap<String, FutureJob>(); | 58 jobs = new HashMap<String, FutureJob>(); |
60 } | 60 } |
61 | 61 |
62 | 62 |
63 public static Scheduler getInstance() { | 63 public static Scheduler getInstance() { |
64 if (INSTANCE == null) { | 64 if (INSTANCE == null) { |
65 logger.info("Create new WSPLGEN Scheduler..."); | 65 log.info("Create new WSPLGEN Scheduler..."); |
66 | 66 |
67 INSTANCE = new Scheduler(); | 67 INSTANCE = new Scheduler(); |
68 } | 68 } |
69 | 69 |
70 return INSTANCE; | 70 return INSTANCE; |
76 WSPLGENFuture f = new WSPLGENFuture(new WSPLGENCallable(this, job)); | 76 WSPLGENFuture f = new WSPLGENFuture(new WSPLGENCallable(this, job)); |
77 pool.execute(f); | 77 pool.execute(f); |
78 | 78 |
79 jobs.put(job.getArtifact().identifier(), new FutureJob(f, job)); | 79 jobs.put(job.getArtifact().identifier(), new FutureJob(f, job)); |
80 | 80 |
81 logger.info("New WSPLGEN job successfully added."); | 81 log.info("New WSPLGEN job successfully added."); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 | 85 |
86 /** | 86 /** |
87 * Cancels a running (or queued) job. | 87 * Cancels a running (or queued) job. |
88 * | 88 * |
89 * @param jobId The id of the job (which is the identifier of an Artifact). | 89 * @param jobId The id of the job (which is the identifier of an Artifact). |
90 */ | 90 */ |
91 public void cancelJob(String jobId) { | 91 public void cancelJob(String jobId) { |
92 logger.debug("Search job in queue: " + jobId); | 92 log.debug("Search job in queue: " + jobId); |
93 | 93 |
94 synchronized (jobs) { | 94 synchronized (jobs) { |
95 FutureJob fj = jobs.get(jobId); | 95 FutureJob fj = jobs.get(jobId); |
96 | 96 |
97 if (fj != null) { | 97 if (fj != null) { |
98 logger.info("Try to cancel job: " + jobId); | 98 log.info("Try to cancel job: " + jobId); |
99 | 99 |
100 fj.future.cancel(true); | 100 fj.future.cancel(true); |
101 | 101 |
102 removeJob(jobId); | 102 removeJob(jobId); |
103 | 103 |
104 fj.job.getCallContext().afterBackground( | 104 fj.job.getCallContext().afterBackground( |
105 CallContext.STORE); | 105 CallContext.STORE); |
106 | 106 |
107 logger.info("Canceled job: " + jobId); | 107 log.info("Canceled job: " + jobId); |
108 } | 108 } |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 | 112 |