From 370cd407f21bdf5307801eb470cbb85e1829ec34 Mon Sep 17 00:00:00 2001 From: Sreerag K S <58926794+sreeragksgh@users.noreply.github.com> Date: Thu, 16 Nov 2023 20:11:15 +0530 Subject: [PATCH] Logs to analyse hierarchy updation issue (#65) * logs to analyse hierarchy updation issue --- .../scala/org/sunbird/managers/UpdateHierarchyManager.scala | 4 +++- .../scala/org/sunbird/managers/UpdateHierarchyManager.scala | 3 +++ .../org/sunbird/graph/external/store/ExternalStore.scala | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/assessment-api/qs-hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala b/assessment-api/qs-hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala index 59cdd1810..c581232f9 100644 --- a/assessment-api/qs-hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala +++ b/assessment-api/qs-hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala @@ -2,9 +2,9 @@ package org.sunbird.managers import java.util import java.util.concurrent.CompletionException - import org.apache.commons.collections4.{CollectionUtils, MapUtils} import org.apache.commons.lang3.StringUtils +import org.slf4j.LoggerFactory import org.sunbird.common.dto.{Request, Response, ResponseHandler} import org.sunbird.common.exception.{ClientException, ErrorCodes, ResourceNotFoundException, ServerException} import org.sunbird.common.{DateUtils, JsonUtils, Platform} @@ -25,9 +25,11 @@ import scala.concurrent.{ExecutionContext, Future} object UpdateHierarchyManager { val neo4jCreateTypes: java.util.List[String] = Platform.getStringList("neo4j_objecttypes_enabled", List("Question").asJava) + val logger = LoggerFactory.getLogger("org.sunbird.managers.UpdateHierarchyManager") @throws[Exception] def updateHierarchy(request: Request)(implicit oec: OntologyEngineContext, ec: ExecutionContext): Future[Response] = { + logger.info("Question set update hierarchy request body : {}", request) val (nodesModified, hierarchy) = validateRequest(request) val rootId: String = getRootId(nodesModified, hierarchy) request.getContext.put(HierarchyConstants.ROOT_ID, rootId) diff --git a/content-api/hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala b/content-api/hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala index fbb73934a..617176c70 100644 --- a/content-api/hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala +++ b/content-api/hierarchy-manager/src/main/scala/org/sunbird/managers/UpdateHierarchyManager.scala @@ -3,6 +3,7 @@ package org.sunbird.managers import java.util.concurrent.CompletionException import org.apache.commons.collections4.{CollectionUtils, MapUtils} import org.apache.commons.lang3.StringUtils +import org.slf4j.LoggerFactory import org.sunbird.common.dto.{Request, Response, ResponseHandler} import org.sunbird.common.exception.{ClientException, ErrorCodes, ResourceNotFoundException, ResponseCode, ServerException} import org.sunbird.common.{DateUtils, JsonUtils, Platform} @@ -23,8 +24,10 @@ import scala.concurrent.{ExecutionContext, Future} object UpdateHierarchyManager { + val logger = LoggerFactory.getLogger("org.sunbird.managers.UpdateHierarchyManager") @throws[Exception] def updateHierarchy(request: Request)(implicit oec: OntologyEngineContext, ec: ExecutionContext): Future[Response] = { + logger.info("UpdateHierarchyManager.updateHierarchy = request Body is : {}", request) validateRequest(request) val nodesModified: java.util.HashMap[String, AnyRef] = request.getRequest.get(HierarchyConstants.NODES_MODIFIED).asInstanceOf[java.util.HashMap[String, AnyRef]] val hierarchy: java.util.HashMap[String, AnyRef] = request.getRequest.get(HierarchyConstants.HIERARCHY).asInstanceOf[java.util.HashMap[String, AnyRef]] diff --git a/ontology-engine/graph-core_2.11/src/main/scala/org/sunbird/graph/external/store/ExternalStore.scala b/ontology-engine/graph-core_2.11/src/main/scala/org/sunbird/graph/external/store/ExternalStore.scala index c9cb9f11e..f944c3abc 100644 --- a/ontology-engine/graph-core_2.11/src/main/scala/org/sunbird/graph/external/store/ExternalStore.scala +++ b/ontology-engine/graph-core_2.11/src/main/scala/org/sunbird/graph/external/store/ExternalStore.scala @@ -3,10 +3,10 @@ package org.sunbird.graph.external.store import java.sql.Timestamp import java.util import java.util.Date - import com.datastax.driver.core.Session import com.datastax.driver.core.querybuilder.{Clause, Insert, QueryBuilder} import com.google.common.util.concurrent.{FutureCallback, Futures, ListenableFuture, MoreExecutors} +import org.slf4j.LoggerFactory import org.sunbird.cassandra.{CassandraConnector, CassandraStore} import org.sunbird.common.JsonUtils import org.sunbird.common.dto.{Response, ResponseHandler} @@ -16,6 +16,7 @@ import org.sunbird.telemetry.logger.TelemetryManager import scala.concurrent.{ExecutionContext, Future, Promise} class ExternalStore(keySpace: String , table: String , primaryKey: java.util.List[String]) extends CassandraStore(keySpace, table, primaryKey) { + val logger = LoggerFactory.getLogger("org.sunbird.graph.external.store.ExternalStore") def insert(request: util.Map[String, AnyRef], propsMapping: Map[String, String])(implicit ec: ExecutionContext): Future[Response] = { val insertQuery: Insert = QueryBuilder.insertInto(keySpace, table) @@ -169,6 +170,8 @@ class ExternalStore(keySpace: String , table: String , primaryKey: java.util.Lis case _ => update.`with`(QueryBuilder.set(column, values(index))) } } + val updateQuery = update.toString + logger.info("Query for update hierarchy is: {}", updateQuery) try { val session: Session = CassandraConnector.getSession session.executeAsync(update).asScala.map( resultset => {