Improve CustomizeConfiguration by avoiding repeatedly resolve file config (#730)
This commit is contained in:
parent
fc86413aae
commit
2059fd4cb7
|
|
@ -11,6 +11,7 @@ Release Notes.
|
||||||
* Add witness class/method for resteasy-server plugin(v3/v4/v6)
|
* Add witness class/method for resteasy-server plugin(v3/v4/v6)
|
||||||
* Add async-profiler feature for performance analysis
|
* Add async-profiler feature for performance analysis
|
||||||
* Support db.instance tag,db.collection tag and AggregateOperation span for mongodb plugin(3.x/4.x)
|
* Support db.instance tag,db.collection tag and AggregateOperation span for mongodb plugin(3.x/4.x)
|
||||||
|
* Improve CustomizeConfiguration by avoiding repeatedly resolve file config
|
||||||
|
|
||||||
All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/222?closed=1)
|
All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/222?closed=1)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
@ -67,6 +68,8 @@ public enum CustomizeConfiguration {
|
||||||
private static final Map<String, ElementMatcher> CONTEXT_ENHANCE_CLASSES = new HashMap<>();
|
private static final Map<String, ElementMatcher> CONTEXT_ENHANCE_CLASSES = new HashMap<>();
|
||||||
private static final AtomicBoolean LOAD_FOR_CONFIGURATION = new AtomicBoolean(false);
|
private static final AtomicBoolean LOAD_FOR_CONFIGURATION = new AtomicBoolean(false);
|
||||||
|
|
||||||
|
private static volatile List<Map<String, Object>> RESOLVED_FILE_CONFIGURATIONS;
|
||||||
|
private static final ReentrantLock RESOLVED_FILE_LOCK = new ReentrantLock();
|
||||||
/**
|
/**
|
||||||
* The loadForEnhance method is resolver configuration file, and parse it
|
* The loadForEnhance method is resolver configuration file, and parse it
|
||||||
*/
|
*/
|
||||||
|
|
@ -107,13 +110,26 @@ public enum CustomizeConfiguration {
|
||||||
* @throws SAXException link {@link SAXException}
|
* @throws SAXException link {@link SAXException}
|
||||||
*/
|
*/
|
||||||
private List<Map<String, Object>> resolver() throws ParserConfigurationException, IOException, SAXException {
|
private List<Map<String, Object>> resolver() throws ParserConfigurationException, IOException, SAXException {
|
||||||
List<Map<String, Object>> customizeMethods = new ArrayList<Map<String, Object>>();
|
if (RESOLVED_FILE_CONFIGURATIONS != null) {
|
||||||
File file = new File(CustomizePluginConfig.Plugin.Customize.ENHANCE_FILE);
|
return RESOLVED_FILE_CONFIGURATIONS;
|
||||||
if (file.exists() && file.isFile()) {
|
|
||||||
NodeList classNodeList = resolverFileClassDesc(file);
|
|
||||||
resolverClassNodeList(classNodeList, customizeMethods);
|
|
||||||
}
|
}
|
||||||
return customizeMethods;
|
|
||||||
|
RESOLVED_FILE_LOCK.lock();
|
||||||
|
try {
|
||||||
|
if (RESOLVED_FILE_CONFIGURATIONS != null) {
|
||||||
|
return RESOLVED_FILE_CONFIGURATIONS;
|
||||||
|
}
|
||||||
|
List<Map<String, Object>> customizeMethods = new ArrayList<Map<String, Object>>();
|
||||||
|
File file = new File(CustomizePluginConfig.Plugin.Customize.ENHANCE_FILE);
|
||||||
|
if (file.exists() && file.isFile()) {
|
||||||
|
NodeList classNodeList = resolverFileClassDesc(file);
|
||||||
|
resolverClassNodeList(classNodeList, customizeMethods);
|
||||||
|
}
|
||||||
|
RESOLVED_FILE_CONFIGURATIONS = customizeMethods;
|
||||||
|
} finally {
|
||||||
|
RESOLVED_FILE_LOCK.unlock();
|
||||||
|
}
|
||||||
|
return RESOLVED_FILE_CONFIGURATIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue