Skip to content

Commit

Permalink
Release 3.7.0 (#100)
Browse files Browse the repository at this point in the history
Merging release-3.7.0 to master
  • Loading branch information
AMIT KUMAR authored Mar 8, 2021
1 parent 95b94c8 commit 1859ea8
Show file tree
Hide file tree
Showing 45 changed files with 523 additions and 156 deletions.
7 changes: 2 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
version: 2.1
jobs:
build:
docker:
- image: circleci/openjdk:8-jdk
environment:
commit_hash: "${CIRCLE_SHA1}"
working_directory: ~/project
machine:
image: ubuntu-2004:202008-01
steps:
- checkout
- restore_cache:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:8-jre-alpine
FROM adoptopenjdk/openjdk11:alpine-slim
RUN apk update \
&& apk add unzip \
&& apk add curl \
Expand Down
17 changes: 5 additions & 12 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ node('build-slave') {
String ANSI_YELLOW = "\u001B[33m"

ansiColor('xterm') {
withEnv(["JAVA_HOME=${JAVA11_HOME}"]) {
stage('Checkout') {
if (!env.hub_org) {
println(ANSI_BOLD + ANSI_RED + "Uh Oh! Please set a Jenkins environment variable named hub_org with value as registery/sunbidrded" + ANSI_NORMAL)
Expand All @@ -15,18 +16,9 @@ node('build-slave') {
println(ANSI_BOLD + ANSI_GREEN + "Found environment variable named hub_org with value as: " + hub_org + ANSI_NORMAL)
}
cleanWs()
if (params.github_release_tag == "") {
checkout scm
commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
branch_name = sh(script: 'git name-rev --name-only HEAD | rev | cut -d "/" -f1| rev', returnStdout: true).trim()
build_tag = branch_name + "_" + commit_hash + "_" + env.BUILD_NUMBER
println(ANSI_BOLD + ANSI_YELLOW + "github_release_tag not specified, using the latest commit hash: " + commit_hash + ANSI_NORMAL)
} else {
def scmVars = checkout scm
checkout scm: [$class: 'GitSCM', branches: [[name: "refs/tags/$params.github_release_tag"]], userRemoteConfigs: [[url: scmVars.GIT_URL]]]
build_tag = params.github_release_tag + "_" + env.BUILD_NUMBER
println(ANSI_BOLD + ANSI_YELLOW + "github_release_tag specified, building from tag: " + params.github_release_tag + ANSI_NORMAL)
}
checkout scm
commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
build_tag = sh(script: "echo " + params.github_release_tag.split('/')[-1] + "_" + commit_hash + "_" + env.BUILD_NUMBER, returnStdout: true).trim()
echo "build_tag: " + build_tag

stage('Build') {
Expand All @@ -49,6 +41,7 @@ node('build-slave') {
currentBuild.description = "${build_tag}"
}
}
}
}
catch (err) {
currentBuild.result = "FAILURE"
Expand Down
29 changes: 16 additions & 13 deletions auto_build_deploy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('deploy-conf') _
@Library('deploy-conf') _
node('build-slave') {
try {
String ANSI_GREEN = "\u001B[32m"
Expand All @@ -8,6 +8,7 @@ node('build-slave') {
String ANSI_YELLOW = "\u001B[33m"

ansiColor('xterm') {
withEnv(["JAVA_HOME=${JAVA11_HOME}"]) {
stage('Checkout') {
tag_name = env.JOB_NAME.split("/")[-1]
pre_checks()
Expand All @@ -18,36 +19,38 @@ node('build-slave') {
println(ANSI_BOLD + ANSI_GREEN + "Found environment variable named hub_org with value as: " + hub_org + ANSI_NORMAL)
}
cleanWs()
checkout scm
def scmVars = checkout scm
checkout scm: [$class: 'GitSCM', branches: [[name: "refs/tags/$tag_name"]], userRemoteConfigs: [[url: scmVars.GIT_URL]]]
build_tag = tag_name + "_" + env.BUILD_NUMBER
commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
artifact_version = tag_name + "_" + commit_hash
echo "build_tag: " + build_tag


// stage Build
// stage('Build') {
env.NODE_ENV = "build"
print "Environment will be : ${env.NODE_ENV}"
sh 'git log -1'
sh 'mvn clean install -U -DskipTests=true'

// stage Package
sh 'mvn clean install -U -DskipTests=true '
//}
//stage('Package') {
dir('service') {
sh 'mvn play2:dist'
sh 'cp target/group-service-1.0.0-dist.zip ../'
sh 'cp target/group-service-1.0.0-dist.zip ../'
}
sh('chmod 777 ./build.sh')
sh("./build.sh ${build_tag} ${env.NODE_NAME} ${hub_org}")
// stage ArchiveArtifacts
// }
// stage('ArchiveArtifacts') {
archiveArtifacts "metadata.json"
currentBuild.description = "${build_tag}"
// }
}
currentBuild.result = "SUCCESS"
slack_notify(currentBuild.result, tag_name)
email_notify()
auto_build_deploy()
}
currentBuild.result = "SUCCESS"
slack_notify(currentBuild.result, tag_name)
email_notify()
auto_build_deploy()
}
catch (err) {
currentBuild.result = "FAILURE"
Expand Down
8 changes: 4 additions & 4 deletions cassandra-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<artifactId>cassandra-utils</artifactId>
<properties>
<version.compiler.plugin>2.3.1</version.compiler.plugin>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<scoverage.plugin.version>1.1.1</scoverage.plugin.version>
Expand Down Expand Up @@ -90,8 +90,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
Expand Down
38 changes: 18 additions & 20 deletions group-actors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.24.1-GA</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
Expand All @@ -107,8 +112,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
Expand All @@ -124,24 +129,17 @@
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs.plugin.version}</version>
<executions>
<execution>
<id>findbug</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<findbugsXmlOutputDirectory>
${project.build.directory}/findbugs
</findbugsXmlOutputDirectory>
<failOnError>false</failOnError>
</configuration>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs.plugin.version}</version>
<dependencies>
<!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs -->
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.2.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Expand Down
14 changes: 7 additions & 7 deletions group-actors/src/main/java/org/sunbird/actors/BaseActor.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public void onReceive(Object message) throws Throwable {
Request request = (Request) message;
String operation = request.getOperation();

if (request.getHeaders().containsKey(JsonKey.REQUEST_MESSAGE_ID)) {
if (request.getHeaders().containsKey(JsonKey.X_REQUEST_ID)) {
ArrayList<String> requestIds =
(ArrayList<String>) request.getHeaders().get(JsonKey.REQUEST_MESSAGE_ID);
trace.put(JsonKey.REQUEST_MESSAGE_ID, requestIds.get(0));
(ArrayList<String>) request.getHeaders().get(JsonKey.X_REQUEST_ID);
trace.put(JsonKey.X_REQUEST_ID, requestIds.get(0));
logger.setMDC(trace);
// set mdc for non actors
new BaseLogger().setReqId(logger.getMDC());
Expand Down Expand Up @@ -63,10 +63,10 @@ public void onReceive(Object message) throws Throwable {
*/
protected void onReceiveException(String callerName, Exception exception) throws Exception {
logger.error(
"Exception in message processing for: {} :: message: {} {}"
, callerName
, exception.getMessage(),
exception);
"Exception in message processing for: {} :: message: {} {}",
callerName,
exception.getMessage(),
exception);
sender().tell(exception, self());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void readGroup(Request actorMessage) throws Exception {
groupResponse = JsonUtils.deserialize(groupInfo, GroupResponse.class);
} else {
logger.info("read group cache is empty. Fetching details from DB for groupId - {} ", groupId);
groupResponse = groupService.readGroupWithActivities(groupId);
groupResponse = groupService.readGroupWithActivities(groupId, actorMessage.getContext());
cacheUtil.setCache(groupId, JsonUtils.serialize(groupResponse), CacheUtil.groupTtl);
}
if (CollectionUtils.isNotEmpty(requestFields) && requestFields.contains(JsonKey.MEMBERS)) {
Expand All @@ -69,7 +69,7 @@ private void readGroup(Request actorMessage) throws Exception {
logger.info(
"read group member cache is empty. Fetching details from DB for groupId - {} ",
groupId);
memberResponses = memberService.readGroupMembers(groupId);
memberResponses = memberService.readGroupMembers(groupId, actorMessage.getContext());
cacheUtil.setCache(
constructRedisIdentifier(groupId),
JsonUtils.serialize(memberResponses),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ public void onReceive(Request request) throws Throwable {
case "searchGroup":
searchGroup(request);
break;

default:
onReceiveUnsupportedMessage("SearchGroupActor");

}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.sunbird.models;

import org.sunbird.exception.BaseException;
import org.sunbird.response.Response;

public class ClientErrorResponse extends Response {

private BaseException exception = null;

public ClientErrorResponse() {}

public BaseException getException() {
return exception;
}

public void setException(BaseException exception) {
this.exception = exception;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.sunbird.models;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.sunbird.telemetry.JsonKey;

public class EntryExitLogEvent {
private String eid;

private Map<String, Object> edata = new HashMap<>();

public String getEid() {
return eid;
}

public void setEid(String eid) {
this.eid = eid;
}

public Map<String, Object> getEdata() {
return edata;
}

public void setEdata(
String type,
String level,
String requestid,
String message,
List<Map<String, Object>> params,
Map<String, Object> context) {
this.edata.put(JsonKey.TYPE, type);
this.edata.put(JsonKey.LEVEL, level);
this.edata.put(JsonKey.REQUEST_ID, requestid);
this.edata.put(JsonKey.MESSAGE, message);
this.edata.put(JsonKey.PARAMS, params);
this.edata.put(JsonKey.CONTEXT, context);
}

public void setEdataParams(List<Map<String, Object>> params) {
this.edata.put(JsonKey.PARAMS, params);
}

public void setEdataContext(Map<String, Object> context) {
this.edata.put(JsonKey.CONTEXT, context);
}

@Override
public String toString() {
return "{" + "eid='" + eid + '\'' + ", edata=" + edata + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ public interface GroupService {

Map<String, Object> readGroup(String groupId) throws BaseException;

GroupResponse readGroupWithActivities(String groupId) throws Exception;
GroupResponse readGroupWithActivities(String groupId, Map<String, Object> reqContext)
throws Exception;

void readGroupActivities(Map<String, Object> dbResGroup);
void readGroupActivities(Map<String, Object> dbResGroup, Map<String, Object> reqContext);

List<GroupResponse> searchGroup(Map<String, Object> searchFilter) throws BaseException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ public String createGroup(Group groupObj) throws BaseException {
return groupId;
}

public GroupResponse readGroupWithActivities(String groupId) throws Exception {
public GroupResponse readGroupWithActivities(String groupId, Map<String, Object> reqContext)
throws Exception {
Map<String, Object> dbResGroup = readGroup(groupId);
logger.info("readGroupActivities started");
readGroupActivities(dbResGroup);
readGroupActivities(dbResGroup, reqContext);
logger.info("readGroupActivities ended");
return JsonUtils.convert(dbResGroup, GroupResponse.class);
}
Expand Down Expand Up @@ -83,11 +84,11 @@ public Map<String, Object> readGroup(String groupId) throws BaseException {
}

@Override
public void readGroupActivities(Map<String, Object> dbResGroup) {
public void readGroupActivities(Map<String, Object> dbResGroup, Map<String, Object> reqContext) {
List<Map<String, Object>> dbResActivities =
(List<Map<String, Object>>) dbResGroup.get(JsonKey.ACTIVITIES);
if (dbResActivities != null && !dbResActivities.isEmpty()) {
addActivityInfoDetails(dbResActivities);
addActivityInfoDetails(dbResActivities, reqContext);
}
}

Expand All @@ -96,7 +97,8 @@ public void readGroupActivities(Map<String, Object> dbResGroup) {
*
* @param dbResActivities
*/
private void addActivityInfoDetails(List<Map<String, Object>> dbResActivities) {
private void addActivityInfoDetails(
List<Map<String, Object>> dbResActivities, Map<String, Object> reqContext) {
logger.info("Fetching activityInfo for activity count: {}", dbResActivities.size());
Map<SearchServiceUtil, Map<String, String>> idClassTypeMap =
GroupUtil.groupActivityIdsBySearchUtilClass(dbResActivities);
Expand All @@ -105,7 +107,7 @@ private void addActivityInfoDetails(List<Map<String, Object>> dbResActivities) {
SearchServiceUtil searchServiceUtil = itr.getKey();
List<String> fields = ActivityConfigReader.getFieldsLists(searchServiceUtil);
Map<String, Map<String, Object>> activityInfoMap =
searchServiceUtil.searchContent(itr.getValue(), fields);
searchServiceUtil.searchContent(itr.getValue(), fields, reqContext);
for (Map<String, Object> activity : dbResActivities) {
String activityKey = (String) activity.get(JsonKey.TYPE) + activity.get(JsonKey.ID);
if (activityInfoMap.containsKey(activityKey)) {
Expand Down
Loading

0 comments on commit 1859ea8

Please sign in to comment.