Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed unnecessary property files for better maintaince #181

Open
wants to merge 8 commits into
base: release-8.0.0
Choose a base branch
from
5 changes: 5 additions & 0 deletions cassandra-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
<artifactId>sb-utils</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.sunbird</groupId>
<artifactId>platform-cache</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.config.getBoolean(Constants.IS_MULTI_DC_ENABLED));

final Metadata metadata = cluster.getMetadata();
String msg = String.format("Connected to cluster: %s", metadata.getClusterName());
Expand All @@ -82,7 +84,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());
}
Expand Down Expand Up @@ -162,7 +164,7 @@ public void run() {
cluster.close();
logger.info("completed resource cleanup Cassandra.");
} catch (Exception ex) {
logger.info("Error :", ex);
logger.error("Error :", ex);
}
}
}
Expand Down
14 changes: 0 additions & 14 deletions cassandra-utils/src/main/resources/cassandra.config.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.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
cacheUtil.deleteCacheSync(userId,actorMessage.getContext());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"},
Expand Down Expand Up @@ -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.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());
cacheUtil.delCache(groupId + "_" + JsonKey.MEMBERS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, Object> searchQueryMap = request.getRequest();
Expand All @@ -66,6 +65,9 @@ private void searchGroup(Request request) throws BaseException {
try {
if (StringUtils.isNotBlank(userId)) {
boolean getFromDB = true;
boolean isUseridRedisEnabled =
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());
if (StringUtils.isNotEmpty(groupList)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"},
Expand Down Expand Up @@ -136,10 +136,9 @@ private void updateGroup(Request actorMessage) throws BaseException {
}
}


boolean isUseridRedisEnabled =
Boolean.parseBoolean(
PropertiesCache.getInstance().getConfigValue(JsonKey.ENABLE_USERID_REDIS_CACHE));
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());
// Remove group list user cache from redis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"},
Expand Down Expand Up @@ -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.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
groups.forEach(
Expand Down
14 changes: 1 addition & 13 deletions group-actors/src/main/resources/cassandra.config.properties
Original file line number Diff line number Diff line change
@@ -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

5 changes: 0 additions & 5 deletions group-actors/src/main/resources/dbconfig.properties
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
db.ip=127.0.0.1
db.port=9042
db.username=cassandra
db.password=password
db.keyspace=sunbird
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 2 additions & 0 deletions group-actors/src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Release-5.4.0 - LR-512
sunbird_groups_keyspace=sunbird_groups
6 changes: 6 additions & 0 deletions sb-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.sunbird</groupId>
<artifactId>platform-cache</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
14 changes: 0 additions & 14 deletions sb-utils/src/main/resources/cassandra.config.properties
Original file line number Diff line number Diff line change
@@ -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
5 changes: 0 additions & 5 deletions sb-utils/src/main/resources/dbconfig.properties
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
db.ip=127.0.0.1
db.port=9042
db.username=cassandra
db.password=password
db.keyspace=sunbird
26 changes: 0 additions & 26 deletions sb-utils/src/main/resources/externalresource.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 0 additions & 4 deletions sb-utils/src/main/resources/sso.properties
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
sso.url=
sso.realm=sunbird
sso.connection.pool.size=20
sso.enabled=true
4 changes: 0 additions & 4 deletions sb-utils/src/main/resources/telemetry.config.properties
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
telemetry_pdata_id=dev.sunbird.groups.service
telemetry_pdata_pid=groups-service
telemetry_pdata_ver=8.0.0

7 changes: 4 additions & 3 deletions sb-utils/src/test/java/org/sunbird/util/ProjectUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 = String.valueOf(Platform.config.getBoolean(JsonKey.SUNBIRD_HEALTH_CHECK_ENABLE));
assertEquals("true", exists);
}

@Test
public void testGetConfigValueWithNotExistsInPropertyFile() {
String exists = ProjectUtil.getConfigValue("sunbird_health_check_not_enable");
assertNull(exists);
Boolean exists = Platform.config.getBoolean("sunbird_health_check_not_enable");
assertFalse(exists);
}
}
26 changes: 26 additions & 0 deletions sb-utils/src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -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
Loading