use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.
the class DataxAction method doGetDataxWorkerHpa.
@Func(value = PermissionConstant.DATAX_MANAGE, sideEffect = false)
public void doGetDataxWorkerHpa(Context context) {
DataXJobWorker jobWorker = DataXJobWorker.getJobWorker(this.getK8SJobWorkerTargetName());
if (jobWorker.getHpa() != null) {
RcHpaStatus hpaStatus = jobWorker.getHpaStatus();
this.setBizResult(context, hpaStatus);
}
}
use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.
the class DataxAction method doSaveWriterColsMeta.
/**
* @param context
*/
@Func(value = PermissionConstant.DATAX_MANAGE)
public void doSaveWriterColsMeta(Context context) {
String dataxName = this.getString(PARAM_KEY_DATAX_NAME);
DataxProcessor.DataXCreateProcessMeta processMeta = DataxProcessor.getDataXCreateProcessMeta(this, dataxName);
if ((processMeta.isReaderRDBMS())) {
throw new IllegalStateException("can not process the flow with:" + processMeta.toString());
}
List<ISelectedTab.ColMeta> writerCols = Lists.newArrayList();
IDataxProcessor.TableMap tableMapper = new IDataxProcessor.TableMap(new ISelectedTab() {
@Override
public List<ColMeta> getCols() {
return writerCols;
}
});
// tableMapper.setSourceCols(writerCols);
// //////////////////
final String keyColsMeta = "colsMeta";
IControlMsgHandler handler = new DelegateControl4JsonPostMsgHandler(this, this.parseJsonPost());
if (!Validator.validate(handler, context, //
Validator.fieldsValidator(//
"writerTargetTabName", new Validator.FieldValidators(Validator.require, Validator.db_col_name) {
@Override
public void setFieldVal(String val) {
tableMapper.setTo(val);
}
}, "writerFromTabName", new Validator.FieldValidators(Validator.require, Validator.db_col_name) {
@Override
public void setFieldVal(String val) {
tableMapper.setFrom(val);
}
}, //
keyColsMeta, new Validator.FieldValidators(Validator.require) {
@Override
public void setFieldVal(String val) {
}
}, new Validator.IFieldValidator() {
@Override
public boolean validate(IFieldErrorHandler msgHandler, Context context, String fieldKey, String fieldData) {
ISelectedTab.ColMeta colMeta = null;
JSONArray targetCols = JSON.parseArray(fieldData);
JSONObject targetCol = null;
int index;
String targetColName = null;
if (targetCols.size() < 1) {
msgHandler.addFieldError(context, fieldKey, "Writer目标表列不能为空");
return false;
}
Map<String, Integer> existCols = Maps.newHashMap();
boolean validateFaild = false;
Integer previousColIndex = null;
for (int i = 0; i < targetCols.size(); i++) {
targetCol = targetCols.getJSONObject(i);
index = targetCol.getInteger("index");
targetColName = targetCol.getString("name");
if (StringUtils.isNotBlank(targetColName) && (previousColIndex = existCols.put(targetColName, index)) != null) {
msgHandler.addFieldError(context, keyColsMeta + "[" + previousColIndex + "]", "内容不能与第" + index + "行重复");
msgHandler.addFieldError(context, keyColsMeta + "[" + index + "]", "内容不能与第" + previousColIndex + "行重复");
return false;
}
if (!Validator.require.validate(DataxAction.this, context, keyColsMeta + "[" + index + "]", targetColName)) {
validateFaild = true;
} else if (!Validator.db_col_name.validate(DataxAction.this, context, keyColsMeta + "[" + index + "]", targetColName)) {
validateFaild = true;
}
colMeta = new ISelectedTab.ColMeta();
colMeta.setName(targetColName);
DataType dataType = targetCol.getObject("type", DataType.class);
// colMeta.setType(ISelectedTab.DataXReaderColType.parse(targetCol.getString("type")));
colMeta.setType(dataType);
writerCols.add(colMeta);
}
return !validateFaild;
}
}))) {
return;
}
this.saveTableMapper(this, dataxName, Collections.singletonList(tableMapper));
}
use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.
the class DataxAction method doLaunchDataxWorker.
/**
* 启动DataX执行器
*
* @param context
*/
@Func(value = PermissionConstant.DATAX_MANAGE)
public void doLaunchDataxWorker(Context context) {
DataXJobWorker dataxJobWorker = DataXJobWorker.getJobWorker(this.getK8SJobWorkerTargetName());
if (dataxJobWorker == null) {
throw new IllegalStateException("dataxJobWorker can not be null,relevant target type:" + this.getK8SJobWorkerTargetName());
}
if (dataxJobWorker.inService()) {
throw new IllegalStateException("dataxJobWorker is in serivce ,can not launch repeat");
}
dataxJobWorker.launchService();
try {
Thread.sleep(4000l);
} catch (InterruptedException e) {
}
this.doGetJobWorkerMeta(context);
AjaxValve.ActionExecResult actionExecResult = MockContext.getActionExecResult();
DataXJobWorkerStatus jobWorkerStatus = (DataXJobWorkerStatus) actionExecResult.getBizResult();
if (jobWorkerStatus == null || !jobWorkerStatus.isK8sReplicationControllerCreated()) {
throw new IllegalStateException("Job Controller launch faild please contract administer");
}
this.addActionMessage(context, "已经成功启动DataX执行器");
}
use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.
the class DataxAction method doSaveDataxWorker.
/**
* 保存K8S dataX worker
*
* @param context
*/
@Func(value = PermissionConstant.DATAX_MANAGE)
public void doSaveDataxWorker(Context context) {
JSONObject postContent = this.parseJsonPost();
JSONObject k8sSpec = postContent.getJSONObject("k8sSpec");
IncrUtils.IncrSpecResult incrSpecResult = IncrUtils.parseIncrSpec(context, k8sSpec, this);
if (!incrSpecResult.isSuccess()) {
return;
}
TargetResName resName = this.getK8SJobWorkerTargetName();
DataXJobWorker worker = DataXJobWorker.getJobWorker(resName);
worker.setReplicasSpec(incrSpecResult.getSpec());
if (incrSpecResult.hpa != null) {
worker.setHpa(incrSpecResult.hpa);
}
DataXJobWorker.setJobWorker(resName, worker);
}
use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.
the class DataxAction method doSaveTableMapper.
/**
* 保存表映射
*
* @param context
*/
@Func(value = PermissionConstant.DATAX_MANAGE)
public void doSaveTableMapper(Context context) {
String dataxName = this.getString(PARAM_KEY_DATAX_NAME);
// 表别名列表
JSONArray tabAliasList = this.parseJsonArrayPost();
Objects.requireNonNull(tabAliasList, "tabAliasList can not be null");
JSONObject alias = null;
IDataxProcessor.TableAlias tabAlias = null;
List<IDataxProcessor.TableAlias> tableMaps = Lists.newArrayList();
String mapperToVal = null;
for (int i = 0; i < tabAliasList.size(); i++) {
alias = tabAliasList.getJSONObject(i);
tabAlias = new IDataxProcessor.TableAlias();
tabAlias.setFrom(alias.getString("from"));
mapperToVal = alias.getString("to");
String mapper2FieldKey = "tabMapperTo[" + i + "]";
if (Validator.require.validate(this, context, mapper2FieldKey, mapperToVal)) {
Validator.db_col_name.validate(this, context, mapper2FieldKey, mapperToVal);
}
tabAlias.setTo(mapperToVal);
tableMaps.add(tabAlias);
}
if (context.hasErrors()) {
return;
}
this.saveTableMapper(this, dataxName, tableMaps);
}
Aggregations