1 |
|
package com.github.funthomas424242.jenkinsmonitor.jenkins; |
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
import java.util.concurrent.ExecutionException; |
26 |
|
import java.util.concurrent.Executors; |
27 |
|
import java.util.concurrent.Future; |
28 |
|
import java.util.concurrent.ThreadPoolExecutor; |
29 |
|
import java.util.concurrent.TimeUnit; |
30 |
|
import java.util.concurrent.TimeoutException; |
31 |
|
import org.slf4j.Logger; |
32 |
|
import org.slf4j.LoggerFactory; |
33 |
|
|
34 |
|
|
|
|
| 70% |
Uncovered Elements: 6 (20) |
Complexity: 3 |
Complexity Density: 0,17 |
|
35 |
|
public class JenkinsRESTClient { |
36 |
|
|
37 |
|
protected static final Logger LOG = LoggerFactory.getLogger(JenkinsRESTClient.class); |
38 |
|
|
|
|
| 81,2% |
Uncovered Elements: 3 (16) |
Complexity: 2 |
Complexity Density: 0,12 |
|
39 |
1 |
public void ladeJobsStatus(final AbstractJobBeschreibungen<JobStatusBeschreibung> jobStatusBeschreibungen, final JobBeschreibungen jobBeschreibungen) {... |
40 |
1 |
LOG.debug("Frage Jobstatus ab"); |
41 |
1 |
final ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10); |
42 |
1 |
AbstractJobBeschreibung.sortedStreamOf(jobBeschreibungen) |
43 |
|
.parallel() |
44 |
|
.map(beschreibung -> { |
45 |
1 |
final JobAbfrage jobAbfrage |
46 |
|
= new JobAbfrage(beschreibung.getJobAbfragedaten(), beschreibung.getJobOrderId()); |
47 |
1 |
final Future<JobStatusBeschreibung> jobAbfrageFuture = executor.submit(jobAbfrage); |
48 |
1 |
return new JobAbfrageFutureWrapper(jobAbfrage, jobAbfrageFuture); |
49 |
|
}) |
50 |
|
.map(jobAbfrageFutureWrapper -> { |
51 |
1 |
final Future<JobStatusBeschreibung> future = jobAbfrageFutureWrapper.getJobAbfrageFuture(); |
52 |
1 |
JobStatusBeschreibung jobStatusBeschreibung; |
53 |
1 |
try { |
54 |
1 |
jobStatusBeschreibung = future.get(5, TimeUnit.SECONDS); |
55 |
|
} catch (InterruptedException | TimeoutException | ExecutionException ex) { |
56 |
0 |
LOG.warn("Read Future Result goes wrong with exception: \n {}", ex.toString()); |
57 |
0 |
jobStatusBeschreibung =getJobStatusOTHER(jobAbfrageFutureWrapper); |
58 |
0 |
future.cancel(true); |
59 |
|
} |
60 |
1 |
LOG.debug("JobStatus geladen: {} : {} at {} ", jobStatusBeschreibung.getJobName(), jobStatusBeschreibung.getJobStatus(), jobStatusBeschreibung.getJobUrl().toExternalForm()); |
61 |
1 |
return jobStatusBeschreibung; |
62 |
|
}) |
63 |
|
.forEach(jobStatusBeschreibung -> jobStatusBeschreibungen.put(jobStatusBeschreibung.getPrimaryKey(), jobStatusBeschreibung)); |
64 |
1 |
executor.shutdown(); |
65 |
|
} |
66 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
67 |
0 |
private static JobStatusBeschreibung getJobStatusOTHER( final JobAbfrageFutureWrapper jobAbfrageFutureWrapper) {... |
68 |
0 |
final JobAbfrage jobAbfrage = jobAbfrageFutureWrapper.getJobAbfrage(); |
69 |
0 |
return new JobStatusBeschreibung("Connection Timeout" + jobAbfrage.getAbfrageUrl().toExternalForm(), JobStatus.OTHER, jobAbfrage.getAbfrageUrl(), jobAbfrage.getJobOrderId()); |
70 |
|
} |
71 |
|
} |
72 |
|
|
73 |
|
|
74 |
|
|