Search in sources :

Example 1 with RunEnvironment

use of com.qlangtech.tis.pubhook.common.RunEnvironment in project tis by qlangtech.

the class AbstractIndexBuildJob method startBuildIndex.

/**
 * 执行单组build任務
 *
 * @return
 * @throws Exception
 */
@SuppressWarnings("all")
public final BuildResult startBuildIndex() throws Exception {
    // final String coreName = state.getIndexName() + '-' + groupNum;
    // + '-' + groupNum;
    final String coreName = state.getCoreName(groupNum);
    final String timePoint = state.getTimepoint();
    final DumpJobStatus status = new DumpJobStatus();
    // status.setUserName(userName);
    status.setTimepoint(state.getTimepoint());
    status.setDumpType("remote");
    DumpJobId dumpJobId = new DumpJobId("jtIdentifier", jobid++);
    status.setDumpJobID(dumpJobId);
    status.setCoreName(coreName);
    RunEnvironment runtime = RunEnvironment.getSysRuntime();
    long now = System.currentTimeMillis();
    final String outPath = state.getIndexBuildOutputPath((this.groupNum));
    logger.info("build out path:" + outPath);
    ITISFileSystem fileSystem = indexBuildFS;
    appDomain.writeResource2fs(fileSystem, coreName, ConfigFileReader.FILE_SCHEMA);
    appDomain.writeResource2fs(fileSystem, coreName, ConfigFileReader.FILE_SOLR);
    // writeResource2Hdfs(coreName, domain, ConfigFileReader.FILE_CORE_PROPERTIES, "config");
    // // TODO 为了兼容老的索引先加上,到时候要删除掉的
    // writeResource2Hdfs(coreName, domain, ConfigFileReader.FILE_SCHEMA, SCHEMA);
    // writeResource2Hdfs(coreName, domain, ConfigFileReader.FILE_APPLICATION, "app");
    // writeResource2Hdfs(coreName, domain, ConfigFileReader.FILE_CORE_PROPERTIES, "core");
    // TODO 为了兼容老的索引先加上,到时候要删除掉的 end
    logger.info("Excute  RemoteDumpJob: Sbumit Remote Job .....  ");
    status.setStartTime(now);
    // String[] core = this.coreName.split("-");
    String serviceName = state.getIndexName();
    // ///////////////////////////////////////////
    logger.info("Excute Remote Dump Job Status: Sbumit  ");
    return buildSliceIndex(coreName, timePoint, status, outPath, serviceName);
}
Also used : DumpJobStatus(com.qlangtech.tis.cloud.dump.DumpJobStatus) RunEnvironment(com.qlangtech.tis.pubhook.common.RunEnvironment) ITISFileSystem(com.qlangtech.tis.fs.ITISFileSystem) DumpJobId(com.qlangtech.tis.cloud.dump.DumpJobId)

Example 2 with RunEnvironment

use of com.qlangtech.tis.pubhook.common.RunEnvironment in project tis by qlangtech.

the class AppDomainSelectedCheckValve method doIntercept.

@Override
protected String doIntercept(ActionInvocation invocation) throws Exception {
    final ActionProxy proxy = invocation.getProxy();
    if ("control".equals(StringUtils.split(proxy.getNamespace(), "#")[1])) {
        return invocation.invoke();
    }
    final Rundata rundata = BasicModule.getRundataInstance();
    AppDomainInfo domain = CheckAppDomainExistValve.getAppDomain(daoContextGetter.get());
    final String actionTarget = getActionTarget(proxy);
    if (!include_urls.containsKey(actionTarget)) {
        // 不在校验范围之内
        return invocation.invoke();
    }
    final String specialTarget = specialForward.get(actionTarget);
    boolean sensitiveRuntime = true;
    try {
        if (StringUtils.isNotBlank(specialTarget)) {
            sensitiveRuntime = "true".equalsIgnoreCase(StringUtils.substringAfter(specialTarget, ","));
        }
    } catch (Throwable e) {
    }
    if (isInvalidDomain((BasicModule) proxy.getAction(), domain, sensitiveRuntime)) {
        if (StringUtils.isNotBlank(specialTarget)) {
            rundata.forwardTo(StringUtils.substringBefore(specialTarget, ","));
        } else {
            rundata.forwardTo("appdomainhasnotselected");
            return Action.NONE;
        }
        // context.breakPipeline(0);
        return invocation.invoke();
    // return;
    }
    Collection<RunEnvironment> runtime = include_urls.get(actionTarget);
    if (runtime.contains(domain.getRunEnvironment())) {
        // 跳转到该应用是不能被使用的,不支持 该环境的应用
        rundata.forwardTo("environmentunuseable");
    }
    return invocation.invoke();
}
Also used : AppDomainInfo(com.qlangtech.tis.manage.common.AppDomainInfo) ActionProxy(com.opensymphony.xwork2.ActionProxy) RunEnvironment(com.qlangtech.tis.pubhook.common.RunEnvironment) Rundata(com.qlangtech.tis.runtime.module.action.BasicModule.Rundata)

