Skip to content

Commit

Permalink
fix builds again
Browse files Browse the repository at this point in the history
Signed-off-by: Subhobrata Dey <sbcd90@gmail.com>
  • Loading branch information
sbcd90 committed Apr 17, 2024
1 parent 7356f94 commit baea3d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ import org.opensearch.action.support.GroupedActionListener
import org.opensearch.alerting.action.DocLevelMonitorFanOutAction
import org.opensearch.alerting.action.DocLevelMonitorFanOutRequest
import org.opensearch.alerting.action.DocLevelMonitorFanOutResponse
import org.opensearch.alerting.model.ActionRunResult
import org.opensearch.alerting.model.DocumentLevelTriggerRunResult
import org.opensearch.alerting.model.IndexExecutionContext
import org.opensearch.alerting.model.InputRunResults
import org.opensearch.alerting.model.MonitorRunResult
import org.opensearch.alerting.model.*
import org.opensearch.alerting.util.AlertingException
import org.opensearch.alerting.util.IndexUtils
import org.opensearch.alerting.workflow.WorkflowRunContext
Expand All @@ -36,12 +32,7 @@ import org.opensearch.core.rest.RestStatus
import org.opensearch.index.IndexNotFoundException
import org.opensearch.index.seqno.SequenceNumbers
import org.opensearch.node.NodeClosedException
import org.opensearch.transport.ActionNotFoundTransportException
import org.opensearch.transport.ConnectTransportException
import org.opensearch.transport.RemoteTransportException
import org.opensearch.transport.TransportException
import org.opensearch.transport.TransportRequestOptions
import org.opensearch.transport.TransportService
import org.opensearch.transport.*
import java.io.IOException
import java.time.Instant
import kotlin.coroutines.resume
Expand Down Expand Up @@ -307,14 +298,18 @@ class DocumentLevelMonitorRunner : MonitorRunner() {
responseReader
) {
override fun handleException(e: TransportException) {
logger.error("Fan out retry failed in node ${localNode.id}")
logger.error("Fan out retry failed in node ${localNode.id}", e)
listener.onResponse(
DocLevelMonitorFanOutResponse(
"",
"",
"",
mutableMapOf(),
exception = AlertingException.wrap(e) as AlertingException
exception = if (e.cause is AlertingException) {
e.cause as AlertingException
} else {
AlertingException.wrap(e) as AlertingException
}
)
)
}
Expand All @@ -332,7 +327,11 @@ class DocumentLevelMonitorRunner : MonitorRunner() {
"",
"",
mutableMapOf(),
exception = AlertingException.wrap(e) as AlertingException
exception = if (e.cause is AlertingException) {
e.cause as AlertingException
} else {
AlertingException.wrap(e) as AlertingException
}
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private val log = LogManager.getLogger(AlertingException::class.java)
/**
* Converts into a user friendly message.
*/
class AlertingException(message: String, val status: RestStatus, ex: Exception) : OpenSearchException(message, ex) {
class AlertingException(message: String, val status: RestStatus, val ex: Exception) : OpenSearchException(message, ex) {

override fun status(): RestStatus {
return status
Expand Down Expand Up @@ -73,14 +73,17 @@ class AlertingException(message: String, val status: RestStatus, ex: Exception)
@JvmStatic
fun merge(vararg ex: AlertingException): AlertingException {
var friendlyMsg = ""
var unwrappedExceptionMsg = ""
ex.forEach {
if (friendlyMsg != "") {
friendlyMsg += ", ${it.message}"
unwrappedExceptionMsg += ", ${it.ex.message}"
} else {
friendlyMsg = it.message.orEmpty()
unwrappedExceptionMsg = "${it.ex.message}"
}
}
return AlertingException(friendlyMsg, ex.first().status, Exception(ex.javaClass.name))
return AlertingException(friendlyMsg, ex.first().status, Exception(unwrappedExceptionMsg))
}
}
}

0 comments on commit baea3d6

Please sign in to comment.