public Long copy()

in streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/SparkApplicationManageServiceImpl.java [322:398]


    public Long copy(SparkApplication appParam) {
        boolean existsByAppName = this.existsByAppName(appParam.getAppName());
        ApiAlertException.throwIfFalse(
            !existsByAppName,
            "[StreamPark] Application names can't be repeated, copy application failed.");

        SparkApplication oldApp = getById(appParam.getId());
        SparkApplication newApp = new SparkApplication();

        newApp.setTeamId(oldApp.getTeamId());
        newApp.setJobType(oldApp.getJobType());
        newApp.setAppType(oldApp.getAppType());
        newApp.setVersionId(oldApp.getVersionId());
        newApp.setAppName(appParam.getAppName());
        newApp.setDeployMode(oldApp.getDeployMode());
        newApp.setResourceFrom(oldApp.getResourceFrom());
        newApp.setProjectId(oldApp.getProjectId());
        newApp.setModule(oldApp.getModule());
        newApp.setMainClass(oldApp.getMainClass());
        newApp.setJar(oldApp.getJar());
        newApp.setJarCheckSum(oldApp.getJarCheckSum());
        newApp.setAppProperties(oldApp.getAppProperties());
        newApp.setAppArgs(appParam.getAppArgs() != null ? appParam.getAppArgs() : oldApp.getAppArgs());
        newApp.setYarnQueue(oldApp.getYarnQueue());
        newApp.resolveYarnQueue();
        newApp.setK8sMasterUrl(oldApp.getK8sMasterUrl());
        newApp.setK8sContainerImage(oldApp.getK8sContainerImage());
        newApp.setK8sImagePullPolicy(oldApp.getK8sImagePullPolicy());
        newApp.setK8sServiceAccount(oldApp.getK8sServiceAccount());
        newApp.setK8sNamespace(oldApp.getK8sNamespace());
        newApp.setK8sDriverPodTemplate(oldApp.getK8sDriverPodTemplate());
        newApp.setK8sExecutorPodTemplate(oldApp.getK8sExecutorPodTemplate());
        newApp.setK8sHadoopIntegration(oldApp.getK8sHadoopIntegration());

        newApp.setHadoopUser(oldApp.getHadoopUser());
        newApp.setRestartSize(oldApp.getRestartSize());
        newApp.setState(SparkAppStateEnum.ADDED.getValue());
        newApp.setOptions(oldApp.getOptions());
        newApp.setOptionState(OptionStateEnum.NONE.getValue());
        newApp.setUserId(ServiceHelper.getUserId());
        newApp.setDescription(oldApp.getDescription());
        newApp.setRelease(ReleaseStateEnum.NEED_RELEASE.get());
        newApp.setAlertId(oldApp.getAlertId());
        newApp.setCreateTime(new Date());
        newApp.setModifyTime(newApp.getCreateTime());
        newApp.setTags(oldApp.getTags());

        Application application = applicationService.create(EngineTypeEnum.SPARK);
        newApp.setId(application.getId());

        boolean saved = save(newApp);
        if (saved) {
            if (newApp.isSparkSqlJob()) {
                SparkSql copySparkSql = sparkSqlService.getLatestSparkSql(appParam.getId(), true);
                newApp.setSparkSql(copySparkSql.getSql());
                newApp.setTeamResource(copySparkSql.getTeamResource());
                newApp.setDependency(copySparkSql.getDependency());
                SparkSql sparkSql = new SparkSql(newApp);
                sparkSqlService.create(sparkSql);
            }
            SparkApplicationConfig copyConfig = configService.getEffective(appParam.getId());
            if (copyConfig != null) {
                SparkApplicationConfig config = new SparkApplicationConfig();
                config.setAppId(newApp.getId());
                config.setFormat(copyConfig.getFormat());
                config.setContent(copyConfig.getContent());
                config.setCreateTime(new Date());
                config.setVersion(1);
                configService.save(config);
                configService.setLatestOrEffective(true, config.getId(), newApp.getId());
            }
            return newApp.getId();
        } else {
            throw new ApiAlertException(
                "create application from copy failed, copy source app: " + oldApp.getAppName());
        }
    }