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

Commit

Permalink
Opendistro 1.4 (#141)
Browse files Browse the repository at this point in the history
* Update to OD 1.3 -> ES 7.3.2, fix broken stats API. Update release docs.

* Update release notes to be correct.

* Github actions works, updating ES version to be correct now.

* Make plugin verison consistant.

* It builds, and runs, and tests. TODO: 3 compiler warnings, no jacoco.

* Bump jacoco version to work with new JDK. Fix one warning for kotlin.

* Uncomment the jacoco.
  • Loading branch information
lucaswin-amzn authored and dbbaughe committed Jan 7, 2020
1 parent 99ba663 commit 826ba47
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, P
indexNameExpressionResolver: IndexNameExpressionResolver?,
nodesInCluster: Supplier<DiscoveryNodes>
): List<RestHandler> {
return listOf(RestGetMonitorAction(settings, restController),
RestDeleteMonitorAction(settings, restController),
return listOf(RestGetMonitorAction(restController),
RestDeleteMonitorAction(restController),
RestIndexMonitorAction(settings, restController, scheduledJobIndices, clusterService),
RestSearchMonitorAction(settings, restController),
RestSearchMonitorAction(restController),
RestExecuteMonitorAction(settings, restController, runner),
RestAcknowledgeAlertAction(settings, restController),
RestScheduledJobStatsHandler(settings, restController, "_alerting"),
RestAcknowledgeAlertAction(restController),
RestScheduledJobStatsHandler(restController, "_alerting"),
RestIndexDestinationAction(settings, restController, scheduledJobIndices, clusterService),
RestDeleteDestinationAction(settings, restController))
RestDeleteDestinationAction(restController))
}

