sdk final
This commit is contained in:
@@ -37,8 +37,8 @@ static int const MAX_UPDATE_RETRY_COUNT = 2;
|
||||
|
||||
@interface HttpdnsScheduleCenter ()
|
||||
|
||||
// 为了简单,无论v4还是v6,都只共同维<EFBFBD><EFBFBD>?个下<EFBFBD><EFBFBD>?
|
||||
// 一般而言,下标当前在哪里并不是那么重要,重要的是轮询的能<EFBFBD><EFBFBD>?
|
||||
// 为了简单,无论v4还是v6,都只共同维?个下?
|
||||
// 一般而言,下标当前在哪里并不是那么重要,重要的是轮询的能?
|
||||
@property (nonatomic, assign) int currentActiveServiceHostIndex;
|
||||
@property (nonatomic, assign) int currentActiveUpdateHostIndex;
|
||||
|
||||
@@ -85,7 +85,7 @@ static int const MAX_UPDATE_RETRY_COUNT = 2;
|
||||
_scheduleCenterResultPath = [[HttpdnsPersistenceUtils scheduleCenterResultDirectory]
|
||||
stringByAppendingPathComponent:kScheduleRegionConfigLocalCacheFileName];
|
||||
|
||||
// 上次更新日期默认设置<EFBFBD><EFBFBD>?天前,这样如果缓存没有记录,就会立即更新
|
||||
// 上次更新日期默认设置?天前,这样如果缓存没有记录,就会立即更新
|
||||
_lastScheduleCenterConnectDate = [NSDate dateWithTimeIntervalSinceNow:(- 24 * 60 * 60)];
|
||||
}
|
||||
return self;
|
||||
@@ -93,11 +93,11 @@ static int const MAX_UPDATE_RETRY_COUNT = 2;
|
||||
|
||||
- (void)initRegion:(NSString *)region {
|
||||
if (![[HttpdnsRegionConfigLoader getAvailableRegionList] containsObject:region]) {
|
||||
region = NEW_HTTPDNS_DEFAULT_REGION_KEY;
|
||||
region = Trust_HTTPDNS_DEFAULT_REGION_KEY;
|
||||
}
|
||||
|
||||
// 先用默认region初始<EFBFBD><EFBFBD>?
|
||||
// 如果用户主动调用了设置region接口,会按照用户设置的再来一<EFBFBD><EFBFBD>?
|
||||
// 先用默认region初始?
|
||||
// 如果用户主动调用了设置region接口,会按照用户设置的再来一?
|
||||
[self initServerListByRegion:region];
|
||||
|
||||
// 再从本地缓存读取之前缓存过的配置
|
||||
@@ -112,7 +112,7 @@ static int const MAX_UPDATE_RETRY_COUNT = 2;
|
||||
self.currentActiveUpdateHostIndex = 0;
|
||||
});
|
||||
|
||||
// 重置region之后马上发起一次更<EFBFBD><EFBFBD>?
|
||||
// 重置region之后马上发起一次更?
|
||||
[self asyncUpdateRegionScheduleConfig];
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ static int const MAX_UPDATE_RETRY_COUNT = 2;
|
||||
}
|
||||
NSDictionary *scheduleCenterResult = (NSDictionary *)obj;
|
||||
|
||||
// 兼容时间戳为NSNumber/NSString,屏蔽NSNull等异常输<EFBFBD><EFBFBD>?
|
||||
// 兼容时间戳为NSNumber/NSString,屏蔽NSNull等异常输?
|
||||
id ts = [scheduleCenterResult objectForKey:kLastUpdateUnixTimestampKey];
|
||||
if ([ts respondsToSelector:@selector(doubleValue)]) {
|
||||
NSDate *lastUpdateDate = [NSDate dateWithTimeIntervalSince1970:[ts doubleValue]];
|
||||
@@ -135,7 +135,7 @@ static int const MAX_UPDATE_RETRY_COUNT = 2;
|
||||
});
|
||||
}
|
||||
|
||||
// 根据指定的时间间隔检查是否需要更<EFBFBD><EFBFBD>?
|
||||
// 根据指定的时间间隔检查是否需要更?
|
||||
- (void)asyncUpdateRegionConfigAfterAtLeast:(NSTimeInterval)interval {
|
||||
__block BOOL shouldUpdate = NO;
|
||||
dispatch_sync(_scheduleConfigLocalOperationQueue, ^{
|
||||
@@ -170,10 +170,10 @@ static int const MAX_UPDATE_RETRY_COUNT = 2;
|
||||
if (error || !scheduleCenterResult) {
|
||||
HttpdnsLogDebug("Update region config failed, error: %@", error);
|
||||
|
||||
// 只有报错了就尝试选择新的调度服务<EFBFBD><EFBFBD>?
|
||||
// 只有报错了就尝试选择新的调度服务?
|
||||
[self rotateUpdateServerHost];
|
||||
|
||||
// 3秒之后重<EFBFBD><EFBFBD>?
|
||||
// 3秒之后重?
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)((retryCount + 1) * NSEC_PER_SEC)), self->_scheduleFetchConfigAsyncQueue, ^{
|
||||
[self asyncUpdateRegionScheduleConfigAtRetry:retryCount + 1];
|
||||
});
|
||||
@@ -192,8 +192,8 @@ static int const MAX_UPDATE_RETRY_COUNT = 2;
|
||||
}
|
||||
|
||||
- (void)updateRegionConfig:(NSDictionary *)scheduleCenterResult {
|
||||
NSArray *v4Result = [scheduleCenterResult objectForKey:kNewHttpdnsRegionConfigV4HostKey];
|
||||
NSArray *v6Result = [scheduleCenterResult objectForKey:kNewHttpdnsRegionConfigV6HostKey];
|
||||
NSArray *v4Result = [scheduleCenterResult objectForKey:kTrustHttpdnsRegionConfigV4HostKey];
|
||||
NSArray *v6Result = [scheduleCenterResult objectForKey:kTrustHttpdnsRegionConfigV6HostKey];
|
||||
|
||||
dispatch_sync(_scheduleConfigLocalOperationQueue, ^{
|
||||
HttpdnsRegionConfigLoader *regionConfigLoader = [HttpdnsRegionConfigLoader sharedInstance];
|
||||
@@ -260,7 +260,7 @@ static int const MAX_UPDATE_RETRY_COUNT = 2;
|
||||
});
|
||||
|
||||
if (timeToUpdate) {
|
||||
// 每次服务server列表轮转之后,尝<EFBFBD><EFBFBD>?个至少间<EFBFBD><EFBFBD>?0秒的更新
|
||||
// 每次服务server列表轮转之后,尝?个至少间?0秒的更新
|
||||
[self asyncUpdateRegionConfigAfterAtLeast:30];
|
||||
}
|
||||
}
|
||||
@@ -286,8 +286,8 @@ static int const MAX_UPDATE_RETRY_COUNT = 2;
|
||||
}
|
||||
|
||||
- (NSString *)currentActiveServiceServerV4Host {
|
||||
// 每次读取时都检查是否需要更新,相当于实现一个懒加载的机<EFBFBD><EFBFBD>?
|
||||
// 因为当前httpdns的初始化方式,没有一个统一的初始化入口,所以需要这样处<EFBFBD><EFBFBD>?
|
||||
// 每次读取时都检查是否需要更新,相当于实现一个懒加载的机?
|
||||
// 因为当前httpdns的初始化方式,没有一个统一的初始化入口,所以需要这样处?
|
||||
[self asyncUpdateRegionConfigAfterAtLeast:(24 * 60 * 60)];
|
||||
|
||||
// 检查是否存在HTTPDNS_DEBUG_V4_SERVICE_IP环境变量
|
||||
|
||||
Reference in New Issue
Block a user