Skip to content

Commit 81f7cab

Browse files
authored
Merge pull request #289 from NigelWu95/dev
Dev
2 parents 0a01803 + 24c92e0 commit 81f7cab

11 files changed

Lines changed: 64 additions & 37 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ resources/.*
2626
assembly/
2727
.DS_Store
2828

29-
logs/
29+
logs*

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version=8.3.12
2+
3+
package_no_test:
4+
mvn package -Dmaven.test.skip=true
5+
6+
deploy_no_test:
7+
mvn clean deploy -P release -Dmaven.test.skip=true
8+
9+
release_jar_to_devtools:
10+
qsuits -s -path=target/qsuits-$(version)-jar-with-dependencies.jar -process=qupload -a=devtools -bucket=devtools -keep-path=false
11+
12+
clean_logs:
13+
rm -rf logs*
14+
15+
clean:
16+
mvn clean
17+
18+
build:
19+
mvn package -Dmaven.test.skip=true
20+
[ -d ~/.qsuits ] || mkdir ~/.qsuits
21+
cp target/qsuits-$(version)-jar-with-dependencies.jar ~/.qsuits/qsuits-$(version).jar

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ qsuits -config=config.txt
137137
```
138138
qsuits -path=qiniu://<bucket> -ak=<ak> -sk=<sk>
139139
```
140-
**注意**:qsuits 执行器依然依赖 java 环境(8 或以上),但是执行器会去检测本地 java 环境,在无匹配的 java 环境时会提示推荐的安装方法并且该执行
141-
器在运行时默认会选择最新的 qsuits-java 版本,其他选项参考 qsuits-exec-go 的文档:https://github.com/NigelWu95/qsuits-exec-go
140+
**注意**:qsuits 执行器依然依赖 java 环境(8 或以上),但是执行器会去检测本地 java 环境,在无匹配的 java 环境时会提示推荐的安装方法并且该执行
141+
器可以选择更新到 qsuits.jar 的最新版本再运行,其他选项参考 qsuits-exec-go 的文档:https://github.com/NigelWu95/qsuits-exec-go
142142

