mirror of
https://github.com/alibaba/DataX.git
synced 2025-05-02 18:11:01 +08:00
修改overwrite为truncate
This commit is contained in:
parent
ed59373005
commit
bcf800e7bf
@ -81,10 +81,10 @@ public class HdfsWriter extends Writer {
|
||||
//writeMode check
|
||||
this.writeMode = this.writerSliceConfig.getNecessaryValue(Key.WRITE_MODE, HdfsWriterErrorCode.REQUIRED_VALUE);
|
||||
writeMode = writeMode.toLowerCase().trim();
|
||||
Set<String> supportedWriteModes = Sets.newHashSet("append", "nonconflict", "overwrite");
|
||||
Set<String> supportedWriteModes = Sets.newHashSet("append", "nonconflict", "truncate");
|
||||
if (!supportedWriteModes.contains(writeMode)) {
|
||||
throw DataXException.asDataXException(HdfsWriterErrorCode.ILLEGAL_VALUE,
|
||||
String.format("仅支持append, nonConflict, overwrite三种模式, 不支持您配置的 writeMode 模式 : [%s]",
|
||||
String.format("仅支持append, nonConflict, truncate三种模式, 不支持您配置的 writeMode 模式 : [%s]",
|
||||
writeMode));
|
||||
}
|
||||
this.writerSliceConfig.set(Key.WRITE_MODE, writeMode);
|
||||
@ -179,8 +179,8 @@ public class HdfsWriter extends Writer {
|
||||
LOG.error(String.format("冲突文件列表为: [%s]", StringUtils.join(allFiles, ",")));
|
||||
throw DataXException.asDataXException(HdfsWriterErrorCode.ILLEGAL_VALUE,
|
||||
String.format("由于您配置了writeMode nonConflict,但您配置的path: [%s] 目录不为空, 下面存在其他文件或文件夹.", path));
|
||||
}else if ("overwrite".equalsIgnoreCase(writeMode) && isExistFile) {
|
||||
LOG.info(String.format("由于您配置了writeMode overwrite, [%s] 下面的内容将被覆盖重写", path));
|
||||
}else if ("truncate".equalsIgnoreCase(writeMode) && isExistFile) {
|
||||
LOG.info(String.format("由于您配置了writeMode truncate, [%s] 下面的内容将被覆盖重写", path));
|
||||
hdfsHelper.deleteFiles(existFilePaths);
|
||||
}
|
||||
}else{
|
||||
|
Loading…
Reference in New Issue
Block a user