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 Configuration configuration;
|
||||||
private ESLogger logger=null;
|
public static ESLogger logger=Loggers.getLogger("ik-analyzer");
|
||||||
|
|
||||||
private static ScheduledExecutorService pool = Executors.newScheduledThreadPool(1);
|
private static ScheduledExecutorService pool = Executors.newScheduledThreadPool(1);
|
||||||
|
|
||||||
@ -90,7 +90,6 @@ public class Dictionary {
|
|||||||
|
|
||||||
private Dictionary(){
|
private Dictionary(){
|
||||||
|
|
||||||
logger = Loggers.getLogger("ik-analyzer");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -367,11 +366,11 @@ public class Dictionary {
|
|||||||
}
|
}
|
||||||
response.close();
|
response.close();
|
||||||
} catch (ClientProtocolException e) {
|
} catch (ClientProtocolException e) {
|
||||||
e.printStackTrace();
|
logger.error( "getRemoteWords {} error" , e , location);
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
e.printStackTrace();
|
logger.error( "getRemoteWords {} error" , e , location );
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
logger.error( "getRemoteWords {} error" , e , location );
|
||||||
}
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
@ -640,6 +639,7 @@ public class Dictionary {
|
|||||||
logger.info("重新加载词典...");
|
logger.info("重新加载词典...");
|
||||||
// 新开一个实例加载词典,减少加载过程对当前词典使用的影响
|
// 新开一个实例加载词典,减少加载过程对当前词典使用的影响
|
||||||
Dictionary tmpDict = new Dictionary();
|
Dictionary tmpDict = new Dictionary();
|
||||||
|
tmpDict.configuration = getSingleton().configuration;
|
||||||
tmpDict.loadMainDict();
|
tmpDict.loadMainDict();
|
||||||
tmpDict.loadStopWordDict();
|
tmpDict.loadStopWordDict();
|
||||||
_MainDict = tmpDict._MainDict;
|
_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();
|
last_modified = response.getLastHeader("Last-Modified")==null?null:response.getLastHeader("Last-Modified").getValue();
|
||||||
eTags = response.getLastHeader("ETags")==null?null:response.getLastHeader("ETags").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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
Dictionary.logger.error("remote_ext_dict {} error!",e , location);
|
||||||
}finally{
|
}finally{
|
||||||
try {
|
try {
|
||||||
|
if (response != null) {
|
||||||
response.close();
|
response.close();
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user