From 0745b085c461497a8ac5c78ab317c1b2d7565c8f Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 13 Oct 2023 15:14:49 +0200 Subject: [PATCH 1/3] refactor/set default api_instance_id to UUID --- .../src/main/resources/props/sample.props.template | 7 +++++-- .../src/main/scala/code/api/constant/constant.scala | 12 ++++++++---- release_notes.md | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/obp-api/src/main/resources/props/sample.props.template b/obp-api/src/main/resources/props/sample.props.template index 5d186d7e05..0bdb302d80 100644 --- a/obp-api/src/main/resources/props/sample.props.template +++ b/obp-api/src/main/resources/props/sample.props.template @@ -123,9 +123,12 @@ long_endpoint_timeout = 55000 #This is the api instance, we create kafka topic based on this number, each instance should have each own id. use it in load balancing + Kafka setup #This is also used for scheduler. -#OBP will concatenate the UUID string with the value. If we set the value to end with "final", obp will retain that value. +#OBP set the default as the non persistent UUID string . +#api_instance_id=7uy8a7e4-6d02-40e3-a129-0b2bf89de8uh +#if set value, OBP will concatenate the UUID string with the value. #api_instance_id=1 -api_instance_id=1_final +# when set the value to end with "final", obp will retain that value. +#api_instance_id=1_final ## DEPRECATED ## Enable user authentication via kafka diff --git a/obp-api/src/main/scala/code/api/constant/constant.scala b/obp-api/src/main/scala/code/api/constant/constant.scala index 0ace75e43b..4ee54c4a83 100644 --- a/obp-api/src/main/scala/code/api/constant/constant.scala +++ b/obp-api/src/main/scala/code/api/constant/constant.scala @@ -23,11 +23,15 @@ object Constant extends MdcLoggable { final val HostName = APIUtil.getPropsValue("hostname").openOrThrowException(ErrorMessages.HostnameNotSpecified) final val ApiInstanceId = { - val apiInstanceIdFromProps = APIUtil.getPropsValue("api_instance_id").openOrThrowException(ErrorMessages.ApiInstanceIdNotSpecified) - if(apiInstanceIdFromProps.endsWith("final")){ - apiInstanceIdFromProps + val apiInstanceIdFromProps = APIUtil.getPropsValue("api_instance_id") + if(apiInstanceIdFromProps.isDefined){ + if(apiInstanceIdFromProps.head.endsWith("final")){ + apiInstanceIdFromProps.head + }else{ + s"${apiInstanceIdFromProps.head}_${APIUtil.generateUUID()}" + } }else{ - s"${apiInstanceIdFromProps}_${APIUtil.generateUUID()}" + APIUtil.generateUUID() } } diff --git a/release_notes.md b/release_notes.md index ed8d397c7f..22e9d423d8 100644 --- a/release_notes.md +++ b/release_notes.md @@ -122,7 +122,7 @@ Date Commit Action 1. accountaccess_backup_2019_05_17_11_16_32_134 2. viewdefinition_backup_2019_05_17_11_16_31_862 29/04/2019 a6b58a1 Added Props system_environment_property_name_prefix, default is OBP_. This adds the prefix only for the system environment property name, eg: db.driver --> OBP_db.driver -07/07/2018 4944572 Added Props api_instance_id, default is 1. This deceides the current api instance number, start from 1. +07/07/2018 4944572 Added Props api_instance_id, default is non persistence UUID 7uy8a7e4-6d02-40e3-a129-0b2bf89de8uh. 29/06/2018 7422894 Added Props logging.database.queries.enable, default is false. This should enable logging all the database queries in log file. 01/06/2018 a286684 Added Props write_connector_metrics, default is false. This decides whether the connector level metric save or not 29/05/2018 c0d50b5 Added Props kafka.partitions, default is 3. This should match the partitions in Kafka config From fcecbd176511f8af4dfd22f1bfb0c15593817d1d Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 13 Oct 2023 15:16:36 +0200 Subject: [PATCH 2/3] refactor/set default api_instance_id to UUID-tweak test.default.props.template --- obp-api/src/main/resources/props/test.default.props.template | 3 --- 1 file changed, 3 deletions(-) diff --git a/obp-api/src/main/resources/props/test.default.props.template b/obp-api/src/main/resources/props/test.default.props.template index 44550f1a55..8f5102df60 100644 --- a/obp-api/src/main/resources/props/test.default.props.template +++ b/obp-api/src/main/resources/props/test.default.props.template @@ -15,9 +15,6 @@ ### if logger.logfile is defined #logger.logfile="obp-api.log" -#This is the api instance -api_instance_id=1_final - #which data connector to use #connector=rest From 957f6c5b72cdb45a0ea92d98e32a324d2a71134e Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 13 Oct 2023 15:21:55 +0200 Subject: [PATCH 3/3] refactor/set default api_instance_id to UUID - tweak the docs --- obp-api/src/main/resources/props/sample.props.template | 8 ++++---- release_notes.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/obp-api/src/main/resources/props/sample.props.template b/obp-api/src/main/resources/props/sample.props.template index 0bdb302d80..492f3d9932 100644 --- a/obp-api/src/main/resources/props/sample.props.template +++ b/obp-api/src/main/resources/props/sample.props.template @@ -123,11 +123,11 @@ long_endpoint_timeout = 55000 #This is the api instance, we create kafka topic based on this number, each instance should have each own id. use it in load balancing + Kafka setup #This is also used for scheduler. -#OBP set the default as the non persistent UUID string . -#api_instance_id=7uy8a7e4-6d02-40e3-a129-0b2bf89de8uh -#if set value, OBP will concatenate the UUID string with the value. +#OBP set the default as the non-persistent UUID string. +#api_instance_id=7uy8a7e4-6d02-40e3-a129-0b2bf89de8uh +#If a value is set, OBP will concatenate the UUID string with the value. #api_instance_id=1 -# when set the value to end with "final", obp will retain that value. +#When the value is set to conclude with "final," OBP will preserve that value. #api_instance_id=1_final ## DEPRECATED diff --git a/release_notes.md b/release_notes.md index 22e9d423d8..efcd1f5f1e 100644 --- a/release_notes.md +++ b/release_notes.md @@ -122,7 +122,7 @@ Date Commit Action 1. accountaccess_backup_2019_05_17_11_16_32_134 2. viewdefinition_backup_2019_05_17_11_16_31_862 29/04/2019 a6b58a1 Added Props system_environment_property_name_prefix, default is OBP_. This adds the prefix only for the system environment property name, eg: db.driver --> OBP_db.driver -07/07/2018 4944572 Added Props api_instance_id, default is non persistence UUID 7uy8a7e4-6d02-40e3-a129-0b2bf89de8uh. +07/07/2018 4944572 Added Props api_instance_id, default is non-persistent UUID 7uy8a7e4-6d02-40e3-a129-0b2bf89de8uh. 29/06/2018 7422894 Added Props logging.database.queries.enable, default is false. This should enable logging all the database queries in log file. 01/06/2018 a286684 Added Props write_connector_metrics, default is false. This decides whether the connector level metric save or not 29/05/2018 c0d50b5 Added Props kafka.partitions, default is 3. This should match the partitions in Kafka config