Skip to content

Commit

Permalink
support the client request time control (#154)
Browse files Browse the repository at this point in the history
update

update
  • Loading branch information
vintmd authored Aug 20, 2024
1 parent 8e46f19 commit 4df8618
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ public class CosNConfigKeys extends CommonConfigurationKeys {

public static final int DEFAULT_COSN_IDLE_CONNECTION_ALIVE = 60000;

// request time out enable then request timeout and client thread size config work
public static final String COSN_CLIENT_USE_REQUEST_TIMEOUT = "fs.cosn.client.use.request.timeout";
public static final boolean DEFAULT_COSN_CLIENT_USE_REQUEST_TIMEOUT = false;
public static final String COSN_CLIENT_REQUEST_TIMEOUT = "fs.cosn.client.request.timeout";
public static final int DEFAULT_COSN_CLIENT_REQUEST_TIMEOUT = 5 * 60 * 1000; //5min
public static final String COSN_CLIENT_REQUEST_TIMEOUT_THREAD_SIZE = "fs.cosn.client.request.timeout.thread.size";
public static final int DEFAULT_COSN_CLIENT_REQUEST_TIMEOUT_THREAD_SIZE = Runtime.getRuntime().availableProcessors() * 5;

public static final String CUSTOMER_DOMAIN = "fs.cosn.customer.domain";
public static final String COSN_SERVER_SIDE_ENCRYPTION_ALGORITHM = "fs.cosn.server-side-encryption.algorithm";
public static final String COSN_SERVER_SIDE_ENCRYPTION_KEY = "fs.cosn.server-side-encryption.key";
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/apache/hadoop/fs/CosNativeFileSystemStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,19 @@ private void initCOSClient(URI uri, Configuration conf) throws IOException {
config.setShortConnection();
}

if (conf.getBoolean(CosNConfigKeys.COSN_CLIENT_USE_REQUEST_TIMEOUT,
CosNConfigKeys.DEFAULT_COSN_CLIENT_USE_REQUEST_TIMEOUT)) {
config.setRequestTimeOutEnable(true);
config.setRequestTimeout(
conf.getInt(
CosNConfigKeys.COSN_CLIENT_REQUEST_TIMEOUT,
CosNConfigKeys.DEFAULT_COSN_CLIENT_REQUEST_TIMEOUT));
config.setTimeoutClientThreadSize(
conf.getInt(
CosNConfigKeys.COSN_CLIENT_REQUEST_TIMEOUT_THREAD_SIZE,
CosNConfigKeys.DEFAULT_COSN_CLIENT_REQUEST_TIMEOUT_THREAD_SIZE));
}

config.setMaxConnectionsCount(
conf.getInt(
CosNConfigKeys.MAX_CONNECTION_NUM,
Expand Down

0 comments on commit 4df8618

Please sign in to comment.