Skip to content

Commit

Permalink
Merge pull request #564 from rahul-tarento/course-batch-refactoring
Browse files Browse the repository at this point in the history
es sync changes for bulk insert and async read
  • Loading branch information
maheshkumargangula committed Jul 30, 2019
2 parents 7237ea1 + 536b158 commit caa7f84
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.google.common.util.concurrent.Futures;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.sunbird.common.CassandraUtil;
Expand Down Expand Up @@ -84,7 +85,7 @@ public void applyOperationOnRecordsAsync(
}
}
ResultSetFuture future = session.executeAsync(select);
Futures.addCallback(future, callback);
Futures.addCallback(future, callback, Executors.newFixedThreadPool(1));
} catch (Exception e) {
ProjectLogger.log(Constants.EXCEPTION_MSG_FETCH + table + " : " + e.getMessage(), e);
throw new ProjectCommonException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public Future<Boolean> bulkInsert(String index, List<Map<String, Object>> dataLi
BulkRequest request = new BulkRequest();
Promise<Boolean> promise = Futures.promise();
for (Map<String, Object> data : dataList) {
request.add(new IndexRequest(index, _DOC).source(data));
request.add(new IndexRequest(index, _DOC, (String) data.get(JsonKey.ID)).source(data));
}
ActionListener<BulkResponse> listener =
new ActionListener<BulkResponse>() {
Expand All @@ -559,12 +559,15 @@ public void onResponse(BulkResponse bulkResponse) {
while (responseItr.hasNext()) {

BulkItemResponse bResponse = responseItr.next();
ProjectLogger.log(
"ElasticSearchRestHighImpl:bulkinsert: api response==="
+ bResponse.getId()
+ " "
+ bResponse.isFailed(),
LoggerEnum.INFO.name());

if (bResponse.isFailed()) {
ProjectLogger.log(
"ElasticSearchRestHighImpl:bulkinsert: api response==="
+ bResponse.getId()
+ " "
+ bResponse.getFailureMessage(),
LoggerEnum.INFO.name());
}
}
}
}
Expand Down

0 comments on commit caa7f84

Please sign in to comment.