getRecentComments speeded up by reducing synchronization time at minimum
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-networking-library@130989 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
59faa6b0d5
commit
fbae17bb34
|
@ -1502,23 +1502,33 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
||||||
.executeWithCallback(new RowCallback<String, String>() {
|
.executeWithCallback(new RowCallback<String, String>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(Rows<String, String> rows) {
|
public void success(Rows<String, String> rows) {
|
||||||
synchronized (commentsByUser) {
|
|
||||||
nextRow: for (Row<String, String> row : rows) {
|
// use a temporary list for each thread
|
||||||
for(Column<String> column: row.getColumns())
|
List<Comment> partialCommentsList = new ArrayList<Comment>();
|
||||||
if(column.getName().equals("Userid")){
|
|
||||||
if(column.getStringValue().equals(userid)){
|
nextRow: for (Row<String, String> row : rows) {
|
||||||
try{
|
for(Column<String> column: row.getColumns()){
|
||||||
Comment c = readCommentById(row.getKey());
|
if(column.getName().equals("Userid")){
|
||||||
Feed f = readFeed(c.getFeedid());
|
if(column.getStringValue().equals(userid)){
|
||||||
if(c.getTime().getTime() >= timeInMillis &&
|
try{
|
||||||
(f.getType() == FeedType.TWEET || f.getType() == FeedType.SHARE || f.getType() == FeedType.PUBLISH))
|
Comment c = readCommentById(row.getKey());
|
||||||
commentsByUser.add(c);
|
Feed f = readFeed(c.getFeedid());
|
||||||
}catch(Exception e){
|
if(c.getTime().getTime() >= timeInMillis &&
|
||||||
_log.error("Unable to read comment with id" + row.getKey(), e);
|
(f.getType() == FeedType.TWEET || f.getType() == FeedType.SHARE || f.getType() == FeedType.PUBLISH))
|
||||||
}
|
partialCommentsList.add(c);
|
||||||
|
}catch(Exception e){
|
||||||
|
_log.error("Unable to read comment with id" + row.getKey(), e);
|
||||||
}
|
}
|
||||||
continue nextRow;
|
|
||||||
}
|
}
|
||||||
|
continue nextRow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if there is something to save...
|
||||||
|
if(partialCommentsList.size() > 0){
|
||||||
|
synchronized (commentsByUser){
|
||||||
|
commentsByUser.addAll(partialCommentsList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1528,12 +1538,11 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
||||||
// decrement value
|
// decrement value
|
||||||
int currentValue = maxRetryExecutions.decrementAndGet();
|
int currentValue = maxRetryExecutions.decrementAndGet();
|
||||||
if(currentValue <= 0){
|
if(currentValue <= 0){
|
||||||
_log.error("Error while fetching user's recent comments ... repeating operation");
|
|
||||||
return true;
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
_log.error("Too many errors while fetching user's comments, exiting");
|
_log.error("Too many errors while fetching user's comments, exiting");
|
||||||
return false;
|
return false;
|
||||||
|
}else{
|
||||||
|
_log.error("Error while fetching user's recent comments ... repeating operation");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue