Skip to content

Commit

Permalink
Issue #LR-766 chore: upgraded the elasticsearch from 6.8.22 to 7.17.13 (
Browse files Browse the repository at this point in the history
  • Loading branch information
AmiableAnil authored Apr 12, 2024
1 parent b171376 commit b8d1c53
Show file tree
Hide file tree
Showing 30 changed files with 393 additions and 821 deletions.
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ jobs:
build:
machine:
image: ubuntu-2004:202201-02
# https://circleci.com/docs/parallelism-faster-jobs/
# parallelism: 4
# The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
resource_class: large
steps:
- checkout
- restore_cache:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class BackgroundJobManager extends BaseActor {
headerMap.put("accept", "application/json");
}

private ElasticSearchService esService = EsClientFactory.getInstance(JsonKey.REST);
private ElasticSearchService esService = EsClientFactory.getInstance();

@Override
public void onReceive(Request request) throws Throwable {
Expand All @@ -56,8 +56,7 @@ public void onReceive(Request request) throws Throwable {
insertCourseBatchInfoToEs(request);
} else if (operation.equalsIgnoreCase(ActorOperations.UPDATE_COURSE_BATCH_ES.getValue())) {
updateCourseBatchInfoToEs(request);
} else if (operation.equalsIgnoreCase(
ActorOperations.UPDATE_USR_COURSES_INFO_ELASTIC.getValue())) {
} else if (operation.equalsIgnoreCase(ActorOperations.UPDATE_USR_COURSES_INFO_ELASTIC.getValue())) {
updateUserCourseInfoToEs(request);
} else {
ProjectCommonException exception =
Expand All @@ -84,9 +83,7 @@ public static List<Map<String, Object>> removeDataFromMap(List<Map<String, Objec

@SuppressWarnings("unchecked")
private void updateUserCourseInfoToEs(Request actorMessage) {

Map<String, Object> batch =
(Map<String, Object>) actorMessage.getRequest().get(JsonKey.USER_COURSES);
Map<String, Object> batch = (Map<String, Object>) actorMessage.getRequest().get(JsonKey.USER_COURSES);
updateDataToElastic(actorMessage.getRequestContext(),
ProjectUtil.EsIndex.sunbird.getIndexName(),
ProjectUtil.EsType.usercourses.getTypeName(),
Expand All @@ -96,9 +93,7 @@ private void updateUserCourseInfoToEs(Request actorMessage) {

@SuppressWarnings("unchecked")
private void insertUserCourseInfoToEs(Request actorMessage) {

Map<String, Object> batch =
(Map<String, Object>) actorMessage.getRequest().get(JsonKey.USER_COURSES);
Map<String, Object> batch = (Map<String, Object>) actorMessage.getRequest().get(JsonKey.USER_COURSES);
String userId = (String) batch.get(JsonKey.USER_ID);
String batchId = (String) batch.get(JsonKey.BATCH_ID);
String identifier = UserCoursesService.generateUserCourseESId(batchId, userId);
Expand All @@ -112,8 +107,7 @@ private void insertUserCourseInfoToEs(Request actorMessage) {
@SuppressWarnings("unchecked")
private void updateCourseBatchInfoToEs(Request actorMessage) {
Map<String, Object> batch = (Map<String, Object>) actorMessage.getRequest().get(JsonKey.BATCH);
updateDataToElastic(
actorMessage.getRequestContext(), ProjectUtil.EsIndex.sunbird.getIndexName(),
updateDataToElastic(actorMessage.getRequestContext(), ProjectUtil.EsIndex.sunbird.getIndexName(),
ProjectUtil.EsType.courseBatch.getTypeName(),
(String) batch.get(JsonKey.ID),
batch);
Expand All @@ -125,17 +119,14 @@ private void insertCourseBatchInfoToEs(Request actorMessage) {
// making call to register tag
registertag(actorMessage.getRequestContext(),
(String) batch.getOrDefault(JsonKey.HASH_TAG_ID, batch.get(JsonKey.ID)),
"{}",
CourseBatchSchedulerUtil.headerMap);
"{}", CourseBatchSchedulerUtil.headerMap);
// register tag for course
registertag(
actorMessage.getRequestContext(), (String) batch.getOrDefault(JsonKey.COURSE_ID, batch.get(JsonKey.COURSE_ID)),
"{}",
CourseBatchSchedulerUtil.headerMap);
registertag(actorMessage.getRequestContext(),
(String) batch.getOrDefault(JsonKey.COURSE_ID, batch.get(JsonKey.COURSE_ID)),
"{}", CourseBatchSchedulerUtil.headerMap);
}

private boolean updateDataToElastic(
RequestContext requestContext, String indexName, String typeName, String identifier, Map<String, Object> data) {
private boolean updateDataToElastic(RequestContext requestContext, String indexName, String typeName, String identifier, Map<String, Object> data) {
Future<Boolean> responseF = esService.update(requestContext, typeName, identifier, data);
boolean response = (boolean) ElasticSearchHelper.getResponseFromFuture(responseF);
if (response) {
Expand All @@ -156,8 +147,7 @@ private boolean updateDataToElastic(
* @param data Map<String,Object>
* @return boolean
*/
private boolean insertDataToElastic(
RequestContext requestContext, String index, String type, String identifier, Map<String, Object> data) {
private boolean insertDataToElastic(RequestContext requestContext, String index, String type, String identifier, Map<String, Object> data) {
logger.info(requestContext, "BackgroundJobManager:insertDataToElastic: type = " + type + " identifier = " + identifier);
Future<String> responseF = esService.save(requestContext, type, identifier, data);
String response = (String) ElasticSearchHelper.getResponseFromFuture(responseF);
Expand Down
Loading

0 comments on commit b8d1c53

Please sign in to comment.