Skip to content

Commit

Permalink
feat: add read/connect timeout param
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangdingxin484 committed May 23, 2024
1 parent 5b6d553 commit 0b6db51
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ public void setHttpsCheck(boolean httpsCheck) {
* when this flag is true, [use project xxx] command with default trigger [use project xxx --with-settings]
*/
private boolean useProjectWithSettings = false;
private int readTimeout;
private int connectTimeout;


public boolean isInitialized() {
return initialized;
Expand Down Expand Up @@ -582,6 +585,9 @@ public static ExecutionContext load(String config) throws ODPSConsoleException {
String interactiveSessionName = properties.getProperty(ODPSConsoleConstants.INTERACTIVE_SERVICE_NAME);
String interactiveOutputCompatible = properties.getProperty(ODPSConsoleConstants.INTERACTIVE_OUTPUT_COMPATIBLE);

String readTimeout = properties.getProperty(ODPSConsoleConstants.NETWORK_READ_TIMEOUT);
String connectTimeout = properties.getProperty(ODPSConsoleConstants.NETWORK_CONNECT_TIMEOUT);

context.setOdpsCupidProxyEndpoint(odpsCupidProxyEndpoint);

context.setLogViewHost(logViewHost);
Expand Down Expand Up @@ -747,6 +753,12 @@ public static ExecutionContext load(String config) throws ODPSConsoleException {
context.predefinedSetCommands.put(key, value);
}
}
if (!StringUtils.isNullOrEmpty(readTimeout)) {
context.setReadTimeout(Integer.parseInt(readTimeout));
}
if (!StringUtils.isNullOrEmpty(connectTimeout)) {
context.setConnectTimeout(Integer.parseInt(connectTimeout));
}

} catch (Exception e) {
throw new ODPSConsoleException(ODPSConsoleConstants.LOAD_CONFIG_ERROR, e);
Expand Down Expand Up @@ -996,4 +1008,17 @@ public boolean isUseProjectWithSettings() {
public void setUseProjectWithSettings(boolean useProjectWithSettings) {
this.useProjectWithSettings = useProjectWithSettings;
}

public void setReadTimeout(int readTimeout) {
this.readTimeout = readTimeout;
}
public int getReadTimeout() {
return readTimeout;
}
public void setConnectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
}
public int getConnectTimeout() {
return connectTimeout;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ public class ODPSConsoleConstants {
public static final String INTERACTIVE_MAX_ATTACH = "interactive_max_attach";
public static final String ATTACH_SESSION_TIMEOUT = "attach_session_timeout";

public static final String NETWORK_READ_TIMEOUT = "network_read_timeout";
public static final String NETWORK_CONNECT_TIMEOUT = "network_connect_timeout";

public static final String FALLBACK_PREFIX = "fallback.";
public static final String FALLBACK_RESOURCE_NOT_ENOUGH = "fallback.resource";
public static final String FALLBACK_UNSUPPORTED = "fallback.unsupported";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public Odps create(ExecutionContext context) throws ODPSConsoleException {
if (!context.isHttpsCheck()) {
odps.getRestClient().setIgnoreCerts(true);
}
odps.getRestClient().setReadTimeout(context.getReadTimeout());
odps.getRestClient().setConnectTimeout(context.getConnectTimeout());

odps.setLogViewHost(context.getLogViewHost());
odps.getRestClient().setRetryLogger(new OdpsRetryLogger());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -875,13 +875,6 @@ public static Options getUpsertOptions() {
"specify strict schema mode. If false, extra data will be abandoned and insufficient field will be filled with null. Default "
+ Constants.DEFAULT_STRICT_SCHEMA)
.build());
opts.addOption(
Option.builder("ow")
.longOpt(Constants.OVERWRITE)
.hasArg()
.argName("true | false")
.desc("overwrite specified table or partition, default: " + Constants.DEFAULT_OVERWRITE)
.build());
return opts;
}

Expand Down

0 comments on commit 0b6db51

Please sign in to comment.