Search in sources :

Example 1 with Application

use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.

the class DownloadServlet method getDownloadResource.

protected DownloadResource getDownloadResource(Matcher matcher) {
    Integer bizid = Integer.parseInt(matcher.group(1));
    Integer appid = Integer.parseInt(matcher.group(2));
    Short groupIndex = Short.parseShort(matcher.group(3));
    // 开发环境 线上 线下。。。。
    Short runtime = Short.parseShort(matcher.group(4));
    final String resourceName = matcher.group(5);
    final ServerGroup group = getServerGroup(appid, groupIndex, runtime, this.getContext().getServerGroupDAO());
    if (group == null) {
        throw new IllegalStateException("appid:" + appid + ",groupIndex:" + groupIndex + " runtime:" + AppDomainInfo.getRunEnvir(runtime) + " can not find a group");
    }
    if (group.getPublishSnapshotId() == null) {
        throw new IllegalStateException("group id:" + group.getGid() + " group have not set publishSnapshotId");
    }
    Application app = this.getContext().getApplicationDAO().selectByPrimaryKey(appid);
    if (bizid.intValue() != app.getDptId()) {
        throw new IllegalArgumentException("bizid.intValue()" + bizid.intValue() + " != app.getBizId()" + app.getDptId());
    }
    final SnapshotDomain snapshot = this.getContext().getSnapshotViewDAO().getView(group.getPublishSnapshotId());
    // Snapshot snapshot, String resourceName
    return new DownloadResource(app, snapshot, resourceName);
}
Also used : ServerGroup(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup) SnapshotDomain(com.qlangtech.tis.manage.common.SnapshotDomain) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application)

Example 2 with Application

use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.

the class TSearcherClusterInfoCollect method getAppNameMap.

/**
 * 保存索引名称和 应用的映射关系
 *
 * @return
 */
private Map<String, /* index Name */
Application> getAppNameMap() {
    if (appNamesMap == null) {
        synchronized (TSearcherClusterInfoCollect.class) {
            if (appNamesMap == null) {
                appNamesMap = new HashMap<String, Application>();
                ApplicationCriteria query = new ApplicationCriteria();
                List<Application> apps = this.getApplicationDAO().selectByExample(query, 1, 500);
                for (Application app : apps) {
                    appNamesMap.put(app.getProjectName(), app);
                }
            }
        }
    }
    return appNamesMap;
}
Also used : ApplicationCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application)

Example 3 with Application

use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.

the class AppViewAction method doGetApps.

/**
 * 取得索引实例列表
 *
 * @param context
 * @throws Exception
 */
public void doGetApps(Context context) throws Exception {
    Integer dptid = this.getInt("dptid", null);
    String appName = this.getString("name");
    Integer dptId = (Integer) context.get("dptId");
    String recept = (String) context.get("recept");
    // 应用集合
    ApplicationCriteria query = new ApplicationCriteria();
    Criteria criteria = query.createCriteria();
    criteria.andAppIdNotEqualTo(SysInitializeAction.TEMPLATE_APPLICATION_DEFAULT_ID);
    if (dptid != null) {
        context.put("bizdomain", this.getDepartmentDAO().loadFromWriteDB(dptid));
    // criteria.andDptIdEqualTo(dptid);
    }
    if (appName != null && !appName.equals("search4")) {
        criteria.andProjectNameLike("%" + appName + "%");
    }
    if (dptId != null) {
        criteria.andDptIdEqualTo(dptId);
    }
    if (recept != null && !StringUtils.isEmpty(recept)) {
        criteria.andReceptEqualTo(recept);
    }
    query.setOrderByClause("last_process_time desc,app_id desc");
    int allRows = this.getApplicationDAO().countByExample(query);
    Pager pager = getPager();
    List<Application> apps = Collections.emptyList();
    pager.setTotalCount(allRows);
    if (allRows < 1) {
        // this.addErrorMessage(context, "很抱歉,未能找到结果");
        this.setBizResult(context, new PaginationResult(pager, apps));
        return;
    }
    context.put("recept", recept);
    context.put("dptId", dptId);
    apps = this.getApplicationDAO().selectByExample(query, pager.getCurPage(), pager.getRowsPerPage());
    apps.forEach((app) -> {
    // WorkFlow df = null;
    // if (app.getWorkFlowId() != null && (df = getWorkflowDAOFacade().getWorkFlowDAO().selectByPrimaryKey(app.getWorkFlowId())) != null) {
    // app.setDataflowName(df.getName());
    // }
    });
    this.setBizResult(context, new PaginationResult(pager, apps));
}
Also used : ApplicationCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria) Pager(com.koubei.web.tag.pager.Pager) Criteria(com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria.Criteria) ApplicationCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application)

Example 4 with Application

use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.

the class TestCollectionAction method clearUpDB.