Example 3 with RunEnvironment

use of com.qlangtech.tis.pubhook.common.RunEnvironment in project tis by qlangtech.

the class OfflineManager method deleteDatasourceTableById.

public void deleteDatasourceTableById(int tableId, BasicModule action, Context context) {
    // 1 检查表是否存在
    DatasourceTable datasourceTable = this.workflowDAOFacade.getDatasourceTableDAO().selectByPrimaryKey(tableId);
    if (datasourceTable == null) {
        action.addErrorMessage(context, "找不到该表,table id = " + tableId);
        return;
    }
    // 2 检查对应的db是否存在
    Integer dbId = datasourceTable.getDbId();
    DatasourceDb datasourceDb = this.workflowDAOFacade.getDatasourceDbDAO().selectByPrimaryKey(dbId);
    if (datasourceDb == null) {
        action.addErrorMessage(context, "找不到该表对应的数据库,db id = " + dbId);
        return;
    }
    // 3 检查是否有工作流用到了该table
    WorkFlowCriteria workFlowCriteria = new WorkFlowCriteria();
    workFlowCriteria.createCriteria();
    List<WorkFlow> workFlows = this.workflowDAOFacade.getWorkFlowDAO().selectByExample(workFlowCriteria);
    for (WorkFlow workFlow : workFlows) {
    // WorkflowPojo workflowPojo = getWorkflowConfig(workFlow.getName(), true);
    // if (!CollectionUtils.isEmpty(workflowPojo.getDependTableIds())
    // && workflowPojo.getDependTableIds().contains(datasourceTable.getId())) {
    // action.addErrorMessage(context,
    // "数据库下面的表" + datasourceTable.getTableLogicName() + "仍然被工作流" +
    // workflowPojo.getName() + "占用");
    // return;
    // }
    }
    // 4 删除git
    try {
        GitUser user = GitUser.dft();
        RunEnvironment runEnvironment = action.getAppDomain().getRunEnvironment();
        if (RunEnvironment.DAILY.equals(runEnvironment)) {
            GitUtils.$().deleteTableDaily(datasourceDb.getName(), datasourceTable.getName(), user);
        } else if (RunEnvironment.ONLINE.equals(runEnvironment)) {
            GitUtils.$().deleteTableOnline(datasourceDb.getName(), datasourceTable.getName(), user);
        } else {
            action.addErrorMessage(context, "当前运行环境" + runEnvironment + "既不是daily也不是online");
            return;
        }
    } catch (Exception e) {
        action.addErrorMessage(context, "删除数据库失败");
        action.addErrorMessage(context, e.getMessage());
        return;
    }
    // 5 删除db
    this.workflowDAOFacade.getDatasourceTableDAO().deleteByPrimaryKey(tableId);
    action.addActionMessage(context, "成功删除table");
}
Also used : RunEnvironment(com.qlangtech.tis.pubhook.common.RunEnvironment) SQLException(java.sql.SQLException) GitUser(com.qlangtech.tis.git.GitUtils.GitUser)

Example 4 with RunEnvironment

use of com.qlangtech.tis.pubhook.common.RunEnvironment in project tis by qlangtech.

the class EnvironmentBindService method getInstance.

public T getInstance() {
    AppAndRuntime appAndRuntime = DefaultFilter.getAppAndRuntime();
    if (appAndRuntime == null) {
        appAndRuntime = new AppAndRuntime();
        appAndRuntime.setRuntime(DefaultFilter.getRuntime());
    }
    RunEnvironment runtime = appAndRuntime.getRuntime();
    return this.getInstance(runtime);
}
Also used : RunEnvironment(com.qlangtech.tis.pubhook.common.RunEnvironment) AppAndRuntime(com.qlangtech.tis.manage.common.DefaultFilter.AppAndRuntime)

