@@ -17,7 +17,7 @@ class AutoRegion extends Region {
17
17
private String ucServer ;
18
18
19
19
/**
20
- * 空间机房,域名信息缓存,此缓存绑定了 actionType、 token、bucket,且仅 AutoRegion 对象内部有效。
20
+ * 空间机房,域名信息缓存,此缓存绑定了 token、bucket,且仅 AutoRegion 对象内部有效。
21
21
*/
22
22
private Map <String , Region > regions ;
23
23
@@ -60,45 +60,12 @@ private UCRet queryRegionInfoFromServerIfNeeded(RegionIndex index) throws QiniuE
60
60
return ret ;
61
61
}
62
62
63
- static Region regionGroup (UCRet ret , int actionType ) {
63
+ static Region regionGroup (UCRet ret ) {
64
64
if (ret == null || ret .hosts == null || ret .hosts .length == 0 ) {
65
65
return null ;
66
66
}
67
67
68
68
RegionGroup group = new RegionGroup ();
69
-
70
- String [] apis = ApiType .apisWithActionType (actionType );
71
- if (apis != null && apis .length > 0 && ret .universal != null &&
72
- ret .universal .support_apis != null &&
73
- ret .universal .support_apis .length > 0 ) {
74
-
75
- boolean support = true ;
76
- for (String api : apis ) {
77
-
78
- // 需要支持的 api 是否存在,任何一个不存在则不支持。
79
- boolean contain = false ;
80
- for (String supportApi : ret .universal .support_apis ) {
81
- if (api .equals (supportApi )) {
82
- contain = true ;
83
- break ;
84
- }
85
- }
86
-
87
- if (!contain ) {
88
- support = false ;
89
- break ;
90
- }
91
- }
92
-
93
- if (support ) {
94
- if (ret .universal .region == null || ret .universal .region .length () == 0 ) {
95
- ret .universal .region = "universal" ;
96
- }
97
- Region region = ret .universal .createRegion ();
98
- group .addRegion (region );
99
- }
100
- }
101
-
102
69
for (HostRet host : ret .hosts ) {
103
70
Region region = host .createRegion ();
104
71
group .addRegion (region );
@@ -110,22 +77,21 @@ static Region regionGroup(UCRet ret, int actionType) {
110
77
/**
111
78
* 首先从缓存读取Region信息,如果没有则发送请求从接口查询
112
79
*
113
- * @param accessKey 账号 accessKey
114
- * @param bucket 空间名
115
- * @param actionType action 类型
80
+ * @param accessKey 账号 accessKey
81
+ * @param bucket 空间名
116
82
* @return 机房域名信息
117
83
*/
118
- private Region queryRegionInfo (String accessKey , String bucket , int actionType ) throws QiniuException {
84
+ private Region queryRegionInfo (String accessKey , String bucket ) throws QiniuException {
119
85
RegionIndex index = new RegionIndex (accessKey , bucket );
120
- String cacheKey = index .accessKey + "::" + index .bucket + "::" + ApiType . actionTypeString ( actionType ) ;
86
+ String cacheKey = index .accessKey + "::" + index .bucket ;
121
87
Region region = regions .get (cacheKey );
122
88
123
89
Exception ex = null ;
124
90
if (region == null || !region .isValid ()) {
125
91
for (int i = 0 ; i < 2 ; i ++) {
126
92
try {
127
93
UCRet ret = queryRegionInfoFromServerIfNeeded (index );
128
- region = AutoRegion .regionGroup (ret , actionType );
94
+ region = AutoRegion .regionGroup (ret );
129
95
if (region != null ) {
130
96
regions .put (cacheKey , region );
131
97
break ;
@@ -152,27 +118,27 @@ private Region queryRegionInfo(String accessKey, String bucket, int actionType)
152
118
* @param regionReqInfo 封装了 accessKey 和 bucket 的对象
153
119
* @return 机房域名信息
154
120
*/
155
- private Region queryRegionInfo (RegionReqInfo regionReqInfo , int actionType ) throws QiniuException {
156
- return queryRegionInfo (regionReqInfo .getAccessKey (), regionReqInfo .getBucket (), actionType );
121
+ private Region queryRegionInfo (RegionReqInfo regionReqInfo ) throws QiniuException {
122
+ return queryRegionInfo (regionReqInfo .getAccessKey (), regionReqInfo .getBucket ());
157
123
}
158
124
159
125
@ Override
160
- boolean switchRegion (RegionReqInfo regionReqInfo , int actionType ) {
161
- Region currentRegion = getCurrentRegion (regionReqInfo , actionType );
126
+ boolean switchRegion (RegionReqInfo regionReqInfo ) {
127
+ Region currentRegion = getCurrentRegion (regionReqInfo );
162
128
if (currentRegion == null ) {
163
129
return false ;
164
130
} else {
165
- return currentRegion .switchRegion (regionReqInfo , actionType );
131
+ return currentRegion .switchRegion (regionReqInfo );
166
132
}
167
133
}
168
134
169
135
@ Override
170
- String getRegion (RegionReqInfo regionReqInfo , int actionType ) {
171
- Region currentRegion = getCurrentRegion (regionReqInfo , actionType );
136
+ String getRegion (RegionReqInfo regionReqInfo ) {
137
+ Region currentRegion = getCurrentRegion (regionReqInfo );
172
138
if (currentRegion == null ) {
173
139
return "" ;
174
140
} else {
175
- return currentRegion .getRegion (regionReqInfo , actionType );
141
+ return currentRegion .getRegion (regionReqInfo );
176
142
}
177
143
}
178
144
@@ -182,10 +148,10 @@ boolean isValid() {
182
148
}
183
149
184
150
@ Override
185
- Region getCurrentRegion (RegionReqInfo regionReqInfo , int actionType ) {
151
+ Region getCurrentRegion (RegionReqInfo regionReqInfo ) {
186
152
try {
187
- Region region = queryRegionInfo (regionReqInfo , actionType );
188
- return region .getCurrentRegion (regionReqInfo , actionType );
153
+ Region region = queryRegionInfo (regionReqInfo );
154
+ return region .getCurrentRegion (regionReqInfo );
189
155
} catch (QiniuException e ) {
190
156
return null ;
191
157
}
@@ -195,24 +161,24 @@ Region getCurrentRegion(RegionReqInfo regionReqInfo, int actionType) {
195
161
* 获取源站直传域名
196
162
*/
197
163
@ Override
198
- List <String > getSrcUpHost (RegionReqInfo regionReqInfo , int actionType ) throws QiniuException {
164
+ List <String > getSrcUpHost (RegionReqInfo regionReqInfo ) throws QiniuException {
199
165
if (regionReqInfo == null ) {
200
166
return null ;
201
167
}
202
- Region region = queryRegionInfo (regionReqInfo , actionType );
203
- return region .getSrcUpHost (regionReqInfo , actionType );
168
+ Region region = queryRegionInfo (regionReqInfo );
169
+ return region .getSrcUpHost (regionReqInfo );
204
170
}
205
171
206
172
/**
207
173
* 获取加速上传域名
208
174
*/
209
175
@ Override
210
- List <String > getAccUpHost (RegionReqInfo regionReqInfo , int actionType ) throws QiniuException {
176
+ List <String > getAccUpHost (RegionReqInfo regionReqInfo ) throws QiniuException {
211
177
if (regionReqInfo == null ) {
212
178
return null ;
213
179
}
214
- Region region = queryRegionInfo (regionReqInfo , actionType );
215
- return region .getAccUpHost (regionReqInfo , actionType );
180
+ Region region = queryRegionInfo (regionReqInfo );
181
+ return region .getAccUpHost (regionReqInfo );
216
182
}
217
183
218
184
/**
@@ -223,7 +189,7 @@ String getIovipHost(RegionReqInfo regionReqInfo) throws QiniuException {
223
189
if (regionReqInfo == null ) {
224
190
return "" ;
225
191
}
226
- Region region = queryRegionInfo (regionReqInfo , ApiType . ActionTypeNone );
192
+ Region region = queryRegionInfo (regionReqInfo );
227
193
return region .getIovipHost (regionReqInfo );
228
194
}
229
195
@@ -235,7 +201,7 @@ String getRsHost(RegionReqInfo regionReqInfo) throws QiniuException {
235
201
if (regionReqInfo == null ) {
236
202
return "" ;
237
203
}
238
- Region region = queryRegionInfo (regionReqInfo , ApiType . ActionTypeNone );
204
+ Region region = queryRegionInfo (regionReqInfo );
239
205
return region .getRsHost (regionReqInfo );
240
206
}
241
207
@@ -247,7 +213,7 @@ String getRsfHost(RegionReqInfo regionReqInfo) throws QiniuException {
247
213
if (regionReqInfo == null ) {
248
214
return "" ;
249
215
}
250
- Region region = queryRegionInfo (regionReqInfo , ApiType . ActionTypeNone );
216
+ Region region = queryRegionInfo (regionReqInfo );
251
217
return region .getRsfHost (regionReqInfo );
252
218
}
253
219
@@ -259,7 +225,7 @@ String getApiHost(RegionReqInfo regionReqInfo) throws QiniuException {
259
225
if (regionReqInfo == null ) {
260
226
return "" ;
261
227
}
262
- Region region = queryRegionInfo (regionReqInfo , ApiType . ActionTypeNone );
228
+ Region region = queryRegionInfo (regionReqInfo );
263
229
return region .getApiHost (regionReqInfo );
264
230
}
265
231
@@ -320,7 +286,7 @@ private void setupDeadline() {
320
286
if (ret != null ) {
321
287
ttl = ret .ttl ;
322
288
}
323
- deadline = System .currentTimeMillis ()/ 1000 + ttl ;
289
+ deadline = System .currentTimeMillis () / 1000 + ttl ;
324
290
}
325
291
}
326
292
@@ -377,7 +343,7 @@ Region createRegion() {
377
343
regionId = "" ;
378
344
}
379
345
380
- return new Region (timestamp , regionId , srcUpHosts , accUpHosts , iovipHost , rsHost , rsfHost , apiHost , ucHost );
346
+ return new Region (timestamp , regionId , srcUpHosts , accUpHosts , iovipHost , rsHost , rsfHost , apiHost , ucHost );
381
347
}
382
348
}
383
349
0 commit comments