Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix loadJobPlugin线程不安全 #2154

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import com.alibaba.datax.core.util.FrameworkErrorCode;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
* Created by jingxing on 14-8-24.
Expand Down Expand Up @@ -44,20 +44,20 @@ public String value() {
* 所有插件配置放置在pluginRegisterCenter中,为区别reader、transformer和writer,还能区别
* 具体pluginName,故使用pluginType.pluginName作为key放置在该map中
*/
private static Configuration pluginRegisterCenter;
private static ThreadLocal<Configuration> pluginRegisterCenter = new InheritableThreadLocal<>();

/**
* jarLoader的缓冲
*/
private static Map<String, JarLoader> jarLoaderCenter = new HashMap();
private static Map<String, JarLoader> jarLoaderCenter = new ConcurrentHashMap();

/**
* 设置pluginConfigs,方便后面插件来获取
*
* @param pluginConfigs
*/
public static void bind(Configuration pluginConfigs) {
pluginRegisterCenter = pluginConfigs;
pluginRegisterCenter.set(pluginConfigs);
}

private static String generatePluginKey(PluginType pluginType,
Expand All @@ -68,7 +68,7 @@ private static String generatePluginKey(PluginType pluginType,

private static Configuration getPluginConf(PluginType pluginType,
String pluginName) {
Configuration pluginConf = pluginRegisterCenter
Configuration pluginConf = pluginRegisterCenter.get()
.getConfiguration(generatePluginKey(pluginType, pluginName));

if (null == pluginConf) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/job/job.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"type": "string"
},
{
"value": 19890604,
"value": 19491001,
"type": "long"
},
{
"value": "1989-06-04 00:00:00",
"value": "1949-10-01 00:00:00",
"type": "date"
},
{
Expand Down
6 changes: 3 additions & 3 deletions elasticsearchwriter/doc/elasticsearchwriter.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@

```
{"value": "1.1.1.1", "type": "string"},
{"value": 19890604.0, "type": "double"},
{"value": 19890604, "type": "long"},
{"value": 19890604, "type": "long"},
{"value": 19491001.0, "type": "double"},
{"value": 19491001, "type": "long"},
{"value": 19491001, "type": "long"},
{"value": "hello world", "type": "string"},
{"value": "hello world", "type": "string"},
{"value": "41.12,-71.34", "type": "string"},
Expand Down
4 changes: 2 additions & 2 deletions selectdbwriter/doc/stream2selectdb.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
},
{
"type":"int",
"value":19890604
"value":19491001
},
{
"type":"date",
"value":"1989-06-04 00:00:00"
"value":"1949-10-01 00:00:00"
},
{
"type":"bool",
Expand Down
4 changes: 2 additions & 2 deletions transformer/doc/transformer.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ String code3 = "Column column = record.getColumn(1);\n" +
"type": "string"
},
{
"value": 19890604,
"value": 19491001,
"type": "long"
},
{
"value": "1989-06-04 00:00:00",
"value": "1949-10-01 00:00:00",
"type": "date"
},
{
Expand Down