Authored by all4you

update

@@ -143,6 +143,16 @@ public class SocialUserIndexBuilder extends IIndexBuilder { @@ -143,6 +143,16 @@ public class SocialUserIndexBuilder extends IIndexBuilder {
143 return dataList; 143 return dataList;
144 } 144 }
145 145
  146 + /**
  147 + * 获取变更的数据总量
  148 + * @return
  149 + * @throws Exception
  150 + */
  151 + @Override
  152 + public int getUpdatedTotalCount() throws Exception{
  153 + // TODO
  154 + return 0;
  155 + }
146 156
147 /** 157 /**
148 * 获取所有变更的数据 158 * 获取所有变更的数据
@@ -150,7 +160,7 @@ public class SocialUserIndexBuilder extends IIndexBuilder { @@ -150,7 +160,7 @@ public class SocialUserIndexBuilder extends IIndexBuilder {
150 * @throws Exception 160 * @throws Exception
151 */ 161 */
152 @Override 162 @Override
153 - public List<?> getUpdatedLists() throws Exception{ 163 + public List<?> getUpdatedLists(int offset, int limit) throws Exception{
154 List<UserFollower> followers = socialUserDetailMapper.selectUserFollower(null); 164 List<UserFollower> followers = socialUserDetailMapper.selectUserFollower(null);
155 List<SocialUser> socialUsers = new ArrayList<>(); 165 List<SocialUser> socialUsers = new ArrayList<>();
156 // 合并socialUser的s_follower等属性 166 // 合并socialUser的s_follower等属性
@@ -190,26 +190,26 @@ public class YohoIndexDataLoader implements ApplicationContextAware { @@ -190,26 +190,26 @@ public class YohoIndexDataLoader implements ApplicationContextAware {
190 result = result & futureResult.get(); 190 result = result & futureResult.get();
191 } 191 }
192 192
193 - List<?> dataList = indexBuilder.getUpdatedLists();  
194 - int resultSize = dataList != null ? dataList.size() : 0;  
195 - INDEX_REBUILD_LOG.info("loadUpdatedData [yohoIndexName=[{}]],[{resultSize={}]", yohoIndexName, resultSize);  
196 - if (resultSize > 0) {  
197 - performanceMonitor.addVisitCount();  
198 - long begin = System.currentTimeMillis();  
199 - INDEX_REBUILD_LOG.debug("[addDataToEs begin][yohoIndexName=[{}]],[selectCount={}][begin={}]", yohoIndexName, dataList.size(), begin);  
200 - List<ESBluk> bluks = new ArrayList<>(dataList.size());  
201 - for(Object ob: dataList){  
202 - bluks.add(new ESBluk(JSONObject.toJSONString(ob),indexBuilder.getId(ob),yohoIndexName,yohoIndexName,false));  
203 - }  
204 - BulkResponse bulkResponse = client.bulk(bluks);  
205 - if(bulkResponse.hasFailures()){  
206 - INDEX_REBUILD_LOG.error("addIndexDataBean has fail,[yohoIndexName=[%s]],[failureMessage=%s]", yohoIndexName,bulkResponse.buildFailureMessage());  
207 - throw new Exception(String.format("addIndexDataBean has fail,[yohoIndexName=[%s]],[failureMessage=%s]", yohoIndexName,bulkResponse.buildFailureMessage()));  
208 - }  
209 - long end = System.currentTimeMillis();  
210 - INDEX_REBUILD_LOG.debug("[addDataToEs begin][yohoIndexName=[{}]],[selectCount={}][cost={}ms]", yohoIndexName, dataList.size(), end-begin);  
211 - performanceMonitor.addCost(end-begin);  
212 - } 193 +// List<?> dataList = indexBuilder.getUpdatedLists();
  194 +// int resultSize = dataList != null ? dataList.size() : 0;
  195 +// INDEX_REBUILD_LOG.info("loadUpdatedData [yohoIndexName=[{}]],[{resultSize={}]", yohoIndexName, resultSize);
  196 +// if (resultSize > 0) {
  197 +// performanceMonitor.addVisitCount();
  198 +// long begin = System.currentTimeMillis();
  199 +// INDEX_REBUILD_LOG.debug("[addDataToEs begin][yohoIndexName=[{}]],[selectCount={}][begin={}]", yohoIndexName, dataList.size(), begin);
  200 +// List<ESBluk> bluks = new ArrayList<>(dataList.size());
  201 +// for(Object ob: dataList){
  202 +// bluks.add(new ESBluk(JSONObject.toJSONString(ob),indexBuilder.getId(ob),yohoIndexName,yohoIndexName,false));
  203 +// }
  204 +// BulkResponse bulkResponse = client.bulk(bluks);
  205 +// if(bulkResponse.hasFailures()){
  206 +// INDEX_REBUILD_LOG.error("addIndexDataBean has fail,[yohoIndexName=[%s]],[failureMessage=%s]", yohoIndexName,bulkResponse.buildFailureMessage());
  207 +// throw new Exception(String.format("addIndexDataBean has fail,[yohoIndexName=[%s]],[failureMessage=%s]", yohoIndexName,bulkResponse.buildFailureMessage()));
  208 +// }
  209 +// long end = System.currentTimeMillis();
  210 +// INDEX_REBUILD_LOG.debug("[addDataToEs begin][yohoIndexName=[{}]],[selectCount={}][cost={}ms]", yohoIndexName, dataList.size(), end-begin);
  211 +// performanceMonitor.addCost(end-begin);
  212 +// }
213 return true; 213 return true;
214 } catch (Exception e) { 214 } catch (Exception e) {
215 // 如果有异常,则处理一下,并等待30s执行下一次 215 // 如果有异常,则处理一下,并等待30s执行下一次