parent
1d750a9bdd
commit
949531572b
2
pom.xml
2
pom.xml
@ -12,7 +12,7 @@
|
|||||||
<inceptionYear>2011</inceptionYear>
|
<inceptionYear>2011</inceptionYear>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<elasticsearch.version>6.3.0</elasticsearch.version>
|
<elasticsearch.version>6.5.0</elasticsearch.version>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<elasticsearch.assembly.descriptor>${project.basedir}/src/main/assemblies/plugin.xml</elasticsearch.assembly.descriptor>
|
<elasticsearch.assembly.descriptor>${project.basedir}/src/main/assemblies/plugin.xml</elasticsearch.assembly.descriptor>
|
||||||
<elasticsearch.plugin.name>analysis-ik</elasticsearch.plugin.name>
|
<elasticsearch.plugin.name>analysis-ik</elasticsearch.plugin.name>
|
||||||
|
@ -51,10 +51,10 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.elasticsearch.SpecialPermission;
|
import org.elasticsearch.SpecialPermission;
|
||||||
import org.elasticsearch.common.io.PathUtils;
|
import org.elasticsearch.common.io.PathUtils;
|
||||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
|
||||||
import org.elasticsearch.plugin.analysis.ik.AnalysisIkPlugin;
|
import org.elasticsearch.plugin.analysis.ik.AnalysisIkPlugin;
|
||||||
import org.wltea.analyzer.cfg.Configuration;
|
import org.wltea.analyzer.cfg.Configuration;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.wltea.analyzer.help.ESPluginLoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,7 +84,7 @@ public class Dictionary {
|
|||||||
*/
|
*/
|
||||||
private Configuration configuration;
|
private Configuration configuration;
|
||||||
|
|
||||||
private static final Logger logger = ESLoggerFactory.getLogger(Monitor.class.getName());
|
private static final Logger logger = ESPluginLoggerFactory.getLogger(Monitor.class.getName());
|
||||||
|
|
||||||
private static ScheduledExecutorService pool = Executors.newScheduledThreadPool(1);
|
private static ScheduledExecutorService pool = Executors.newScheduledThreadPool(1);
|
||||||
|
|
||||||
|
@ -11,11 +11,11 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.elasticsearch.SpecialPermission;
|
import org.elasticsearch.SpecialPermission;
|
||||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
import org.wltea.analyzer.help.ESPluginLoggerFactory;
|
||||||
|
|
||||||
public class Monitor implements Runnable {
|
public class Monitor implements Runnable {
|
||||||
|
|
||||||
private static final Logger logger = ESLoggerFactory.getLogger(Monitor.class.getName());
|
private static final Logger logger = ESPluginLoggerFactory.getLogger(Monitor.class.getName());
|
||||||
|
|
||||||
private static CloseableHttpClient httpclient = HttpClients.createDefault();
|
private static CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||||
/*
|
/*
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package org.wltea.analyzer.help;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.logging.log4j.spi.ExtendedLogger;
|
||||||
|
|
||||||
|
public class ESPluginLoggerFactory {
|
||||||
|
|
||||||
|
private ESPluginLoggerFactory() {
|
||||||
|
}
|
||||||
|
|
||||||
|
static public Logger getLogger(String name) {
|
||||||
|
return getLogger("", LogManager.getLogger(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
static public Logger getLogger(String prefix, String name) {
|
||||||
|
return getLogger(prefix, LogManager.getLogger(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
static public Logger getLogger(String prefix, Class<?> clazz) {
|
||||||
|
return getLogger(prefix, LogManager.getLogger(clazz.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static public Logger getLogger(String prefix, Logger logger) {
|
||||||
|
return (Logger)(prefix != null && prefix.length() != 0 ? new PrefixPluginLogger((ExtendedLogger)logger, logger.getName(), prefix) : logger);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package org.wltea.analyzer.help;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.Level;
|
||||||
|
import org.apache.logging.log4j.Marker;
|
||||||
|
import org.apache.logging.log4j.MarkerManager;
|
||||||
|
import org.apache.logging.log4j.message.Message;
|
||||||
|
import org.apache.logging.log4j.message.MessageFactory;
|
||||||
|
import org.apache.logging.log4j.spi.ExtendedLogger;
|
||||||
|
import org.apache.logging.log4j.spi.ExtendedLoggerWrapper;
|
||||||
|
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
|
public class PrefixPluginLogger extends ExtendedLoggerWrapper {
|
||||||
|
private static final WeakHashMap<String, Marker> markers = new WeakHashMap();
|
||||||
|
private final Marker marker;
|
||||||
|
|
||||||
|
static int markersSize() {
|
||||||
|
return markers.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String prefix() {
|
||||||
|
return this.marker.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
PrefixPluginLogger(ExtendedLogger logger, String name, String prefix) {
|
||||||
|
super(logger, name, (MessageFactory) null);
|
||||||
|
String actualPrefix = prefix == null ? "" : prefix;
|
||||||
|
WeakHashMap var6 = markers;
|
||||||
|
MarkerManager.Log4jMarker actualMarker;
|
||||||
|
synchronized (markers) {
|
||||||
|
MarkerManager.Log4jMarker maybeMarker = (MarkerManager.Log4jMarker) markers.get(actualPrefix);
|
||||||
|
if (maybeMarker == null) {
|
||||||
|
actualMarker = new MarkerManager.Log4jMarker(actualPrefix);
|
||||||
|
markers.put(new String(actualPrefix), actualMarker);
|
||||||
|
} else {
|
||||||
|
actualMarker = maybeMarker;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.marker = (Marker) actualMarker;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logMessage(String fqcn, Level level, Marker marker, Message message, Throwable t) {
|
||||||
|
assert marker == null;
|
||||||
|
|
||||||
|
super.logMessage(fqcn, level, this.marker, message, t);
|
||||||
|
}
|
||||||
|
}
|
@ -1,27 +1,29 @@
|
|||||||
package org.wltea.analyzer.help;
|
package org.wltea.analyzer.help;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
|
||||||
|
|
||||||
public class Sleep {
|
public class Sleep {
|
||||||
|
|
||||||
private static final Logger logger = ESLoggerFactory.getLogger(Sleep.class.getName());
|
private static final Logger logger = ESPluginLoggerFactory.getLogger(Sleep.class.getName());
|
||||||
|
|
||||||
public enum Type{MSEC,SEC,MIN,HOUR};
|
public enum Type {MSEC, SEC, MIN, HOUR}
|
||||||
public static void sleep(Type type,int num){
|
|
||||||
|
;
|
||||||
|
|
||||||
|
public static void sleep(Type type, int num) {
|
||||||
try {
|
try {
|
||||||
switch(type){
|
switch (type) {
|
||||||
case MSEC:
|
case MSEC:
|
||||||
Thread.sleep(num);
|
Thread.sleep(num);
|
||||||
return;
|
return;
|
||||||
case SEC:
|
case SEC:
|
||||||
Thread.sleep(num*1000);
|
Thread.sleep(num * 1000);
|
||||||
return;
|
return;
|
||||||
case MIN:
|
case MIN:
|
||||||
Thread.sleep(num*60*1000);
|
Thread.sleep(num * 60 * 1000);
|
||||||
return;
|
return;
|
||||||
case HOUR:
|
case HOUR:
|
||||||
Thread.sleep(num*60*60*1000);
|
Thread.sleep(num * 60 * 60 * 1000);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
System.err.println("输入类型错误,应为MSEC,SEC,MIN,HOUR之一");
|
System.err.println("输入类型错误,应为MSEC,SEC,MIN,HOUR之一");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user