fix reload dict error , optimize code and add some useful log
This commit is contained in:
parent
b97a6d89d8
commit
bb27162a24
@ -77,7 +77,7 @@ public class Dictionary {
|
||||
* 配置对象
|
||||
*/
|
||||
private Configuration configuration;
|
||||
private ESLogger logger=null;
|
||||
public static ESLogger logger=Loggers.getLogger("ik-analyzer");
|
||||
|
||||
private static ScheduledExecutorService pool = Executors.newScheduledThreadPool(1);
|
||||
|
||||
@ -90,7 +90,6 @@ public class Dictionary {
|
||||
|
||||
private Dictionary(){
|
||||
|
||||
logger = Loggers.getLogger("ik-analyzer");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -367,11 +366,11 @@ public class Dictionary {
|
||||
}
|
||||
response.close();
|
||||
} catch (ClientProtocolException e) {
|
||||
e.printStackTrace();
|
||||
logger.error( "getRemoteWords {} error" , e , location);
|
||||
} catch (IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
logger.error( "getRemoteWords {} error" , e , location );
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.error( "getRemoteWords {} error" , e , location );
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
@ -640,6 +639,7 @@ public class Dictionary {
|
||||
logger.info("重新加载词典...");
|
||||
// 新开一个实例加载词典,减少加载过程对当前词典使用的影响
|
||||
Dictionary tmpDict = new Dictionary();
|
||||
tmpDict.configuration = getSingleton().configuration;
|
||||
tmpDict.loadMainDict();
|
||||
tmpDict.loadStopWordDict();
|
||||
_MainDict = tmpDict._MainDict;
|
||||
|
@ -72,13 +72,17 @@ public class Monitor implements Runnable {
|
||||
last_modified = response.getLastHeader("Last-Modified")==null?null:response.getLastHeader("Last-Modified").getValue();
|
||||
eTags = response.getLastHeader("ETags")==null?null:response.getLastHeader("ETags").getValue();
|
||||
}
|
||||
}else{
|
||||
Dictionary.logger.info("remote_ext_dict {} return bad code {}" , location , response.getStatusLine().getStatusCode() );
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Dictionary.logger.error("remote_ext_dict {} error!",e , location);
|
||||
}finally{
|
||||
try {
|
||||
response.close();
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user