Search in sources :

Example 11 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class UserAction method doChangeDepartment.

/**
 * 用户部门更新
 *
 * @param context
 */
@Func(PermissionConstant.AUTHORITY_USER_MANAGE)
public void doChangeDepartment(Context context) {
    String usrid = this.getString("usrid");
    Integer selecteddptid = this.getInt("selecteddptid");
    Assert.assertNotNull(usrid);
    Assert.assertNotNull(selecteddptid);
    UsrDptRelation usr = this.getUsrDptRelationDAO().loadFromWriteDB(usrid);
    Assert.assertNotNull(usr);
    Department department = this.getDepartmentDAO().loadFromWriteDB(selecteddptid);
    Assert.assertNotNull(department);
    UsrDptRelationCriteria criteria = new UsrDptRelationCriteria();
    criteria.createCriteria().andUsrIdEqualTo(usrid);
    UsrDptRelation record = new UsrDptRelation();
    record.setDptName(department.getFullName());
    record.setDptId(department.getDptId());
    record.setUpdateTime(new Date());
    this.getUsrDptRelationDAO().updateByExampleSelective(record, criteria);
    this.addActionMessage(context, "已经将用户“" + usr.getUserName() + "”归属到新的部门:" + department.getFullName());
}
Also used : Department(com.qlangtech.tis.manage.biz.dal.pojo.Department) UsrDptRelationCriteria(com.qlangtech.tis.manage.biz.dal.pojo.UsrDptRelationCriteria) UsrDptRelation(com.qlangtech.tis.manage.biz.dal.pojo.UsrDptRelation) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 12 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class AppSynAction method doInitAppFromDaily.

// private ITerminatorTriggerBizDalDAOFacade triggerContext;
/**
 * 接收从日常环境中推送上来的配置文件,<br>
 * 当第一次推送的时候线上还不存在索引实例的时候,会自动创建索引实例
 *
 * @param context
 * @throws Exception
 */
