|
|
package com.yohomars.search.job;
|
|
|
|
|
|
import com.yohomars.search.index.service.IYohoIndexService;
|
|
|
import com.yohomars.search.queue.RunnableQueueFactory;
|
|
|
import com.yohomars.search.utils.Index;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import com.yohomars.search.index.service.IYohoIndexService;
|
|
|
import com.yohomars.search.utils.Index;
|
|
|
|
|
|
/**
|
|
|
* 定时任务
|
|
|
*/
|
...
|
...
|
@@ -20,9 +20,6 @@ public class IndexRebuildJob { |
|
|
@Autowired
|
|
|
private IYohoIndexService yohoIndexService;
|
|
|
|
|
|
@Autowired
|
|
|
private RunnableQueueFactory runnableQueueFactory;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 定时任务重建索引(每1小时执行一次)
|
...
|
...
|
@@ -48,7 +45,7 @@ public class IndexRebuildJob { |
|
|
*/
|
|
|
@Scheduled(cron = "50 */10 * * * ?")
|
|
|
public void appendIndexJob() {
|
|
|
this.appendIndex(Index.social_user);
|
|
|
//this.appendIndex(Index.social_user);
|
|
|
this.appendIndex(Index.content);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -62,12 +59,16 @@ public class IndexRebuildJob { |
|
|
return;
|
|
|
}
|
|
|
String indexName = index.getIndexName();
|
|
|
runnableQueueFactory.addTask(indexName, new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
yohoIndexService.rebuildIndex(indexName);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// RunnableQueueFactory.getInstance().addTask(indexName, new Runnable() {
|
|
|
// @Override
|
|
|
// public void run() {
|
|
|
// yohoIndexService.rebuildIndex(indexName);
|
|
|
// }
|
|
|
// });
|
|
|
} catch (Exception e) {
|
|
|
LOGGER.error("rebuildIndex error,cause:", e);
|
|
|
}
|
...
|
...
|
@@ -84,12 +85,16 @@ public class IndexRebuildJob { |
|
|
return;
|
|
|
}
|
|
|
String indexName = index.getIndexName();
|
|
|
runnableQueueFactory.addTask(indexName, new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
yohoIndexService.appendIndex(indexName);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// RunnableQueueFactory.getInstance().addTask(indexName, new Runnable() {
|
|
|
// @Override
|
|
|
// public void run() {
|
|
|
// yohoIndexService.appendIndex(indexName);
|
|
|
// }
|
|
|
// });
|
|
|
} catch (Exception e) {
|
|
|
LOGGER.error("buildAppendedIndex error,cause:", e);
|
|
|
}
|
...
|
...
|
|