projectmanager SyncMatchResult completed

This commit is contained in:
zhanyun 2016-08-28 10:35:54 +08:00
parent d46569f25d
commit b7782f6a64
4 changed files with 23 additions and 19 deletions

View File

@ -17,13 +17,8 @@ public interface RelativeMemoToOpenSourceProjectDao {
@Param("osp_id") int osp_id,
@Param("targetTableName") String targetTableName);
// 读取项目id对应的所有关联的帖子
@Select("select * from relative_memo_to_open_source_projects_new where osp_id=#{osp_id}")
public List<RelativeMemoToOpenSourceProject> getRelativeMemosByspId(
@Param("osp_id") int osp_id);
// 批量读取匹配结果
@Select("select * from ${targetTableName} where has_synchronized = 0 limit ${batch} ")
@Select("select * from ${targetTableName} where has_synchronized = 0 limit #{batch} ")
public List<RelativeMemoToOpenSourceProject> getMatchResultsByHassync(@Param("targetTableName") String targetTableName,
@Param("batch") int batch);
@ -34,9 +29,9 @@ public interface RelativeMemoToOpenSourceProjectDao {
@Param("ospId") int ospId);
//同步匹配结果表冗余
@Update("update ${targetTableName} set (replies_num, view_num_crawled, memo_type, has_synchronized, created_time) "
+ "values (#{rmtosp.replies_num}, #{rmtosp.view_num_crawled}, #{rmtosp.memo_type}, 1, #{rmtosp.created_time} where id = #{rmtosp.id})")
public void syncMatchResult(RelativeMemoToOpenSourceProject rmtosp);
@Update("update ${targetTableName} set replies_num = #{rmtosp.replies_num}, view_num_crawled = #{rmtosp.view_num_crawled}, "
+ "memo_type = #{rmtosp.memo_type}, has_synchronized = 1, created_time = #{rmtosp.created_time} where id = #{rmtosp.id}")
public void syncMatchResult(@Param("targetTableName") String targetTableName, @Param("rmtosp") RelativeMemoToOpenSourceProject rmtosp);
// 读取项目id对应的匹配权重较大的所有关联的帖子
@Select("select count(*) from ${targetTableName} where has_synchronized = 0")

View File

@ -13,7 +13,7 @@ public class RelativeMemo {
private String created_time;
private String updated_time;
private String url;
private int view_num_crawled;
private int view_num;
private int vote_up_num;
private int collection_num;
private String abstractText;
@ -97,11 +97,11 @@ public class RelativeMemo {
public void setUrl(String url) {
this.url = url;
}
public int getView_num_crawled() {
return view_num_crawled;
public int getView_num() {
return view_num;
}
public void setView_num_crawled(int view_num_crawled) {
this.view_num_crawled = view_num_crawled;
public void setView_num(int view_num) {
this.view_num = view_num;
}
public int getVote_up_num() {
return vote_up_num;

View File

@ -29,8 +29,17 @@ public class SyncMatchResult {
*/
public void syncMatchResult() {
while (true) {
int notSyncNum = matchResultDao.getNotSyncCount("relative_memo_to_open_source_projects_1");
if (notSyncNum < 1) {
try {
logger.info("sleeping 10s......");
Thread.sleep(10000);
} catch (InterruptedException e) {
logger.error(e);
}
}
logger.info("starting syncMatchResult......");
for (int i = 1; i < 70; i++) {
for (int i = 1; i <= 70; i++) {
String matchResultTableName = "relative_memo_to_open_source_projects_" + String.valueOf(i);
logger.info("starting sync " + matchResultTableName + "......");
List<RelativeMemoToOpenSourceProject> rmtospList = matchResultDao.getMatchResultsByHassync(matchResultTableName, 50000);
@ -41,8 +50,8 @@ public class SyncMatchResult {
rmtosp.setCreated_time(curMemo.getCreated_time());
rmtosp.setMemo_type(curMemo.getMemo_type());
rmtosp.setReplies_num(curMemo.getReplies_num());
rmtosp.setView_num_crawled(curMemo.getView_num_crawled());
matchResultDao.syncMatchResult(rmtosp);
rmtosp.setView_num_crawled(curMemo.getView_num());
matchResultDao.syncMatchResult(matchResultTableName, rmtosp);
}
}
}

View File

@ -39,9 +39,9 @@
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url"
value="jdbc:mysql://localhost:3306/ossean_production?characterEncoding=UTF-8&amp;zeroDateTimeBehavior=convertToNull&amp;autoReconnect=true" />
value="jdbc:mysql://localhost:3306/ossean_new?characterEncoding=UTF-8&amp;zeroDateTimeBehavior=convertToNull&amp;autoReconnect=true" />
<property name="username" value="root" />
<property name="password" value="1234" />
<property name="password" value="123456" />
<property name="validationQuery" value="SELECT 1" />
<property name="testOnBorrow" value="true"/>
</bean>