@@ -43,6 +43,7 @@ public class SourceDestConfig extends GCPConfig {
4343 public static final String NAME_SOURCE_PATH = "sourcePath" ;
4444 public static final String NAME_DEST_PATH = "destPath" ;
4545 public static final String NAME_LOCATION = "location" ;
46+ public static final String READ_TIMEOUT = "readTimeout" ;
4647
4748 @ Name (NAME_SOURCE_PATH )
4849 @ Macro
@@ -74,15 +75,25 @@ public class SourceDestConfig extends GCPConfig {
7475 " at https://cloud.google.com/data-fusion/docs/how-to/customer-managed-encryption-keys" )
7576 protected String cmekKey ;
7677
78+ @ Name (READ_TIMEOUT )
79+ @ Macro
80+ @ Nullable
81+ @ Description ("Timeout in seconds to read data from an established HTTP connection (Default value is 20). " +
82+ ("For performing copy/move operation on large files in GCS buckets, set a higher value. " +
83+ "Set it to 0 for infinite(no limit)" ))
84+ protected Integer readTimeout ;
85+
7786 public SourceDestConfig (@ Nullable String project , @ Nullable String serviceAccountType ,
7887 @ Nullable String serviceFilePath , @ Nullable String serviceAccountJson ,
79- @ Nullable String destPath , @ Nullable String location , @ Nullable String cmekKey ) {
88+ @ Nullable String destPath , @ Nullable String location , @ Nullable Integer readTimeout ,
89+ @ Nullable String cmekKey ) {
8090 this .serviceAccountType = serviceAccountType ;
8191 this .serviceAccountJson = serviceAccountJson ;
8292 this .serviceFilePath = serviceFilePath ;
8393 this .project = project ;
8494 this .destPath = destPath ;
8595 this .location = location ;
96+ this .readTimeout = readTimeout ;
8697 this .cmekKey = cmekKey ;
8798 }
8899
@@ -125,9 +136,22 @@ public void validate(FailureCollector collector, Map<String, String> arguments)
125136 if (!containsMacro (NAME_CMEK_KEY )) {
126137 validateCmekKey (collector , arguments );
127138 }
139+ if (!containsMacro (READ_TIMEOUT )) {
140+ validateReadTimeout (collector );
141+ }
128142 collector .getOrThrowException ();
129143 }
130144
145+ void validateReadTimeout (FailureCollector collector ) {
146+ if (readTimeout == null ) {
147+ return ;
148+ }
149+ if (readTimeout < 0 ) {
150+ collector .addFailure ("Read Timeout cannot be less than 0. " ,
151+ "Please enter 0 or a positive value." ).withConfigProperty (READ_TIMEOUT );
152+ }
153+ }
154+
131155 //This method validated the pattern of CMEK Key resource ID.
132156 void validateCmekKey (FailureCollector failureCollector , Map <String , String > arguments ) {
133157 CryptoKeyName cmekKeyName = CmekUtils .getCmekKey (cmekKey , arguments , failureCollector );
@@ -161,6 +185,7 @@ public static class Builder {
161185 private String destPath ;
162186 private String cmekKey ;
163187 private String location ;
188+ private Integer readTimeout ;
164189
165190 public SourceDestConfig .Builder setProject (@ Nullable String project ) {
166191 this .project = project ;
@@ -205,6 +230,7 @@ public SourceDestConfig build() {
205230 serviceAccountJson ,
206231 destPath ,
207232 location ,
233+ readTimeout ,
208234 cmekKey
209235 );
210236 }
0 commit comments