-
Notifications
You must be signed in to change notification settings - Fork 79
Add actions to create, execute, get monitors api #240
Conversation
Codecov Report
@@ Coverage Diff @@
## master #240 +/- ##
============================================
+ Coverage 77.51% 78.79% +1.28%
Complexity 164 164
============================================
Files 75 91 +16
Lines 2948 3249 +301
Branches 442 458 +16
============================================
+ Hits 2285 2560 +275
- Misses 433 446 +13
- Partials 230 243 +13
Continue to review full report at Codecov.
|
sin.readEnum(RestStatus::class.java), // RestStatus | ||
if (sin.readBoolean()) { | ||
Monitor.readFrom(sin) // monitor | ||
} else null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This response is used for GET or HEAD request. With HEAD request we wont have monitor object in response. This checks if monitor is present. Also refer to writeTo
if (monitor != null) { out.writeBoolean(true) monitor?.writeTo(out) } else { out.writeBoolean(false) }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misread the code, just realized that this is inside a constructor call. Makes sense why this is done
ElasticsearchStatusException("Can't find monitor with id: ${response.id}", RestStatus.NOT_FOUND) | ||
) | ||
} | ||
if (!response.isSourceEmpty) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This statement was not there before in the RestExecuteMonitorAction.kt
file. Is this fixing a bug that was there before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I added this extra check here to be extra safe. We were doing that in RestGetMonitorAction
Line 91 in 9f405c2
if (!response.isSourceEmpty) { |
init { | ||
clusterService.clusterSettings.addSettingsUpdateConsumer(ALERTING_MAX_MONITORS) { maxMonitors = it } | ||
clusterService.clusterSettings.addSettingsUpdateConsumer(REQUEST_TIMEOUT) { requestTimeout = it } | ||
clusterService.clusterSettings.addSettingsUpdateConsumer(INDEX_TIMEOUT) { indexTimeout = it } | ||
clusterService.clusterSettings.addSettingsUpdateConsumer(MAX_ACTION_THROTTLE_VALUE) { maxActionThrottle = it } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be set if it is done in RestIndexMonitorAction.kt
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I missed to remove this from RestIndexMonitorAction. Will fix it.
req.writeTo(out) | ||
val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) | ||
val newReq = ExecuteMonitorRequest(sin) | ||
assertNull(newReq.monitorId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please compare this with the original monitorId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this test the monitorId is null, so left this to check assertNull
. Added a new check below to compare monitor.
Monitor( | ||
"123", | ||
0L, "test-monitor", true, cronSchedule, Instant.now(), | ||
Instant.now(), 0, mutableListOf(), mutableListOf(), mutableMapOf() | ||
|
||
)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix formatting so it is consistent for the input attributes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed formatting.
Monitor( | ||
"123", | ||
0L, "test-monitor", true, cronSchedule, Instant.now(), | ||
Instant.now(), 0, mutableListOf(), mutableListOf(), mutableMapOf() | ||
|
||
)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix formatting so it is consistent for the input attributes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed formatting.
Issue #, if available:
#232
Description of changes:
This to add actions to create/modify , execute, get monitor.
#232
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.