Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Commit 9f405c2

Browse files
authored
Adds support for ES 7.7.0 (#205)
* Adds support for ES 7.7.0 * Update the Release Notes * Update the requirement of JDK 14 in README * Update the Java version in 'push-notification-jar' workflow
1 parent 16cfc36 commit 9f405c2

25 files changed

+126
-88
lines changed

.github/workflows/push-notification-jar.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ jobs:
2222
- name: Setup Java
2323
uses: actions/setup-java@v1
2424
with:
25-
java-version: '13'
25+
java-version: '14'
2626

2727
- name: Upload Notification Jar to Maven
2828
env:
2929
passphrase: ${{ secrets.PASSPHRASE }}
3030
run: |
3131
cd ..
32-
export JAVA13_HOME=$JAVA_HOME
32+
export JAVA14_HOME=$JAVA_HOME
3333
aws s3 cp s3://opendistro-docs/github-actions/pgp-public-key .
3434
aws s3 cp s3://opendistro-docs/github-actions/pgp-private-key .
3535
@@ -41,4 +41,4 @@ jobs:
4141
4242
cd alerting/notification
4343
44-
../gradlew publishShadowPublicationToSonatype-stagingRepository -Dcompiler.java=13 -Dbuild.snapshot=false -Djavax.net.ssl.trustStore=$JAVA_HOME/lib/security/cacerts
44+
../gradlew publishShadowPublicationToSonatype-stagingRepository -Dcompiler.java=14 -Dbuild.snapshot=false -Djavax.net.ssl.trustStore=$JAVA_HOME/lib/security/cacerts

.github/workflows/release-workflow.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
build:
1010
strategy:
1111
matrix:
12-
java: [13]
12+
java: [14]
1313
# Job name
1414
name: Build Alerting with JDK ${{ matrix.java }}
1515
# This job runs on Linux

.github/workflows/test-workflow.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
build:
1111
strategy:
1212
matrix:
13-
java: [13]
13+
java: [14]
1414
# Job name
1515
name: Build Alerting with JDK ${{ matrix.java }}
1616
# This job runs on Linux

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Please see our [documentation](https://opendistro.github.io/for-elasticsearch-do
2626

2727
1. Check out this package from version control.
2828
1. Launch Intellij IDEA, choose **Import Project**, and select the `settings.gradle` file in the root of this package.
29-
1. To build from the command line, set `JAVA_HOME` to point to a JDK >= 13 before running `./gradlew`.
29+
1. To build from the command line, set `JAVA_HOME` to point to a JDK >= 14 before running `./gradlew`.
3030

3131

3232
## Build

alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/AlertingPlugin.kt

+11-10
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, P
102102
indexNameExpressionResolver: IndexNameExpressionResolver?,
103103
nodesInCluster: Supplier<DiscoveryNodes>
104104
): List<RestHandler> {
105-
return listOf(RestGetMonitorAction(restController),
106-
RestDeleteMonitorAction(restController),
107-
RestIndexMonitorAction(settings, restController, scheduledJobIndices, clusterService),
108-
RestSearchMonitorAction(restController),
109-
RestExecuteMonitorAction(settings, restController, runner),
110-
RestAcknowledgeAlertAction(restController),
111-
RestScheduledJobStatsHandler(restController, "_alerting"),
112-
RestIndexDestinationAction(settings, restController, scheduledJobIndices, clusterService),
113-
RestDeleteDestinationAction(restController))
105+
return listOf(RestGetMonitorAction(),
106+
RestDeleteMonitorAction(),
107+
RestIndexMonitorAction(settings, scheduledJobIndices, clusterService),
108+
RestSearchMonitorAction(),
109+
RestExecuteMonitorAction(settings, runner),
110+
RestAcknowledgeAlertAction(),
111+
RestScheduledJobStatsHandler("_alerting"),
112+
RestIndexDestinationAction(settings, scheduledJobIndices, clusterService),
113+
RestDeleteDestinationAction())
114114
}
115115

116116
override fun getActions(): List<ActionPlugin.ActionHandler<out ActionRequest, out ActionResponse>> {
@@ -130,7 +130,8 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, P
130130
xContentRegistry: NamedXContentRegistry,
131131
environment: Environment,
132132
nodeEnvironment: NodeEnvironment,
133-
namedWriteableRegistry: NamedWriteableRegistry
133+
namedWriteableRegistry: NamedWriteableRegistry,
134+
indexNameExpressionResolver: IndexNameExpressionResolver
134135
): Collection<Any> {
135136
// Need to figure out how to use the Elasticsearch DI classes rather than handwiring things here.
136137
val settings = environment.settings()

alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/alerts/AlertIndices.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ class AlertIndices(
205205
}
206206
if (existsResponse.isExists) return true
207207

208-
val request = CreateIndexRequest(index).mapping(MAPPING_TYPE, alertMapping(), XContentType.JSON)
208+
val request = CreateIndexRequest(index)
209+
.mapping(MAPPING_TYPE, alertMapping(), XContentType.JSON)
210+
.settings(Settings.builder().put("index.hidden", true).build())
211+
209212
if (alias != null) request.alias(Alias(alias))
210213
return try {
211214
val createIndexResponse: CreateIndexResponse = client.admin().indices().suspendUntil { create(request, it) }
@@ -259,6 +262,7 @@ class AlertIndices(
259262
val request = RolloverRequest(HISTORY_WRITE_INDEX, null)
260263
request.createIndexRequest.index(HISTORY_INDEX_PATTERN)
261264
.mapping(MAPPING_TYPE, alertMapping(), XContentType.JSON)
265+
.settings(Settings.builder().put("index.hidden", true).build())
262266
request.addMaxIndexDocsCondition(historyMaxDocs)
263267
request.addMaxIndexAgeCondition(historyMaxAge)
264268
val response = client.admin().indices().rolloversIndex(request).actionGet(requestTimeout)

alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/resthandler/RestAcknowledgeAlertAction.kt

+9-7
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import org.elasticsearch.rest.BaseRestHandler
4747
import org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer
4848
import org.elasticsearch.rest.BytesRestResponse
4949
import org.elasticsearch.rest.RestChannel
50-
import org.elasticsearch.rest.RestController
50+
import org.elasticsearch.rest.RestHandler.Route
5151
import org.elasticsearch.rest.RestRequest
5252
import org.elasticsearch.rest.RestRequest.Method.POST
5353
import org.elasticsearch.rest.RestStatus
@@ -62,17 +62,19 @@ private val log: Logger = LogManager.getLogger(RestAcknowledgeAlertAction::class
6262
* The user provides the monitorID to which these alerts pertain and in the content of the request provides
6363
* the ids to the alerts he would like to acknowledge.
6464
*/
65-
class RestAcknowledgeAlertAction(controller: RestController) : BaseRestHandler() {
66-
67-
init {
68-
// Acknowledge alerts
69-
controller.registerHandler(POST, "${AlertingPlugin.MONITOR_BASE_URI}/{monitorID}/_acknowledge/alerts", this)
70-
}
65+
class RestAcknowledgeAlertAction : BaseRestHandler() {
7166

7267
override fun getName(): String {
7368
return "acknowledge_alert_action"
7469
}
7570

71+
override fun routes(): List<Route> {
72+
return listOf(
73+
// Acknowledge alerts
74+
Route(POST, "${AlertingPlugin.MONITOR_BASE_URI}/{monitorID}/_acknowledge/alerts")
75+
)
76+
}
77+
7678
@Throws(IOException::class)
7779
override fun prepareRequest(request: RestRequest, client: NodeClient): RestChannelConsumer {
7880
val monitorId = request.param("monitorID")

alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/resthandler/RestDeleteDestinationAction.kt

+8-6
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,26 @@ import org.elasticsearch.action.support.WriteRequest
2323
import org.elasticsearch.client.node.NodeClient
2424
import org.elasticsearch.rest.BaseRestHandler
2525
import org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer
26-
import org.elasticsearch.rest.RestController
26+
import org.elasticsearch.rest.RestHandler.Route
2727
import org.elasticsearch.rest.RestRequest
2828
import org.elasticsearch.rest.action.RestStatusToXContentListener
2929
import java.io.IOException
3030

3131
/**
3232
* This class consists of the REST handler to delete destination.
3333
*/
34-
class RestDeleteDestinationAction(controller: RestController) : BaseRestHandler() {
35-
36-
init {
37-
controller.registerHandler(RestRequest.Method.DELETE, "${AlertingPlugin.DESTINATION_BASE_URI}/{destinationID}", this)
38-
}
34+
class RestDeleteDestinationAction : BaseRestHandler() {
3935

4036
override fun getName(): String {
4137
return "delete_destination_action"
4238
}
4339

40+
override fun routes(): List<Route> {
41+
return listOf(
42+
Route(RestRequest.Method.DELETE, "${AlertingPlugin.DESTINATION_BASE_URI}/{destinationID}")
43+
)
44+
}
45+
4446
@Throws(IOException::class)
4547
override fun prepareRequest(request: RestRequest, client: NodeClient): RestChannelConsumer {
4648
val destinationId = request.param("destinationID")

alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/resthandler/RestDeleteMonitorAction.kt

+8-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import org.elasticsearch.action.support.WriteRequest.RefreshPolicy
2323
import org.elasticsearch.client.node.NodeClient
2424
import org.elasticsearch.rest.BaseRestHandler
2525
import org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer
26-
import org.elasticsearch.rest.RestController
26+
import org.elasticsearch.rest.RestHandler.Route
2727
import org.elasticsearch.rest.RestRequest
2828
import org.elasticsearch.rest.RestRequest.Method.DELETE
2929
import org.elasticsearch.rest.action.RestStatusToXContentListener
@@ -34,17 +34,18 @@ import java.io.IOException
3434
* When a monitor is deleted, all alerts are moved to the [Alert.State.DELETED] state and moved to the alert history index.
3535
* If this process fails the monitor is not deleted.
3636
*/
37-
class RestDeleteMonitorAction(controller: RestController) :
38-
BaseRestHandler() {
39-
40-
init {
41-
controller.registerHandler(DELETE, "${AlertingPlugin.MONITOR_BASE_URI}/{monitorID}", this) // Delete a monitor
42-
}
37+
class RestDeleteMonitorAction : BaseRestHandler() {
4338

4439
override fun getName(): String {
4540
return "delete_monitor_action"
4641
}
4742

43+
override fun routes(): List<Route> {
44+
return listOf(
45+
Route(DELETE, "${AlertingPlugin.MONITOR_BASE_URI}/{monitorID}") // Delete a monitor
46+
)
47+
}
48+
4849
@Throws(IOException::class)
4950
override fun prepareRequest(request: RestRequest, client: NodeClient): RestChannelConsumer {
5051
val monitorId = request.param("monitorID")

alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/resthandler/RestExecuteMonitorAction.kt

+8-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import org.elasticsearch.rest.BaseRestHandler
3737
import org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer
3838
import org.elasticsearch.rest.BytesRestResponse
3939
import org.elasticsearch.rest.RestChannel
40-
import org.elasticsearch.rest.RestController
40+
import org.elasticsearch.rest.RestHandler.Route
4141
import org.elasticsearch.rest.RestRequest
4242
import org.elasticsearch.rest.RestRequest.Method.POST
4343
import org.elasticsearch.rest.RestStatus
@@ -48,17 +48,18 @@ private val log = LogManager.getLogger(RestExecuteMonitorAction::class.java)
4848

4949
class RestExecuteMonitorAction(
5050
val settings: Settings,
51-
restController: RestController,
5251
private val runner: MonitorRunner
5352
) : BaseRestHandler() {
5453

55-
init {
56-
restController.registerHandler(POST, "${AlertingPlugin.MONITOR_BASE_URI}/{monitorID}/_execute", this)
57-
restController.registerHandler(POST, "${AlertingPlugin.MONITOR_BASE_URI}/_execute", this)
58-
}
59-
6054
override fun getName(): String = "execute_monitor_action"
6155

56+
override fun routes(): List<Route> {
57+
return listOf(
58+
Route(POST, "${AlertingPlugin.MONITOR_BASE_URI}/{monitorID}/_execute"),
59+
Route(POST, "${AlertingPlugin.MONITOR_BASE_URI}/_execute")
60+
)
61+
}
62+
6263
override fun prepareRequest(request: RestRequest, client: NodeClient): RestChannelConsumer {
6364
return RestChannelConsumer { channel ->
6465
val dryrun = request.paramAsBoolean("dryrun", false)

alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/resthandler/RestGetMonitorAction.kt

+10-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import org.elasticsearch.rest.BaseRestHandler
3232
import org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer
3333
import org.elasticsearch.rest.BytesRestResponse
3434
import org.elasticsearch.rest.RestChannel
35-
import org.elasticsearch.rest.RestController
35+
import org.elasticsearch.rest.RestHandler.Route
3636
import org.elasticsearch.rest.RestRequest
3737
import org.elasticsearch.rest.RestRequest.Method.GET
3838
import org.elasticsearch.rest.RestRequest.Method.HEAD
@@ -45,18 +45,20 @@ import org.elasticsearch.search.fetch.subphase.FetchSourceContext
4545
/**
4646
* This class consists of the REST handler to retrieve a monitor .
4747
*/
48-
class RestGetMonitorAction(controller: RestController) : BaseRestHandler() {
49-
50-
init {
51-
// Get a specific monitor
52-
controller.registerHandler(GET, "${AlertingPlugin.MONITOR_BASE_URI}/{monitorID}", this)
53-
controller.registerHandler(HEAD, "${AlertingPlugin.MONITOR_BASE_URI}/{monitorID}", this)
54-
}
48+
class RestGetMonitorAction : BaseRestHandler() {
5549

5650
override fun getName(): String {
5751
return "get_monitor_action"
5852
}
5953

54+
override fun routes(): List<Route> {
55+
return listOf(
56+
// Get a specific monitor
57+
Route(GET, "${AlertingPlugin.MONITOR_BASE_URI}/{monitorID}"),
58+
Route(HEAD, "${AlertingPlugin.MONITOR_BASE_URI}/{monitorID}")
59+
)
60+
}
61+
6062
override fun prepareRequest(request: RestRequest, client: NodeClient): RestChannelConsumer {
6163
val monitorId = request.param("monitorID")
6264
if (monitorId == null || monitorId.isEmpty()) {

alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/resthandler/RestIndexDestinationAction.kt

+8-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import org.elasticsearch.rest.BaseRestHandler
4949
import org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer
5050
import org.elasticsearch.rest.BytesRestResponse
5151
import org.elasticsearch.rest.RestChannel
52-
import org.elasticsearch.rest.RestController
52+
import org.elasticsearch.rest.RestHandler.Route
5353
import org.elasticsearch.rest.RestRequest
5454
import org.elasticsearch.rest.RestResponse
5555
import org.elasticsearch.rest.RestStatus
@@ -63,7 +63,6 @@ private val log = LogManager.getLogger(RestIndexDestinationAction::class.java)
6363
*/
6464
class RestIndexDestinationAction(
6565
settings: Settings,
66-
controller: RestController,
6766
jobIndices: ScheduledJobIndices,
6867
clusterService: ClusterService
6968
) : BaseRestHandler() {
@@ -72,8 +71,6 @@ class RestIndexDestinationAction(
7271
@Volatile private var indexTimeout = INDEX_TIMEOUT.get(settings)
7372

7473
init {
75-
controller.registerHandler(RestRequest.Method.POST, AlertingPlugin.DESTINATION_BASE_URI, this) // Creates new destination
76-
controller.registerHandler(RestRequest.Method.PUT, "${AlertingPlugin.DESTINATION_BASE_URI}/{destinationID}", this)
7774
scheduledJobIndices = jobIndices
7875

7976
clusterService.clusterSettings.addSettingsUpdateConsumer(INDEX_TIMEOUT) { indexTimeout = it }
@@ -84,6 +81,13 @@ class RestIndexDestinationAction(
8481
return "index_destination_action"
8582
}
8683

84+
override fun routes(): List<Route> {
85+
return listOf(
86+
Route(RestRequest.Method.POST, AlertingPlugin.DESTINATION_BASE_URI), // Creates new destination
87+
Route(RestRequest.Method.PUT, "${AlertingPlugin.DESTINATION_BASE_URI}/{destinationID}")
88+
)
89+
}
90+
8791
@Throws(IOException::class)
8892
override fun prepareRequest(request: RestRequest, client: NodeClient): BaseRestHandler.RestChannelConsumer {
8993
val id = request.param("destinationID", Destination.NO_ID)

alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/resthandler/RestIndexMonitorAction.kt

+8-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import org.elasticsearch.rest.BaseRestHandler
5858
import org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer
5959
import org.elasticsearch.rest.BytesRestResponse
6060
import org.elasticsearch.rest.RestChannel
61-
import org.elasticsearch.rest.RestController
61+
import org.elasticsearch.rest.RestHandler.Route
6262
import org.elasticsearch.rest.RestRequest
6363
import org.elasticsearch.rest.RestRequest.Method.POST
6464
import org.elasticsearch.rest.RestRequest.Method.PUT
@@ -77,7 +77,6 @@ private val log = LogManager.getLogger(RestIndexMonitorAction::class.java)
7777
*/
7878
class RestIndexMonitorAction(
7979
settings: Settings,
80-
controller: RestController,
8180
jobIndices: ScheduledJobIndices,
8281
clusterService: ClusterService
8382
) : BaseRestHandler() {
@@ -90,8 +89,6 @@ class RestIndexMonitorAction(
9089
@Volatile private var maxActionThrottle = MAX_ACTION_THROTTLE_VALUE.get(settings)
9190

9291
init {
93-
controller.registerHandler(POST, AlertingPlugin.MONITOR_BASE_URI, this) // Create a new monitor
94-
controller.registerHandler(PUT, "${AlertingPlugin.MONITOR_BASE_URI}/{monitorID}", this)
9592
scheduledJobIndices = jobIndices
9693

9794
clusterService.clusterSettings.addSettingsUpdateConsumer(ALERTING_MAX_MONITORS) { maxMonitors = it }
@@ -105,6 +102,13 @@ class RestIndexMonitorAction(
105102
return "index_monitor_action"
106103
}
107104

105+
override fun routes(): List<Route> {
106+
return listOf(
107+
Route(POST, AlertingPlugin.MONITOR_BASE_URI), // Create a new monitor
108+
Route(PUT, "${AlertingPlugin.MONITOR_BASE_URI}/{monitorID}")
109+
)
110+
}
111+
108112
@Throws(IOException::class)
109113
override fun prepareRequest(request: RestRequest, client: NodeClient): RestChannelConsumer {
110114
val id = request.param("monitorID", Monitor.NO_ID)

alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/resthandler/RestSearchMonitorAction.kt

+10-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import org.elasticsearch.rest.BaseRestHandler
3232
import org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer
3333
import org.elasticsearch.rest.BytesRestResponse
3434
import org.elasticsearch.rest.RestChannel
35-
import org.elasticsearch.rest.RestController
35+
import org.elasticsearch.rest.RestHandler.Route
3636
import org.elasticsearch.rest.RestRequest
3737
import org.elasticsearch.rest.RestRequest.Method.GET
3838
import org.elasticsearch.rest.RestRequest.Method.POST
@@ -45,17 +45,20 @@ import java.io.IOException
4545
/**
4646
* Rest handlers to search for monitors.
4747
*/
48-
class RestSearchMonitorAction(controller: RestController) : BaseRestHandler() {
49-
init {
50-
// Search for monitors
51-
controller.registerHandler(POST, "${AlertingPlugin.MONITOR_BASE_URI}/_search", this)
52-
controller.registerHandler(GET, "${AlertingPlugin.MONITOR_BASE_URI}/_search", this)
53-
}
48+
class RestSearchMonitorAction : BaseRestHandler() {
5449

5550
override fun getName(): String {
5651
return "search_monitor_action"
5752
}
5853

54+
override fun routes(): List<Route> {
55+
return listOf(
56+
// Search for monitors
57+
Route(POST, "${AlertingPlugin.MONITOR_BASE_URI}/_search"),
58+
Route(GET, "${AlertingPlugin.MONITOR_BASE_URI}/_search")
59+
)
60+
}
61+
5962
@Throws(IOException::class)
6063
override fun prepareRequest(request: RestRequest, client: NodeClient): RestChannelConsumer {
6164
val searchSourceBuilder = SearchSourceBuilder()

0 commit comments

Comments
 (0)