Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.qcloud</groupId>
<artifactId>cos_migrate_tool</artifactId>
<version>1.4.11</version>
<version>1.4.12</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -52,7 +52,7 @@
<dependency>
<groupId>com.qcloud</groupId>
<artifactId>cos_api</artifactId>
<version>5.6.58</version>
<version>5.6.126</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public class CommonConfig {
private String sk;
private String token;
private String cosPath;
private boolean enableHttps;
private boolean enableHttps = false;
private boolean isShortConnection = false;
private boolean entireFileMd5Attached;
private int taskExecutorNumber = 68;
private StorageClass storageClass = StorageClass.Standard;
Expand Down Expand Up @@ -525,4 +526,19 @@ public long getBigFileUploadPartSize() {
public void setBigFileUploadPartSize(long bigFileUploadPartSize) {
this.bigFileUploadPartSize = bigFileUploadPartSize;
}

public boolean isShortConnection() {
return isShortConnection;
}

public void setShortConnection(String shortConnection) throws IllegalArgumentException {
if (shortConnection.equalsIgnoreCase("true")) {
isShortConnection = true;
} else if (shortConnection.equalsIgnoreCase("false")) {
isShortConnection = false;
} else {
throw new IllegalArgumentException("invalid short connection config. only support true/false");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class ConfigParser {
private static final String COMMON_COSPATH = "cosPath";
private static final String COMMON_DB_COSPATH = "dbCosPath";
private static final String COMMON_HTTPS = "https";
private static final String COMMON_SHORT_CONNECTION = "shortConnection";
private static final String COMMON_TMP = "tmpFolder";
private static final String COMMON_SMALL_FILE_ThRESHOLD = "smallFileThreshold";
private static final String COMMON_STORAGE_CLASS = "storageClass";
Expand Down Expand Up @@ -489,6 +490,11 @@ private boolean initCommonConfig(Preferences prefs, CommonConfig commonConfig) {
assert (enableHttpsStr != null);
commonConfig.setEnableHttps(enableHttpsStr);

String shortConnectionStr = getConfigValue(prefs, COMMON_SECTION_NAME, COMMON_SHORT_CONNECTION);
if (shortConnectionStr != null && !shortConnectionStr.trim().isEmpty()) {
commonConfig.setShortConnection(shortConnectionStr);
}

String tmpFolder = getConfigValue(prefs, COMMON_SECTION_NAME, COMMON_TMP);
assert (tmpFolder != null);
commonConfig.setTempFileFolder(tmpFolder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public MigrateCopyBucketTaskExecutor(CopyBucketConfig config) {
clientConfig.setHttpProtocol(HttpProtocol.http);
}

// 源也是cos的,就直接使用一样的配置,没有再像从其他云一样使用单独的src配置
if (config.isShortConnection()) {
clientConfig.setShortConnection();
}

if (config.getSrcEndpointSuffix() != null) {
clientConfig.setEndPointSuffix(config.getSrcEndpointSuffix());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public MigrateCspTaskExecutor(CopyFromCspConfig config) {
clientConfig.setHttpProtocol(HttpProtocol.http);
}

// 没有使用common config里的短链接,csp一般没有公有云一样的问题

clientConfig.setRegion(new Region(""));
clientConfig.setEndpointBuilder(new SuffixEndpointBuilder(config.getSrcEndpoint()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ public TaskExecutor(MigrateType migrateType, CommonConfig config) {
clientConfig.setHttpProxyPort(config.getProxyPort());
}

if (config.isShortConnection()) {
clientConfig.setShortConnection();
}

if (config.getClientEncrypt()) {
this.cosClient = createEncryptClient(config, cred, clientConfig);
} else {
Expand Down