Authored by all4you

update socialUser

... ... @@ -137,12 +137,6 @@ public interface IYohoIndexService {
void buildAppended(final String yohoIndexName);
/**
* 更新变更的索引数据
* @param yohoIndexName
*/
void buildUpdated(final String yohoIndexName);
/**
* 添加索引数据
*
* @param yohoIndexName
... ...
... ... @@ -139,6 +139,7 @@ public class YohoIndexDataLoader implements ApplicationContextAware {
INDEX_REBUILD_LOG.info("loadAllData for index=[{}],with minId={},maxId={}",yohoIndexName,defaultMinId,defaultMaxId);
int minId = defaultMinId;
int maxId = minId+limit;
int tmpMaxId;
// 3、分配任务、并包装异步执行结果
List<Future<Boolean>> futureResults = new ArrayList<Future<Boolean>>();
do{
... ... @@ -158,9 +159,10 @@ public class YohoIndexDataLoader implements ApplicationContextAware {
}
});
futureResults.add(futureResult);
tmpMaxId = maxId;
minId = maxId+1;
maxId = minId+limit;
}while(maxId<=defaultMaxId);
}while(tmpMaxId<=defaultMaxId);
// 4.等待全部任务执行完成,并获取执行结果
boolean result = true;
... ... @@ -210,12 +212,14 @@ public class YohoIndexDataLoader implements ApplicationContextAware {
INDEX_REBUILD_LOG.info("loadAppendedData for index=[{}],with minId={},maxId={}",yohoIndexName,defaultMinId,defaultMaxId);
int minId = defaultMinId;
int maxId = minId+limit;
int taskMaxId;
int tmpMaxId;
do{
tmpMaxId = doLoadAppendedData(yohoIndexName, indexAppender, client, minId, limit);
minId = tmpMaxId!=0?tmpMaxId+1:maxId+1;
taskMaxId = doLoadAppendedData(yohoIndexName, indexAppender, client, minId, limit);
tmpMaxId = maxId;
minId = taskMaxId!=0?taskMaxId+1:maxId+1;
maxId = minId+limit;
}while(maxId<=defaultMaxId);
}while(tmpMaxId<=defaultMaxId);
return true;
}
... ...
... ... @@ -444,42 +444,6 @@ public class YohoIndexServiceImpl implements IYohoIndexService {
}
}
/**
* 更新变更的索引数据
* @param yohoIndexName
*/
@Override
public void buildUpdated(final String yohoIndexName) {
final IYohoIndex yohoIndex = this.getIndex(yohoIndexName);
if (yohoIndex == null) {
return;
}
if(!this.indexExists(yohoIndexName)){
INDEX_REBUILD_LOG.info("YohoIndex does not exists when buildUpdated with indexName=[{}] will call rebuild instead", yohoIndexName);
this.rebuild(yohoIndexName);
}else{
try {
long begin = System.currentTimeMillis();
INDEX_REBUILD_LOG.info("buildUpdated [{}],step=[1.buildUpdated begin], begin=[{}] ", yohoIndexName, begin);
IElasticsearchClient client = yohoIndex.getIndexClient();
final IndexUpdater indexUpdater = yohoIndex.getIndexUpdater();
// 2、更新数据
if (yohoIndexDataLoader.loadUpdatedData(yohoIndexName, indexUpdater, client)) {
INDEX_REBUILD_LOG.info("buildUpdated [{}],step=[2.loadUpdatedData success]", yohoIndexName);
}
// 3、记录耗时时间
INDEX_REBUILD_LOG.info("buildUpdated [{}],step=[3.loadUpdatedData success],cost=[{}]s", yohoIndexName, (System.currentTimeMillis()-begin)/1000);
} catch (Exception e) {
INDEX_REBUILD_LOG.error(e.getMessage(), e);
} finally {
rebuildFlagService.updateBuilding(false);
}
}
}
@Override
... ...