@@ -22,6 +22,11 @@ public class ClientConfiguration {
2222 */
2323 public static final int DEFAULT_MAX_RETRIES = 3 ;
2424
25+ /**
26+ * 默认重试间隔时间(毫秒)
27+ */
28+ public static final long DEFAULT_RETRY_INTERVAL_MS = 200 ;
29+
2530 /**
2631 * 默认自动更新签名
2732 */
@@ -45,6 +50,7 @@ public class ClientConfiguration {
4550 public static final ConnectionPool DEFAULT_CONNECTION_POOL = new ConnectionPool ();
4651
4752 private int maxRetries = DEFAULT_MAX_RETRIES ;
53+ private long retryIntervalMs = DEFAULT_RETRY_INTERVAL_MS ;
4854 private long connectTimeout = DEFAULT_CONNECT_TIMEOUT ;
4955 private long readTimeout = DEFAULT_READ_TIMEOUT ;
5056 private long writeTimeout = DEFAULT_WRITE_TIMEOUT ;
@@ -57,13 +63,14 @@ public class ClientConfiguration {
5763 public ClientConfiguration () {
5864 }
5965
60- public ClientConfiguration (int maxRetries , long connectTimeout , long readTimeout , long writeTimeout ,
66+ public ClientConfiguration (int maxRetries , long retryIntervalMs , long connectTimeout , long readTimeout , long writeTimeout ,
6167 long callTimeout , long expireTime , boolean autoRenewSig ,
6268 String userAgent , ConnectionPool connectionPool ) {
6369 if (connectionPool == null ) {
6470 connectionPool = DEFAULT_CONNECTION_POOL ;
6571 }
6672 this .maxRetries = Math .max (0 , maxRetries );
73+ this .retryIntervalMs = retryIntervalMs ;
6774 this .connectTimeout = connectTimeout ;
6875 this .readTimeout = readTimeout ;
6976 this .writeTimeout = writeTimeout ;
@@ -76,6 +83,7 @@ public ClientConfiguration(int maxRetries, long connectTimeout, long readTimeout
7683
7784 private ClientConfiguration (Builder builder ) {
7885 this .maxRetries = builder .maxRetries ;
86+ this .retryIntervalMs = builder .retryIntervalMs ;
7987 this .connectTimeout = builder .connectTimeout ;
8088 this .readTimeout = builder .readTimeout ;
8189 this .writeTimeout = builder .writeTimeout ;
@@ -98,6 +106,14 @@ public void setMaxRetries(int maxRetries) {
98106 this .maxRetries = Math .max (0 , maxRetries );
99107 }
100108
109+ public long getRetryIntervalMs () {
110+ return retryIntervalMs ;
111+ }
112+
113+ public void setRetryIntervalMs (long retryIntervalMs ) {
114+ this .retryIntervalMs = retryIntervalMs ;
115+ }
116+
101117 public long getConnectTimeout () {
102118 return connectTimeout ;
103119 }
@@ -178,6 +194,9 @@ public boolean equals(Object o) {
178194 if (maxRetries != that .maxRetries ) {
179195 return false ;
180196 }
197+ if (retryIntervalMs != that .retryIntervalMs ) {
198+ return false ;
199+ }
181200 if (connectTimeout != that .connectTimeout ) {
182201 return false ;
183202 }
@@ -204,11 +223,12 @@ public boolean equals(Object o) {
204223
205224 @ Override
206225 public int hashCode () {
207- return Objects .hash (maxRetries , connectTimeout , readTimeout , writeTimeout , callTimeout , expireTime , autoRenewSig , userAgent , connectionPool );
226+ return Objects .hash (maxRetries , retryIntervalMs , connectTimeout , readTimeout , writeTimeout , callTimeout , expireTime , autoRenewSig , userAgent , connectionPool );
208227 }
209228
210229 public static final class Builder {
211230 private int maxRetries = DEFAULT_MAX_RETRIES ;
231+ private long retryIntervalMs = DEFAULT_RETRY_INTERVAL_MS ;
212232 private long connectTimeout = DEFAULT_CONNECT_TIMEOUT ;
213233 private long readTimeout = DEFAULT_READ_TIMEOUT ;
214234 private long writeTimeout = DEFAULT_WRITE_TIMEOUT ;
@@ -230,6 +250,11 @@ public Builder maxRetries(int maxRetries) {
230250 return this ;
231251 }
232252
253+ public Builder retryIntervalMs (int retryIntervalMs ) {
254+ this .retryIntervalMs = retryIntervalMs ;
255+ return this ;
256+ }
257+
233258 public Builder connectTimeout (long connectTimeout ) {
234259 this .connectTimeout = connectTimeout ;
235260 return this ;
0 commit comments