1
|
|
package com.github.strengthened.prometheus.healthchecks; |
2
|
|
|
3
|
|
import java.util.concurrent.ScheduledExecutorService; |
4
|
|
import java.util.concurrent.ScheduledFuture; |
5
|
|
|
6
|
|
/** |
7
|
|
* A health check decorator to manage asynchronous executions. |
8
|
|
*/ |
9
|
|
final class AsyncHealthCheckDecorator extends HealthCheck implements Runnable { |
10
|
|
|
11
|
|
private final HealthCheck healthCheck; |
12
|
|
private final ScheduledFuture<?> future; |
13
|
|
private volatile HealthStatus result; |
14
|
|
|
15
|
|
/** Private constructor. */ |
16
|
|
AsyncHealthCheckDecorator(HealthCheck healthCheck, ScheduledExecutorService executorService) { |
17
|
2
1. : removed call to com/github/strengthened/prometheus/healthchecks/AsyncHealthCheckDecorator::check → SURVIVED
2. : negated conditional → KILLED
|
check(healthCheck != null, "healthCheck cannot be null"); |
18
|
2
1. : removed call to com/github/strengthened/prometheus/healthchecks/AsyncHealthCheckDecorator::check → SURVIVED
2. : negated conditional → KILLED
|
check(executorService != null, "executorService cannot be null"); |
19
|
|
final Async async = healthCheck.getClass().getAnnotation(Async.class); |
20
|
2
1. : removed call to com/github/strengthened/prometheus/healthchecks/AsyncHealthCheckDecorator::check → SURVIVED
2. : negated conditional → KILLED
|
check(async != null, "healthCheck must contain Async annotation"); |
21
|
3
1. : changed conditional boundary → SURVIVED
2. : removed call to com/github/strengthened/prometheus/healthchecks/AsyncHealthCheckDecorator::check → SURVIVED
3. : negated conditional → KILLED
|
check(async.period() > 0, "period cannot be less than or equal to zero"); |
22
|
3
1. : removed call to com/github/strengthened/prometheus/healthchecks/AsyncHealthCheckDecorator::check → SURVIVED
2. : changed conditional boundary → KILLED
3. : negated conditional → KILLED
|
check(async.initialDelay() >= 0, "initialDelay cannot be less than zero"); |
23
|
|
|
24
|
|
this.healthCheck = healthCheck; |
25
|
|
result = async.initialState(); |
26
|
1
1. : negated conditional → SURVIVED
|
if (Async.ScheduleType.FIXED_RATE.equals(async.scheduleType())) { |
27
|
|
future = executorService.scheduleAtFixedRate(this, async.initialDelay(), async.period(), |
28
|
|
async.unit()); |
29
|
|
} else { |
30
|
|
future = executorService.scheduleWithFixedDelay(this, async.initialDelay(), async.period(), |
31
|
|
async.unit()); |
32
|
|
} |
33
|
|
|
34
|
|
} |
35
|
|
|
36
|
|
@Override |
37
|
|
public void run() { |
38
|
|
result = healthCheck.execute(); |
39
|
|
} |
40
|
|
|
41
|
|
@Override |
42
|
|
public HealthStatus check() throws Exception { |
43
|
1
1. check : mutated return of Object value for com/github/strengthened/prometheus/healthchecks/AsyncHealthCheckDecorator::check to ( if (x != null) null else throw new RuntimeException ) → KILLED
|
return result; |
44
|
|
} |
45
|
|
|
46
|
|
boolean tearDown() { |
47
|
1
1. tearDown : replaced return of integer sized value with (x == 0 ? 1 : 0) → SURVIVED
|
return future.cancel(true); |
48
|
|
} |
49
|
|
|
50
|
|
HealthCheck getHealthCheck() { |
51
|
1
1. getHealthCheck : mutated return of Object value for com/github/strengthened/prometheus/healthchecks/AsyncHealthCheckDecorator::getHealthCheck to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
|
return healthCheck; |
52
|
|
} |
53
|
|
|
54
|
|
private static void check(boolean expression, String message) { |
55
|
1
1. check : negated conditional → KILLED
|
if (!expression) { |
56
|
|
throw new IllegalArgumentException(message); |
57
|
|
} |
58
|
|
} |
59
|
|
|
60
|
|
} |
| | Mutations |
17 |
|
1.1 Location : Killed by : com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest.shouldNotAddSameName(com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest) negated conditional → KILLED 2.2 Location : Killed by : none removed call to com/github/strengthened/prometheus/healthchecks/AsyncHealthCheckDecorator::check → SURVIVED
|
18 |
|
1.1 Location : Killed by : com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest.shouldNotAddSameName(com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest) negated conditional → KILLED 2.2 Location : Killed by : none removed call to com/github/strengthened/prometheus/healthchecks/AsyncHealthCheckDecorator::check → SURVIVED
|
20 |
|
1.1 Location : Killed by : com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest.shouldNotAddSameName(com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest) negated conditional → KILLED 2.2 Location : Killed by : none removed call to com/github/strengthened/prometheus/healthchecks/AsyncHealthCheckDecorator::check → SURVIVED
|
21 |
|
1.1 Location : Killed by : none changed conditional boundary → SURVIVED 2.2 Location : Killed by : com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest.shouldNotAddSameName(com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest) negated conditional → KILLED 3.3 Location : Killed by : none removed call to com/github/strengthened/prometheus/healthchecks/AsyncHealthCheckDecorator::check → SURVIVED
|
22 |
|
1.1 Location : Killed by : com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest.shouldNotAddSameName(com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest) changed conditional boundary → KILLED 2.2 Location : Killed by : com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest.shouldNotAddSameName(com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest) negated conditional → KILLED 3.3 Location : Killed by : none removed call to com/github/strengthened/prometheus/healthchecks/AsyncHealthCheckDecorator::check → SURVIVED
|
26 |
|
1.1 Location : Killed by : none negated conditional → SURVIVED
|
43 |
|
1.1 Location : check Killed by : com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest.shouldShutDown(com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest) mutated return of Object value for com/github/strengthened/prometheus/healthchecks/AsyncHealthCheckDecorator::check to ( if (x != null) null else throw new RuntimeException ) → KILLED
|
47 |
|
1.1 Location : tearDown Killed by : none replaced return of integer sized value with (x == 0 ? 1 : 0) → SURVIVED
|
51 |
|
1.1 Location : getHealthCheck Killed by : none mutated return of Object value for com/github/strengthened/prometheus/healthchecks/AsyncHealthCheckDecorator::getHealthCheck to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
|
55 |
|
1.1 Location : check Killed by : com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest.shouldNotAddSameName(com.github.strengthened.prometheus.healthchecks.HealthChecksCollectorTest) negated conditional → KILLED
|