forked from sunbird-cb/sunbird-course-service
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 4.8.20 dev v1 (#48) * 4.8.18 dev hot fix (#41) * Added Local Cache for Storing Enrollment List Batches * Add log to confirm batch retrieval from cache * removed unused class (#42) --------- Co-authored-by: saipradeep_ravipati <[email protected]> Co-authored-by: shankaragoudab <[email protected]> * added code for reissue certificates for events * changed kafka topic --------- Co-authored-by: Karthikeyan Rajendran <[email protected]> Co-authored-by: saipradeep_ravipati <[email protected]> Co-authored-by: shankaragoudab <[email protected]> Co-authored-by: karthik-tarento <[email protected]> Co-authored-by: anilkumar <[email protected]> * added action type for event (#49) Co-authored-by: anilkumar <[email protected]> * update kafka msg for event (#50) Co-authored-by: anilkumar <[email protected]> --------- Co-authored-by: anilkumarkammalapalli <[email protected]> Co-authored-by: saipradeep_ravipati <[email protected]> Co-authored-by: shankaragoudab <[email protected]> Co-authored-by: anilkumar <[email protected]>
- Loading branch information
1 parent
12a1e83
commit 552380b
Showing
14 changed files
with
282 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
course-mw/course-actors-common/src/main/java/org/sunbird/learner/util/BatchCacheHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** */ | ||
package org.sunbird.learner.util; | ||
|
||
import org.sunbird.common.models.util.JsonKey; | ||
import org.sunbird.common.models.util.LoggerUtil; | ||
import org.sunbird.common.models.util.PropertiesCache; | ||
|
||
import java.util.Arrays; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
/** | ||
* This class will handle the data cache. | ||
* | ||
* @author Amit Kumar | ||
*/ | ||
public class BatchCacheHandler implements Runnable { | ||
|
||
private static Map<String, Object> batchMap = new ConcurrentHashMap<>(); | ||
|
||
private LoggerUtil logger = new LoggerUtil(BatchCacheHandler.class); | ||
|
||
@Override | ||
public void run() { | ||
logger.info(null, "BatchCacheHandler:run: Cache refresh started."); | ||
cache(batchMap); | ||
logger.info(null, "BatchCacheHandler:run: Cache refresh completed."); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private void cache(Map<String, Object> map) { | ||
try { | ||
Map contents = ContentUtil.getAllBatches(Integer.parseInt(PropertiesCache.getInstance() | ||
.getProperty(JsonKey.PAGE_SIZE_CONTENT_FETCH))); | ||
batchMap.putAll(contents); | ||
logger.debug(null, "content keyset " + map.keySet()); | ||
logger.info(null, " cache size: " + map.size()); | ||
} catch (Exception e) { | ||
logger.error(null, "ContentCacheHandler:cache: Exception in retrieving content section " + e.getMessage(), e); | ||
} | ||
} | ||
|
||
/** @return the contentCache */ | ||
public static Map<String, Object> getBatchMap() { | ||
return batchMap; | ||
} | ||
|
||
public static Map<String, Object> getBatch(String id) { | ||
Map<String, Object> obj = (Map<String, Object>) batchMap.get(id); | ||
if(obj != null) | ||
return obj; | ||
else{ | ||
batchMap.putAll(ContentUtil.getAllBatches(Arrays.asList(id),Integer.parseInt(PropertiesCache.getInstance() | ||
.getProperty(JsonKey.PAGE_SIZE_CONTENT_FETCH)))); | ||
return (Map<String, Object>) batchMap.get(id); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.