Skip to content

Commit a07c8e6

Browse files
committed
Merge pull request #10364 from vpavic
* pr/10364: Polish "Add Quartz actuator endpoint" Add Quartz actuator endpoint Closes gh-10364
2 parents 095ff18 + b11602a commit a07c8e6

File tree

20 files changed

+2881
-13
lines changed

20 files changed

+2881
-13
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ dependencies {
8686
optional("org.mongodb:mongodb-driver-reactivestreams")
8787
optional("org.mongodb:mongodb-driver-sync")
8888
optional("org.neo4j.driver:neo4j-java-driver")
89+
optional("org.quartz-scheduler:quartz")
8990
optional("org.springframework:spring-jdbc")
9091
optional("org.springframework:spring-jms")
9192
optional("org.springframework:spring-messaging")
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
[[quartz]]
2+
= Quartz (`quartz`)
3+
4+
The `quartz` endpoint provides information about jobs and triggers that are managed by the Quartz Scheduler.
5+
6+
7+
8+
[[quartz-report]]
9+
== Retrieving Registered Groups
10+
11+
Jobs and triggers are managed in groups.
12+
To retrieve the list of registered job and trigger groups, make a `GET` request to `/actuator/quartz`, as shown in the following curl-based example:
13+
14+
include::{snippets}/quartz/report/curl-request.adoc[]
15+
16+
The resulting response is similar to the following:
17+
18+
include::{snippets}/quartz/report/http-response.adoc[]
19+
20+
21+
22+
[[quartz-report-response-structure]]
23+
=== Response Structure
24+
The response contains the groups names for registered jobs and triggers.
25+
The following table describes the structure of the response:
26+
27+
[cols="3,1,3"]
28+
include::{snippets}/quartz/report/response-fields.adoc[]
29+
30+
31+
32+
[[quartz-job-groups]]
33+
== Retrieving Registered Job Names
34+
35+
To retrieve the list of registered job names, make a `GET` request to `/actuator/quartz/jobs`, as shown in the following curl-based example:
36+
37+
include::{snippets}/quartz/jobs/curl-request.adoc[]
38+
39+
The resulting response is similar to the following:
40+
41+
include::{snippets}/quartz/jobs/http-response.adoc[]
42+
43+
44+
[[quartz-job-groups-response-structure]]
45+
=== Response Structure
46+
The response contains the registered job names for each group.
47+
The following table describes the structure of the response:
48+
49+
[cols="3,1,3"]
50+
include::{snippets}/quartz/jobs/response-fields.adoc[]
51+
52+
53+
54+
[[quartz-trigger-groups]]
55+
== Retrieving Registered Trigger Names
56+
57+
To retrieve the list of registered trigger names, make a `GET` request to `/actuator/quartz/triggers`, as shown in the following curl-based example:
58+
59+
include::{snippets}/quartz/triggers/curl-request.adoc[]
60+
61+
The resulting response is similar to the following:
62+
63+
include::{snippets}/quartz/triggers/http-response.adoc[]
64+
65+
66+
67+
[[quartz-trigger-groups-response-structure]]
68+
=== Response Structure
69+
The response contains the registered trigger names for each group.
70+
The following table describes the structure of the response:
71+
72+
[cols="3,1,3"]
73+
include::{snippets}/quartz/triggers/response-fields.adoc[]
74+
75+
76+
77+
[[quartz-job-group]]
78+
== Retrieving Overview of a Job Group
79+
80+
To retrieve an overview of the jobs in a particular group, make a `GET` request to `/actuator/quartz/jobs/\{groupName}`, as shown in the following curl-based example:
81+
82+
include::{snippets}/quartz/job-group/curl-request.adoc[]
83+
84+
The preceding example retrieves the summary for jobs in the `samples` group.
85+
The resulting response is similar to the following:
86+
87+
include::{snippets}/quartz/job-group/http-response.adoc[]
88+
89+
90+
91+
[[quartz-job-group-response-structure]]
92+
=== Response Structure
93+
The response contains an overview of jobs in a particular group.
94+
The following table describes the structure of the response:
95+
96+
[cols="3,1,3"]
97+
include::{snippets}/quartz/job-group/response-fields.adoc[]
98+
99+
100+
101+
[[quartz-trigger-group]]
102+
== Retrieving Overview of a Trigger Group
103+
104+
To retrieve an overview of the triggers in a particular group, make a `GET` request to `/actuator/quartz/triggers/\{groupName}`, as shown in the following curl-based example:
105+
106+
include::{snippets}/quartz/trigger-group/curl-request.adoc[]
107+
108+
The preceding example retrieves the summary for triggers in the `tests` group.
109+
The resulting response is similar to the following:
110+
111+
include::{snippets}/quartz/trigger-group/http-response.adoc[]
112+
113+
114+
115+
[[quartz-trigger-group-response-structure]]
116+
=== Response Structure
117+
The response contains an overview of triggers in a particular group.
118+
Trigger implementation specific details are available.
119+
The following table describes the structure of the response:
120+
121+
[cols="3,1,3"]
122+
include::{snippets}/quartz/trigger-group/response-fields.adoc[]
123+
124+
125+
126+
[[quartz-job]]
127+
== Retrieving Details of a Job
128+
129+
To retrieve the details about a particular job, make a `GET` request to `/actuator/quartz/jobs/\{groupName}/\{jobName}`, as shown in the following curl-based example:
130+
131+
include::{snippets}/quartz/job-details/curl-request.adoc[]
132+
133+
The preceding example retrieves the details of the job identified by the `samples` group and `jobOne` name.
134+
The resulting response is similar to the following:
135+
136+
include::{snippets}/quartz/job-details/http-response.adoc[]
137+
138+
If a key in the data map is identified as sensitive, its value is sanitized.
139+
140+
[[quartz-job-response-structure]]
141+
=== Response Structure
142+
143+
The response contains the full details of a job including a summary of the triggers associated with it, if any.
144+
The triggers are sorted by next fire time and priority.
145+
The following table describes the structure of the response:
146+
147+
[cols="2,1,3"]
148+
include::{snippets}/quartz/job-details/response-fields.adoc[]
149+
150+
151+
[[quartz-trigger]]
152+
== Retrieving Details of a Trigger
153+
154+
To retrieve the details about a particular trigger, make a `GET` request to `/actuator/quartz/triggers/\{groupName}/\{triggerName}`, as shown in the following curl-based example:
155+
156+
include::{snippets}/quartz/trigger-details-cron/curl-request.adoc[]
157+
158+
The preceding example retrieves the details of trigger identified by the `samples` group and `example` name.
159+
160+
The resulting response has a common structure and a specific additional object according to the trigger implementation.
161+
There are five supported types:
162+
163+
* `cron` for `CronTrigger`
164+
* `simple` for `SimpleTrigger`
165+
* `dailyTimeInterval` for `DailyTimeIntervalTrigger`
166+
* `calendarInterval` for `CalendarIntervalTrigger`
167+
* `custom` for any other trigger implementations
168+
169+
170+
171+
[[quartz-trigger-cron]]
172+
=== Cron Trigger Response Structure
173+
174+
A cron trigger defines the cron expression that is used to determine when it has to fire.
175+
The resulting response for such a trigger implementation is similar to the following:
176+
177+
include::{snippets}/quartz/trigger-details-cron/http-response.adoc[]
178+
179+
180+
The following table describes the structure of the response:
181+
182+
[cols="2,1,3"]
183+
include::{snippets}/quartz/trigger-details-cron/response-fields.adoc[]
184+
185+
186+
187+
[[quartz-trigger-simple]]
188+
=== Simple Trigger Response Structure
189+
190+
A simple trigger is used to fire a Job at a given moment in time, and optionally repeated at a specified interval.
191+
The resulting response for such a trigger implementation is similar to the following:
192+
193+
include::{snippets}/quartz/trigger-details-simple/http-response.adoc[]
194+
195+
196+
The following table describes the structure of the response:
197+
198+
[cols="2,1,3"]
199+
include::{snippets}/quartz/trigger-details-simple/response-fields.adoc[]
200+
201+
202+
203+
[[quartz-trigger-daily-time-interval]]
204+
=== Daily Time Interval Trigger Response Structure
205+
206+
A daily time interval trigger is used to fire a Job based upon daily repeating time intervals.
207+
The resulting response for such a trigger implementation is similar to the following:
208+
209+
include::{snippets}/quartz/trigger-details-daily-time-interval/http-response.adoc[]
210+
211+
212+
The following table describes the structure of the response:
213+
214+
[cols="2,1,3"]
215+
include::{snippets}/quartz/trigger-details-daily-time-interval/response-fields.adoc[]
216+
217+
218+
219+
[[quartz-trigger-calendar-interval]]
220+
=== Calendar Interval Trigger Response Structure
221+
222+
A daily time interval trigger is used to fire a Job based upon repeating calendar time intervals.
223+
The resulting response for such a trigger implementation is similar to the following:
224+
225+
include::{snippets}/quartz/trigger-details-calendar-interval/http-response.adoc[]
226+
227+
228+
The following table describes the structure of the response:
229+
230+
[cols="2,1,3"]
231+
include::{snippets}/quartz/trigger-details-calendar-interval/response-fields.adoc[]
232+
233+
234+
235+
[[quartz-trigger-custom]]
236+
=== Custom Trigger Response Structure
237+
238+
A custom trigger is any other implementation.
239+
The resulting response for such a trigger implementation is similar to the following:
240+
241+
include::{snippets}/quartz/trigger-details-custom/http-response.adoc[]
242+
243+
244+
The following table describes the structure of the response:
245+
246+
[cols="2,1,3"]
247+
include::{snippets}/quartz/trigger-details-custom/response-fields.adoc[]

spring-boot-project/spring-boot-actuator-autoconfigure/src/docs/asciidoc/index.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ include::endpoints/loggers.adoc[leveloffset=+1]
6767
include::endpoints/mappings.adoc[leveloffset=+1]
6868
include::endpoints/metrics.adoc[leveloffset=+1]
6969
include::endpoints/prometheus.adoc[leveloffset=+1]
70+
include::endpoints/quartz.adoc[leveloffset=+1]
7071
include::endpoints/scheduledtasks.adoc[leveloffset=+1]
7172
include::endpoints/sessions.adoc[leveloffset=+1]
7273
include::endpoints/shutdown.adoc[leveloffset=+1]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright 2012-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.actuate.autoconfigure.quartz;
18+
19+
import org.quartz.Scheduler;
20+
21+
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
22+
import org.springframework.boot.actuate.quartz.QuartzEndpoint;
23+
import org.springframework.boot.actuate.quartz.QuartzEndpointWebExtension;
24+
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
25+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
26+
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
27+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
28+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
29+
import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration;
30+
import org.springframework.context.annotation.Bean;
31+
import org.springframework.context.annotation.Configuration;
32+
33+
/**
34+
* {@link EnableAutoConfiguration Auto-configuration} for {@link QuartzEndpoint}.
35+
*
36+
* @author Vedran Pavic
37+
* @author Stephane Nicoll
38+
* @since 2.5.0
39+
*/
40+
@Configuration(proxyBeanMethods = false)
41+
@ConditionalOnClass(Scheduler.class)
42+
@AutoConfigureAfter(QuartzAutoConfiguration.class)
43+
@ConditionalOnAvailableEndpoint(endpoint = QuartzEndpoint.class)
44+
public class QuartzEndpointAutoConfiguration {
45+
46+
@Bean
47+
@ConditionalOnBean(Scheduler.class)
48+
@ConditionalOnMissingBean
49+
public QuartzEndpoint quartzEndpoint(Scheduler scheduler) {
50+
return new QuartzEndpoint(scheduler);
51+
}
52+
53+
@Bean
54+
@ConditionalOnBean(QuartzEndpoint.class)
55+
@ConditionalOnMissingBean
56+
public QuartzEndpointWebExtension quartzEndpointWebExtension(QuartzEndpoint endpoint) {
57+
return new QuartzEndpointWebExtension(endpoint);
58+
}
59+
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2012-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Auto-configuration for actuator Quartz Scheduler concerns.
19+
*/
20+
package org.springframework.boot.actuate.autoconfigure.quartz;

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring.factories

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ org.springframework.boot.actuate.autoconfigure.metrics.web.tomcat.TomcatMetricsA
8080
org.springframework.boot.actuate.autoconfigure.mongo.MongoHealthContributorAutoConfiguration,\
8181
org.springframework.boot.actuate.autoconfigure.mongo.MongoReactiveHealthContributorAutoConfiguration,\
8282
org.springframework.boot.actuate.autoconfigure.neo4j.Neo4jHealthContributorAutoConfiguration,\
83+
org.springframework.boot.actuate.autoconfigure.quartz.QuartzEndpointAutoConfiguration,\
8384
org.springframework.boot.actuate.autoconfigure.r2dbc.ConnectionFactoryHealthContributorAutoConfiguration,\
8485
org.springframework.boot.actuate.autoconfigure.redis.RedisHealthContributorAutoConfiguration,\
8586
org.springframework.boot.actuate.autoconfigure.redis.RedisReactiveHealthContributorAutoConfiguration,\

0 commit comments

Comments
 (0)