use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.
the class CollectionAction method doCreate.
// /**
// * 回调获取索引创建的状态
// *
// * @param context
// * @throws Exception
// */
// public void doGetTaskStatus(Context context) throws Exception {
// JSONObject post = this.parseJsonPost();
// Integer taskId = post.getInteger(IParamContext.KEY_TASK_ID);
// boolean showLog = post.getBooleanValue(KEY_SHOW_LOG);
//
// WorkFlowBuildHistory buildHistory = this.getWorkflowDAOFacade().getWorkFlowBuildHistoryDAO().selectByPrimaryKey(taskId);
// if (buildHistory == null) {
// throw new IllegalStateException("taskid:" + taskId + "relevant buildHistory can not be null");
// }
// if (StringUtils.isEmpty(buildHistory.getAppName())) {
// throw new IllegalStateException("the prop appname of buildHistory can not be empty");
// }
// LogReader logReader = new LogReader();
// if (showLog) {
// RpcServiceReference service = StatusRpcClient.getService(getSolrZkClient());
// PMonotorTarget.Builder t = PMonotorTarget.newBuilder();
// t.setLogtype(LogCollectorClient.convert(LogType.FULL.typeKind));
// t.setCollection(buildHistory.getAppName());
// if (taskId > 0) {
// t.setTaskid(taskId);
// }
// StatusRpcClient.AssembleSvcCompsite feedbackRpc = service.get();
// StreamObserver<PMonotorTarget> observer = feedbackRpc.registerMonitorEvent(logReader);
// observer.onNext(t.build());
// Thread.sleep(3000);
// observer.onCompleted();
// }
// Map<String, Object> bizResult = Maps.newHashMap();
// bizResult.put("status", new ExtendWorkFlowBuildHistory(buildHistory));
// if (showLog) {
// bizResult.put("log", logReader.logContent.toString());
// }
// this.setBizResult(context, bizResult);
//
// }
/**
* 创建索实例
*
* @param context
* @throws Exception
*/
public void doCreate(Context context) throws Exception {
JSONObject post = getIndexWithPost();
Objects.requireNonNull(this.indexName, "indexName can not be null");
JSONObject datasource = post.getJSONObject("datasource");
JSONObject incrCfg = post.getJSONObject("incr");
if (datasource == null) {
throw new IllegalStateException("prop 'datasource' can not be null");
}
final String targetTable = post.getString("table");
if (StringUtils.isEmpty(targetTable)) {
throw new IllegalStateException("param 'table' can not be null");
}
// this.indexName = StringUtils.defaultIfEmpty(post.getString(KEY_INDEX_NAME), targetTable);
List<String> existCollection = CoreAction.listCollection(this, context);
if (existCollection.contains(this.getCollectionName())) {
// throw new IllegalStateException();
this.addErrorMessage(context, "index:" + this.getCollectionName() + " already exist in cloud");
return;
}
PluginItems dataSourceItems = getDataSourceItems(datasource);
if (dataSourceItems.items.size() < 1) {
throw new IllegalStateException("datasource item can not small than 1,now:" + dataSourceItems.items.size());
}
TargetColumnMeta targetColMetas = getTargetColumnMeta(this, context, post, targetTable, dataSourceItems);
if (!targetColMetas.valid) {
return;
}
dataSourceItems.save(context);
if (context.hasErrors()) {
return;
}
DBConfigSuit dsDb = (DBConfigSuit) context.get(IMessageHandler.ACTION_BIZ_RESULT);
Objects.requireNonNull(dsDb, "can not find dsDb which has insert into DB just now");
TISTable table = new TISTable();
table.setTableName(targetTable);
table.setDbId(dsDb.getDbId());
OfflineManager.ProcessedTable dsTable = offlineManager.addDatasourceTable(table, this, this, context, false, true);
if (context.hasErrors()) {
return;
}
this.setBizResult(context, new Object());
Objects.requireNonNull(dsTable, "dsTable can not be null");
// 开始创建DF
final String topologyName = indexName.param;
File parent = new File(SqlTaskNode.parent, topologyName);
FileUtils.forceMkdir(parent);
final SqlTaskNodeMeta.SqlDataFlowTopology topology = this.createTopology(topologyName, dsTable, targetColMetas);
OfflineDatasourceAction.CreateTopologyUpdateCallback dbSaver = new OfflineDatasourceAction.CreateTopologyUpdateCallback(this.getUser(), this.getWorkflowDAOFacade(), true);
WorkFlow df = dbSaver.execute(topologyName, topology);
// 保存一个时间戳
SqlTaskNodeMeta.persistence(topology, parent);
boolean hasCreateCollection = false;
Optional<Application> createdApp = Optional.empty();
try {
// 在在引擎节点上创建实例节点
createdApp = this.createCollection(context, df, indexName.param, targetColMetas);
hasCreateCollection = true;
if (incrCfg != null) {
logger.info("start incr channel create");
if (!createIncrSyncChannel(context, incrCfg)) {
return;
}
}
} catch (Throwable e) {
if (hasCreateCollection) {
// 需要将已经 创建的索引删除
this.deleteCollectionInCloud(context, indexName.getCollectionName());
}
throw e;
}
// 需要提交一下事务
TransactionStatus tranStatus = (TransactionStatus) ActionContext.getContext().get(TransactionStatus.class.getSimpleName());
Objects.requireNonNull(tranStatus, "transtatus can not be null");
transactionManager.commit(tranStatus);
if (!createdApp.isPresent()) {
throw new IllegalStateException("createdApp can not be null");
}
// 现在需要开始触发全量索引了
CoreAction.TriggerBuildResult triggerBuildResult = CoreAction.triggerFullIndexSwape(this, context, createdApp.get(), SHARED_COUNT);
this.setBizResult(context, triggerBuildResult);
}
use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.
the class DataxAction method doUpdateDatax.
@Func(value = PermissionConstant.DATAX_MANAGE)
public void doUpdateDatax(Context context) throws Exception {
String dataxName = this.getCollectionName();
DataxProcessor old = IAppSource.load(null, dataxName);
DataxProcessor editting = IAppSource.load(this, dataxName);
File oldWorkDir = old.getDataXWorkDir((IPluginContext) null);
File edittingDir = editting.getDataXWorkDir((IPluginContext) this);
String edittingDirSuffix = StringUtils.substringAfter(edittingDir.getName(), oldWorkDir.getName());
Matcher matcher = PatternEdittingDirSuffix.matcher(edittingDirSuffix);
if (!matcher.matches()) {
throw new IllegalStateException("dir name is illegal,oldDir:" + oldWorkDir.getAbsolutePath() + " editting dir:" + edittingDir.getAbsolutePath());
}
File backDir = new File(oldWorkDir.getParentFile(), oldWorkDir.getName() + ".bak");
// 先备份
try {
FileUtils.moveDirectory(oldWorkDir, backDir);
FileUtils.moveDirectory(edittingDir, oldWorkDir);
FileUtils.forceDelete(backDir);
} catch (Exception e) {
try {
FileUtils.moveDirectory(backDir, oldWorkDir);
} catch (Throwable ex) {
}
throw new IllegalStateException("oldWorkDir update is illegal:" + oldWorkDir.getAbsolutePath(), e);
}
// 更新一下时间戳,workflow 会重新创建流程
Application dataXApp = new Application();
dataXApp.setUpdateTime(new Date());
ApplicationCriteria appCriteria = new ApplicationCriteria();
appCriteria.createCriteria().andProjectNameEqualTo(dataxName);
this.getApplicationDAO().updateByExampleSelective(dataXApp, appCriteria);
IAppSource.cleanAppSourcePluginStoreCache(null, dataxName);
IAppSource.cleanAppSourcePluginStoreCache(this, dataxName);
this.addActionMessage(context, "已经成功更新");
}
use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.
the class DataxAction method doValidateDataxProfile.
/**
* @param context
* @throws Exception
*/
@Func(value = PermissionConstant.DATAX_MANAGE, sideEffect = false)
public void doValidateDataxProfile(Context context) throws Exception {
Application app = this.parseJsonPost(Application.class);
SchemaAction.CreateAppResult validateResult = this.createNewApp(context, app, true, (newAppId) -> {
throw new UnsupportedOperationException();
});
}
use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.
the class DataxAction method doCreateDatax.
/**
* 创建DataX实例
*
* @param context
*/
@Func(value = PermissionConstant.DATAX_MANAGE)
public void doCreateDatax(Context context) throws Exception {
String dataxName = this.getString(PARAM_KEY_DATAX_NAME);
DataxProcessor dataxProcessor = IAppSource.load(null, dataxName);
Application app = dataxProcessor.buildApp();
SchemaAction.CreateAppResult createAppResult = this.createNewApp(context, app, false, (newAppId) -> {
SchemaAction.CreateAppResult appResult = new SchemaAction.CreateAppResult();
appResult.setSuccess(true);
appResult.setNewAppId(newAppId);
return appResult;
});
}
use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.
the class ApplicationDAOImpl method deleteByPrimaryKey.
public int deleteByPrimaryKey(Integer appId) {
Application key = new Application();
key.setAppId(appId);
return this.deleteRecords("application.ibatorgenerated_deleteByPrimaryKey", key);
}
Aggregations