From c658463a70e18ad10266d7719829e604470400ab Mon Sep 17 00:00:00 2001 From: Harikumar Palemkota Date: Mon, 22 Jan 2024 12:27:28 +0530 Subject: [PATCH 1/5] Removedd unnecessary property files for better maintaince --- .../src/test/resources/application.conf | 26 ++ sb-utils/src/test/resources/application.conf | 314 ++++++++++++++++++ service/app/utils/ApplicationStart.java | 13 + .../app/utils/module/OnRequestHandler.java | 7 +- service/conf/application.conf | 48 +++ service/pom.xml | 5 + 6 files changed, 410 insertions(+), 3 deletions(-) create mode 100644 group-actors/src/test/resources/application.conf create mode 100644 sb-utils/src/test/resources/application.conf diff --git a/group-actors/src/test/resources/application.conf b/group-actors/src/test/resources/application.conf new file mode 100644 index 00000000..9d26bf62 --- /dev/null +++ b/group-actors/src/test/resources/application.conf @@ -0,0 +1,26 @@ +sunbird_sso_client_id="" +sunbird_sso_username="" +sunbird_sso_password="" +sunbird_sso_url="" +sunbird_sso_realm="" +LEARNER_SERVICE_PORT="" +sunbird_user_service_search_url=/private/api/user/v1/search +CONTENT_SERVICE_PORT="" +sunbird_cs_search_url="" +sunbird_authorization="" +sunbird_health_check_enable=true +sunbird_us_system_setting_url=/api/data/v1/system/settings/list +sunbird_us_org_read_url=/v1/org/read +enable_userid_redis_cache=true +groups_redis_ttl=86400 +user_redis_ttl=3600 +max_group_members_limit =150 +max_activity_limit=20 +max_group_limit=50 +max_batch_limit=2 +notification_service_base_url="" +notification_service_api_url=/v2/notification/send +enable_tenant_config=["custchannel","tc"] + +#Release-5.4.0 - LR-512 +sunbird_groups_keyspace=sunbird_groups \ No newline at end of file diff --git a/sb-utils/src/test/resources/application.conf b/sb-utils/src/test/resources/application.conf new file mode 100644 index 00000000..87db6662 --- /dev/null +++ b/sb-utils/src/test/resources/application.conf @@ -0,0 +1,314 @@ +# This is the main configuration file for the application. +# https://www.playframework.com/documentation/latest/ConfigFile +# ~~~~~ +# Play uses HOCON as its configuration file format. HOCON has a number +# of advantages over other config formats, but there are two things that +# can be used when modifying settings. +# +# You can include other configuration files in this main application.conf file: +#include "extra-config.conf" +# +# You can declare variables and substitute for them: +#mykey = ${some.value} +# +# And if an environment variable exists when there is no other substitution, then +# HOCON will fall back to substituting environment variable: +#mykey = ${JAVA_HOME} + +## Akka +# https://www.playframework.com/documentation/latest/ScalaAkka#Configuration +# https://www.playframework.com/documentation/latest/JavaAkka#Configuration +# ~~~~~ +# Play uses Akka internally and exposes Akka Streams and actors in Websockets and +# other streaming HTTP responses. +akka { + # "akka.log-config-on-start" is extraordinarly useful because it log the complete + # configuration at INFO level, including defaults and overrides, so it s worth + # putting at the very top. + # + # Put the following in your conf/logback.xml file: + # + # + # + # And then uncomment this line to debug the configuration. + # + #log-config-on-start = true +} + +## Secret key +# http://www.playframework.com/documentation/latest/ApplicationSecret +# ~~~~~ +# The secret key is used to sign Play's session cookie. +# This must be changed for production, but we don't recommend you change it in this file. +play.http.secret.key = a-long-secret-to-calm-the-rage-of-the-entropy-gods + +## Modules +# https://www.playframework.com/documentation/latest/Modules +# ~~~~~ +# Control which modules are loaded when Play starts. Note that modules are +# the replacement for "GlobalSettings", which are deprecated in 2.5.x. +# Please see https://www.playframework.com/documentation/latest/GlobalSettings +# for more information. +# +# You can also extend Play functionality by using one of the publically available +# Play modules: https://playframework.com/documentation/latest/ModuleDirectory +play.modules { + # By default, Play will load any class called Module that is defined + # in the root package (the "app" directory), or you can define them + # explicitly below. + # If there are any built-in modules that you want to enable, you can list them here. + #enabled += my.application.Module + + # If there are any built-in modules that you want to disable, you can list them here. + #disabled += "" + enabled += modules.SearchModule +} + +## IDE +# https://www.playframework.com/documentation/latest/IDE +# ~~~~~ +# Depending on your IDE, you can add a hyperlink for errors that will jump you +# directly to the code location in the IDE in dev mode. The following line makes +# use of the IntelliJ IDEA REST interface: +#play.editor="http://localhost:63342/api/file/?file=%s&line=%s" + +## Internationalisation +# https://www.playframework.com/documentation/latest/JavaI18N +# https://www.playframework.com/documentation/latest/ScalaI18N +# ~~~~~ +# Play comes with its own i18n settings, which allow the user's preferred language +# to map through to internal messages, or allow the language to be stored in a cookie. +play.i18n { + # The application languages + langs = [ "en" ] + + # Whether the language cookie should be secure or not + #langCookieSecure = true + + # Whether the HTTP only attribute of the cookie should be set to true + #langCookieHttpOnly = true +} + +## Play HTTP settings +# ~~~~~ +play.http { + ## Router + # https://www.playframework.com/documentation/latest/JavaRouting + # https://www.playframework.com/documentation/latest/ScalaRouting + # ~~~~~ + # Define the Router object to use for this application. + # This router will be looked up first when the application is starting up, + # so make sure this is the entry point. + # Furthermore, it's assumed your route file is named properly. + # So for an application router like `my.application.Router`, + # you may need to define a router file `conf/my.application.routes`. + # Default to Routes in the root package (aka "apps" folder) (and conf/routes) + #router = my.application.Router + + ## Action Creator + # https://www.playframework.com/documentation/latest/JavaActionCreator + # ~~~~~ + #actionCreator = null + + ## ErrorHandler + # https://www.playframework.com/documentation/latest/JavaRouting + # https://www.playframework.com/documentation/latest/ScalaRouting + # ~~~~~ + # If null, will attempt to load a class called ErrorHandler in the root package, + #errorHandler = null + + ## Session & Flash + # https://www.playframework.com/documentation/latest/JavaSessionFlash + # https://www.playframework.com/documentation/latest/ScalaSessionFlash + # ~~~~~ + session { + # Sets the cookie to be sent only over HTTPS. + #secure = true + + # Sets the cookie to be accessed only by the server. + #httpOnly = true + + # Sets the max-age field of the cookie to 5 minutes. + # NOTE: this only sets when the browser will discard the cookie. Play will consider any + # cookie value with a valid signature to be a valid session forever. To implement a server side session timeout, + # you need to put a timestamp in the session and check it at regular intervals to possibly expire it. + #maxAge = 300 + + # Sets the domain on the session cookie. + #domain = "example.com" + } + + flash { + # Sets the cookie to be sent only over HTTPS. + #secure = true + + # Sets the cookie to be accessed only by the server. + #httpOnly = true + } +} + +play.http.parser.maxDiskBuffer = 10MB +parsers.anyContent.maxLength = 10MB + +play.server.provider = play.core.server.NettyServerProvider + +## Netty Provider +# https://www.playframework.com/documentation/latest/SettingsNetty +# ~~~~~ +play.server.netty { + # Whether the Netty wire should be logged + log.wire = true + + # If you run Play on Linux, you can use Netty's native socket transport + # for higher performance with less garbage. + transport = "native" +} + +## WS (HTTP Client) +# https://www.playframework.com/documentation/latest/ScalaWS#Configuring-WS +# ~~~~~ +# The HTTP client primarily used for REST APIs. The default client can be +# configured directly, but you can also create different client instances +# with customized settings. You must enable this by adding to build.sbt: +# +# libraryDependencies += ws // or javaWs if using java +# +play.ws { + # Sets HTTP requests not to follow 302 requests + #followRedirects = false + + # Sets the maximum number of open HTTP connections for the client. + #ahc.maxConnectionsTotal = 50 + + ## WS SSL + # https://www.playframework.com/documentation/latest/WsSSL + # ~~~~~ + ssl { + # Configuring HTTPS with Play WS does not require programming. You can + # set up both trustManager and keyManager for mutual authentication, and + # turn on JSSE debugging in development with a reload. + #debug.handshake = true + #trustManager = { + # stores = [ + # { type = "JKS", path = "exampletrust.jks" } + # ] + #} + } +} + +## Cache +# https://www.playframework.com/documentation/latest/JavaCache +# https://www.playframework.com/documentation/latest/ScalaCache +# ~~~~~ +# Play comes with an integrated cache API that can reduce the operational +# overhead of repeated requests. You must enable this by adding to build.sbt: +# +# libraryDependencies += cache +# +play.cache { + # If you want to bind several caches, you can bind the individually + #bindCaches = ["db-cache", "user-cache", "session-cache"] +} + +## Filter Configuration +# https://www.playframework.com/documentation/latest/Filters +# ~~~~~ +# There are a number of built-in filters that can be enabled and configured +# to give Play greater security. +# +play.filters { + + # Enabled filters are run automatically against Play. + # CSRFFilter, AllowedHostFilters, and SecurityHeadersFilters are enabled by default. + enabled = [filters.AccessLogFilter] + + # Disabled filters remove elements from the enabled list. + # disabled += filters.CSRFFilter + + + ## CORS filter configuration + # https://www.playframework.com/documentation/latest/CorsFilter + # ~~~~~ + # CORS is a protocol that allows web applications to make requests from the browser + # across different domains. + # NOTE: You MUST apply the CORS configuration before the CSRF filter, as CSRF has + # dependencies on CORS settings. + cors { + # Filter paths by a whitelist of path prefixes + #pathPrefixes = ["/some/path", ...] + + # The allowed origins. If null, all origins are allowed. + #allowedOrigins = ["http://www.example.com"] + + # The allowed HTTP methods. If null, all methods are allowed + #allowedHttpMethods = ["GET", "POST"] + } + + ## Security headers filter configuration + # https://www.playframework.com/documentation/latest/SecurityHeaders + # ~~~~~ + # Defines security headers that prevent XSS attacks. + # If enabled, then all options are set to the below configuration by default: + headers { + # The X-Frame-Options header. If null, the header is not set. + #frameOptions = "DENY" + + # The X-XSS-Protection header. If null, the header is not set. + #xssProtection = "1; mode=block" + + # The X-Content-Type-Options header. If null, the header is not set. + #contentTypeOptions = "nosniff" + + # The X-Permitted-Cross-Domain-Policies header. If null, the header is not set. + #permittedCrossDomainPolicies = "master-only" + + # The Content-Security-Policy header. If null, the header is not set. + #contentSecurityPolicy = "default-src 'self'" + } + + ## Allowed hosts filter configuration + # https://www.playframework.com/documentation/latest/AllowedHostsFilter + # ~~~~~ + # Play provides a filter that lets you configure which hosts can access your application. + # This is useful to prevent cache poisoning attacks. + hosts { + # Allow requests to example.com, its subdomains, and localhost:9000. + #allowed = [".example.com", "localhost:9000"] + } +} + +play.http.parser.maxMemoryBuffer = 50MB +akka.http.parsing.max-content-length = 50MB + +schema.base_path="../../schemas/" + + +content.relatedBoards.properties=["channel","board","subject","medium"] + + +# Path for elasticsearch.properties file +search.config.path=/home/learning/platform/search + +# Cache-Manager Configuration +cache.type="redis" + +search.es_conn_info="localhost:9200" +search.fields.query=["name^100","title^100","lemma^100","code^100","domain","subject","description^10","keywords^100","ageGroup^10","filter^10","theme^10","genre^10","objects^25","contentType^100","language^200","teachingMode^25","skills^10","learningObjective^10","curriculum^100","gradeLevel^100","developer^100","attributions^10","identifier^100","IL_UNIQUE_ID^100","owner^50","board^100","relatedBoards^100","creator^100", "dialcodes^100","text","words","releaseNotes"] +search.fields.date=["lastUpdatedOn","createdOn","versionDate","lastSubmittedOn","lastPublishedOn"] +search.fields.mode_collection=["identifier","name","objectType","contentType","mimeType","size","childNodes","board","subject","medium","gradeLevel","appIcon", "origin", "originData"] +search.batch.size=500 +search.connection.timeout=30 + +platform-api-url="http://localhost:8080/learning-service" +language.map={"Hindi":"hi", "English":"en", "Telugu":"te", "Kannada":"ka", "Tamil":"ta", "Assamese":"as", "Bengali":"bn", "Bodo":"bo", "Gujarati":"gu", "Konkani":"ko", "Malayalam":"ml", "Marathi":"mr", "Nepali":"ne", "Odia":"or", "Punjabi":"pj", "Sanskrit":"sk"} +#Top N Config for Search Telemetry +telemetry.search.topn=5 +telemetry_env=dev +installation.id=ekstep + +# Configuration for default channel ID +channel.default="in.ekstep" +ekstepPlatformApiUserId="search-service" + + +content.tagging.property=["subject","medium"] \ No newline at end of file diff --git a/service/app/utils/ApplicationStart.java b/service/app/utils/ApplicationStart.java index b40084b0..52d31e63 100644 --- a/service/app/utils/ApplicationStart.java +++ b/service/app/utils/ApplicationStart.java @@ -5,8 +5,11 @@ import javax.inject.Singleton; import org.sunbird.Application; import org.sunbird.auth.verifier.KeyManager; +import org.sunbird.cache.util.Platform; import org.sunbird.common.exception.BaseException; +import org.sunbird.telemetry.TelemetryEnvKey; import org.sunbird.util.*; +import org.sunbird.util.helper.PropertiesCache; import play.api.Environment; import play.api.inject.ApplicationLifecycle; @@ -16,6 +19,8 @@ */ @Singleton public class ApplicationStart { + + LoggerUtil logger = new LoggerUtil(ApplicationStart.class); /** * All one time initialization which required during server startup will fall here. * @@ -37,6 +42,14 @@ public ApplicationStart(ApplicationLifecycle lifecycle, Environment environment) return CompletableFuture.completedFuture(null); }); KeyManager.init(); + logger.info("sunbird_user_service_search_url:1 "+ System.getenv("sunbird_user_service_search_url")); + logger.info("sunbird_user_service_search_url:2 "+ PropertiesCache.getInstance().getProperty("sunbird_user_service_search_url")); + logger.info("sunbird_user_service_search_url:3 "+ Platform.getString("sunbird_user_service_search_url", "")); + logger.info("sunbird_health_check_enable:1 "+ PropertiesCache.getInstance().getProperty("sunbird_health_check_enable")); + logger.info("sunbird_health_check_enable:2 "+ Platform.getBoolean("sunbird_health_check_enable", false)); + logger.info("user_redis_ttl:1 "+ PropertiesCache.getInstance().getProperty("user_redis_ttl")); + logger.info("user_redis_ttl:2 "+ Platform.getLong("user_redis_ttl", 0l)); + logger.info("groupid: "+ TelemetryEnvKey.GROUPID); } private void setEnvironment(Environment environment) { diff --git a/service/app/utils/module/OnRequestHandler.java b/service/app/utils/module/OnRequestHandler.java index c9a3b1d6..64100858 100644 --- a/service/app/utils/module/OnRequestHandler.java +++ b/service/app/utils/module/OnRequestHandler.java @@ -11,6 +11,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; +import org.sunbird.cache.util.Platform; import org.sunbird.common.exception.AuthorizationException; import org.sunbird.common.exception.BaseException; import org.sunbird.common.message.IResponseMessage; @@ -207,11 +208,11 @@ private String getCustodianOrgHashTagId() { private static Map cacheTelemetryPdata() { Map telemetryPdata = new HashMap<>(); - telemetryPdata.put("telemetry_pdata_id", PropertiesCache.getConfigValue("telemetry_pdata_id")); + telemetryPdata.put("telemetry_pdata_id", Platform.getString("telemetry_pdata_id", "")); telemetryPdata.put( - "telemetry_pdata_pid", PropertiesCache.getConfigValue("telemetry_pdata_pid")); + "telemetry_pdata_pid", Platform.getString("telemetry_pdata_pid", "")); telemetryPdata.put( - "telemetry_pdata_ver", PropertiesCache.getConfigValue("telemetry_pdata_ver")); + "telemetry_pdata_ver", Platform.getString("telemetry_pdata_ver", "")); return telemetryPdata; } diff --git a/service/conf/application.conf b/service/conf/application.conf index 9b076975..7a9fd73a 100755 --- a/service/conf/application.conf +++ b/service/conf/application.conf @@ -307,6 +307,54 @@ redis.maxConnections=${?sunbird_redis_max_connections} #Release 5.4.0 LR-512 redis.dbIndex=${?sunbird_redis_db_index} +sunbird_sso_client_id="" +sunbird_sso_username="" +sunbird_sso_password="" +sunbird_sso_url="" +sunbird_sso_realm="" +LEARNER_SERVICE_PORT="" +sunbird_user_service_search_url=/private/api/user/v1/search +CONTENT_SERVICE_PORT="" +sunbird_cs_search_url="" +sunbird_authorization="" +sunbird_health_check_enable=true +sunbird_us_system_setting_url=/api/data/v1/system/settings/list +sunbird_us_org_read_url=/v1/org/read +enable_userid_redis_cache=true +groups_redis_ttl=86400 +user_redis_ttl=3600 +max_group_members_limit =150 +max_activity_limit=20 +max_group_limit=50 +max_batch_limit=2 +notification_service_base_url="" +notification_service_api_url=/v2/notification/send +enable_tenant_config=["custchannel","tc"] + +#Release-5.4.0 - LR-512 +sunbird_groups_keyspace=sunbird_groups + +#telemetry.config.properties +telemetry_pdata_id=dev.sunbird.groups.service +telemetry_pdata_pid=groups-service +telemetry_pdata_ver=5.0.0 + +#cassandra.config.properties +coreConnectionsPerHostForLocal=4 +coreConnectionsPerHostForRemote=2 +maxConnectionsPerHostForLocal=10 +maxConnectionsPerHostForRemote=4 +maxRequestsPerConnection=32768 +heartbeatIntervalSeconds=60 +poolTimeoutMillis=0 +contactPoint=127.0.0.1 +port=9042 +userName=cassandra +password=password +queryLoggerConstantThreshold=300 +keyspace=sunbird +isMultiDCEnabled=true + ## WS (HTTP Client) # ~~~~~ diff --git a/service/pom.xml b/service/pom.xml index 8b11d887..0923872d 100755 --- a/service/pom.xml +++ b/service/pom.xml @@ -96,6 +96,11 @@ config 1.3.0 + + org.sunbird + platform-cache + ${project.version} + com.github.danielwegener logback-kafka-appender From fd80a747568304582caa2107ffa65f89e9731983 Mon Sep 17 00:00:00 2001 From: Harikumar Palemkota Date: Mon, 22 Jan 2024 12:55:56 +0530 Subject: [PATCH 2/5] Removedd unnecessary property files for better maintaince-1 --- cassandra-utils/pom.xml | 5 + .../CassandraConnectionManagerImpl.java | 20 +- .../resources/cassandra.config.properties | 14 - .../resources/cassandra.config.properties | 14 +- .../src/main/resources/dbconfig.properties | 5 - .../org/sunbird/actors/EmbeddedCassandra.java | 3 +- .../src/test/resources/application.conf | 24 -- sb-utils/pom.xml | 6 + .../resources/cassandra.config.properties | 14 - .../src/main/resources/dbconfig.properties | 5 - .../resources/externalresource.properties | 26 -- sb-utils/src/main/resources/sso.properties | 4 - .../resources/telemetry.config.properties | 4 +- .../org/sunbird/util/ProjectUtilTest.java | 7 +- sb-utils/src/test/resources/application.conf | 340 ++---------------- 15 files changed, 56 insertions(+), 435 deletions(-) diff --git a/cassandra-utils/pom.xml b/cassandra-utils/pom.xml index 0f82ab5d..ad6d653c 100644 --- a/cassandra-utils/pom.xml +++ b/cassandra-utils/pom.xml @@ -78,6 +78,11 @@ sb-utils ${project.version} + + org.sunbird + platform-cache + ${project.version} + diff --git a/cassandra-utils/src/main/java/org/sunbird/helper/CassandraConnectionManagerImpl.java b/cassandra-utils/src/main/java/org/sunbird/helper/CassandraConnectionManagerImpl.java index f3e9ba5a..4ea2fe03 100644 --- a/cassandra-utils/src/main/java/org/sunbird/helper/CassandraConnectionManagerImpl.java +++ b/cassandra-utils/src/main/java/org/sunbird/helper/CassandraConnectionManagerImpl.java @@ -16,6 +16,7 @@ import org.sunbird.common.message.IResponseMessage; import org.sunbird.common.message.ResponseCode; import org.sunbird.util.helper.PropertiesCache; +import org.sunbird.cache.util.Platform; public class CassandraConnectionManagerImpl implements CassandraConnectionManager { private static Cluster cluster; @@ -45,30 +46,31 @@ public Session getSession(String keyspace) { private void createCassandraConnection(String[] hosts) throws BaseException { try { - PropertiesCache cache = PropertiesCache.getInstance(); + /*PropertiesCache cache = PropertiesCache.getInstance();*/ + //PropertiesCache cache = PropertiesCache.getInstance(); PoolingOptions poolingOptions = new PoolingOptions(); poolingOptions.setCoreConnectionsPerHost( HostDistance.LOCAL, - Integer.parseInt(cache.getProperty(Constants.CORE_CONNECTIONS_PER_HOST_FOR_LOCAL))); + Platform.getInteger(Constants.CORE_CONNECTIONS_PER_HOST_FOR_LOCAL, 0)); poolingOptions.setMaxConnectionsPerHost( HostDistance.LOCAL, - Integer.parseInt(cache.getProperty(Constants.MAX_CONNECTIONS_PER_HOST_FOR_LOCAl))); + Platform.getInteger(Constants.CORE_CONNECTIONS_PER_HOST_FOR_LOCAL, 0)); poolingOptions.setCoreConnectionsPerHost( HostDistance.REMOTE, - Integer.parseInt(cache.getProperty(Constants.CORE_CONNECTIONS_PER_HOST_FOR_REMOTE))); + Platform.getInteger(Constants.MAX_CONNECTIONS_PER_HOST_FOR_REMOTE, 0)); poolingOptions.setMaxConnectionsPerHost( HostDistance.REMOTE, - Integer.parseInt(cache.getProperty(Constants.MAX_CONNECTIONS_PER_HOST_FOR_REMOTE))); + Platform.getInteger(Constants.MAX_CONNECTIONS_PER_HOST_FOR_REMOTE, 0)); poolingOptions.setMaxRequestsPerConnection( HostDistance.LOCAL, - Integer.parseInt(cache.getProperty(Constants.MAX_REQUEST_PER_CONNECTION))); + Platform.getInteger(Constants.MAX_REQUEST_PER_CONNECTION, 0)); poolingOptions.setHeartbeatIntervalSeconds( - Integer.parseInt(cache.getProperty(Constants.HEARTBEAT_INTERVAL))); + Platform.getInteger(Constants.HEARTBEAT_INTERVAL, 0)); poolingOptions.setPoolTimeoutMillis( - Integer.parseInt(cache.getProperty(Constants.POOL_TIMEOUT))); + Platform.getInteger(Constants.POOL_TIMEOUT, 0)); //check for multi DC enabled or not from configuration file and send the value - cluster = createCluster(hosts, poolingOptions, Boolean.parseBoolean(cache.getProperty(Constants.IS_MULTI_DC_ENABLED))); + cluster = createCluster(hosts, poolingOptions,Platform.getBoolean(Constants.IS_MULTI_DC_ENABLED, false)); final Metadata metadata = cluster.getMetadata(); String msg = String.format("Connected to cluster: %s", metadata.getClusterName()); diff --git a/cassandra-utils/src/main/resources/cassandra.config.properties b/cassandra-utils/src/main/resources/cassandra.config.properties index d6641ac8..e69de29b 100644 --- a/cassandra-utils/src/main/resources/cassandra.config.properties +++ b/cassandra-utils/src/main/resources/cassandra.config.properties @@ -1,14 +0,0 @@ -coreConnectionsPerHostForLocal=4 -coreConnectionsPerHostForRemote=2 -maxConnectionsPerHostForLocal=10 -maxConnectionsPerHostForRemote=4 -maxRequestsPerConnection=32768 -heartbeatIntervalSeconds=60 -poolTimeoutMillis=0 -contactPoint=127.0.0.1 -port=9042 -userName=cassandra -password=password -queryLoggerConstantThreshold=300 -keyspace=sunbird -isMultiDCEnabled=true \ No newline at end of file diff --git a/group-actors/src/main/resources/cassandra.config.properties b/group-actors/src/main/resources/cassandra.config.properties index e2fdff87..8b137891 100644 --- a/group-actors/src/main/resources/cassandra.config.properties +++ b/group-actors/src/main/resources/cassandra.config.properties @@ -1,13 +1 @@ -coreConnectionsPerHostForLocal=4 -coreConnectionsPerHostForRemote=2 -maxConnectionsPerHostForLocal=10 -maxConnectionsPerHostForRemote=4 -maxRequestsPerConnection=32768 -heartbeatIntervalSeconds=60 -poolTimeoutMillis=0 -contactPoint=127.0.0.1 -port=9042 -userName=cassandra -password=password -queryLoggerConstantThreshold=300 -keyspace=sunbird \ No newline at end of file + diff --git a/group-actors/src/main/resources/dbconfig.properties b/group-actors/src/main/resources/dbconfig.properties index a89505eb..e69de29b 100644 --- a/group-actors/src/main/resources/dbconfig.properties +++ b/group-actors/src/main/resources/dbconfig.properties @@ -1,5 +0,0 @@ -db.ip=127.0.0.1 -db.port=9042 -db.username=cassandra -db.password=password -db.keyspace=sunbird \ No newline at end of file diff --git a/group-actors/src/test/java/org/sunbird/actors/EmbeddedCassandra.java b/group-actors/src/test/java/org/sunbird/actors/EmbeddedCassandra.java index d24db593..e232de67 100644 --- a/group-actors/src/test/java/org/sunbird/actors/EmbeddedCassandra.java +++ b/group-actors/src/test/java/org/sunbird/actors/EmbeddedCassandra.java @@ -10,12 +10,13 @@ import org.cassandraunit.dataset.cql.ClassPathCQLDataSet; import org.cassandraunit.dataset.cql.FileCQLDataSet; import org.cassandraunit.utils.EmbeddedCassandraServerHelper; +import org.sunbird.cache.util.Platform; import org.sunbird.common.util.JsonKey; import org.sunbird.util.ProjectUtil; public class EmbeddedCassandra { - static final String KEYSPACE = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_GROUPS_KEYSPACE); + static final String KEYSPACE = Platform.getString(JsonKey.SUNBIRD_GROUPS_KEYSPACE, ""); static final String GROUP_TABLE = "group"; static final String MEMBER_TABLE = "group_member"; static final String USER_GROUP = "user_group"; diff --git a/group-actors/src/test/resources/application.conf b/group-actors/src/test/resources/application.conf index 9d26bf62..090f9921 100644 --- a/group-actors/src/test/resources/application.conf +++ b/group-actors/src/test/resources/application.conf @@ -1,26 +1,2 @@ -sunbird_sso_client_id="" -sunbird_sso_username="" -sunbird_sso_password="" -sunbird_sso_url="" -sunbird_sso_realm="" -LEARNER_SERVICE_PORT="" -sunbird_user_service_search_url=/private/api/user/v1/search -CONTENT_SERVICE_PORT="" -sunbird_cs_search_url="" -sunbird_authorization="" -sunbird_health_check_enable=true -sunbird_us_system_setting_url=/api/data/v1/system/settings/list -sunbird_us_org_read_url=/v1/org/read -enable_userid_redis_cache=true -groups_redis_ttl=86400 -user_redis_ttl=3600 -max_group_members_limit =150 -max_activity_limit=20 -max_group_limit=50 -max_batch_limit=2 -notification_service_base_url="" -notification_service_api_url=/v2/notification/send -enable_tenant_config=["custchannel","tc"] - #Release-5.4.0 - LR-512 sunbird_groups_keyspace=sunbird_groups \ No newline at end of file diff --git a/sb-utils/pom.xml b/sb-utils/pom.xml index bbd0498c..4b744b86 100644 --- a/sb-utils/pom.xml +++ b/sb-utils/pom.xml @@ -114,6 +114,12 @@ + + org.sunbird + platform-cache + 1.0.0 + test + diff --git a/sb-utils/src/main/resources/cassandra.config.properties b/sb-utils/src/main/resources/cassandra.config.properties index d6641ac8..e69de29b 100644 --- a/sb-utils/src/main/resources/cassandra.config.properties +++ b/sb-utils/src/main/resources/cassandra.config.properties @@ -1,14 +0,0 @@ -coreConnectionsPerHostForLocal=4 -coreConnectionsPerHostForRemote=2 -maxConnectionsPerHostForLocal=10 -maxConnectionsPerHostForRemote=4 -maxRequestsPerConnection=32768 -heartbeatIntervalSeconds=60 -poolTimeoutMillis=0 -contactPoint=127.0.0.1 -port=9042 -userName=cassandra -password=password -queryLoggerConstantThreshold=300 -keyspace=sunbird -isMultiDCEnabled=true \ No newline at end of file diff --git a/sb-utils/src/main/resources/dbconfig.properties b/sb-utils/src/main/resources/dbconfig.properties index a89505eb..e69de29b 100644 --- a/sb-utils/src/main/resources/dbconfig.properties +++ b/sb-utils/src/main/resources/dbconfig.properties @@ -1,5 +0,0 @@ -db.ip=127.0.0.1 -db.port=9042 -db.username=cassandra -db.password=password -db.keyspace=sunbird \ No newline at end of file diff --git a/sb-utils/src/main/resources/externalresource.properties b/sb-utils/src/main/resources/externalresource.properties index 6133d390..e69de29b 100644 --- a/sb-utils/src/main/resources/externalresource.properties +++ b/sb-utils/src/main/resources/externalresource.properties @@ -1,26 +0,0 @@ -sunbird_sso_client_id= -sunbird_sso_username= -sunbird_sso_password= -sunbird_sso_url= -sunbird_sso_realm= -LEARNER_SERVICE_PORT= -sunbird_user_service_search_url=/private/api/user/v1/search -CONTENT_SERVICE_PORT= -sunbird_cs_search_url= -sunbird_authorization= -sunbird_health_check_enable=true -sunbird_us_system_setting_url=/api/data/v1/system/settings/list -sunbird_us_org_read_url=/v1/org/read -enable_userid_redis_cache=true -groups_redis_ttl=86400 -user_redis_ttl=3600 -max_group_members_limit =150 -max_activity_limit=20 -max_group_limit=50 -max_batch_limit=2 -notification_service_base_url= -notification_service_api_url=/v2/notification/send -enable_tenant_config=custchannel,tc - -#Release-5.4.0 - LR-512 -sunbird_groups_keyspace=sunbird_groups \ No newline at end of file diff --git a/sb-utils/src/main/resources/sso.properties b/sb-utils/src/main/resources/sso.properties index ce3a6507..e69de29b 100644 --- a/sb-utils/src/main/resources/sso.properties +++ b/sb-utils/src/main/resources/sso.properties @@ -1,4 +0,0 @@ -sso.url= -sso.realm=sunbird -sso.connection.pool.size=20 -sso.enabled=true diff --git a/sb-utils/src/main/resources/telemetry.config.properties b/sb-utils/src/main/resources/telemetry.config.properties index 0af9f6c3..139597f9 100644 --- a/sb-utils/src/main/resources/telemetry.config.properties +++ b/sb-utils/src/main/resources/telemetry.config.properties @@ -1,4 +1,2 @@ -telemetry_pdata_id=dev.sunbird.groups.service -telemetry_pdata_pid=groups-service -telemetry_pdata_ver=5.0.0 + diff --git a/sb-utils/src/test/java/org/sunbird/util/ProjectUtilTest.java b/sb-utils/src/test/java/org/sunbird/util/ProjectUtilTest.java index 6d49b1d7..72cb0ae2 100644 --- a/sb-utils/src/test/java/org/sunbird/util/ProjectUtilTest.java +++ b/sb-utils/src/test/java/org/sunbird/util/ProjectUtilTest.java @@ -3,19 +3,20 @@ import static org.junit.Assert.*; import org.junit.Test; +import org.sunbird.cache.util.Platform; import org.sunbird.common.util.JsonKey; public class ProjectUtilTest { @Test public void testGetConfigValueWithExistsInPropertyFile() { - String exists = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_HEALTH_CHECK_ENABLE); + String exists = Platform.getBoolean(JsonKey.SUNBIRD_HEALTH_CHECK_ENABLE, false).toString(); assertEquals("true", exists); } @Test public void testGetConfigValueWithNotExistsInPropertyFile() { - String exists = ProjectUtil.getConfigValue("sunbird_health_check_not_enable"); - assertNull(exists); + Boolean exists = Platform.getBoolean("sunbird_health_check_not_enable", false); + assertFalse(exists); } } diff --git a/sb-utils/src/test/resources/application.conf b/sb-utils/src/test/resources/application.conf index 87db6662..9d26bf62 100644 --- a/sb-utils/src/test/resources/application.conf +++ b/sb-utils/src/test/resources/application.conf @@ -1,314 +1,26 @@ -# This is the main configuration file for the application. -# https://www.playframework.com/documentation/latest/ConfigFile -# ~~~~~ -# Play uses HOCON as its configuration file format. HOCON has a number -# of advantages over other config formats, but there are two things that -# can be used when modifying settings. -# -# You can include other configuration files in this main application.conf file: -#include "extra-config.conf" -# -# You can declare variables and substitute for them: -#mykey = ${some.value} -# -# And if an environment variable exists when there is no other substitution, then -# HOCON will fall back to substituting environment variable: -#mykey = ${JAVA_HOME} - -## Akka -# https://www.playframework.com/documentation/latest/ScalaAkka#Configuration -# https://www.playframework.com/documentation/latest/JavaAkka#Configuration -# ~~~~~ -# Play uses Akka internally and exposes Akka Streams and actors in Websockets and -# other streaming HTTP responses. -akka { - # "akka.log-config-on-start" is extraordinarly useful because it log the complete - # configuration at INFO level, including defaults and overrides, so it s worth - # putting at the very top. - # - # Put the following in your conf/logback.xml file: - # - # - # - # And then uncomment this line to debug the configuration. - # - #log-config-on-start = true -} - -## Secret key -# http://www.playframework.com/documentation/latest/ApplicationSecret -# ~~~~~ -# The secret key is used to sign Play's session cookie. -# This must be changed for production, but we don't recommend you change it in this file. -play.http.secret.key = a-long-secret-to-calm-the-rage-of-the-entropy-gods - -## Modules -# https://www.playframework.com/documentation/latest/Modules -# ~~~~~ -# Control which modules are loaded when Play starts. Note that modules are -# the replacement for "GlobalSettings", which are deprecated in 2.5.x. -# Please see https://www.playframework.com/documentation/latest/GlobalSettings -# for more information. -# -# You can also extend Play functionality by using one of the publically available -# Play modules: https://playframework.com/documentation/latest/ModuleDirectory -play.modules { - # By default, Play will load any class called Module that is defined - # in the root package (the "app" directory), or you can define them - # explicitly below. - # If there are any built-in modules that you want to enable, you can list them here. - #enabled += my.application.Module - - # If there are any built-in modules that you want to disable, you can list them here. - #disabled += "" - enabled += modules.SearchModule -} - -## IDE -# https://www.playframework.com/documentation/latest/IDE -# ~~~~~ -# Depending on your IDE, you can add a hyperlink for errors that will jump you -# directly to the code location in the IDE in dev mode. The following line makes -# use of the IntelliJ IDEA REST interface: -#play.editor="http://localhost:63342/api/file/?file=%s&line=%s" - -## Internationalisation -# https://www.playframework.com/documentation/latest/JavaI18N -# https://www.playframework.com/documentation/latest/ScalaI18N -# ~~~~~ -# Play comes with its own i18n settings, which allow the user's preferred language -# to map through to internal messages, or allow the language to be stored in a cookie. -play.i18n { - # The application languages - langs = [ "en" ] - - # Whether the language cookie should be secure or not - #langCookieSecure = true - - # Whether the HTTP only attribute of the cookie should be set to true - #langCookieHttpOnly = true -} - -## Play HTTP settings -# ~~~~~ -play.http { - ## Router - # https://www.playframework.com/documentation/latest/JavaRouting - # https://www.playframework.com/documentation/latest/ScalaRouting - # ~~~~~ - # Define the Router object to use for this application. - # This router will be looked up first when the application is starting up, - # so make sure this is the entry point. - # Furthermore, it's assumed your route file is named properly. - # So for an application router like `my.application.Router`, - # you may need to define a router file `conf/my.application.routes`. - # Default to Routes in the root package (aka "apps" folder) (and conf/routes) - #router = my.application.Router - - ## Action Creator - # https://www.playframework.com/documentation/latest/JavaActionCreator - # ~~~~~ - #actionCreator = null - - ## ErrorHandler - # https://www.playframework.com/documentation/latest/JavaRouting - # https://www.playframework.com/documentation/latest/ScalaRouting - # ~~~~~ - # If null, will attempt to load a class called ErrorHandler in the root package, - #errorHandler = null - - ## Session & Flash - # https://www.playframework.com/documentation/latest/JavaSessionFlash - # https://www.playframework.com/documentation/latest/ScalaSessionFlash - # ~~~~~ - session { - # Sets the cookie to be sent only over HTTPS. - #secure = true - - # Sets the cookie to be accessed only by the server. - #httpOnly = true - - # Sets the max-age field of the cookie to 5 minutes. - # NOTE: this only sets when the browser will discard the cookie. Play will consider any - # cookie value with a valid signature to be a valid session forever. To implement a server side session timeout, - # you need to put a timestamp in the session and check it at regular intervals to possibly expire it. - #maxAge = 300 - - # Sets the domain on the session cookie. - #domain = "example.com" - } - - flash { - # Sets the cookie to be sent only over HTTPS. - #secure = true - - # Sets the cookie to be accessed only by the server. - #httpOnly = true - } -} - -play.http.parser.maxDiskBuffer = 10MB -parsers.anyContent.maxLength = 10MB - -play.server.provider = play.core.server.NettyServerProvider - -## Netty Provider -# https://www.playframework.com/documentation/latest/SettingsNetty -# ~~~~~ -play.server.netty { - # Whether the Netty wire should be logged - log.wire = true - - # If you run Play on Linux, you can use Netty's native socket transport - # for higher performance with less garbage. - transport = "native" -} - -## WS (HTTP Client) -# https://www.playframework.com/documentation/latest/ScalaWS#Configuring-WS -# ~~~~~ -# The HTTP client primarily used for REST APIs. The default client can be -# configured directly, but you can also create different client instances -# with customized settings. You must enable this by adding to build.sbt: -# -# libraryDependencies += ws // or javaWs if using java -# -play.ws { - # Sets HTTP requests not to follow 302 requests - #followRedirects = false - - # Sets the maximum number of open HTTP connections for the client. - #ahc.maxConnectionsTotal = 50 - - ## WS SSL - # https://www.playframework.com/documentation/latest/WsSSL - # ~~~~~ - ssl { - # Configuring HTTPS with Play WS does not require programming. You can - # set up both trustManager and keyManager for mutual authentication, and - # turn on JSSE debugging in development with a reload. - #debug.handshake = true - #trustManager = { - # stores = [ - # { type = "JKS", path = "exampletrust.jks" } - # ] - #} - } -} - -## Cache -# https://www.playframework.com/documentation/latest/JavaCache -# https://www.playframework.com/documentation/latest/ScalaCache -# ~~~~~ -# Play comes with an integrated cache API that can reduce the operational -# overhead of repeated requests. You must enable this by adding to build.sbt: -# -# libraryDependencies += cache -# -play.cache { - # If you want to bind several caches, you can bind the individually - #bindCaches = ["db-cache", "user-cache", "session-cache"] -} - -## Filter Configuration -# https://www.playframework.com/documentation/latest/Filters -# ~~~~~ -# There are a number of built-in filters that can be enabled and configured -# to give Play greater security. -# -play.filters { - - # Enabled filters are run automatically against Play. - # CSRFFilter, AllowedHostFilters, and SecurityHeadersFilters are enabled by default. - enabled = [filters.AccessLogFilter] - - # Disabled filters remove elements from the enabled list. - # disabled += filters.CSRFFilter - - - ## CORS filter configuration - # https://www.playframework.com/documentation/latest/CorsFilter - # ~~~~~ - # CORS is a protocol that allows web applications to make requests from the browser - # across different domains. - # NOTE: You MUST apply the CORS configuration before the CSRF filter, as CSRF has - # dependencies on CORS settings. - cors { - # Filter paths by a whitelist of path prefixes - #pathPrefixes = ["/some/path", ...] - - # The allowed origins. If null, all origins are allowed. - #allowedOrigins = ["http://www.example.com"] - - # The allowed HTTP methods. If null, all methods are allowed - #allowedHttpMethods = ["GET", "POST"] - } - - ## Security headers filter configuration - # https://www.playframework.com/documentation/latest/SecurityHeaders - # ~~~~~ - # Defines security headers that prevent XSS attacks. - # If enabled, then all options are set to the below configuration by default: - headers { - # The X-Frame-Options header. If null, the header is not set. - #frameOptions = "DENY" - - # The X-XSS-Protection header. If null, the header is not set. - #xssProtection = "1; mode=block" - - # The X-Content-Type-Options header. If null, the header is not set. - #contentTypeOptions = "nosniff" - - # The X-Permitted-Cross-Domain-Policies header. If null, the header is not set. - #permittedCrossDomainPolicies = "master-only" - - # The Content-Security-Policy header. If null, the header is not set. - #contentSecurityPolicy = "default-src 'self'" - } - - ## Allowed hosts filter configuration - # https://www.playframework.com/documentation/latest/AllowedHostsFilter - # ~~~~~ - # Play provides a filter that lets you configure which hosts can access your application. - # This is useful to prevent cache poisoning attacks. - hosts { - # Allow requests to example.com, its subdomains, and localhost:9000. - #allowed = [".example.com", "localhost:9000"] - } -} - -play.http.parser.maxMemoryBuffer = 50MB -akka.http.parsing.max-content-length = 50MB - -schema.base_path="../../schemas/" - - -content.relatedBoards.properties=["channel","board","subject","medium"] - - -# Path for elasticsearch.properties file -search.config.path=/home/learning/platform/search - -# Cache-Manager Configuration -cache.type="redis" - -search.es_conn_info="localhost:9200" -search.fields.query=["name^100","title^100","lemma^100","code^100","domain","subject","description^10","keywords^100","ageGroup^10","filter^10","theme^10","genre^10","objects^25","contentType^100","language^200","teachingMode^25","skills^10","learningObjective^10","curriculum^100","gradeLevel^100","developer^100","attributions^10","identifier^100","IL_UNIQUE_ID^100","owner^50","board^100","relatedBoards^100","creator^100", "dialcodes^100","text","words","releaseNotes"] -search.fields.date=["lastUpdatedOn","createdOn","versionDate","lastSubmittedOn","lastPublishedOn"] -search.fields.mode_collection=["identifier","name","objectType","contentType","mimeType","size","childNodes","board","subject","medium","gradeLevel","appIcon", "origin", "originData"] -search.batch.size=500 -search.connection.timeout=30 - -platform-api-url="http://localhost:8080/learning-service" -language.map={"Hindi":"hi", "English":"en", "Telugu":"te", "Kannada":"ka", "Tamil":"ta", "Assamese":"as", "Bengali":"bn", "Bodo":"bo", "Gujarati":"gu", "Konkani":"ko", "Malayalam":"ml", "Marathi":"mr", "Nepali":"ne", "Odia":"or", "Punjabi":"pj", "Sanskrit":"sk"} -#Top N Config for Search Telemetry -telemetry.search.topn=5 -telemetry_env=dev -installation.id=ekstep - -# Configuration for default channel ID -channel.default="in.ekstep" -ekstepPlatformApiUserId="search-service" - - -content.tagging.property=["subject","medium"] \ No newline at end of file +sunbird_sso_client_id="" +sunbird_sso_username="" +sunbird_sso_password="" +sunbird_sso_url="" +sunbird_sso_realm="" +LEARNER_SERVICE_PORT="" +sunbird_user_service_search_url=/private/api/user/v1/search +CONTENT_SERVICE_PORT="" +sunbird_cs_search_url="" +sunbird_authorization="" +sunbird_health_check_enable=true +sunbird_us_system_setting_url=/api/data/v1/system/settings/list +sunbird_us_org_read_url=/v1/org/read +enable_userid_redis_cache=true +groups_redis_ttl=86400 +user_redis_ttl=3600 +max_group_members_limit =150 +max_activity_limit=20 +max_group_limit=50 +max_batch_limit=2 +notification_service_base_url="" +notification_service_api_url=/v2/notification/send +enable_tenant_config=["custchannel","tc"] + +#Release-5.4.0 - LR-512 +sunbird_groups_keyspace=sunbird_groups \ No newline at end of file From 3a966e289f36616c3b83dcaee956546180e1fc29 Mon Sep 17 00:00:00 2001 From: Harikumar Palemkota Date: Thu, 28 Mar 2024 12:10:10 +0530 Subject: [PATCH 3/5] Removed un-necessary property files for better maintaince-2 --- .../sunbird/helper/CassandraConnectionManagerImpl.java | 7 +++++-- .../main/java/org/sunbird/actors/CreateGroupActor.java | 5 +++-- .../main/java/org/sunbird/actors/DeleteGroupActor.java | 6 +++--- .../main/java/org/sunbird/actors/SearchGroupActor.java | 8 +++++--- .../main/java/org/sunbird/actors/UpdateGroupActor.java | 7 +++---- .../org/sunbird/actors/UpdateGroupMembershipActor.java | 6 +++--- service/conf/application.conf | 2 +- 7 files changed, 23 insertions(+), 18 deletions(-) diff --git a/cassandra-utils/src/main/java/org/sunbird/helper/CassandraConnectionManagerImpl.java b/cassandra-utils/src/main/java/org/sunbird/helper/CassandraConnectionManagerImpl.java index 4ea2fe03..01fbd268 100644 --- a/cassandra-utils/src/main/java/org/sunbird/helper/CassandraConnectionManagerImpl.java +++ b/cassandra-utils/src/main/java/org/sunbird/helper/CassandraConnectionManagerImpl.java @@ -70,6 +70,9 @@ private void createCassandraConnection(String[] hosts) throws BaseException { Platform.getInteger(Constants.POOL_TIMEOUT, 0)); //check for multi DC enabled or not from configuration file and send the value + boolean isMultiDCEnabled = Platform.config.hasPath(Constants.IS_MULTI_DC_ENABLED); + logger.info( + "CassandraConnectionManagerImpl:createCassandraConnection: isMultiDCEnabled = " + isMultiDCEnabled); cluster = createCluster(hosts, poolingOptions,Platform.getBoolean(Constants.IS_MULTI_DC_ENABLED, false)); final Metadata metadata = cluster.getMetadata(); @@ -84,7 +87,7 @@ private void createCassandraConnection(String[] hosts) throws BaseException { logger.info(msg); } } catch (Exception e) { - logger.info("Error occured while creating cassandra connection :", e); + logger.error("Error occured while creating cassandra connection :", e); throw new BaseException( IResponseMessage.INTERNAL_ERROR, e.getMessage(), ResponseCode.SERVER_ERROR.getCode()); } @@ -164,7 +167,7 @@ public void run() { cluster.close(); logger.info("completed resource cleanup Cassandra."); } catch (Exception ex) { - logger.info("Error :", ex); + logger.error("Error :", ex); } } } diff --git a/group-actors/src/main/java/org/sunbird/actors/CreateGroupActor.java b/group-actors/src/main/java/org/sunbird/actors/CreateGroupActor.java index 51d93460..a9cf2b68 100644 --- a/group-actors/src/main/java/org/sunbird/actors/CreateGroupActor.java +++ b/group-actors/src/main/java/org/sunbird/actors/CreateGroupActor.java @@ -9,6 +9,7 @@ import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.sunbird.actor.core.ActorConfig; +import org.sunbird.cache.util.Platform; import org.sunbird.common.exception.AuthorizationException; import org.sunbird.common.exception.BaseException; import org.sunbird.common.message.ResponseCode; @@ -92,8 +93,8 @@ private void createGroup(Request actorMessage) throws BaseException { if (CollectionUtils.isNotEmpty(memberList)) { logger.info(actorMessage.getContext(), MessageFormat.format("Adding members to the group: {0} started", groupId)); boolean isUseridRedisEnabled = - Boolean.parseBoolean( - PropertiesCache.getInstance().getConfigValue(JsonKey.ENABLE_USERID_REDIS_CACHE)); + Platform.getBoolean(JsonKey.ENABLE_USERID_REDIS_CACHE, false); + logger.info(actorMessage.getContext(),"createGroup ENABLE_USERID_REDIS_CACHE value: "+ isUseridRedisEnabled); if (isUseridRedisEnabled) { // Remove group list user cache from redis cacheUtil.deleteCacheSync(userId,actorMessage.getContext()); diff --git a/group-actors/src/main/java/org/sunbird/actors/DeleteGroupActor.java b/group-actors/src/main/java/org/sunbird/actors/DeleteGroupActor.java index 54240716..bd70f6af 100644 --- a/group-actors/src/main/java/org/sunbird/actors/DeleteGroupActor.java +++ b/group-actors/src/main/java/org/sunbird/actors/DeleteGroupActor.java @@ -6,6 +6,7 @@ import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.sunbird.actor.core.ActorConfig; +import org.sunbird.cache.util.Platform; import org.sunbird.common.exception.AuthorizationException; import org.sunbird.common.exception.BaseException; import org.sunbird.common.message.ResponseCode; @@ -20,7 +21,6 @@ import org.sunbird.service.MemberServiceImpl; import org.sunbird.util.*; import org.sunbird.common.util.JsonKey; -import org.sunbird.util.helper.PropertiesCache; @ActorConfig( tasks = {"deleteGroup"}, @@ -76,8 +76,8 @@ private void deleteGroup(Request actorMessage) throws BaseException { Response response = groupService.deleteGroup(groupId, membersInDB, actorMessage.getContext()); // delete cache for the group and all members belong to the group boolean isUseridRedisEnabled = - Boolean.parseBoolean( - PropertiesCache.getInstance().getConfigValue(JsonKey.ENABLE_USERID_REDIS_CACHE)); + Platform.getBoolean(JsonKey.ENABLE_USERID_REDIS_CACHE, false); + logger.info(actorMessage.getContext(),"deleteGroup ENABLE_USERID_REDIS_CACHE value: "+ isUseridRedisEnabled); if (isUseridRedisEnabled) { cacheUtil.deleteCacheSync(groupId, actorMessage.getContext()); cacheUtil.delCache(groupId + "_" + JsonKey.MEMBERS); diff --git a/group-actors/src/main/java/org/sunbird/actors/SearchGroupActor.java b/group-actors/src/main/java/org/sunbird/actors/SearchGroupActor.java index eddbe35f..c3ff341c 100644 --- a/group-actors/src/main/java/org/sunbird/actors/SearchGroupActor.java +++ b/group-actors/src/main/java/org/sunbird/actors/SearchGroupActor.java @@ -10,6 +10,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.sunbird.actor.core.ActorConfig; +import org.sunbird.cache.util.Platform; import org.sunbird.common.exception.BaseException; import org.sunbird.common.message.ResponseCode; import org.sunbird.models.GroupResponse; @@ -52,9 +53,7 @@ public void onReceive(Request request) throws Throwable { * @param request */ private void searchGroup(Request request) throws BaseException { - boolean isUseridRedisEnabled = - Boolean.parseBoolean( - PropertiesCache.getInstance().getConfigValue(JsonKey.ENABLE_USERID_REDIS_CACHE)); + CacheUtil cacheUtil = new CacheUtil(); GroupService groupService = new GroupServiceImpl(); Map searchQueryMap = request.getRequest(); @@ -66,6 +65,9 @@ private void searchGroup(Request request) throws BaseException { try { if (StringUtils.isNotBlank(userId)) { boolean getFromDB = true; + boolean isUseridRedisEnabled = + Platform.getBoolean(JsonKey.ENABLE_USERID_REDIS_CACHE, false); + logger.info(request.getContext(),"searchGroup ENABLE_USERID_REDIS_CACHE value: "+ isUseridRedisEnabled); if (isUseridRedisEnabled) { String groupList = cacheUtil.getCache(userId,request.getContext()); if (StringUtils.isNotEmpty(groupList)) { diff --git a/group-actors/src/main/java/org/sunbird/actors/UpdateGroupActor.java b/group-actors/src/main/java/org/sunbird/actors/UpdateGroupActor.java index f736cf8b..c986e560 100644 --- a/group-actors/src/main/java/org/sunbird/actors/UpdateGroupActor.java +++ b/group-actors/src/main/java/org/sunbird/actors/UpdateGroupActor.java @@ -9,6 +9,7 @@ import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.sunbird.actor.core.ActorConfig; +import org.sunbird.cache.util.Platform; import org.sunbird.common.exception.AuthorizationException; import org.sunbird.common.exception.BaseException; import org.sunbird.common.exception.ValidationException; @@ -25,7 +26,6 @@ import org.sunbird.service.MemberServiceImpl; import org.sunbird.util.*; import org.sunbird.common.util.JsonKey; -import org.sunbird.util.helper.PropertiesCache; @ActorConfig( tasks = {"updateGroup"}, @@ -136,10 +136,9 @@ private void updateGroup(Request actorMessage) throws BaseException { } } - boolean isUseridRedisEnabled = - Boolean.parseBoolean( - PropertiesCache.getInstance().getConfigValue(JsonKey.ENABLE_USERID_REDIS_CACHE)); + Platform.getBoolean(JsonKey.ENABLE_USERID_REDIS_CACHE, false); + logger.info(actorMessage.getContext(),"updateGroup ENABLE_USERID_REDIS_CACHE value: "+ isUseridRedisEnabled); if (isUseridRedisEnabled) { cacheUtil.deleteCacheSync(userId,actorMessage.getContext()); // Remove group list user cache from redis diff --git a/group-actors/src/main/java/org/sunbird/actors/UpdateGroupMembershipActor.java b/group-actors/src/main/java/org/sunbird/actors/UpdateGroupMembershipActor.java index 94515460..f6dcdc0f 100644 --- a/group-actors/src/main/java/org/sunbird/actors/UpdateGroupMembershipActor.java +++ b/group-actors/src/main/java/org/sunbird/actors/UpdateGroupMembershipActor.java @@ -9,6 +9,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.sunbird.actor.core.ActorConfig; +import org.sunbird.cache.util.Platform; import org.sunbird.common.exception.AuthorizationException; import org.sunbird.common.exception.BaseException; import org.sunbird.common.exception.ValidationException; @@ -20,7 +21,6 @@ import org.sunbird.service.MemberServiceImpl; import org.sunbird.util.*; import org.sunbird.common.util.JsonKey; -import org.sunbird.util.helper.PropertiesCache; @ActorConfig( tasks = {"updateGroupMembership"}, @@ -68,8 +68,8 @@ private void updateGroupMembership(Request actorMessage) { response = memberService.editMembers(members,actorMessage.getContext(), userId); } boolean isUseridRedisEnabled = - Boolean.parseBoolean( - PropertiesCache.getInstance().getConfigValue(JsonKey.ENABLE_USERID_REDIS_CACHE)); + Platform.getBoolean(JsonKey.ENABLE_USERID_REDIS_CACHE, false); + logger.info(actorMessage.getContext(),"updateGroupMembership ENABLE_USERID_REDIS_CACHE value: "+ isUseridRedisEnabled); if (isUseridRedisEnabled) { // Remove updated groups from cache groups.forEach( diff --git a/service/conf/application.conf b/service/conf/application.conf index 7a9fd73a..08a29ace 100755 --- a/service/conf/application.conf +++ b/service/conf/application.conf @@ -353,7 +353,7 @@ userName=cassandra password=password queryLoggerConstantThreshold=300 keyspace=sunbird -isMultiDCEnabled=true +isMultiDCEnabled = true ## WS (HTTP Client) From 9304169db775cbd195f2713c80409a86038b2852 Mon Sep 17 00:00:00 2001 From: Harikumar Palemkota Date: Thu, 28 Mar 2024 14:47:11 +0530 Subject: [PATCH 4/5] Removed un-necessary property files for better maintaince-3 --- .../org/sunbird/helper/CassandraConnectionManagerImpl.java | 5 +---- service/conf/application.conf | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cassandra-utils/src/main/java/org/sunbird/helper/CassandraConnectionManagerImpl.java b/cassandra-utils/src/main/java/org/sunbird/helper/CassandraConnectionManagerImpl.java index 01fbd268..97e9fda1 100644 --- a/cassandra-utils/src/main/java/org/sunbird/helper/CassandraConnectionManagerImpl.java +++ b/cassandra-utils/src/main/java/org/sunbird/helper/CassandraConnectionManagerImpl.java @@ -70,10 +70,7 @@ private void createCassandraConnection(String[] hosts) throws BaseException { Platform.getInteger(Constants.POOL_TIMEOUT, 0)); //check for multi DC enabled or not from configuration file and send the value - boolean isMultiDCEnabled = Platform.config.hasPath(Constants.IS_MULTI_DC_ENABLED); - logger.info( - "CassandraConnectionManagerImpl:createCassandraConnection: isMultiDCEnabled = " + isMultiDCEnabled); - cluster = createCluster(hosts, poolingOptions,Platform.getBoolean(Constants.IS_MULTI_DC_ENABLED, false)); + cluster = createCluster(hosts, poolingOptions, Platform.config.getBoolean(Constants.IS_MULTI_DC_ENABLED)); final Metadata metadata = cluster.getMetadata(); String msg = String.format("Connected to cluster: %s", metadata.getClusterName()); diff --git a/service/conf/application.conf b/service/conf/application.conf index 08a29ace..a5814fcf 100755 --- a/service/conf/application.conf +++ b/service/conf/application.conf @@ -337,7 +337,7 @@ sunbird_groups_keyspace=sunbird_groups #telemetry.config.properties telemetry_pdata_id=dev.sunbird.groups.service telemetry_pdata_pid=groups-service -telemetry_pdata_ver=5.0.0 +telemetry_pdata_ver=8.0.0 #cassandra.config.properties coreConnectionsPerHostForLocal=4 From df37a7380d70824d41ea9d46edbee088a42972d8 Mon Sep 17 00:00:00 2001 From: Harikumar Palemkota Date: Thu, 28 Mar 2024 16:32:40 +0530 Subject: [PATCH 5/5] Removed un-necessary property files for better maintaince-4 --- .../src/main/java/org/sunbird/actors/CreateGroupActor.java | 2 +- .../src/main/java/org/sunbird/actors/DeleteGroupActor.java | 2 +- .../src/main/java/org/sunbird/actors/SearchGroupActor.java | 2 +- .../src/main/java/org/sunbird/actors/UpdateGroupActor.java | 2 +- .../java/org/sunbird/actors/UpdateGroupMembershipActor.java | 2 +- sb-utils/src/test/java/org/sunbird/util/ProjectUtilTest.java | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/group-actors/src/main/java/org/sunbird/actors/CreateGroupActor.java b/group-actors/src/main/java/org/sunbird/actors/CreateGroupActor.java index a9cf2b68..31c02f83 100644 --- a/group-actors/src/main/java/org/sunbird/actors/CreateGroupActor.java +++ b/group-actors/src/main/java/org/sunbird/actors/CreateGroupActor.java @@ -93,7 +93,7 @@ private void createGroup(Request actorMessage) throws BaseException { if (CollectionUtils.isNotEmpty(memberList)) { logger.info(actorMessage.getContext(), MessageFormat.format("Adding members to the group: {0} started", groupId)); boolean isUseridRedisEnabled = - Platform.getBoolean(JsonKey.ENABLE_USERID_REDIS_CACHE, false); + Platform.config.getBoolean(JsonKey.ENABLE_USERID_REDIS_CACHE); logger.info(actorMessage.getContext(),"createGroup ENABLE_USERID_REDIS_CACHE value: "+ isUseridRedisEnabled); if (isUseridRedisEnabled) { // Remove group list user cache from redis diff --git a/group-actors/src/main/java/org/sunbird/actors/DeleteGroupActor.java b/group-actors/src/main/java/org/sunbird/actors/DeleteGroupActor.java index bd70f6af..af894692 100644 --- a/group-actors/src/main/java/org/sunbird/actors/DeleteGroupActor.java +++ b/group-actors/src/main/java/org/sunbird/actors/DeleteGroupActor.java @@ -76,7 +76,7 @@ private void deleteGroup(Request actorMessage) throws BaseException { Response response = groupService.deleteGroup(groupId, membersInDB, actorMessage.getContext()); // delete cache for the group and all members belong to the group boolean isUseridRedisEnabled = - Platform.getBoolean(JsonKey.ENABLE_USERID_REDIS_CACHE, false); + Platform.config.getBoolean(JsonKey.ENABLE_USERID_REDIS_CACHE); logger.info(actorMessage.getContext(),"deleteGroup ENABLE_USERID_REDIS_CACHE value: "+ isUseridRedisEnabled); if (isUseridRedisEnabled) { cacheUtil.deleteCacheSync(groupId, actorMessage.getContext()); diff --git a/group-actors/src/main/java/org/sunbird/actors/SearchGroupActor.java b/group-actors/src/main/java/org/sunbird/actors/SearchGroupActor.java index c3ff341c..9e5ab418 100644 --- a/group-actors/src/main/java/org/sunbird/actors/SearchGroupActor.java +++ b/group-actors/src/main/java/org/sunbird/actors/SearchGroupActor.java @@ -66,7 +66,7 @@ private void searchGroup(Request request) throws BaseException { if (StringUtils.isNotBlank(userId)) { boolean getFromDB = true; boolean isUseridRedisEnabled = - Platform.getBoolean(JsonKey.ENABLE_USERID_REDIS_CACHE, false); + Platform.config.getBoolean(JsonKey.ENABLE_USERID_REDIS_CACHE); logger.info(request.getContext(),"searchGroup ENABLE_USERID_REDIS_CACHE value: "+ isUseridRedisEnabled); if (isUseridRedisEnabled) { String groupList = cacheUtil.getCache(userId,request.getContext()); diff --git a/group-actors/src/main/java/org/sunbird/actors/UpdateGroupActor.java b/group-actors/src/main/java/org/sunbird/actors/UpdateGroupActor.java index c986e560..20d34e45 100644 --- a/group-actors/src/main/java/org/sunbird/actors/UpdateGroupActor.java +++ b/group-actors/src/main/java/org/sunbird/actors/UpdateGroupActor.java @@ -137,7 +137,7 @@ private void updateGroup(Request actorMessage) throws BaseException { } boolean isUseridRedisEnabled = - Platform.getBoolean(JsonKey.ENABLE_USERID_REDIS_CACHE, false); + Platform.config.getBoolean(JsonKey.ENABLE_USERID_REDIS_CACHE); logger.info(actorMessage.getContext(),"updateGroup ENABLE_USERID_REDIS_CACHE value: "+ isUseridRedisEnabled); if (isUseridRedisEnabled) { cacheUtil.deleteCacheSync(userId,actorMessage.getContext()); diff --git a/group-actors/src/main/java/org/sunbird/actors/UpdateGroupMembershipActor.java b/group-actors/src/main/java/org/sunbird/actors/UpdateGroupMembershipActor.java index f6dcdc0f..4841f7b1 100644 --- a/group-actors/src/main/java/org/sunbird/actors/UpdateGroupMembershipActor.java +++ b/group-actors/src/main/java/org/sunbird/actors/UpdateGroupMembershipActor.java @@ -68,7 +68,7 @@ private void updateGroupMembership(Request actorMessage) { response = memberService.editMembers(members,actorMessage.getContext(), userId); } boolean isUseridRedisEnabled = - Platform.getBoolean(JsonKey.ENABLE_USERID_REDIS_CACHE, false); + Platform.config.getBoolean(JsonKey.ENABLE_USERID_REDIS_CACHE); logger.info(actorMessage.getContext(),"updateGroupMembership ENABLE_USERID_REDIS_CACHE value: "+ isUseridRedisEnabled); if (isUseridRedisEnabled) { // Remove updated groups from cache diff --git a/sb-utils/src/test/java/org/sunbird/util/ProjectUtilTest.java b/sb-utils/src/test/java/org/sunbird/util/ProjectUtilTest.java index 72cb0ae2..aff046e8 100644 --- a/sb-utils/src/test/java/org/sunbird/util/ProjectUtilTest.java +++ b/sb-utils/src/test/java/org/sunbird/util/ProjectUtilTest.java @@ -10,13 +10,13 @@ public class ProjectUtilTest { @Test public void testGetConfigValueWithExistsInPropertyFile() { - String exists = Platform.getBoolean(JsonKey.SUNBIRD_HEALTH_CHECK_ENABLE, false).toString(); + String exists = String.valueOf(Platform.config.getBoolean(JsonKey.SUNBIRD_HEALTH_CHECK_ENABLE)); assertEquals("true", exists); } @Test public void testGetConfigValueWithNotExistsInPropertyFile() { - Boolean exists = Platform.getBoolean("sunbird_health_check_not_enable", false); + Boolean exists = Platform.config.getBoolean("sunbird_health_check_not_enable"); assertFalse(exists); } }