Skip to content

Commit

Permalink
feature: support acc
Browse files Browse the repository at this point in the history
  • Loading branch information
YangSen-qn committed May 24, 2024
1 parent 1a697ee commit 0b32ed1
Show file tree
Hide file tree
Showing 26 changed files with 327 additions and 83 deletions.
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ allprojects {
repositories {
jcenter()
google()
mavenCentral()
}
// gradle.projectsEvaluated {
// tasks.withType(JavaCompile) {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
android.useAndroidX=true
android.disableAutomaticComponentCreation=true

VERSION_NAME=
VERSION_CODE=
Expand Down
14 changes: 7 additions & 7 deletions library/src/androidTest/java/com/qiniu/android/TestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ public final class TestConfig {
// TODO: 2020-05-09 bad token for testPutBytesWithFixedZoneUseBackupDomains
// 华东上传凭证
public static final String bucket_z0 = "kodo-phone-zone0-space";
public static final String token_z0 = "dxVQk8gyk3WswArbNhdKIwmwibJ9nFsQhMNUmtIM:kCuN1lxE7wby0SgsYmgleVQh5pk=:eyJzY29wZSI6ImtvZG8tcGhvbmUtem9uZTAtc3BhY2UiLCJkZWFkbGluZSI6MTcwMjk1Mzg5MSwgInJldHVybkJvZHkiOiJ7XCJmb29cIjokKHg6Zm9vKSwgXCJiYXJcIjokKHg6YmFyKSwgXCJtaW1lVHlwZVwiOiQobWltZVR5cGUpLCBcImhhc2hcIjokKGV0YWcpLCBcImtleVwiOiQoa2V5KSwgXCJmbmFtZVwiOiQoZm5hbWUpLCBcImZzaXplXCI6JChmc2l6ZSl9In0=";
public static final String token_z0 = "dxVQk8gyk3WswArbNhdKIwmwibJ9nFsQhMNUmtIM:gHBZrJTOKxxJlXjYoUxWmRSvuU8=:eyJzY29wZSI6ImtvZG8tcGhvbmUtem9uZTAtc3BhY2UiLCJkZWFkbGluZSI6MTcyMTcwMDU5MiwgInJldHVybkJvZHkiOiJ7XCJmb29cIjokKHg6Zm9vKSwgXCJiYXJcIjokKHg6YmFyKSwgXCJtaW1lVHlwZVwiOiQobWltZVR5cGUpLCBcImhhc2hcIjokKGV0YWcpLCBcImtleVwiOiQoa2V5KSwgXCJmbmFtZVwiOiQoZm5hbWUpLCBcImZzaXplXCI6JChmc2l6ZSl9In0=";
// 华北上传凭证
public static final String bucket_z1 = "kodo-phone-zone1-space";
public static final String token_z1 = "dxVQk8gyk3WswArbNhdKIwmwibJ9nFsQhMNUmtIM:6GJohI_Ldf_hBwGATV3iYeuMVZ0=:eyJzY29wZSI6ImtvZG8tcGhvbmUtem9uZTEtc3BhY2UiLCJkZWFkbGluZSI6MTcwMjk1Mzg5MSwgInJldHVybkJvZHkiOiJ7XCJmb29cIjokKHg6Zm9vKSwgXCJiYXJcIjokKHg6YmFyKSwgXCJtaW1lVHlwZVwiOiQobWltZVR5cGUpLCBcImhhc2hcIjokKGV0YWcpLCBcImtleVwiOiQoa2V5KSwgXCJmbmFtZVwiOiQoZm5hbWUpLCBcImZzaXplXCI6JChmc2l6ZSl9In0=";
public static final String token_z1 = "dxVQk8gyk3WswArbNhdKIwmwibJ9nFsQhMNUmtIM:8kFB5kF7f3INNSUZLToOBDTGMbU=:eyJzY29wZSI6ImtvZG8tcGhvbmUtem9uZTEtc3BhY2UiLCJkZWFkbGluZSI6MTcyMTcwMDU5MiwgInJldHVybkJvZHkiOiJ7XCJmb29cIjokKHg6Zm9vKSwgXCJiYXJcIjokKHg6YmFyKSwgXCJtaW1lVHlwZVwiOiQobWltZVR5cGUpLCBcImhhc2hcIjokKGV0YWcpLCBcImtleVwiOiQoa2V5KSwgXCJmbmFtZVwiOiQoZm5hbWUpLCBcImZzaXplXCI6JChmc2l6ZSl9In0=";
// 华南上传凭证
public static final String bucket_z2 = "kodo-phone-zone2-space";
public static final String token_z2 = "dxVQk8gyk3WswArbNhdKIwmwibJ9nFsQhMNUmtIM:gy-wF5GQuoffNKUmRMKC0wVQDHQ=:eyJzY29wZSI6ImtvZG8tcGhvbmUtem9uZTItc3BhY2UiLCJkZWFkbGluZSI6MTcwMjk1Mzg5MSwgInJldHVybkJvZHkiOiJ7XCJmb29cIjokKHg6Zm9vKSwgXCJiYXJcIjokKHg6YmFyKSwgXCJtaW1lVHlwZVwiOiQobWltZVR5cGUpLCBcImhhc2hcIjokKGV0YWcpLCBcImtleVwiOiQoa2V5KSwgXCJmbmFtZVwiOiQoZm5hbWUpLCBcImZzaXplXCI6JChmc2l6ZSl9In0=";
public static final String token_z2 = "dxVQk8gyk3WswArbNhdKIwmwibJ9nFsQhMNUmtIM:CR7NjzaMWAqQAt6b7mPuwvwIzLs=:eyJzY29wZSI6ImtvZG8tcGhvbmUtem9uZTItc3BhY2UiLCJkZWFkbGluZSI6MTcyMTcwMDU5MiwgInJldHVybkJvZHkiOiJ7XCJmb29cIjokKHg6Zm9vKSwgXCJiYXJcIjokKHg6YmFyKSwgXCJtaW1lVHlwZVwiOiQobWltZVR5cGUpLCBcImhhc2hcIjokKGV0YWcpLCBcImtleVwiOiQoa2V5KSwgXCJmbmFtZVwiOiQoZm5hbWUpLCBcImZzaXplXCI6JChmc2l6ZSl9In0=";
// 北美上传凭证
public static final String bucket_na0 = "kodo-phone-zone-na0-space";
public static final String token_na0 = "dxVQk8gyk3WswArbNhdKIwmwibJ9nFsQhMNUmtIM:mEbYwqz9BbvKpjemh7arZA01SCY=:eyJzY29wZSI6ImtvZG8tcGhvbmUtem9uZS1uYTAtc3BhY2UiLCJkZWFkbGluZSI6MTcwMjk1Mzg5MSwgInJldHVybkJvZHkiOiJ7XCJmb29cIjokKHg6Zm9vKSwgXCJiYXJcIjokKHg6YmFyKSwgXCJtaW1lVHlwZVwiOiQobWltZVR5cGUpLCBcImhhc2hcIjokKGV0YWcpLCBcImtleVwiOiQoa2V5KSwgXCJmbmFtZVwiOiQoZm5hbWUpLCBcImZzaXplXCI6JChmc2l6ZSl9In0=";
public static final String token_na0 = "dxVQk8gyk3WswArbNhdKIwmwibJ9nFsQhMNUmtIM:4TBEbspih6VzaNbPYlrpRIkm7xU=:eyJzY29wZSI6ImtvZG8tcGhvbmUtem9uZS1uYTAtc3BhY2UiLCJkZWFkbGluZSI6MTcyMTcwMDU5MiwgInJldHVybkJvZHkiOiJ7XCJmb29cIjokKHg6Zm9vKSwgXCJiYXJcIjokKHg6YmFyKSwgXCJtaW1lVHlwZVwiOiQobWltZVR5cGUpLCBcImhhc2hcIjokKGV0YWcpLCBcImtleVwiOiQoa2V5KSwgXCJmbmFtZVwiOiQoZm5hbWUpLCBcImZzaXplXCI6JChmc2l6ZSl9In0=";
// 东南亚上传凭证
public static final String bucket_as0 = "kodo-phone-zone-as0-space";
public static final String token_as0 = "dxVQk8gyk3WswArbNhdKIwmwibJ9nFsQhMNUmtIM:b5V9b1I3FCrNYJ1aQznlcGvyKe0=:eyJzY29wZSI6ImtvZG8tcGhvbmUtem9uZS1hczAtc3BhY2UiLCJkZWFkbGluZSI6MTcwMjk1Mzg5MSwgInJldHVybkJvZHkiOiJ7XCJmb29cIjokKHg6Zm9vKSwgXCJiYXJcIjokKHg6YmFyKSwgXCJtaW1lVHlwZVwiOiQobWltZVR5cGUpLCBcImhhc2hcIjokKGV0YWcpLCBcImtleVwiOiQoa2V5KSwgXCJmbmFtZVwiOiQoZm5hbWUpLCBcImZzaXplXCI6JChmc2l6ZSl9In0=";
public static final String token_as0 = "dxVQk8gyk3WswArbNhdKIwmwibJ9nFsQhMNUmtIM:JczpyfXUYEan2qrimbu6GlOCADo=:eyJzY29wZSI6ImtvZG8tcGhvbmUtem9uZS1hczAtc3BhY2UiLCJkZWFkbGluZSI6MTcyMTcwMDU5MiwgInJldHVybkJvZHkiOiJ7XCJmb29cIjokKHg6Zm9vKSwgXCJiYXJcIjokKHg6YmFyKSwgXCJtaW1lVHlwZVwiOiQobWltZVR5cGUpLCBcImhhc2hcIjokKGV0YWcpLCBcImtleVwiOiQoa2V5KSwgXCJmbmFtZVwiOiQoZm5hbWUpLCBcImZzaXplXCI6JChmc2l6ZSl9In0=";
// 华北浙江2上传凭证
public static final String bucket_cn_east_2 = "kodo-phone-cn-east-2";
public static final String token_cn_east_2 = "dxVQk8gyk3WswArbNhdKIwmwibJ9nFsQhMNUmtIM:5wMZsrDWTJuYW-aYz6AsBJJhol4=:eyJzY29wZSI6ImtvZG8tcGhvbmUtY24tZWFzdC0yIiwiZGVhZGxpbmUiOjE3MDI5NTM4OTEsICJyZXR1cm5Cb2R5Ijoie1wiZm9vXCI6JCh4OmZvbyksIFwiYmFyXCI6JCh4OmJhciksIFwibWltZVR5cGVcIjokKG1pbWVUeXBlKSwgXCJoYXNoXCI6JChldGFnKSwgXCJrZXlcIjokKGtleSksIFwiZm5hbWVcIjokKGZuYW1lKSwgXCJmc2l6ZVwiOiQoZnNpemUpfSJ9";
public static final String invalidBucketToken = "dxVQk8gyk3WswArbNhdKIwmwibJ9nFsQhMNUmtIM:AF6tAFx4teQul_zEMXWzbN79_eI=:eyJzY29wZSI6InpvbmVfaW52YWxpZCIsImRlYWRsaW5lIjoxNzAyOTUzODkxLCAicmV0dXJuQm9keSI6IntcImZvb1wiOiQoeDpmb28pLCBcImJhclwiOiQoeDpiYXIpLCBcIm1pbWVUeXBlXCI6JChtaW1lVHlwZSksIFwiaGFzaFwiOiQoZXRhZyksIFwia2V5XCI6JChrZXkpLCBcImZuYW1lXCI6JChmbmFtZSksIFwiZnNpemVcIjokKGZzaXplKX0ifQ==";
public static final String token_cn_east_2 = "dxVQk8gyk3WswArbNhdKIwmwibJ9nFsQhMNUmtIM:LWCzEeHkDWcYVBViMzZdJ4IaZ0U=:eyJzY29wZSI6ImtvZG8tcGhvbmUtY24tZWFzdC0yIiwiZGVhZGxpbmUiOjE3MjE3MDA1OTIsICJyZXR1cm5Cb2R5Ijoie1wiZm9vXCI6JCh4OmZvbyksIFwiYmFyXCI6JCh4OmJhciksIFwibWltZVR5cGVcIjokKG1pbWVUeXBlKSwgXCJoYXNoXCI6JChldGFnKSwgXCJrZXlcIjokKGtleSksIFwiZm5hbWVcIjokKGZuYW1lKSwgXCJmc2l6ZVwiOiQoZnNpemUpfSJ9";
public static final String invalidBucketToken = "dxVQk8gyk3WswArbNhdKIwmwibJ9nFsQhMNUmtIM:FLgR-iEqqbGw-2vCdA9m5X7nOTY=:eyJzY29wZSI6InpvbmVfaW52YWxpZCIsImRlYWRsaW5lIjoxNzIxNzAwNTkyLCAicmV0dXJuQm9keSI6IntcImZvb1wiOiQoeDpmb28pLCBcImJhclwiOiQoeDpiYXIpLCBcIm1pbWVUeXBlXCI6JChtaW1lVHlwZSksIFwiaGFzaFwiOiQoZXRhZyksIFwia2V5XCI6JChrZXkpLCBcImZuYW1lXCI6JChmbmFtZSksIFwiZnNpemVcIjokKGZzaXplKX0ifQ==";

// -----------
public static final String ak = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void testPreFetch() {
FixedZone fixedZone = new FixedZone(new String[]{host});

final DnsPrefetcher dnsPrefetcher = DnsPrefetcher.getInstance();
dnsPrefetcher.checkAndPrefetchDnsIfNeed(fixedZone, UpToken.parse(TestConfig.token_z0));
dnsPrefetcher.checkAndPrefetchDnsIfNeed(null, fixedZone, UpToken.parse(TestConfig.token_z0));

wait(new WaitConditional() {
@Override
Expand Down Expand Up @@ -95,7 +95,7 @@ public void testMutiThreadPrefetch(){
new Thread(new Runnable() {
@Override
public void run() {
boolean isSuccess = DnsPrefetchTransaction.addDnsCheckAndPrefetchTransaction(zone, UpToken.parse(TestConfig.token_z0));
boolean isSuccess = DnsPrefetchTransaction.addDnsCheckAndPrefetchTransaction(null, zone, UpToken.parse(TestConfig.token_z0));
synchronized (this){
if (isSuccess){
param.successCount += 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void test_CheckAndPrefetch(){
@Override
public void run() {

boolean isSuccess = DnsPrefetchTransaction.addDnsCheckAndPrefetchTransaction(zone, UpToken.parse(TestConfig.token_z0));
boolean isSuccess = DnsPrefetchTransaction.addDnsCheckAndPrefetchTransaction(null, zone, UpToken.parse(TestConfig.token_z0));
synchronized (this) {
if (isSuccess) {
successCount += 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void testGetOneServer(){
String type = Utils.getIpType(null, host);
FixedZone zone = new FixedZone(new String[]{host});

UploadDomainRegion region = new UploadDomainRegion();
UploadDomainRegion region = new UploadDomainRegion(null);
region.setupRegionData(zone.getZonesInfo(null).zonesInfo.get(0));

UploadServerFreezeManager.getInstance().freezeType(type, 100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.qiniu.android.http.request.RequestTransaction;
import com.qiniu.android.storage.UpToken;
import com.qiniu.android.transaction.TransactionManager;
import com.qiniu.android.utils.AsyncRun;
import com.qiniu.android.utils.LogUtil;
import com.qiniu.android.utils.StringUtils;
import com.qiniu.android.utils.Utils;
Expand All @@ -24,7 +23,6 @@
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -254,7 +252,7 @@ private byte[] getLogData() {
randomAccessFile = new RandomAccessFile(recorderTempFile, "r");
ByteArrayOutputStream out = new ByteArrayOutputStream(fileSize);
int len = 0;
byte[] buff = new byte[fileSize];
byte[] buff = new byte[32*1024];
while ((len = randomAccessFile.read(buff)) >= 0) {
out.write(buff, 0, len);
}
Expand Down
59 changes: 43 additions & 16 deletions library/src/main/java/com/qiniu/android/common/AutoZone.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import com.qiniu.android.http.dns.DnsPrefetchTransaction;
import com.qiniu.android.http.metrics.UploadRegionRequestMetrics;
import com.qiniu.android.http.request.RequestTransaction;
import com.qiniu.android.storage.Configuration;
import com.qiniu.android.storage.UpToken;
import com.qiniu.android.utils.Cache;
import com.qiniu.android.utils.ListUtils;
import com.qiniu.android.utils.SingleFlight;
import com.qiniu.android.utils.UrlSafeBase64;

Expand Down Expand Up @@ -111,11 +113,12 @@ private String[] getUcServerArray() {
}

@Override
@Deprecated
public ZonesInfo getZonesInfo(UpToken token) {
if (token == null) {
return null;
}
String cacheKey = makeCacheKey(token.index());
String cacheKey = makeCacheKey(null, token.index());
ZonesInfo zonesInfo = zonesInfoMap.get(cacheKey);
if (zonesInfo != null) {
try {
Expand All @@ -128,15 +131,27 @@ public ZonesInfo getZonesInfo(UpToken token) {

@Override
public void preQuery(final UpToken token, final QueryHandler completeHandler) {
preQuery(null, token, new QueryHandlerV2() {
@Override
public void complete(ResponseInfo responseInfo, UploadRegionRequestMetrics metrics, ZonesInfo zonesInfo) {
if (completeHandler != null) {
completeHandler.complete(responseInfo != null ? responseInfo.statusCode : ResponseInfo.NetworkError, responseInfo, metrics);
}
}
});
}

@Override
public void preQuery(Configuration configuration, UpToken token, QueryHandlerV2 completeHandler) {
if (token == null || !token.isValid()) {
completeHandler.complete(-1, ResponseInfo.invalidToken("invalid token"), null);
completeHandler.complete(ResponseInfo.invalidToken("invalid token"), null, null);
return;
}

UploadRegionRequestMetrics localMetrics = new UploadRegionRequestMetrics(null);
localMetrics.start();

final String cacheKey = makeCacheKey(token.index());
final String cacheKey = makeCacheKey(configuration, token.index());

ZonesInfo zonesInfo = null;
Cache.Object object = zoneCache.cacheForKey(cacheKey);
Expand All @@ -147,7 +162,7 @@ public void preQuery(final UpToken token, final QueryHandler completeHandler) {
if (zonesInfo != null && zonesInfo.isValid()) {
localMetrics.end();
zonesInfoMap.put(cacheKey, zonesInfo);
completeHandler.complete(0, ResponseInfo.successResponse(), localMetrics);
completeHandler.complete(ResponseInfo.successResponse(), localMetrics, zonesInfo);
return;
}

Expand All @@ -159,7 +174,7 @@ public void preQuery(final UpToken token, final QueryHandler completeHandler) {
@Override
public void action(final com.qiniu.android.utils.SingleFlight.CompleteHandler<SingleFlightValue> completeHandler) throws Exception {

final RequestTransaction transaction = createUploadRequestTransaction(token);
final RequestTransaction transaction = createUploadRequestTransaction(configuration, token);
transaction.queryUploadHosts(true, new RequestTransaction.RequestCompleteHandler() {
@Override
public void complete(ResponseInfo responseInfo, UploadRegionRequestMetrics requestMetrics, JSONObject response) {
Expand All @@ -186,36 +201,47 @@ public void complete(SingleFlightValue singleFlightValue) {
if (zonesInfoP.isValid()) {
zoneCache.cache(cacheKey, zonesInfoP, true);
zonesInfoMap.put(cacheKey, zonesInfoP);
completeHandler.complete(0, responseInfo, requestMetrics);
completeHandler.complete(responseInfo, requestMetrics, zonesInfoP);
} else {
completeHandler.complete(ResponseInfo.ParseError, responseInfo, requestMetrics);
responseInfo = ResponseInfo.parseError("origin response:" + responseInfo);
completeHandler.complete(responseInfo, requestMetrics, null);
}
} else {
if (defaultZone != null) {
// 备用只能用一次
ZonesInfo defaultZoneZonesInfo = defaultZone.getZonesInfo(token);
zonesInfoMap.put(cacheKey, defaultZoneZonesInfo);
completeHandler.complete(0, responseInfo, requestMetrics);
String message = "origin response:" + responseInfo;
responseInfo = ResponseInfo.successResponse();
responseInfo.message = message;
completeHandler.complete(responseInfo, requestMetrics, defaultZoneZonesInfo);
} else if (finalZonesInfo != null) {
// 缓存有,但是失效也可使用
zonesInfoMap.put(cacheKey, finalZonesInfo);
completeHandler.complete(0, responseInfo, requestMetrics);
String message = "origin response:" + responseInfo;
responseInfo = ResponseInfo.successResponse();
responseInfo.message = message;
completeHandler.complete(responseInfo, requestMetrics, finalZonesInfo);
} else {
completeHandler.complete(ResponseInfo.NetworkError, responseInfo, requestMetrics);
completeHandler.complete(responseInfo, requestMetrics, null);
}
}
}
});

} catch (Exception e) {
/// 此处永远不会执行,回调只为占位
completeHandler.complete(ResponseInfo.NetworkError, ResponseInfo.localIOError(e.toString()), null);
completeHandler.complete(ResponseInfo.localIOError(e.toString()), null, null);
}
}

private String makeCacheKey(String akAndBucket) {
private String makeCacheKey(Configuration configuration, String akAndBucket) {
String key = akAndBucket;
if (configuration != null) {
key += akAndBucket + ":" + configuration.accelerateUploading;
}
List<String> ucHosts = getUcServerList();
if (ucHosts == null || ucHosts.isEmpty()) {
if (ListUtils.isEmpty(ucHosts)) {
return akAndBucket;
}

Expand All @@ -227,13 +253,14 @@ private String makeCacheKey(String akAndBucket) {
hosts.append(host).append(":");
}

return UrlSafeBase64.encodeToString(hosts + akAndBucket);
return UrlSafeBase64.encodeToString(hosts + key);
}

private RequestTransaction createUploadRequestTransaction(UpToken token) {
private RequestTransaction createUploadRequestTransaction(Configuration configuration, UpToken token) {
List<String> hosts = getUcServerList();

RequestTransaction transaction = new RequestTransaction(hosts, ZoneInfo.EmptyRegionId, token);
RequestTransaction transaction = new RequestTransaction(configuration, null,
hosts, ZoneInfo.EmptyRegionId, null, token);
transactions.add(transaction);
return transaction;
}
Expand Down
3 changes: 2 additions & 1 deletion library/src/main/java/com/qiniu/android/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public final class Config {
/**
* preQuery host
*/
@Deprecated
public static String preQueryHost03 = "api.qiniu.com";

/**
Expand All @@ -95,7 +96,7 @@ public final class Config {
* @return preQuery hosts
*/
public static String[] preQueryHosts() {
return new String[]{preQueryHost00, preQueryHost01, preQueryHost02, preQueryHost03};
return new String[]{preQueryHost00, preQueryHost01, preQueryHost02};
}

/**
Expand Down
10 changes: 10 additions & 0 deletions library/src/main/java/com/qiniu/android/common/FixedZone.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.qiniu.android.common;

import com.qiniu.android.http.ResponseInfo;
import com.qiniu.android.http.metrics.UploadRegionRequestMetrics;
import com.qiniu.android.storage.Configuration;
import com.qiniu.android.storage.UpToken;

import java.util.ArrayList;
Expand Down Expand Up @@ -212,4 +215,11 @@ public void preQuery(UpToken token, QueryHandler completeHandler) {
completeHandler.complete(0, null, null);
}
}

@Override
public void preQuery(Configuration configuration, UpToken token, QueryHandlerV2 completeHandler) {
if (completeHandler != null) {
completeHandler.complete(null, null, zonesInfo);
}
}
}
24 changes: 24 additions & 0 deletions library/src/main/java/com/qiniu/android/common/Zone.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.qiniu.android.http.ResponseInfo;
import com.qiniu.android.http.metrics.UploadRegionRequestMetrics;
import com.qiniu.android.storage.Configuration;
import com.qiniu.android.storage.UpToken;

/**
Expand Down Expand Up @@ -29,8 +30,18 @@ protected Zone() {
* @param token 上传 token
* @param completeHandler 预查询结束回调
*/
@Deprecated
public abstract void preQuery(UpToken token, QueryHandler completeHandler);

/**
* 根据上传 token 对区域进行预查询
*
* @param configuration 配置信息
* @param token 上传 token
* @param completeHandler 预查询结束回调
*/
public abstract void preQuery(Configuration configuration, UpToken token, final QueryHandlerV2 completeHandler);

/**
* 预查询结束回调
*/
Expand All @@ -44,4 +55,17 @@ public interface QueryHandler {
*/
void complete(int code, ResponseInfo responseInfo, UploadRegionRequestMetrics metrics);
}

/**
* 预查询结束回调
*/
public interface QueryHandlerV2 {
/**
* 预查询结束回调
*
* @param responseInfo 查询响应
* @param metrics 查询指标
*/
void complete(ResponseInfo responseInfo, UploadRegionRequestMetrics metrics, ZonesInfo zonesInfo);
}
}
Loading

0 comments on commit 0b32ed1

Please sign in to comment.