gpt4 book ai didi

com.qiniu.android.common.ZoneInfo类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:39:53 31 4
gpt4 key购买 nike

本文整理了Java中com.qiniu.android.common.ZoneInfo类的一些代码示例,展示了ZoneInfo类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneInfo类的具体详情如下:
包路径:com.qiniu.android.common.ZoneInfo
类名称: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);

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com