本文整理了Java中com.qiniu.android.common.ZoneInfo
类的一些代码示例,展示了ZoneInfo
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneInfo
类的具体详情如下:
包路径:com.qiniu.android.common.ZoneInfo
类名称:ZoneInfo
[英]Created by jemy on 17/04/2017.
[中]杰米于2017年4月17日创作。
代码示例来源:origin: qiniu/android-sdk
public static ZoneInfo createZoneInfo(String[] upDomains) {
List<String> upDomainsList = new ArrayList<String>();
Map<String, Long> upDomainsMap = new ConcurrentHashMap<String, Long>();
for (String domain : upDomains) {
upDomainsList.add(domain);
upDomainsMap.put(domain, 0L);
}
return new ZoneInfo(0, upDomainsList, upDomainsMap);
}
代码示例来源:origin: com.qiniu/qiniu-android-sdk
@Override
public synchronized void frozenDomain(String upHostUrl) {
if (upHostUrl != null) {
URI uri = URI.create(upHostUrl);
//frozen domain
String frozenDomain = uri.getHost();
zoneInfo.frozenDomain(frozenDomain);
}
}
}
代码示例来源:origin: com.qiniu/qiniu-android-sdk
boolean preQueryIndex(final ZoneIndex index) {
boolean success = false;
if (index != null) {
ZoneInfo info = zones.get(index);
if (info != null) {
success = true;
} else {
try {
ResponseInfo responseInfo = getZoneJsonSync(index);
ZoneInfo info2 = ZoneInfo.buildFromJson(responseInfo.response);
zones.put(index, info2);
success = true;
} catch (JSONException e) {
e.printStackTrace();
}
}
}
return success;
}
代码示例来源:origin: qiniu/android-sdk
boolean preQueryIndex(final ZoneIndex index) {
boolean success = false;
if (index != null) {
ZoneInfo info = zones.get(index);
if (info != null) {
success = true;
} else {
try {
ResponseInfo responseInfo = getZoneJsonSync(index);
ZoneInfo info2 = ZoneInfo.buildFromJson(responseInfo.response);
zones.put(index, info2);
success = true;
} catch (JSONException e) {
e.printStackTrace();
}
}
}
return success;
}
代码示例来源:origin: qiniu/android-sdk
@Override
public synchronized void frozenDomain(String upHostUrl) {
if (upHostUrl != null) {
URI uri = URI.create(upHostUrl);
//frozen domain
String frozenDomain = uri.getHost();
zoneInfo.frozenDomain(frozenDomain);
}
}
}
代码示例来源:origin: com.qiniu/qiniu-android-sdk
public static ZoneInfo createZoneInfo(String[] upDomains) {
List<String> upDomainsList = new ArrayList<String>();
Map<String, Long> upDomainsMap = new ConcurrentHashMap<String, Long>();
for (String domain : upDomains) {
upDomainsList.add(domain);
upDomainsMap.put(domain, 0L);
}
return new ZoneInfo(0, upDomainsList, upDomainsMap);
}
代码示例来源:origin: qiniu/android-sdk
@Override
public void complete(ResponseInfo info, JSONObject response) {
if (info.isOK() && response != null) {
try {
ZoneInfo info2 = ZoneInfo.buildFromJson(response);
zones.put(index, info2);
complete.onSuccess();
return;
} catch (JSONException e) {
e.printStackTrace();
complete.onFailure(ResponseInfo.NetworkError);
return;
}
}
complete.onFailure(info.statusCode);
}
});
代码示例来源:origin: qiniu/android-sdk
@Override
public synchronized void frozenDomain(String upHostUrl) {
if (upHostUrl != null) {
URI uri = URI.create(upHostUrl);
//frozen domain
String frozenDomain = uri.getHost();
ZoneInfo zoneInfo = null;
for (Map.Entry<ZoneIndex, ZoneInfo> entry : this.zones.entrySet()) {
ZoneInfo eachZoneInfo = entry.getValue();
if (eachZoneInfo.upDomainsList.contains(frozenDomain)) {
zoneInfo = eachZoneInfo;
break;
}
}
if (zoneInfo != null) {
zoneInfo.frozenDomain(frozenDomain);
}
}
}
代码示例来源:origin: qiniu/android-sdk
public static ZoneInfo buildFromJson(JSONObject obj) throws JSONException {
int ttl = obj.getInt("ttl");
List<String> domainsList = new ArrayList<>();
ConcurrentHashMap<String, Long> domainsMap = new ConcurrentHashMap<>();
JSONObject upObj = obj.getJSONObject("up");
String[] upDomainTags = new String[]{"acc", "src", "old_acc", "old_src"};
for (String tag : upDomainTags) {
JSONObject tagRootObj = upObj.getJSONObject(tag);
JSONArray tagMainObj = tagRootObj.getJSONArray("main");
for (int i = 0; i < tagMainObj.length(); i++) {
String upDomain = tagMainObj.getString(i);
domainsList.add(upDomain);
domainsMap.put(upDomain, 0L);
}
try {
JSONArray tagBackupObj = tagRootObj.getJSONArray("backup");
if (tagBackupObj != null) {
//this backup tag is optional
for (int i = 0; i < tagBackupObj.length(); i++) {
String upHost = tagBackupObj.getString(i);
domainsList.add(upHost);
domainsMap.put(upHost, 0L);
}
}
} catch (JSONException ex) {
//some zone has not backup domain, just ignore here
}
}
return new ZoneInfo(ttl, domainsList, domainsMap);
}
代码示例来源:origin: com.qiniu/qiniu-android-sdk
@Override
public void complete(ResponseInfo info, JSONObject response) {
if (info.isOK() && response != null) {
try {
ZoneInfo info2 = ZoneInfo.buildFromJson(response);
zones.put(index, info2);
complete.onSuccess();
return;
} catch (JSONException e) {
e.printStackTrace();
complete.onFailure(ResponseInfo.NetworkError);
return;
}
}
complete.onFailure(info.statusCode);
}
});
代码示例来源:origin: com.qiniu/qiniu-android-sdk
@Override
public synchronized void frozenDomain(String upHostUrl) {
if (upHostUrl != null) {
URI uri = URI.create(upHostUrl);
//frozen domain
String frozenDomain = uri.getHost();
ZoneInfo zoneInfo = null;
for (Map.Entry<ZoneIndex, ZoneInfo> entry : this.zones.entrySet()) {
ZoneInfo eachZoneInfo = entry.getValue();
if (eachZoneInfo.upDomainsList.contains(frozenDomain)) {
zoneInfo = eachZoneInfo;
break;
}
}
if (zoneInfo != null) {
zoneInfo.frozenDomain(frozenDomain);
}
}
}
代码示例来源:origin: com.qiniu/qiniu-android-sdk
public static ZoneInfo buildFromJson(JSONObject obj) throws JSONException {
int ttl = obj.getInt("ttl");
List<String> domainsList = new ArrayList<>();
ConcurrentHashMap<String, Long> domainsMap = new ConcurrentHashMap<>();
JSONObject upObj = obj.getJSONObject("up");
String[] upDomainTags = new String[]{"acc", "src", "old_acc", "old_src"};
for (String tag : upDomainTags) {
JSONObject tagRootObj = upObj.getJSONObject(tag);
JSONArray tagMainObj = tagRootObj.getJSONArray("main");
for (int i = 0; i < tagMainObj.length(); i++) {
String upDomain = tagMainObj.getString(i);
domainsList.add(upDomain);
domainsMap.put(upDomain, 0L);
}
try {
JSONArray tagBackupObj = tagRootObj.getJSONArray("backup");
if (tagBackupObj != null) {
//this backup tag is optional
for (int i = 0; i < tagBackupObj.length(); i++) {
String upHost = tagBackupObj.getString(i);
domainsList.add(upHost);
domainsMap.put(upHost, 0L);
}
}
} catch (JSONException ex) {
//some zone has not backup domain, just ignore here
}
}
return new ZoneInfo(ttl, domainsList, domainsMap);
}
代码示例来源:origin: qiniu/android-sdk
zoneInfo.frozenDomain(frozenDomain);
代码示例来源:origin: com.qiniu/qiniu-android-sdk
zoneInfo.frozenDomain(frozenDomain);
内容来源于网络,如有侵权,请联系作者删除!