Ver código fonte

底层优化

xueli.xue 8 anos atrás
pai
commit
17e7dd5a28

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

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

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

@@ -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) {