Skip to content

Commit

Permalink
bumping ktlint and resolving conflicts (opensearch-project#1792)
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Li <lnse@amazon.com>
(cherry picked from commit 34f6490)
  • Loading branch information
sejli committed Feb 6, 2024
1 parent f28ebc0 commit 58c735f
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 27 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ configurations.all {
force "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${jackson_version}"
force "org.mockito:mockito-core:4.6.1"
force "org.yaml:snakeyaml:2.0"
force "org.slf4j:slf4j-api:2.0.0"
}
}

Expand Down Expand Up @@ -212,7 +213,7 @@ dependencies {
testImplementation "org.mockito:mockito-junit-jupiter:4.3.1"
testImplementation "com.google.code.gson:gson:2.8.9"

ktlint "com.pinterest:ktlint:0.45.0"
ktlint "com.pinterest:ktlint:0.47.1"
}

javadoc.enabled = false // turn off javadoc as it barfs on Kotlin code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ObservabilityPlugin : Plugin(), ActionPlugin, ClusterPlugin {
): List<RestHandler> {
return listOf(
ObservabilityRestHandler(),
ObservabilityStatsRestHandler(),
ObservabilityStatsRestHandler()
)
}

Expand Down
17 changes: 11 additions & 6 deletions src/main/kotlin/org/opensearch/observability/metrics/Metrics.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,24 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) {
OBSERVABILITY_EXCEPTIONS_VERSION_CONFLICT_ENGINE_EXCEPTION("exception.version_conflict_engine", RollingCounter()),
OBSERVABILITY_EXCEPTIONS_INDEX_NOT_FOUND_EXCEPTION("exception.index_not_found", RollingCounter()),
OBSERVABILITY_EXCEPTIONS_INVALID_INDEX_NAME_EXCEPTION(
"exception.invalid_index_name", RollingCounter()
"exception.invalid_index_name",
RollingCounter()
),
OBSERVABILITY_EXCEPTIONS_ILLEGAL_ARGUMENT_EXCEPTION(
"exception.illegal_argument", RollingCounter()
"exception.illegal_argument",
RollingCounter()
),
OBSERVABILITY_EXCEPTIONS_ILLEGAL_STATE_EXCEPTION(
"exception.illegal_state", RollingCounter()
"exception.illegal_state",
RollingCounter()
),
OBSERVABILITY_EXCEPTIONS_IO_EXCEPTION(
"exception.io", RollingCounter()
"exception.io",
RollingCounter()
),
OBSERVABILITY_EXCEPTIONS_INTERNAL_SERVER_ERROR(
"exception.internal_server_error", RollingCounter()
"exception.internal_server_error",
RollingCounter()
),

// ==== REST endpoint metrics ==== //
Expand Down Expand Up @@ -155,6 +160,6 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) {
*/
enum class Action {
CREATE,
UPDATE,
UPDATE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ internal data class SavedQuery(

internal data class Token(
val name: String,
val type: String,
val type: String
) : BaseModel {
internal companion object {
private const val NAME_TAG = "name"
Expand Down Expand Up @@ -291,7 +291,7 @@ internal data class SavedQuery(
*/
constructor(input: StreamInput) : this(
name = input.readString(),
type = input.readString(),
type = input.readString()
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ internal data class SavedVisualization(
val subType: String?,
val metricType: String? = null,
val unitsOfMeasure: String? = null,
val selectedLabels: SelectedLabels? = null,
val selectedLabels: SelectedLabels? = null
) : BaseObjectData {

internal companion object {
Expand Down Expand Up @@ -155,7 +155,7 @@ internal data class SavedVisualization(
subType,
metricType,
unitsOfMeasure,
selectedLabels,
selectedLabels
)
}
}
Expand Down Expand Up @@ -186,7 +186,7 @@ internal data class SavedVisualization(
subType = input.readString(),
metricType = input.readOptionalString(),
unitsOfMeasure = input.readOptionalString(),
selectedLabels = input.readOptionalWriteable(SelectedLabels.reader),
selectedLabels = input.readOptionalWriteable(SelectedLabels.reader)
)

/**
Expand Down Expand Up @@ -231,7 +231,7 @@ internal data class SavedVisualization(
}

internal data class Token(
val label: String,
val label: String
) : BaseModel {
internal companion object {
private const val LABEL_TAG = "label"
Expand Down Expand Up @@ -276,7 +276,7 @@ internal data class SavedVisualization(
* @param input StreamInput stream to deserialize data from.
*/
constructor(input: StreamInput) : this(
label = input.readString(),
label = input.readString()
)

/**
Expand All @@ -299,7 +299,7 @@ internal data class SavedVisualization(
}

internal data class SelectedLabels(
val labels: List<Token>?,
val labels: List<Token>?
) : BaseModel {
internal companion object {
private const val LABELS_TAG = "labels"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal data class Timestamp(
val name: String?,
val index: String?,
val type: String?,
val dslType: String?,
val dslType: String?
) : BaseObjectData {

internal companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,61 +283,70 @@ internal object PluginSettings {
OPERATION_TIMEOUT_MS_KEY,
defaultSettings[OPERATION_TIMEOUT_MS_KEY]!!.toLong(),
MINIMUM_OPERATION_TIMEOUT_MS,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val JOB_LOCK_DURATION_S: Setting<Int> = Setting.intSetting(
JOB_LOCK_DURATION_S_KEY,
defaultSettings[JOB_LOCK_DURATION_S_KEY]!!.toInt(),
MINIMUM_JOB_LOCK_DURATION_S,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val MIN_POLLING_DURATION_S: Setting<Int> = Setting.intSetting(
MIN_POLLING_DURATION_S_KEY,
defaultSettings[MIN_POLLING_DURATION_S_KEY]!!.toInt(),
MINIMUM_MIN_POLLING_DURATION_S,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val MAX_POLLING_DURATION_S: Setting<Int> = Setting.intSetting(
MAX_POLLING_DURATION_S_KEY,
defaultSettings[MAX_POLLING_DURATION_S_KEY]!!.toInt(),
MINIMUM_MAX_POLLING_DURATION_S,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val MAX_LOCK_RETRIES: Setting<Int> = Setting.intSetting(
MAX_LOCK_RETRIES_KEY,
defaultSettings[MAX_LOCK_RETRIES_KEY]!!.toInt(),
MINIMUM_LOCK_RETRIES,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val DEFAULT_ITEMS_QUERY_COUNT: Setting<Int> = Setting.intSetting(
DEFAULT_ITEMS_QUERY_COUNT_KEY,
defaultSettings[DEFAULT_ITEMS_QUERY_COUNT_KEY]!!.toInt(),
MINIMUM_ITEMS_QUERY_COUNT,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val ADMIN_ACCESS: Setting<String> = Setting.simpleString(
ADMIN_ACCESS_KEY,
defaultSettings[ADMIN_ACCESS_KEY]!!,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val FILTER_BY: Setting<String> = Setting.simpleString(
FILTER_BY_KEY,
defaultSettings[FILTER_BY_KEY]!!,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val IGNORED_ROLES: Setting<List<String>> = Setting.listSetting(
IGNORE_ROLE_KEY,
DEFAULT_IGNORED_ROLES,
{ it },
NodeScope, Dynamic
NodeScope,
Dynamic
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ abstract class PluginRestTestCase : OpenSearchRestTestCase() {
val response = client().performRequest(Request("GET", "/_cat/indices?format=json&expand_wildcards=all"))
val xContentType = MediaType.fromMediaType(response.entity.contentType.value)
xContentType.xContent().createParser(
NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
NamedXContentRegistry.EMPTY,
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
response.entity.content
).use { parser ->
for (index in parser.list()) {
Expand Down
2 changes: 2 additions & 0 deletions src/test/kotlin/org/opensearch/observability/TestHelpers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ fun constructNotebookRequest(name: String = "test notebook"): String {
}
""".trimIndent()
}

@Suppress("MaxLineLength")
fun constructSavedQueryRequest(name: String = "test saved query"): String {
return """
Expand Down Expand Up @@ -101,6 +102,7 @@ fun constructSavedQueryRequest(name: String = "test saved query"): String {
}
""".trimIndent()
}

@Suppress("MaxLineLength")
fun constructSavedVisualizationRequest(name: String = "test saved visualization"): String {
return """
Expand Down

0 comments on commit 58c735f

Please sign in to comment.