private void clearUpDB() {
    IWorkflowDAOFacade wfDaoFacade = applicationContext.getBean("wfDaoFacade", IWorkflowDAOFacade.class);
    DatasourceTableCriteria tabCriteria = new DatasourceTableCriteria();
    tabCriteria.createCriteria().andNameEqualTo(TEST_TABLE_EMPLOYEES_NAME);
    wfDaoFacade.getDatasourceTableDAO().deleteByExample(tabCriteria);
    DatasourceDbCriteria dbCriteria = new DatasourceDbCriteria();
    dbCriteria.createCriteria().andNameEqualTo(TEST_DS_NAME);
    wfDaoFacade.getDatasourceDbDAO().deleteByExample(dbCriteria);
    WorkFlowCriteria wfCriteria = new WorkFlowCriteria();
    wfCriteria.createCriteria().andNameEqualTo(TEST_TABLE_EMPLOYEES_NAME);
    wfDaoFacade.getWorkFlowDAO().deleteByExample(wfCriteria);
    // daoContext" class="com.qlangtech.tis.manage.common.RunContextImpl
    RunContext daoContext = applicationContext.getBean("daoContext", RunContext.class);
    ApplicationCriteria appCriteria = new ApplicationCriteria();
    appCriteria.createCriteria().andProjectNameEqualTo(TISCollectionUtils.NAME_PREFIX + TEST_TABLE_EMPLOYEES_NAME);
    for (Application app : daoContext.getApplicationDAO().selectByExample(appCriteria)) {
        ServerGroupCriteria sgCriteria = new ServerGroupCriteria();
        sgCriteria.createCriteria().andAppIdEqualTo(app.getAppId());
        daoContext.getServerGroupDAO().deleteByExample(sgCriteria);
    }
    daoContext.getApplicationDAO().deleteByExample(appCriteria);
    for (Long gid : daoContext.getServerGroupDAO().getServergroupWithoutAppReference()) {
        // assertNotNull(g.getGid());
        daoContext.getServerGroupDAO().deleteByPrimaryKey(gid.intValue());
    }
// select g.gid
// from server_group g left join application a on g.app_id = a.app_id
// where a.app_id is null
}
Also used : ApplicationCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria) DatasourceTableCriteria(com.qlangtech.tis.workflow.pojo.DatasourceTableCriteria) ServerGroupCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria) IWorkflowDAOFacade(com.qlangtech.tis.workflow.dao.IWorkflowDAOFacade) WorkFlowCriteria(com.qlangtech.tis.workflow.pojo.WorkFlowCriteria) DatasourceDbCriteria(com.qlangtech.tis.workflow.pojo.DatasourceDbCriteria) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application)

Example 5 with Application

use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.

the class CollectionAction method doDeleteIndex.

/**
 * 删除索引实例
 *
 * @param context
 * @throws Exception
 */
public void doDeleteIndex(Context context) throws Exception {
    getIndexWithPost();
    // 删除
    Application app = this.getApplicationDAO().selectByName(this.indexName.getCollectionName());
    if (app == null) {
        throw new IllegalStateException("indexName:" + this.indexName.getCollectionName() + " relevant instance in db can not be empty");
    }
    // final WorkFlow workFlow = this.loadDF(app.getWorkFlowId());
    this.rescycleAppDB(app.getAppId());
    // this.getWorkflowDAOFacade().getWorkFlowDAO().deleteByPrimaryKey(workFlow.getId());
    WorkFlowBuildHistoryCriteria wfHistoryCriteria = new WorkFlowBuildHistoryCriteria();
    // wfHistoryCriteria.createCriteria().andWorkFlowIdEqualTo(workFlow.getId());
    this.getWorkflowDAOFacade().getWorkFlowBuildHistoryDAO().deleteByExample(wfHistoryCriteria);
    this.deleteCollectionInCloud(context, app.getProjectName());
    // 删除workflow数据库及本地存储文件
    // TopologyDir topologyDir = SqlTaskNodeMeta.getTopologyDir(workFlow.getName());
    // if (topologyDir.synchronizeSubRemoteRes().size() > 0) {
    // IndexStreamCodeGenerator indexStreamCodeGenerator
    // = CoreAction.getIndexStreamCodeGenerator(this, workFlow, false);
    // indexStreamCodeGenerator.deleteScript();
    // }
    // topologyDir.delete();
    IPluginStore<IncrStreamFactory> store = CoreAction.getIncrStreamFactoryStore(this);
    try {
        if (store.getPlugin() != null) {
            // 删除增量实例
            TISK8sDelegate k8sDelegate = TISK8sDelegate.getK8SDelegate(this.getCollectionName());
            k8sDelegate.removeIncrProcess();
        }
    } catch (Throwable e) {
        // 可能创建过程增量没有正常,不能导致删除失败
        logger.warn("k8sDelegate illegal", e);
    }
}
Also used : Application(com.qlangtech.tis.manage.biz.dal.pojo.Application) IncrStreamFactory(com.qlangtech.tis.plugin.incr.IncrStreamFactory)

Aggregations

Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)26 ApplicationCriteria (com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria)7 Func (com.qlangtech.tis.manage.spring.aop.Func)5 Department (com.qlangtech.tis.manage.biz.dal.pojo.Department)2 Nullable (com.qlangtech.tis.pubhook.common.Nullable)2 SchemaAction (com.qlangtech.tis.runtime.module.action.SchemaAction)2 File (java.io.File)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 JSONTokener (org.json.JSONTokener)2 JSONObject (com.alibaba.fastjson.JSONObject)1 Pager (com.koubei.web.tag.pager.Pager)1 FullbuildPhase (com.qlangtech.tis.assemble.FullbuildPhase)1 TriggerType (com.qlangtech.tis.assemble.TriggerType)1 DBConfigSuit (com.qlangtech.tis.db.parser.DBConfigSuit)1 GitUser (com.qlangtech.tis.git.GitUtils.GitUser)1 Criteria (com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria.Criteria)1 ServerGroup (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup)1