Skip to content

Commit

Permalink
Merge branch 'master' into hotfix/compiler-error
Browse files Browse the repository at this point in the history
  • Loading branch information
Garfier authored Sep 11, 2024
2 parents a76ff31 + 76a0135 commit ae71c48
Show file tree
Hide file tree
Showing 568 changed files with 43,739 additions and 5,682 deletions.
47 changes: 31 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
- name: DeepSource Test Coverage Action
# You may pin to the exact commit or the version.
# uses: DeepSourceCorp/test-coverage-action@e02a039827236fa21a95866e7cd0b1c52ca61e76
uses: DeepSourceCorp/test-coverage-action@v1.1.2
with:
# Programming language shortcode for which coverage is reported. Allowed values are — python, go, javascript, ruby, java, kotlin, scala, php, csharp, cxx, rust, swift
key:
# Path to the coverage data file. e.g. ./coverage.xml
coverage-file:
# DeepSource DSN of this repository. It is available under Settings → Reporting tab of the repository page on DeepSource.
dsn:
# Should the CI build fail if there is an error while uploading the report to DeepSource? Allowed values are — true, false
fail-ci-on-error: # optional
# HEAD commit for which the Test Coverage report is being sent
commit-sha: # optional, default is ${{ github.event.pull_request.head.sha }}

name: Java CI with Maven

on:
push:
branches: [ "main" ] # 触发分支
pull_request:
branches: [ "main" ] # 触发分支

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin' # 选择一个Java发行版
cache: maven # 缓存m2仓库以加速构建
- name: Build with Maven
run: mvn -B clean package --file pom.xml
- name: Run JUnit tests
run: mvn -B verify --file pom.xml
- name: Archive test results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results
path: target/surefire-reports/
2 changes: 1 addition & 1 deletion README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ MigrationX 是一款基于 FlowSpec 规范的工作流迁移工具,它可以

## 整体架构

![image](docs/images/architecture.jpg)
![image](docs/images/architecture-cn.jpg)

### 领域模型

Expand Down
39 changes: 28 additions & 11 deletions client/migrationx-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@
<parent>
<artifactId>migrationx</artifactId>
<groupId>com.aliyun.dataworks</groupId>
<version>1.1.5</version>
<version>1.1.7-workflow-preview3</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>migrationx-common</artifactId>
<version>1.1.5</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
Expand All @@ -42,13 +38,9 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
Expand Down Expand Up @@ -95,10 +87,35 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,27 @@

package com.aliyun.migrationx.common.command.appbase;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Map;

import com.aliyun.migrationx.common.exception.BizException;
import com.aliyun.migrationx.common.exception.ErrorCode;
import com.aliyun.migrationx.common.utils.GsonUtils;

import com.google.common.base.Joiner;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.cli.*;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Map;

/**
* @author 聿剑
* @date 2022/10/20
Expand Down Expand Up @@ -85,10 +91,10 @@ private static Map<AppType, Map<String, AppMeta>> loadApps(String conf) throws I
appMeta.setName(appName);
appMeta.setType(appType);
log.info("register command app type: {}, name: {}, class: {}", appType, appName, appMeta.getAppClass());
CommandAppFactory.register(appType, appName, (Class<? extends CommandApp>)Class.forName(appMeta.getAppClass()));
CommandAppFactory.register(appType, appName, (Class<? extends CommandApp>) Class.forName(appMeta.getAppClass()));
} catch (ClassNotFoundException e) {
log.info("register command app failed, appType: {}, appName: {}, class: {}, error: {}",
appType, appName, appMeta.getAppClass(), e.getMessage());
appType, appName, appMeta.getAppClass(), e);
}
}));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.aliyun.migrationx.common.context;

import java.io.File;
import java.io.FileNotFoundException;

import com.aliyun.migrationx.common.metrics.DolphinMetricsCollector;
import com.aliyun.migrationx.common.metrics.MetricsCollector;
import com.aliyun.migrationx.common.metrics.enums.CollectorType;

import org.apache.commons.lang3.StringUtils;

public class TransformerContext {
private static final ThreadLocal<TransformerContext> threadLocal = new ThreadLocal<>();

private MetricsCollector metricsCollector;

private File checkpoint;
private File load;

public File getCheckpoint() {
return checkpoint;
}

public void setCheckpoint(String checkpoint) throws FileNotFoundException {
if (StringUtils.isNotEmpty(checkpoint)) {
File file = new File(checkpoint);
if (file.exists()) {
this.checkpoint = file;
} else {
throw new FileNotFoundException(checkpoint);
}
}
}

public File getLoad() {
return load;
}

public void setLoad(String load) throws FileNotFoundException {
if (StringUtils.isNotEmpty(load)) {
File file = new File(load);
if (file.exists()) {
this.load = file;
} else {
throw new FileNotFoundException(load);
}
}
}

private TransformerContext() {
}

public static void init(CollectorType type) {
TransformerContext context = new TransformerContext();
switch (type) {
case DolphinScheduler:
context.metricsCollector = new DolphinMetricsCollector();
break;
default:
throw new UnsupportedOperationException(type.name());
}
threadLocal.set(context);
}

public static TransformerContext getContext() {
return threadLocal.get();
}

public static MetricsCollector getCollector() {
return threadLocal.get().metricsCollector;
}

public static void clear() {
threadLocal.remove();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.aliyun.migrationx.common.exception;

public class UnSupportedTypeException extends RuntimeException {
private String type;

public UnSupportedTypeException(String type) {
super("unsupported converter task type: " + type);
this.type = type;
}
}
Loading

0 comments on commit ae71c48

Please sign in to comment.