@Func(PermissionConstant.APP_ADD)
public void doInitAppFromDaily(Context context) throws Exception {
    String content = null;
    try (InputStream reader = this.getRequest().getInputStream()) {
        content = IOUtils.toString(reader, getEncode());
        if (StringUtils.isEmpty(content)) {
            throw new IllegalArgumentException("upload content can not be null");
        }
    }
    final ConfigPush configPush = (ConfigPush) HttpConfigFileReader.xstream.fromXML(content);
    final String collection = configPush.getCollection();
    ISchemaPluginContext schemaPlugin = SchemaAction.createSchemaPlugin(collection);
    // 校验当前的snapshot 版本是否就是传输上来的snapshot版本
    ServerGroup serverGroup = null;
    if (configPush.getRemoteSnapshotId() != null) {
        serverGroup = this.getServerGroupDAO().load(collection, (short) 0, /* groupIndex */
        RunEnvironment.ONLINE.getId());
        if (serverGroup.getPublishSnapshotId() != (configPush.getRemoteSnapshotId() + 0)) {
            this.addErrorMessage(context, "exist snapshotid:" + serverGroup.getPublishSnapshotId() + " is not equal push snapshotid:" + configPush.getRemoteSnapshotId());
            return;
        }
    }
    // List<UploadResource> resources = configPush.getUploadResources();
    Snapshot snapshot = null;
    SnapshotDomain snapshotDomain = null;
    Application app = null;
    ApplicationCriteria criteria = new ApplicationCriteria();
    criteria.createCriteria().andProjectNameEqualTo(collection);
    List<Application> apps = this.getApplicationDAO().selectByExample(criteria);
    for (Application p : apps) {
        app = p;
        break;
    }
    if (app == null) {
        // 在服务端创建新应用
        app = new Application();
    // Integer newAppid = this.createNewApp(context, configPush);
    // app.setAppId(newAppid);
    }
    String snycDesc = "NEW CREATE";
    serverGroup = this.getServerGroupDAO().load(collection, (short) 0, /* groupIndex */
    RunEnvironment.ONLINE.getId());
    boolean newSnapshot = false;
    if (serverGroup == null || serverGroup.getPublishSnapshotId() == null) {
        snapshot = new Snapshot();
        snapshot.setSnId(-1);
        snapshot.setPreSnId(-1);
        snapshot.setAppId(app.getAppId());
        newSnapshot = true;
    } else {
        snycDesc = "PUSH FROM DAILY";
        snapshotDomain = this.getSnapshotViewDAO().getView(configPush.getRemoteSnapshotId());
        snapshot = snapshotDomain.getSnapshot();
    }
    if (snapshot == null) {
        throw new IllegalStateException("snapshot can not be null,collection:" + collection);
    }
    snapshot.setCreateUserId(0l);
    snapshot.setCreateUserName(configPush.getReception());
    // ///////////////////////////////////
    // 组装新的snapshot
    PropteryGetter pGetter = null;
    for (UploadResource res : configPush.getUploadResources()) {
        pGetter = ConfigFileReader.createPropertyGetter(res.getResourceType());
        // 校验配置是否相等
        if (!newSnapshot) {
            final String md5 = ConfigFileReader.md5file(res.getContent());
            if (StringUtils.equals(md5, pGetter.getMd5CodeValue(snapshotDomain))) {
                this.addErrorMessage(context, "resource " + pGetter.getFileName() + " is newest,shall not be updated");
                return;
            }
        }
        Integer newResId = ResSynManager.createNewResource(context, schemaPlugin, res.getContent(), ConfigFileReader.md5file(res.getContent()), pGetter, this, this);
        snapshot = pGetter.createNewSnapshot(newResId, snapshot);
    }
    serverGroup = new ServerGroup();
    serverGroup.setPublishSnapshotId(SaveFileContentAction.createNewSnapshot(snapshot, snycDesc, this, 0l, configPush.getReception()));
    serverGroup.setUpdateTime(new Date());
    ServerGroupCriteria serverGroupCriteria = new ServerGroupCriteria();
    serverGroupCriteria.createCriteria().andAppIdEqualTo(app.getAppId()).andRuntEnvironmentEqualTo(RunEnvironment.ONLINE.getId()).andGroupIndexEqualTo((short) 0);
    this.getServerGroupDAO().updateByExampleSelective(serverGroup, serverGroupCriteria);
    // /////////////////////////////////////
    this.addActionMessage(context, "synsuccess");
}
Also used : SnapshotDomain(com.qlangtech.tis.manage.common.SnapshotDomain) InputStream(java.io.InputStream) Date(java.util.Date) PropteryGetter(com.qlangtech.tis.manage.common.PropteryGetter) ISchemaPluginContext(com.qlangtech.tis.solrdao.ISchemaPluginContext) ConfigPush(com.qlangtech.tis.runtime.pojo.ConfigPush) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 13 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class CoreAction method doCompileAndPackage.

/**
 * 编译打包
 *
 * @param context
 * @throws Exception
 */
@Func(value = PermissionConstant.PERMISSION_INCR_PROCESS_CONFIG_EDIT)
public void doCompileAndPackage(Context context) throws Exception {
    IBasicAppSource appSource = IAppSource.load(null, this.getCollectionName());
    IndexStreamCodeGenerator indexStreamCodeGenerator = getIndexStreamCodeGenerator(this);
    IndexIncrStatus incrStatus = new IndexIncrStatus();
    GenerateDAOAndIncrScript daoAndIncrScript = new GenerateDAOAndIncrScript(this, indexStreamCodeGenerator);
    // if (appSource.isExcludeFacadeDAOSupport()) {
    if (true) {
        daoAndIncrScript.generateIncrScript(context, incrStatus, true, Collections.emptyMap());
    } else {
        Map<Integer, Long> dependencyDbs = getDependencyDbsMap(this, indexStreamCodeGenerator);
        // 需要facadeDAO支持
        daoAndIncrScript.generate(context, incrStatus, true, dependencyDbs);
    }
}
Also used : IndexStreamCodeGenerator(com.qlangtech.tis.compiler.streamcode.IndexStreamCodeGenerator) GenerateDAOAndIncrScript(com.qlangtech.tis.compiler.streamcode.GenerateDAOAndIncrScript) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 14 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class CoreAction method doDeployIncrSyncChannal.

/**
 * 部署实例
 * https://nightlies.apache.org/flink/flink-docs-release-1.14/docs/deployment/resource-providers/standalone/kubernetes/
 *
 * @param context
 * @throws Exception
 */
