Commit cfaf3818 by shentao

2018/8/2 平台选配调整

parent 51394b16
package com.zhiwei.messageflow;
import java.io.IOException;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.zhiwei.messageflow.mongo.bean.Project;
public class ES4RedisThread extends Thread {
private final static Logger log = LoggerFactory.getLogger(ES4RedisThread.class);
// 线程
private Thread t;
// 线程名
private String threadName;
// 项目
private Project project;
// 平台列表
private List<String> platformNames;
private ES4RedisTask es4RedisTask;
// 单个平台单个关键词组每次查询数量
private static final int count = 300;
// private static final int max_Thread_num = 40;
// private static int Thread_num = 0;
// private static final int max_Running_num = 3;
// private static Integer Running_num = 0;
// private static List<String> ThreadList = new ArrayList<>();
public ES4RedisThread(String name, Project project, List<String> platformNames, ES4RedisTask es4RedisTask) {
threadName = name;
this.project = project;
this.platformNames = platformNames;
this.es4RedisTask = es4RedisTask;
}
public ES4RedisThread() {
}
public static ES4RedisThread getThread(String name, Project project, List<String> platformNames,
ES4RedisTask es4RedisTask) {
ES4RedisThread es4RedisThread = new ES4RedisThread(name, project, platformNames, es4RedisTask);
return es4RedisThread;
}
public void start() {
// 线程开始
log.info("Starting {}", threadName);
if (t == null) {
t = new Thread(this, threadName);
// 通知执行run方法
t.start();
}
// 超时控制器
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
// 超时则线程中止
if (t.isAlive()) {
t.interrupt();
log.warn("{}项目超时线程状态:{}", project.getProjectName(),t.isInterrupted());
}
}
}, 49 * 1000L);
}
@SuppressWarnings("static-access")
@Override
public void run() {
try {
Thread.sleep(10L);
// 超时控制器
// Timer timer = new Timer();
// timer.schedule(new TimerTask() {
// @Override
// public void run() {
// // 超时则线程中止
// Thread.currentThread().interrupted();
// log.warn("{}项目超时", project.getProjectName());
// }
// }, 49 * 1000L);
// 程序运行
log.info("Running {}", threadName);
// 该项目执行消息流获取
boolean flag = es4RedisTask.ES4Redis(project, platformNames, count);
if (!flag) {
// 程序执行出现异常则线程中止
// timer.cancel();
Thread.currentThread().interrupted();
log.error("{}项目出现异常,线程状态:{}", project.getProjectName(),Thread.currentThread().isInterrupted());
}
// else
// // 程序正常执行完毕,关闭超时控制器
// timer.cancel();
} catch (JsonParseException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
// 线程退出
log.info("Thread {} exiting.", threadName);
}
}
}
\ No newline at end of file
package com.zhiwei.messageflow.config;
import java.util.Arrays;
import java.util.List;
public class BossZhipingChannelList {
public static final List<String> BOSSZPLIST = Arrays.asList("人民日报", "人民网", "新华社", "中新社", "光明日报", "光明网", "中央人民广播电台",
"36氪", "Techweb网", "中国网", "新京报网", "新京报", "法晚网", "法制晚报", "中国青年报", "中青在线", "经济生活网", "经济日报", "中国经济网", "央视网",
"国际在线", "京报网", "北晨网", "北京日报", "北京青年报", "北青网", "北京晚报", "北京晨报", "上观新闻", "解放日报", "文汇报", "新民晚报", "新民网", "文汇网",
"界面新闻", "澎湃新闻", "新闻晨报网", "新闻晨报", "南方网", "奥一网", "南方日报", "南方都市报", "21世纪经济报道", "南方周末", "金羊网", "羊城晚报", "四川在线",
"华西都市网", "封面新闻", "四川日报网", "四川日报", "成都商报", "成都晚报", "红星新闻", "四川新闻网", "现代快报网", "现代快报", "晚报", "金陵晚报网", "扬子晚报网",
"扬子晚报", "今晚网", "今晚报", "三秦都市报", "三秦网", "钱江晚报", "浙江24小时", "腾讯科技", "搜狐科技", "凤凰科技", "网易科技", "新浪科技", "好奇心日报",
"36Kr", "虎嗅", "钛媒体", "AI财经社", "腾讯财经", "搜狐财经", "凤凰财经", "网易财经", "新浪财经", "财经网", "财新网", "Techweb", "DoNews",
"亿欧网", "投资界", "ifanr", "中国政府网", "人社部", "民政部", "司法部", "商务部", "国家广电总局", "国家市场监督管理总局", "中国人民银行", "教育部", "科技部", "工信部",
"公安部", "国家知识产权局", "首都之窗", "天津政务网", "中国上海", "江苏省政府", "四川省政府", "广东省政府", "浙江省政府", "重庆市政府");
}
...@@ -636,7 +636,11 @@ public class NoiseProcessingServiceImpl implements NoiseProcessingService { ...@@ -636,7 +636,11 @@ public class NoiseProcessingServiceImpl implements NoiseProcessingService {
String text = map.get("text") != null ? map.get("text").toString() : null; String text = map.get("text") != null ? map.get("text").toString() : null;
String roottext = map.get("roottext") != null ? map.get("roottext").toString() : null; String roottext = map.get("roottext") != null ? map.get("roottext").toString() : null;
String username = map.get("username") != null ? map.get("username").toString() : null;
boolean isnoise = false; boolean isnoise = false;
if (null == username) {
return isnoise;
}
if (noiseRules != null) { if (noiseRules != null) {
for (NoiseRule n : noiseRules) { for (NoiseRule n : noiseRules) {
/** /**
...@@ -983,8 +987,11 @@ public class NoiseProcessingServiceImpl implements NoiseProcessingService { ...@@ -983,8 +987,11 @@ public class NoiseProcessingServiceImpl implements NoiseProcessingService {
String text = map.get("title") != null ? map.get("title").toString() : null; String text = map.get("title") != null ? map.get("title").toString() : null;
String roottext = map.get("content") != null ? map.get("content").toString() : null; String roottext = map.get("content") != null ? map.get("content").toString() : null;
String username = map.get("source") != null ? map.get("source").toString() : null;
boolean isnoise = false; boolean isnoise = false;
if (null == username) {
return isnoise;
}
if (noiseRules != null) { if (noiseRules != null) {
for (NoiseRule n : noiseRules) { for (NoiseRule n : noiseRules) {
/** /**
......
...@@ -21,4 +21,5 @@ public class KeywordNew { ...@@ -21,4 +21,5 @@ public class KeywordNew {
private String submitter; private String submitter;
private long createAt; private long createAt;
private Boolean isUsed; private Boolean isUsed;
private List<String> ptList;//平台列表
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment