use of com.dtstack.taier.pluginapi.client.IClient in project Taier by DTStack.
the class Launcher method main.
public static void main(String[] args) throws Exception {
System.setProperty("HADOOP_USER_NAME", "admin");
// job json path
String jobJsonPath = USER_DIR + SP + "local-test/src/main/json/dtscript-agent.json";
// create jobClient
String content = getJobContent(jobJsonPath);
Map params = PublicUtil.jsonStrToObject(content, Map.class);
ParamAction paramAction = PublicUtil.mapToObject(params, ParamAction.class);
JobClient jobClient = new JobClient(paramAction);
// create jobIdentifier
String jobId = "jobId";
String appId = "appId";
String taskId = "taskId";
JobIdentifier jobIdentifier = JobIdentifier.createInstance(jobId, appId, taskId);
// get pluginInfo
String pluginInfo = jobClient.getPluginInfo();
Properties properties = PublicUtil.jsonStrToObject(pluginInfo, Properties.class);
String md5plugin = MD5Util.getMd5String(pluginInfo);
properties.setProperty("md5sum", md5plugin);
// create client
String pluginParentPath = USER_DIR + SP + "pluginLibs";
IClient client = ClientFactory.buildPluginClient(pluginInfo, pluginParentPath);
// client init
ClassLoaderCallBackMethod.callbackAndReset(new CallBack<String>() {
@Override
public String execute() throws Exception {
client.init(properties);
return null;
}
}, client.getClass().getClassLoader(), true);
// test target method
ClassLoaderCallBackMethod.callbackAndReset(new CallBack<Object>() {
@Override
public Object execute() throws Exception {
JobResult jobResult = client.submitJob(jobClient);
return jobResult;
}
}, client.getClass().getClassLoader(), true);
LOG.info("Launcher Success!");
System.exit(0);
}
use of com.dtstack.taier.pluginapi.client.IClient in project Taier by DTStack.
the class ClientCache method getDefaultPlugin.
public IClient getDefaultPlugin(String typeName) {
IClient defaultClient = defaultClientMap.get(typeName);
try {
if (defaultClient == null) {
synchronized (defaultClientMap) {
defaultClient = defaultClientMap.get(typeName);
if (defaultClient == null) {
JSONObject pluginInfo = new JSONObject();
pluginInfo.put(ConfigConstant.TYPE_NAME_KEY, typeName);
defaultClient = ClientFactory.buildPluginClient(pluginInfo.toJSONString(), pluginPath);
defaultClientMap.putIfAbsent(typeName, defaultClient);
}
}
}
} catch (Throwable e) {
LOGGER.error("-------job.pluginInfo is empty, either can't find plugin('In console is the typeName') which typeName:{}", typeName, e);
throw new IllegalArgumentException("job.pluginInfo is empty, either can't find plugin('In console is the typeName') which typeName:" + typeName, e);
}
return defaultClient;
}
Aggregations