xueli.xue hace 8 años
padre
commit
17e7dd5a28

+ 1 - 1
xxl-job-core/src/main/java/com/xxl/job/core/thread/ExecutorRegistryThread.java Ver fichero

26
     public void start(final int port, final String ip, final String appName){
26
     public void start(final int port, final String ip, final String appName){
27
 
27
 
28
         // valid
28
         // valid
29
-        if (AdminApiUtil.allowCallApi && (appName!=null && appName.trim().length()>0) ) {
29
+        if ( !(AdminApiUtil.allowCallApi() && (appName!=null && appName.trim().length()>0)) ) {
30
             logger.warn(">>>>>>>>>>>> xxl-job, executor registry config fail");
30
             logger.warn(">>>>>>>>>>>> xxl-job, executor registry config fail");
31
             return;
31
             return;
32
         }
32
         }

+ 8 - 11
xxl-job-core/src/main/java/com/xxl/job/core/util/AdminApiUtil.java Ver fichero

28
 	public static final String REGISTRY = "/api/registry";
28
 	public static final String REGISTRY = "/api/registry";
29
 
29
 
30
 	private static List<String> adminAddressList = null;
30
 	private static List<String> adminAddressList = null;
31
-	public static boolean allowCallApi = true;
32
-
33
 	public static void init(String adminAddresses){
31
 	public static void init(String adminAddresses){
34
 		// admin assress list
32
 		// admin assress list
35
 		if (adminAddresses != null) {
33
 		if (adminAddresses != null) {
36
 			Set<String> adminAddressSet = new HashSet<String>();
34
 			Set<String> adminAddressSet = new HashSet<String>();
37
 			for (String adminAddressItem: adminAddresses.split(",")) {
35
 			for (String adminAddressItem: adminAddresses.split(",")) {
38
-				if (adminAddressItem.trim().length()>0 && !adminAddressSet.contains(adminAddressItem)) {
36
+				if (adminAddressItem.trim().length()>0) {
39
 					adminAddressSet.add(adminAddressItem);
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
 	public static ReturnT<String> callApiFailover(String subUrl, Object requestObj) throws Exception {
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
 		for (String adminAddress: adminAddressList) {
54
 		for (String adminAddress: adminAddressList) {