|
@@ -28,30 +28,27 @@ public class AdminApiUtil {
|
28
|
28
|
public static final String REGISTRY = "/api/registry";
|
29
|
29
|
|
30
|
30
|
private static List<String> adminAddressList = null;
|
31
|
|
- public static boolean allowCallApi = true;
|
32
|
|
-
|
33
|
31
|
public static void init(String adminAddresses){
|
34
|
32
|
// admin assress list
|
35
|
33
|
if (adminAddresses != null) {
|
36
|
34
|
Set<String> adminAddressSet = new HashSet<String>();
|
37
|
35
|
for (String adminAddressItem: adminAddresses.split(",")) {
|
38
|
|
- if (adminAddressItem.trim().length()>0 && !adminAddressSet.contains(adminAddressItem)) {
|
|
36
|
+ if (adminAddressItem.trim().length()>0) {
|
39
|
37
|
adminAddressSet.add(adminAddressItem);
|
40
|
38
|
}
|
41
|
39
|
}
|
42
|
|
- if (adminAddressSet==null || adminAddressSet.size()==0) {
|
43
|
|
- adminAddressList = new ArrayList<String>(adminAddressSet);
|
44
|
|
- }
|
|
40
|
+ adminAddressList = new ArrayList<String>(adminAddressSet);
|
45
|
41
|
}
|
46
|
|
-
|
47
|
|
- // parse
|
48
|
|
- allowCallApi = (adminAddressList!=null && adminAddressList.size()>0);
|
49
|
42
|
}
|
|
43
|
+ public static boolean allowCallApi(){
|
|
44
|
+ boolean allowCallApi = (adminAddressList!=null && adminAddressList.size()>0);
|
|
45
|
+ return allowCallApi;
|
|
46
|
+ }
|
50
|
47
|
|
51
|
48
|
public static ReturnT<String> callApiFailover(String subUrl, Object requestObj) throws Exception {
|
52
|
49
|
|
53
|
|
- if (!allowCallApi) {
|
54
|
|
- return new ReturnT<String>(ReturnT.FAIL_CODE, "allowCallback fail.");
|
|
50
|
+ if (!allowCallApi()) {
|
|
51
|
+ return new ReturnT<String>(ReturnT.FAIL_CODE, "allowCallApi fail.");
|
55
|
52
|
}
|
56
|
53
|
|
57
|
54
|
for (String adminAddress: adminAddressList) {
|