19
19
20
20
package org .elasticsearch .repositories .gcs ;
21
21
22
+ import org .apache .logging .log4j .Logger ;
22
23
import org .elasticsearch .cluster .metadata .RepositoryMetaData ;
23
24
import org .elasticsearch .common .Strings ;
24
25
import org .elasticsearch .common .blobstore .BlobPath ;
28
29
import org .elasticsearch .common .settings .Setting ;
29
30
import org .elasticsearch .common .unit .ByteSizeUnit ;
30
31
import org .elasticsearch .common .unit .ByteSizeValue ;
32
+ import org .elasticsearch .common .unit .TimeValue ;
31
33
import org .elasticsearch .common .xcontent .NamedXContentRegistry ;
32
34
import org .elasticsearch .env .Environment ;
33
35
import org .elasticsearch .repositories .RepositoryException ;
46
48
47
49
class GoogleCloudStorageRepository extends BlobStoreRepository {
48
50
51
+ private final Logger logger = ESLoggerFactory .getLogger (GoogleCloudStorageRepository .class );
52
+ private final DeprecationLogger deprecationLogger = new DeprecationLogger (logger );
53
+
49
54
// package private for testing
50
55
static final ByteSizeValue MIN_CHUNK_SIZE = new ByteSizeValue (1 , ByteSizeUnit .BYTES );
51
56
static final ByteSizeValue MAX_CHUNK_SIZE = new ByteSizeValue (100 , ByteSizeUnit .MB );
52
57
53
58
static final String TYPE = "gcs" ;
54
59
60
+ static final TimeValue NO_TIMEOUT = timeValueMillis (-1 );
61
+
55
62
static final Setting <String > BUCKET =
56
63
simpleString ("bucket" , Property .NodeScope , Property .Dynamic );
57
64
static final Setting <String > BASE_PATH =
@@ -62,6 +69,18 @@ class GoogleCloudStorageRepository extends BlobStoreRepository {
62
69
byteSizeSetting ("chunk_size" , MAX_CHUNK_SIZE , MIN_CHUNK_SIZE , MAX_CHUNK_SIZE , Property .NodeScope , Property .Dynamic );
63
70
static final Setting <String > CLIENT_NAME = new Setting <>("client" , "default" , Function .identity ());
64
71
72
+ @ Deprecated
73
+ static final Setting <String > APPLICATION_NAME =
74
+ new Setting <>("application_name" , "" , Function .identity (), Property .NodeScope , Property .Dynamic );
75
+
76
+ @ Deprecated
77
+ static final Setting <TimeValue > HTTP_READ_TIMEOUT =
78
+ timeSetting ("http.read_timeout" , NO_TIMEOUT , Property .NodeScope , Property .Dynamic );
79
+
80
+ @ Deprecated
81
+ static final Setting <TimeValue > HTTP_CONNECT_TIMEOUT =
82
+ timeSetting ("http.connect_timeout" , NO_TIMEOUT , Property .NodeScope , Property .Dynamic );
83
+
65
84
private final ByteSizeValue chunkSize ;
66
85
private final boolean compress ;
67
86
private final BlobPath basePath ;
@@ -90,7 +109,32 @@ class GoogleCloudStorageRepository extends BlobStoreRepository {
90
109
91
110
logger .debug ("using bucket [{}], base_path [{}], chunk_size [{}], compress [{}]" , bucket , basePath , chunkSize , compress );
92
111
93
- Storage client = SocketAccess .doPrivilegedIOException (() -> storageService .createClient (clientName ));
112
+ String application = APPLICATION_NAME .get (metadata .settings ());
113
+ if (Strings .hasText (application )) {
114
+ deprecationLogger .deprecated ("Setting [application_name] in repository settings is deprecated, " +
115
+ "it must be specified in the client settings instead" );
116
+ }
117
+ TimeValue connectTimeout = null ;
118
+ TimeValue readTimeout = null ;
119
+
120
+ TimeValue timeout = HTTP_CONNECT_TIMEOUT .get (metadata .settings ());
121
+ if ((timeout != null ) && (timeout .millis () != NO_TIMEOUT .millis ())) {
122
+ deprecationLogger .deprecated ("Setting [http.connect_timeout] in repository settings is deprecated, " +
123
+ "it must be specified in the client settings instead" );
124
+ connectTimeout = timeout ;
125
+ }
126
+ timeout = HTTP_READ_TIMEOUT .get (metadata .settings ());
127
+ if ((timeout != null ) && (timeout .millis () != NO_TIMEOUT .millis ())) {
128
+ deprecationLogger .deprecated ("Setting [http.read_timeout] in repository settings is deprecated, " +
129
+ "it must be specified in the client settings instead" );
130
+ readTimeout = timeout ;
131
+ }
132
+
133
+ TimeValue finalConnectTimeout = connectTimeout ;
134
+ TimeValue finalReadTimeout = readTimeout ;
135
+
136
+ Storage client = SocketAccess .doPrivilegedIOException (() ->
137
+ storageService .createClient (clientName , application , finalConnectTimeout , finalReadTimeout ));
94
138
this .blobStore = new GoogleCloudStorageBlobStore (settings , bucket , client );
95
139
}
96
140
0 commit comments