@Func(value = PermissionConstant.PERMISSION_INCR_PROCESS_MANAGE)
public void doDeployIncrSyncChannal(Context context) throws Exception {
    // 先进行打包编译
    StringBuffer logger = new StringBuffer("flin sync app:" + this.getCollectionName());
    try {
        TISK8sDelegate k8sClient = TISK8sDelegate.getK8SDelegate(this.getCollectionName());
        k8sClient.checkUseable();
        long start = System.currentTimeMillis();
        this.doCompileAndPackage(context);
        if (context.hasErrors()) {
            return;
        }
        logger.append("\n compile and package consume:" + (System.currentTimeMillis() - start) + "ms ");
        // 编译并且打包
        IndexStreamCodeGenerator indexStreamCodeGenerator = getIndexStreamCodeGenerator(this);
        // 将打包好的构建,发布到k8s集群中去
        // https://github.com/kubernetes-client/java
        start = System.currentTimeMillis();
        // 通过k8s发布
        k8sClient.deploy(null, indexStreamCodeGenerator.getIncrScriptTimestamp());
        logger.append("\n deploy to flink cluster consume:" + (System.currentTimeMillis() - start) + "ms ");
        IndexIncrStatus incrStatus = new IndexIncrStatus();
        this.setBizResult(context, incrStatus);
    } catch (Exception ex) {
        logger.append("an error occur:" + ex.getMessage());
        throw new TisException(ex.getMessage(), ex);
    } finally {
        log.info(logger.toString());
    }
}
Also used : TisException(com.qlangtech.tis.lang.TisException) IndexStreamCodeGenerator(com.qlangtech.tis.compiler.streamcode.IndexStreamCodeGenerator) SolrServerException(org.apache.solr.client.solrj.SolrServerException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) TisException(com.qlangtech.tis.lang.TisException) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 15 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class CoreAction method doCreateCore.

/**
 * 创建一个应用
 */
@SuppressWarnings("all")
@Func(PermissionConstant.APP_INITIALIZATION)
public void doCreateCore(final Context context) throws Exception {
    final Integer groupNum = this.getInt("group");
    // 最大组内副本数目 改过了
    final Integer repliation = this.getInt("replica");
    if (groupNum == null || groupNum < 1) {
        this.addErrorMessage(context, "组数不能小于1");
        return;
    }
    if (repliation == null || repliation < 1) {
        this.addErrorMessage(context, "组内副本数不能小于1");
        return;
    }
    FCoreRequest request = createCoreRequest(context, groupNum, repliation, "创建", true);
    this.createCollection(this, context, groupNum, repliation, request, this.getServerGroup0().getPublishSnapshotId());
}
Also used : FCoreRequest(com.qlangtech.tis.coredefine.biz.FCoreRequest) Func(com.qlangtech.tis.manage.spring.aop.Func)

Aggregations

Func (com.qlangtech.tis.manage.spring.aop.Func)64 JSONObject (com.alibaba.fastjson.JSONObject)12 DataXJobWorker (com.qlangtech.tis.datax.job.DataXJobWorker)6 File (java.io.File)6 Date (java.util.Date)6 Context (com.alibaba.citrus.turbine.Context)5 Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)5 JSONObject (org.json.JSONObject)5 Validator (com.qlangtech.tis.plugin.annotation.Validator)4 IControlMsgHandler (com.qlangtech.tis.runtime.module.misc.IControlMsgHandler)4 IFieldErrorHandler (com.qlangtech.tis.runtime.module.misc.IFieldErrorHandler)4 DelegateControl4JsonPostMsgHandler (com.qlangtech.tis.runtime.module.misc.impl.DelegateControl4JsonPostMsgHandler)4 WorkFlow (com.qlangtech.tis.workflow.pojo.WorkFlow)4 JSONArray (org.json.JSONArray)4 ExecResult (com.qlangtech.tis.assemble.ExecResult)3 FullbuildPhase (com.qlangtech.tis.assemble.FullbuildPhase)3 IndexStreamCodeGenerator (com.qlangtech.tis.compiler.streamcode.IndexStreamCodeGenerator)3 DescriptorExtensionList (com.qlangtech.tis.extension.DescriptorExtensionList)3 IOException (java.io.IOException)3 Matcher (java.util.regex.Matcher)3