Authored by all4you

update socialUser

@@ -137,12 +137,6 @@ public interface IYohoIndexService { @@ -137,12 +137,6 @@ public interface IYohoIndexService {
137 void buildAppended(final String yohoIndexName); 137 void buildAppended(final String yohoIndexName);
138 138
139 /** 139 /**
140 - * 更新变更的索引数据  
141 - * @param yohoIndexName  
142 - */  
143 - void buildUpdated(final String yohoIndexName);  
144 -  
145 - /**  
146 * 添加索引数据 140 * 添加索引数据
147 * 141 *
148 * @param yohoIndexName 142 * @param yohoIndexName
@@ -139,6 +139,7 @@ public class YohoIndexDataLoader implements ApplicationContextAware { @@ -139,6 +139,7 @@ public class YohoIndexDataLoader implements ApplicationContextAware {
139 INDEX_REBUILD_LOG.info("loadAllData for index=[{}],with minId={},maxId={}",yohoIndexName,defaultMinId,defaultMaxId); 139 INDEX_REBUILD_LOG.info("loadAllData for index=[{}],with minId={},maxId={}",yohoIndexName,defaultMinId,defaultMaxId);
140 int minId = defaultMinId; 140 int minId = defaultMinId;
141 int maxId = minId+limit; 141 int maxId = minId+limit;
  142 + int tmpMaxId;
142 // 3、分配任务、并包装异步执行结果 143 // 3、分配任务、并包装异步执行结果
143 List<Future<Boolean>> futureResults = new ArrayList<Future<Boolean>>(); 144 List<Future<Boolean>> futureResults = new ArrayList<Future<Boolean>>();
144 do{ 145 do{
@@ -158,9 +159,10 @@ public class YohoIndexDataLoader implements ApplicationContextAware { @@ -158,9 +159,10 @@ public class YohoIndexDataLoader implements ApplicationContextAware {
158 } 159 }
159 }); 160 });
160 futureResults.add(futureResult); 161 futureResults.add(futureResult);
  162 + tmpMaxId = maxId;
161 minId = maxId+1; 163 minId = maxId+1;
162 maxId = minId+limit; 164 maxId = minId+limit;
163 - }while(maxId<=defaultMaxId); 165 + }while(tmpMaxId<=defaultMaxId);
164 166
165 // 4.等待全部任务执行完成,并获取执行结果 167 // 4.等待全部任务执行完成,并获取执行结果
166 boolean result = true; 168 boolean result = true;
@@ -210,12 +212,14 @@ public class YohoIndexDataLoader implements ApplicationContextAware { @@ -210,12 +212,14 @@ public class YohoIndexDataLoader implements ApplicationContextAware {
210 INDEX_REBUILD_LOG.info("loadAppendedData for index=[{}],with minId={},maxId={}",yohoIndexName,defaultMinId,defaultMaxId); 212 INDEX_REBUILD_LOG.info("loadAppendedData for index=[{}],with minId={},maxId={}",yohoIndexName,defaultMinId,defaultMaxId);
211 int minId = defaultMinId; 213 int minId = defaultMinId;
212 int maxId = minId+limit; 214 int maxId = minId+limit;
  215 + int taskMaxId;
213 int tmpMaxId; 216 int tmpMaxId;
214 do{ 217 do{
215 - tmpMaxId = doLoadAppendedData(yohoIndexName, indexAppender, client, minId, limit);  
216 - minId = tmpMaxId!=0?tmpMaxId+1:maxId+1; 218 + taskMaxId = doLoadAppendedData(yohoIndexName, indexAppender, client, minId, limit);
  219 + tmpMaxId = maxId;
  220 + minId = taskMaxId!=0?taskMaxId+1:maxId+1;
217 maxId = minId+limit; 221 maxId = minId+limit;
218 - }while(maxId<=defaultMaxId); 222 + }while(tmpMaxId<=defaultMaxId);
219 223
220 return true; 224 return true;
221 } 225 }
@@ -444,42 +444,6 @@ public class YohoIndexServiceImpl implements IYohoIndexService { @@ -444,42 +444,6 @@ public class YohoIndexServiceImpl implements IYohoIndexService {
444 } 444 }
445 } 445 }
446 446
447 - /**  
448 - * 更新变更的索引数据  
449 - * @param yohoIndexName  
450 - */  
451 - @Override  
452 - public void buildUpdated(final String yohoIndexName) {  
453 - final IYohoIndex yohoIndex = this.getIndex(yohoIndexName);  
454 - if (yohoIndex == null) {  
455 - return;  
456 - }  
457 - if(!this.indexExists(yohoIndexName)){  
458 - INDEX_REBUILD_LOG.info("YohoIndex does not exists when buildUpdated with indexName=[{}] will call rebuild instead", yohoIndexName);  
459 - this.rebuild(yohoIndexName);  
460 - }else{  
461 - try {  
462 - long begin = System.currentTimeMillis();  
463 - INDEX_REBUILD_LOG.info("buildUpdated [{}],step=[1.buildUpdated begin], begin=[{}] ", yohoIndexName, begin);  
464 -  
465 - IElasticsearchClient client = yohoIndex.getIndexClient();  
466 - final IndexUpdater indexUpdater = yohoIndex.getIndexUpdater();  
467 -  
468 - // 2、更新数据  
469 - if (yohoIndexDataLoader.loadUpdatedData(yohoIndexName, indexUpdater, client)) {  
470 - INDEX_REBUILD_LOG.info("buildUpdated [{}],step=[2.loadUpdatedData success]", yohoIndexName);  
471 - }  
472 -  
473 - // 3、记录耗时时间  
474 - INDEX_REBUILD_LOG.info("buildUpdated [{}],step=[3.loadUpdatedData success],cost=[{}]s", yohoIndexName, (System.currentTimeMillis()-begin)/1000);  
475 -  
476 - } catch (Exception e) {  
477 - INDEX_REBUILD_LOG.error(e.getMessage(), e);  
478 - } finally {  
479 - rebuildFlagService.updateBuilding(false);  
480 - }  
481 - }  
482 - }  
483 447
484 448
485 @Override 449 @Override