Example 5 with RunEnvironment

use of com.qlangtech.tis.pubhook.common.RunEnvironment in project tis by qlangtech.

the class SchemaAction method appendNewSchema.

@SuppressWarnings("all")
protected boolean appendNewSchema(Context context, ISchemaPluginContext schemaPlugin, byte[] content, Application app) throws UnsupportedEncodingException, JSONException {
    if (content == null) {
        throw new NullPointerException("param content can not be null");
    }
    Integer publishSnapshotId = null;
    final ServerGroupCriteria gquery = new ServerGroupCriteria();
    final RunEnvironment runtime = RunEnvironment.getSysRuntime();
    gquery.createCriteria().andAppIdEqualTo(app.getAppId()).andRuntEnvironmentEqualTo(runtime.getId()).andGroupIndexEqualTo((short) 0);
    for (ServerGroup group : this.getServerGroupDAO().selectByExample(gquery)) {
        publishSnapshotId = group.getPublishSnapshotId();
        break;
    }
    if (publishSnapshotId == null) {
        throw new IllegalStateException("app:" + app.getProjectName() + " publishSnapshotId can not be null");
    }
    IUser user = this.getUser();
    // new
    Long usrId = Long.parseLong(user.getId());
    // Long(this.getCurrentIsv().getId());
    CreateSnapshotResult result = createNewSnapshot(context, schemaPlugin, this.getSnapshotViewDAO().getView(publishSnapshotId), ConfigFileReader.FILE_SCHEMA, content, this, new IMessageHandler() {

        @Override
        public void errorsPageShow(Context context) {
        }

        @Override
        public void addActionMessage(Context context, String msg) {
            SchemaAction.this.addActionMessage(context, msg);
        }

        @Override
        public void setBizResult(Context context, Object result) {
            SchemaAction.this.setBizResult(context, result);
        }

        @Override
        public void addErrorMessage(Context context, String msg) {
            SchemaAction.this.addErrorMessage(context, msg);
        }
    }, StringUtils.EMPTY, usrId, user.getName());
    if (!result.isSuccess()) {
        List<String> errorMsgList = (List<String>) context.get(BasicModule.ACTION_ERROR_MSG);
        StringBuffer err = new StringBuffer();
        if (errorMsgList != null) {
            for (String e : errorMsgList) {
                err.append(e).append("<br/>");
            }
        }
        JSONObject errors = new JSONObject();
        errors.put("code", 300);
        errors.put("reason", err.toString());
        context.put("query_result", errors);
        return false;
    }
    ServerGroup record = new ServerGroup();
    record.setPublishSnapshotId(result.getNewId());
    // .andGroupIndexEqualTo((short) 0);
    if (this.getServerGroupDAO().updateByExampleSelective(record, gquery) < 0) {
        throw new IllegalStateException("app:" + app.getProjectName() + " upate getServerGroupDAO have not success");
    }
    return true;
}
Also used : Context(com.alibaba.citrus.turbine.Context) RunEnvironment(com.qlangtech.tis.pubhook.common.RunEnvironment) JSONObject(com.alibaba.fastjson.JSONObject) JSONObject(com.alibaba.fastjson.JSONObject)

Aggregations

RunEnvironment (com.qlangtech.tis.pubhook.common.RunEnvironment)9 Context (com.alibaba.citrus.turbine.Context)1 JSONObject (com.alibaba.fastjson.JSONObject)1 ActionProxy (com.opensymphony.xwork2.ActionProxy)1 DumpJobId (com.qlangtech.tis.cloud.dump.DumpJobId)1 DumpJobStatus (com.qlangtech.tis.cloud.dump.DumpJobStatus)1 ITISFileSystem (com.qlangtech.tis.fs.ITISFileSystem)1 GitUser (com.qlangtech.tis.git.GitUtils.GitUser)1 OperationLogCriteria (com.qlangtech.tis.manage.biz.dal.pojo.OperationLogCriteria)1 AppDomainInfo (com.qlangtech.tis.manage.common.AppDomainInfo)1 AppAndRuntime (com.qlangtech.tis.manage.common.DefaultFilter.AppAndRuntime)1 Func (com.qlangtech.tis.manage.spring.aop.Func)1 Rundata (com.qlangtech.tis.runtime.module.action.BasicModule.Rundata)1 V1EnvVar (io.kubernetes.client.openapi.models.V1EnvVar)1 SQLException (java.sql.SQLException)1