aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin')
-rw-r--r--ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtils.kt55
1 files changed, 30 insertions, 25 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtils.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtils.kt
index 0d4310c79..cc0681c72 100644
--- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtils.kt
+++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/utils/BlueprintMessageUtils.kt
@@ -22,31 +22,36 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.defaultToUUID
import kotlin.math.max
-class BlueprintMessageUtils {
- companion object {
- fun kafkaMetricTag(topic: String): MutableList<Tag> =
- mutableListOf(
- Tag.of(BluePrintConstants.METRIC_TAG_TOPIC, topic)
- )
-
- /**
- * get OS hostname's last 5 characters
- * Used to generate unique client ID.
- */
- fun getHostnameSuffix(): String =
- System.getenv("HOSTNAME").defaultToUUID().let {
- it.substring(max(0, it.length - 5))
- }
+object BlueprintMessageUtils {
- fun getMessageLogData(message: Any): String =
- when (message) {
- is CommonExecutionServiceData -> {
- val actionIdentifiers = message.actionIdentifiers
- val commonHeaders = message.commonHeader
- "requestID(${commonHeaders.requestId}), subrequestID(${commonHeaders.subRequestId}) " +
- "CBA(${actionIdentifiers.blueprintName}/${actionIdentifiers.blueprintVersion}/${actionIdentifiers.actionName})"
- }
- else -> "message($message)"
- }
+ fun getHostname(): String? {
+ return System.getenv("HOSTNAME")
+ }
+
+ fun kafkaMetricTag(topic: String): MutableList<Tag> =
+ mutableListOf(
+ Tag.of(BluePrintConstants.METRIC_TAG_TOPIC, topic)
+ )
+
+ /**
+ * get OS hostname's last 5 characters
+ * Used to generate unique client ID.
+ */
+ fun getHostnameSuffix(): String {
+ return getHostname().defaultToUUID().let {
+ it.substring(max(0, it.length - 5))
+ }
}
+
+ fun getMessageLogData(message: Any): String =
+ when (message) {
+ is CommonExecutionServiceData -> {
+ val actionIdentifiers = message.actionIdentifiers
+ val commonHeaders = message.commonHeader
+ "requestID(${commonHeaders.requestId}), subrequestID(${commonHeaders.subRequestId}) " +
+ "CBA(${actionIdentifiers.blueprintName}/${actionIdentifiers.blueprintVersion}/${actionIdentifiers.actionName})"
+ }
+
+ else -> "message($message)"
+ }
}