override fun getActions(): List<ActionPlugin.ActionHandler<out ActionRequest, out ActionResponse>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ suspend fun moveAlerts(client: Client, monitorId: String, monitor: Monitor? = nu
val response: SearchResponse = client.suspendUntil { search(activeAlertsRequest, it) }

// If no alerts are found, simply return
if (response.hits.totalHits.value == 0L) return
if (response.hits.totalHits?.value == 0L) return
val indexRequests = response.hits.map { hit ->
IndexRequest(AlertIndices.HISTORY_WRITE_INDEX)
.routing(monitorId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import org.elasticsearch.action.support.WriteRequest
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy
import org.elasticsearch.action.update.UpdateRequest
import org.elasticsearch.client.node.NodeClient
import org.elasticsearch.common.settings.Settings
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler
import org.elasticsearch.common.xcontent.XContentBuilder
import org.elasticsearch.common.xcontent.XContentFactory
Expand Down Expand Up @@ -63,7 +62,7 @@ private val log: Logger = LogManager.getLogger(RestAcknowledgeAlertAction::class
* The user provides the monitorID to which these alerts pertain and in the content of the request provides
* the ids to the alerts he would like to acknowledge.
*/
class RestAcknowledgeAlertAction(settings: Settings, controller: RestController) : BaseRestHandler(settings) {
class RestAcknowledgeAlertAction(controller: RestController) : BaseRestHandler() {

init {
// Acknowledge alerts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.amazon.opendistroforelasticsearch.alerting.util.REFRESH
import org.elasticsearch.action.delete.DeleteRequest
import org.elasticsearch.action.support.WriteRequest
import org.elasticsearch.client.node.NodeClient
import org.elasticsearch.common.settings.Settings
import org.elasticsearch.rest.BaseRestHandler
import org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer
import org.elasticsearch.rest.RestController
Expand All @@ -32,7 +31,7 @@ import java.io.IOException
/**
* This class consists of the REST handler to delete destination.
*/
class RestDeleteDestinationAction(settings: Settings, controller: RestController) : BaseRestHandler(settings) {
class RestDeleteDestinationAction(controller: RestController) : BaseRestHandler() {

init {
controller.registerHandler(RestRequest.Method.DELETE, "${AlertingPlugin.DESTINATION_BASE_URI}/{destinationID}", this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.amazon.opendistroforelasticsearch.alerting.AlertingPlugin
import org.elasticsearch.action.delete.DeleteRequest
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy
import org.elasticsearch.client.node.NodeClient
import org.elasticsearch.common.settings.Settings
import org.elasticsearch.rest.BaseRestHandler
import org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer
import org.elasticsearch.rest.RestController
Expand All @@ -35,8 +34,8 @@ import java.io.IOException
* When a monitor is deleted, all alerts are moved to the [Alert.State.DELETED] state and moved to the alert history index.
* If this process fails the monitor is not deleted.
*/
class RestDeleteMonitorAction(settings: Settings, controller: RestController) :
BaseRestHandler(settings) {
class RestDeleteMonitorAction(controller: RestController) :
BaseRestHandler() {

init {
controller.registerHandler(DELETE, "${AlertingPlugin.MONITOR_BASE_URI}/{monitorID}", this) // Delete a monitor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RestExecuteMonitorAction(
val settings: Settings,
restController: RestController,
private val runner: MonitorRunner
) : BaseRestHandler(settings) {
) : BaseRestHandler() {

init {
restController.registerHandler(POST, "${AlertingPlugin.MONITOR_BASE_URI}/{monitorID}/_execute", this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import com.amazon.opendistroforelasticsearch.alerting.util._SEQ_NO
import org.elasticsearch.action.get.GetRequest
import org.elasticsearch.action.get.GetResponse
import org.elasticsearch.client.node.NodeClient
import org.elasticsearch.common.settings.Settings
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler
import org.elasticsearch.common.xcontent.XContentHelper
import org.elasticsearch.common.xcontent.XContentType
Expand All @@ -46,7 +45,7 @@ import org.elasticsearch.search.fetch.subphase.FetchSourceContext
/**
* This class consists of the REST handler to retrieve a monitor .
*/
class RestGetMonitorAction(settings: Settings, controller: RestController) : BaseRestHandler(settings) {
class RestGetMonitorAction(controller: RestController) : BaseRestHandler() {

init {
// Get a specific monitor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class RestIndexDestinationAction(
controller: RestController,
jobIndices: ScheduledJobIndices,
clusterService: ClusterService
) : BaseRestHandler(settings) {
) : BaseRestHandler() {
private var scheduledJobIndices: ScheduledJobIndices
private val clusterService: ClusterService
@Volatile private var indexTimeout = INDEX_TIMEOUT.get(settings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class RestIndexMonitorAction(
controller: RestController,
jobIndices: ScheduledJobIndices,
clusterService: ClusterService
) : BaseRestHandler(settings) {
) : BaseRestHandler() {

private var scheduledJobIndices: ScheduledJobIndices
private val clusterService: ClusterService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import org.elasticsearch.action.search.SearchRequest
import org.elasticsearch.action.search.SearchResponse
import org.elasticsearch.client.node.NodeClient
import org.elasticsearch.common.bytes.BytesReference
import org.elasticsearch.common.settings.Settings
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler
import org.elasticsearch.common.xcontent.ToXContent.EMPTY_PARAMS
import org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder
Expand All @@ -46,7 +45,7 @@ import java.io.IOException
/**
* Rest handlers to search for monitors.
*/
class RestSearchMonitorAction(settings: Settings, controller: RestController) : BaseRestHandler(settings) {
class RestSearchMonitorAction(controller: RestController) : BaseRestHandler() {
init {
// Search for monitors
controller.registerHandler(POST, "${AlertingPlugin.MONITOR_BASE_URI}/_search", this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import org.elasticsearch.test.junit.annotations.TestLogging
import org.junit.Assert
import java.time.Instant

@TestLogging("level:DEBUG")
@TestLogging("level:DEBUG", reason = "Debug for tests.")
@Suppress("UNCHECKED_CAST")
class DestinationRestApiIT : AlertingRestTestCase() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import java.time.ZoneId
import java.time.temporal.ChronoUnit
import org.elasticsearch.common.unit.TimeValue

@TestLogging("level:DEBUG")
@TestLogging("level:DEBUG", reason = "Debug for tests.")
@Suppress("UNCHECKED_CAST")
class MonitorRestApiIT : AlertingRestTestCase() {

Expand Down
2 changes: 1 addition & 1 deletion build-tools/merged-coverage.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
allprojects {
plugins.withId('jacoco') {
// 0.8.2 doesn't show missing coverage of Kotlin generated methods. Remove once this becomes gradle's default
jacoco.toolVersion = '0.8.2'
jacoco.toolVersion = '0.8.5'
tasks.withType(Test) {
jacoco { append = false }
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {
apply from: 'build-tools/repositories.gradle'

ext {
es_version = '7.3.2'
es_version = '7.4.2'
kotlin_version = '1.3.21'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ScheduledJobStats : BaseNodeResponse, ToXContentFragment {
var jobSweeperMetrics: JobSweeperMetrics? = null
var jobInfos: Array<JobSchedulerMetrics>? = null

constructor()
constructor(si: StreamInput): super(si)

constructor(
node: DiscoveryNode,
Expand All @@ -59,18 +59,7 @@ class ScheduledJobStats : BaseNodeResponse, ToXContentFragment {

companion object {
@JvmStatic
fun readScheduledJobStatus(si: StreamInput): ScheduledJobStats {
val scheduledJobStatus = ScheduledJobStats()
scheduledJobStatus.readFrom(si)
return scheduledJobStatus
}
}

override fun readFrom(si: StreamInput) {
super.readFrom(si)
this.status = si.readEnum(ScheduleStatus::class.java)
this.jobSweeperMetrics = si.readOptionalWriteable { JobSweeperMetrics(si) }
this.jobInfos = si.readOptionalArray({ JobSchedulerMetrics(si) }, { arrayOfNulls<JobSchedulerMetrics>(it) })
fun readScheduledJobStatus(si: StreamInput) = ScheduledJobStats(si)
}

override fun writeTo(out: StreamOutput) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class ScheduledJobsStatsAction : ActionType<ScheduledJobsStatsResponse>(NAME, re
const val NAME = "cluster:admin/opendistro/_scheduled_jobs/stats"

val reader = Writeable.Reader {
val response = ScheduledJobsStatsResponse()
response.readFrom(it)
val response = ScheduledJobsStatsResponse(it)
response
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@ class ScheduledJobsStatsRequest : BaseNodesRequest<ScheduledJobsStatsRequest> {
var jobSchedulingMetrics: Boolean = true
var jobsInfo: Boolean = true

constructor()
constructor(nodeIds: Array<String>) : super(*nodeIds)

@Throws(IOException::class)
override fun readFrom(si: StreamInput) {
super.readFrom(si)
constructor(si: StreamInput): super(si) {
jobSchedulingMetrics = si.readBoolean()
jobsInfo = si.readBoolean()
}
constructor(nodeIds: Array<String>) : super(*nodeIds)

@Throws(IOException::class)
override fun writeTo(out: StreamOutput) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class ScheduledJobsStatsResponse : BaseNodesResponse<ScheduledJobStats>, ToXCont
private var indexExists: Boolean? = null
private var indexHealth: ClusterIndexHealth? = null

constructor()
constructor(si: StreamInput): super(si)

constructor(
clusterName: ClusterName,
nodeResponses: List<ScheduledJobStats>,
Expand All @@ -53,7 +54,7 @@ class ScheduledJobsStatsResponse : BaseNodesResponse<ScheduledJobStats>, ToXCont
out: StreamOutput,
nodes: MutableList<ScheduledJobStats>
) {
out.writeStreamableList(nodes)
out.writeList(nodes)
}

override fun readNodesFrom(si: StreamInput): MutableList<ScheduledJobStats> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class ScheduledJobsStatsTransportAction : TransportNodesAction<ScheduledJobsStat
clusterService,
transportService,
actionFilters,
{ ScheduledJobsStatsRequest() },
{ ScheduledJobStatusRequest() },
{ ScheduledJobsStatsRequest(it) },
{ ScheduledJobStatusRequest(it) },
ThreadPool.Names.MANAGEMENT,
ScheduledJobStats::class.java
) {
Expand All @@ -72,8 +72,8 @@ class ScheduledJobsStatsTransportAction : TransportNodesAction<ScheduledJobsStat
return ScheduledJobStatusRequest(request)
}

override fun newNodeResponse(): ScheduledJobStats {
return ScheduledJobStats()
override fun newNodeResponse(si: StreamInput): ScheduledJobStats {
return ScheduledJobStats(si)
}

override fun newResponse(
Expand Down Expand Up @@ -128,15 +128,13 @@ class ScheduledJobsStatsTransportAction : TransportNodesAction<ScheduledJobsStat
lateinit var request: ScheduledJobsStatsRequest

constructor() : super()
constructor(request: ScheduledJobsStatsRequest) : super() {
this.request = request

constructor(si: StreamInput): super(si) {
request = ScheduledJobsStatsRequest(si)
}

@Throws(IOException::class)
override fun readFrom(si: StreamInput) {
super.readFrom(si)
request = ScheduledJobsStatsRequest()
request.readFrom(si)
constructor(request: ScheduledJobsStatsRequest) : super() {
this.request = request
}

@Throws(IOException::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import com.amazon.opendistroforelasticsearch.alerting.core.action.node.Scheduled
import com.amazon.opendistroforelasticsearch.alerting.core.action.node.ScheduledJobsStatsRequest
import org.elasticsearch.client.node.NodeClient
import org.elasticsearch.common.Strings
import org.elasticsearch.common.settings.Settings
import org.elasticsearch.rest.BaseRestHandler
import org.elasticsearch.rest.RestController
import org.elasticsearch.rest.RestRequest
Expand All @@ -32,7 +31,7 @@ import java.util.TreeSet
/**
* RestScheduledJobStatsHandler is handler for getting ScheduledJob Stats.
*/
class RestScheduledJobStatsHandler(settings: Settings, controller: RestController, private val path: String) : BaseRestHandler(settings) {
class RestScheduledJobStatsHandler(controller: RestController, private val path: String) : BaseRestHandler() {
init {
controller.registerHandler(GET, "/_opendistro/$path/{nodeId}/stats/", this)
controller.registerHandler(GET, "/_opendistro/$path/{nodeId}/stats/{metric}", this)
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip

0 comments on commit 826ba47

Please sign in to comment.