143143
#### 程序依赖 jar
144144
引入 jar 包([下载 jar 包](https://search.maven.org/search?q=a:qsuits)或者 [使用 maven 仓库](https://mvnrepository.com/artifact/com.qiniu/qsuits)),
@@ -315,9 +315,8 @@ rm-fields=
315315
#### 关于 save-total
316316
(1)用于选择是否直接保存数据源完整输出结果,针对存在过滤条件或下一步处理过程时是否需要保存原始数据,如 bucket 的 list 操作需要在列举出结果之后再针
317317
对字段进行过滤或者做删除,save-total=true 则表示保存列举出来的完整数据,而过滤的结果会单独保存,如果只需要过滤之后的数据,则设置为 false,如
318-
果是删除等操作,通常删除结果会直接保存文件名和删除结果,原始数据也不需要保存。
319-
(1)本地文件数据源时默认如果存在 process 或者 filter 则设置 save-total=false,反之则设置 save-total=true(说明可能是单纯格式转换)。
320-
(2)云存储数据源时默认设置 save-total=true。
318+
果是删除等操作,通常删除结果会直接保存文件名和删除结果,原始数据也不需要保存则设置 save-total=false。
319+
(2)如果存在 process 或者 filter 则默认设置 save-total=false,反之则 save-total=true(说明可能是单纯列举云存储资源或者本地数据格式转换)。
321320
(3)保存结果的路径 **默认(save-path)使用 <bucket\>(云存储数据源情况下)名称或者 <path\>-result 来创建目录**
322321

323322
#### 关于 save-format

docs/resultsave.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ rm-fields=
2222
### 关于 save-total
2323
(1)用于选择是否直接保存数据源完整输出结果,针对存在过滤条件或下一步处理过程时是否需要保存原始数据,如 bucket 的 list 操作需要在列举出结果之后再针
2424
对字段进行过滤或者做删除,save-total=true 则表示保存列举出来的完整数据,而过滤的结果会单独保存,如果只需要过滤之后的数据,则设置为 false,如
25-
果是删除等操作,通常删除结果会直接保存文件名和删除结果,原始数据也不需要保存。
26-
(1)本地文件数据源时默认如果存在 process 或者 filter 则设置 save-total=false,反之则设置 save-total=true(说明可能是单纯格式转换)。
27-
(2)云存储数据源时默认设置 save-total=true。
25+
果是删除等操作,通常删除结果会直接保存文件名和删除结果,原始数据也不需要保存则设置 save-total=false。
26+
(2)如果存在 process 或者 filter 则默认设置 save-total=false,反之则 save-total=true(说明可能是单纯列举云存储资源或者本地数据格式转换)。
2827
(3)保存结果的路径 **默认(save-path)使用 <bucket\>(云存储数据源情况下)名称或者 <path\>-result 来创建目录**
2928

3029
### 关于 save-format

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.qiniu</groupId>
88
<artifactId>qsuits</artifactId>
9-
<version>8.3.11</version>
9+
<version>8.3.12</version>
1010
<name>qsuits</name>
1111
<description>qiniu-suits is a efficient tools for qiniu api implemented by java8.</description>
1212
<url>https://github.com/NigelWu95/qiniu-suits-java</url>

src/main/java/com/qiniu/datasource/FileContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ private void directoriesListing() throws Exception {
559559
@Override
560560
public void export() throws Exception {
561561
String info = processor == null ? String.join(" ", "list files from path:", path) :
562-
String.join(" ", "read files from path: ", path, "and", processor.getProcessName());
562+
String.join(" ", "read files from path:", path, "and", processor.getProcessName());
563563
rootLogger.info("{} running...", info);
564564
rootLogger.info("order\tprefix\tquantity");
565565
showdownHook();

src/main/java/com/qiniu/entry/CommonParams.java

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ public CommonParams(Map<String, String> paramsMap) throws Exception {
239239
case "copy":
240240
case "move":
241241
case "rename":
242-
if (!fromLine) mapLine.put("key", entryParam.getValue("key", ""));
242+
if (!fromLine) mapLine.put("key", entryParam.getValue("key", entryParam.getParamsMap().containsKey("key") ? "" : null));
243243
indexMap.put("toKey", "toKey");
244-
mapLine.put("toKey", entryParam.getValue("to-key", ""));
244+
mapLine.put("toKey", entryParam.getValue("to-key", entryParam.getParamsMap().containsKey("to-key") ? "" : null));
245245
break;
246246
case "download":
247247
case "fetch":
@@ -305,13 +305,13 @@ public CommonParams(Map<String, String> paramsMap) throws Exception {
305305
setSaveSeparator();
306306
break;
307307
case "qupload":
308-
String key = entryParam.getValue("key", "");
308+
String key = entryParam.getValue("key", entryParam.getParamsMap().containsKey("key") ? "" : null);
309309
if (!fromLine) mapLine.put("key", key);
310-
String filepath = entryParam.getValue("filepath", "");
310+
String filepath = entryParam.getValue("filepath", entryParam.getValue("path", ""));
311311
if (!"".equals(filepath)) {
312312
indexMap.put("filepath", "filepath");
313313
mapLine.put("filepath", filepath);
314-
} else if ("".equals(key)) {
314+
} else if (key == null || "".equals(key)) {
315315
throw new IOException("filepath and key shouldn't all be empty, file must be found with them.");
316316
}
317317
break;
@@ -1218,29 +1218,35 @@ private void setRetryTimes() throws IOException {
12181218
private void setSaveTotal() throws IOException {
12191219
String saveTotal = entryParam.getValue("save-total", "").trim();
12201220
if ("".equals(saveTotal)) {
1221-
if (isStorageSource) {
1222-
saveTotal = "true";
1223-
//(2)云存储数据源时如果无 process 则为 true,如果存在 process 但不包含 filter 设置时为 false,既存在 process 同时包含 filter 设置时为 true。
1221+
if ((process != null && !"".equals(process))) {
1222+
this.saveTotal = "delete".equals(process);
1223+
} else {
1224+
this.saveTotal = baseFilter == null && seniorFilter == null;
1225+
}
1226+
// if (isStorageSource) {
1227+
// this.saveTotal = true;
1228+
//(2)云存储数据源时如果无 process 则 saveTotal 默认为 true,如果存在 process 则 saveTotal 默认为 false。
12241229
// if (process == null || "".equals(process)) {
1225-
// saveTotal = "true";
1230+
// this.saveTotal = true;
12261231
// } else {
1227-
// if (baseFilter != null || seniorFilter != null) saveTotal = "true";
1228-
// else saveTotal = "false";
1232+
// if (baseFilter != null || seniorFilter != null) this.saveTotal = true;
1233+
// else this.saveTotal = false;
12291234
// }
1230-
} else {
1235+
// } else {
12311236
// if (isSelfUpload) { // 自上传时将上传路径的路径等信息做下保存
1232-
// saveTotal = "true";
1237+
// this.saveTotal = true;
12331238
// }
12341239
// else
1235-
if ((process != null && !"".equals(process)) || baseFilter != null || seniorFilter != null) {
1236-
saveTotal = "false";
1237-
} else {
1238-
saveTotal = "true";
1239-
}
1240-
}
1240+
// if ((process != null && !"".equals(process)) || baseFilter != null || seniorFilter != null) {
1241+
// this.saveTotal = false;
1242+
// } else {
1243+
// this.saveTotal = true;
1244+
// }
1245+
// }
1246+
} else {
1247+
ParamsUtils.checked(saveTotal, "save-total", "(true|false)");
1248+
this.saveTotal = Boolean.parseBoolean(saveTotal);
12411249
}
1242-
ParamsUtils.checked(saveTotal, "save-total", "(true|false)");
1243-
this.saveTotal = Boolean.parseBoolean(saveTotal);
12441250
}
12451251

12461252
private void setSavePath() throws IOException {

src/main/java/com/qiniu/process/Base.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public void setAutoIncrease(boolean autoIncrease) {
6666
public void setBatchSize(int batchSize) throws IOException {
6767
if (!ProcessUtils.canBatch(processName)) {
6868
throw new IOException(processName + " is not support batch operation.");
69-
} else if (batchSize > 1000 || batchSize < 1) {
70-
throw new IOException("batch size must less than 1000 and more than 1.");
69+
} else if (batchSize > 1000 || batchSize < 0) {
70+
throw new IOException("batch size must less than 1000 and more than 0.");
7171
} else {
7272
this.batchSize = batchSize;
7373
}

src/main/java/com/qiniu/process/qiniu/CdnUrlProcess.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ public void closeResource() {
185185
batches = null;
186186
lines = null;
187187
cdnApplier = null;
188-
if (saveIndex != null) saveIndex.decrementAndGet();
188+
saveIndex = null;
189+
} else {
190+
saveIndex.decrementAndGet();
189191
}
190192
}
191193
}

src/main/java/com/qiniu/process/qiniu/StatFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public StatFile(String accessKey, String secretKey, Configuration configuration,
4040
String format, String separator, List<String> rmFields, int saveIndex) throws IOException {
4141
super("stat", accessKey, secretKey, bucket, savePath, saveIndex);
4242
set(configuration, rmFields, format, separator);
43-
this.batchSize = 1000;
43+
this.batchSize = 100;
4444
this.batchOperations = new BatchOperations();
4545
this.lines = new ArrayList<>();
4646
this.bucketManager = new BucketManager(Auth.create(accessKey, secretKey), configuration.clone());

0 commit comments

Comments
 (0)