Skip to content

Commit

Permalink
fix ktlint issues
Browse files Browse the repository at this point in the history
Signed-off-by: Subhobrata Dey <[email protected]>
  • Loading branch information
sbcd90 committed May 31, 2024
1 parent ae13a15 commit 5564e3a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@

package org.opensearch.alerting

import kotlinx.coroutines.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import org.apache.logging.log4j.LogManager
import org.opensearch.OpenSearchStatusException
import org.opensearch.action.bulk.BackoffPolicy
import org.opensearch.action.search.TransportSearchAction.SEARCH_CANCEL_AFTER_TIME_INTERVAL_SETTING
import org.opensearch.action.support.master.AcknowledgedResponse
import org.opensearch.alerting.action.*
import org.opensearch.alerting.action.ExecuteMonitorAction
import org.opensearch.alerting.action.ExecuteMonitorRequest
import org.opensearch.alerting.action.ExecuteMonitorResponse
import org.opensearch.alerting.action.ExecuteWorkflowAction
import org.opensearch.alerting.action.ExecuteWorkflowRequest
import org.opensearch.alerting.action.ExecuteWorkflowResponse
import org.opensearch.alerting.alerts.AlertIndices
import org.opensearch.alerting.alerts.AlertMover.Companion.moveAlerts
import org.opensearch.alerting.core.JobRunner
Expand Down Expand Up @@ -49,7 +58,13 @@ import org.opensearch.cluster.service.ClusterService
import org.opensearch.common.lifecycle.AbstractLifecycleComponent
import org.opensearch.common.settings.Settings
import org.opensearch.common.unit.TimeValue
import org.opensearch.commons.alerting.model.*
import org.opensearch.commons.alerting.model.Alert
import org.opensearch.commons.alerting.model.Monitor
import org.opensearch.commons.alerting.model.MonitorRunResult
import org.opensearch.commons.alerting.model.ScheduledJob
import org.opensearch.commons.alerting.model.TriggerRunResult
import org.opensearch.commons.alerting.model.Workflow
import org.opensearch.commons.alerting.model.WorkflowRunResult
import org.opensearch.commons.alerting.model.action.Action
import org.opensearch.commons.alerting.util.isBucketLevelMonitor
import org.opensearch.commons.alerting.util.isMonitorOfStandardType
Expand All @@ -65,7 +80,7 @@ import org.opensearch.transport.TransportService
import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneOffset
import java.util.*
import java.util.UUID
import kotlin.coroutines.CoroutineContext

object MonitorRunnerService : JobRunner, CoroutineScope, AbstractLifecycleComponent() {
Expand Down Expand Up @@ -352,7 +367,7 @@ object MonitorRunnerService : JobRunner, CoroutineScope, AbstractLifecycleCompon
logger.debug("lock ${lock!!.lockId} acquired")
logger.debug(
"PERF_DEBUG: executing ${job.monitorType} ${job.id} on node " +
monitorCtx.clusterService!!.state().nodes().localNode.id
monitorCtx.clusterService!!.state().nodes().localNode.id
)
val executeMonitorRequest = ExecuteMonitorRequest(
false,
Expand Down Expand Up @@ -424,7 +439,7 @@ object MonitorRunnerService : JobRunner, CoroutineScope, AbstractLifecycleCompon
if (monitor.isMonitorOfStandardType()) {
logger.info(
"Executing scheduled monitor - id: ${monitor.id}, type: ${monitor.monitorType}, periodStart: $periodStart, " +
"periodEnd: $periodEnd, dryrun: $dryrun, executionId: $executionId"
"periodEnd: $periodEnd, dryrun: $dryrun, executionId: $executionId"
)
val runResult = if (monitor.isBucketLevelMonitor()) {
BucketLevelMonitorRunner.runMonitor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ import org.opensearch.common.xcontent.XContentType
import org.opensearch.commons.alerting.action.AlertingActions
import org.opensearch.commons.alerting.action.IndexWorkflowRequest
import org.opensearch.commons.alerting.action.IndexWorkflowResponse
import org.opensearch.commons.alerting.model.*
import org.opensearch.commons.alerting.model.CompositeInput
import org.opensearch.commons.alerting.model.Delegate
import org.opensearch.commons.alerting.model.DocLevelMonitorInput
import org.opensearch.commons.alerting.model.Monitor
import org.opensearch.commons.alerting.model.ScheduledJob
import org.opensearch.commons.alerting.model.ScheduledJob.Companion.SCHEDULED_JOBS_INDEX
import org.opensearch.commons.alerting.model.SearchInput
import org.opensearch.commons.alerting.model.Workflow
import org.opensearch.commons.alerting.util.AlertingException
import org.opensearch.commons.alerting.util.isMonitorOfStandardType
import org.opensearch.commons.authuser.User
Expand All @@ -74,7 +80,8 @@ import org.opensearch.rest.RestRequest
import org.opensearch.search.builder.SearchSourceBuilder
import org.opensearch.tasks.Task
import org.opensearch.transport.TransportService
import java.util.*
import java.util.Locale
import java.util.UUID
import java.util.stream.Collectors

private val log = LogManager.getLogger(TransportIndexWorkflowAction::class.java)
Expand Down Expand Up @@ -141,7 +148,7 @@ class TransportIndexWorkflowAction @Inject constructor(
if (transformedRequest.rbacRoles?.stream()?.anyMatch { !user.backendRoles.contains(it) } == true) {
log.error(
"User specified backend roles, ${transformedRequest.rbacRoles}, " +
"that they don' have access to. User backend roles: ${user.backendRoles}"
"that they don' have access to. User backend roles: ${user.backendRoles}"
)
actionListener.onFailure(
AlertingException.wrap(
Expand All @@ -155,7 +162,7 @@ class TransportIndexWorkflowAction @Inject constructor(
} else if (transformedRequest.rbacRoles?.isEmpty() == true) {
log.error(
"Non-admin user are not allowed to specify an empty set of backend roles. " +
"Please don't pass in the parameter or pass in at least one backend role."
"Please don't pass in the parameter or pass in at least one backend role."
)
actionListener.onFailure(
AlertingException.wrap(
Expand Down Expand Up @@ -618,7 +625,7 @@ class TransportIndexWorkflowAction @Inject constructor(
throw AlertingException.wrap(
IllegalArgumentException(
"Delegate monitor indices ${delegateMonitorIndices.joinToString()} " +
"doesn't query all of chained findings monitor's indices ${chainedMonitorIndices.joinToString()}}"
"doesn't query all of chained findings monitor's indices ${chainedMonitorIndices.joinToString()}}"
)
)
}
Expand Down

0 comments on commit 5564e3a

Please sign in to comment.