-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from aliyun/feature/release-v1.1.7
Feature/release v1.1.7
- Loading branch information
Showing
540 changed files
with
42,825 additions
and
6,503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...rationx-common/src/main/java/com/aliyun/migrationx/common/context/TransformerContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...common/src/main/java/com/aliyun/migrationx/common/exception/UnSupportedTypeException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.