Skip to content

Commit

Permalink
底层优化
Browse files Browse the repository at this point in the history
  • Loading branch information
xueli.xue committed May 11, 2017
1 parent 650682d commit 17e7dd5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static ExecutorRegistryThread getInstance(){
public void start(final int port, final String ip, final String appName){

// valid
if (AdminApiUtil.allowCallApi && (appName!=null && appName.trim().length()>0) ) {
if ( !(AdminApiUtil.allowCallApi() && (appName!=null && appName.trim().length()>0)) ) {
logger.warn(">>>>>>>>>>>> xxl-job, executor registry config fail");
return;
}
Expand Down
19 changes: 8 additions & 11 deletions xxl-job-core/src/main/java/com/xxl/job/core/util/AdminApiUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,27 @@ public class AdminApiUtil {
public static final String REGISTRY = "/api/registry";

private static List<String> adminAddressList = null;
public static boolean allowCallApi = true;

public static void init(String adminAddresses){
// admin assress list
if (adminAddresses != null) {
Set<String> adminAddressSet = new HashSet<String>();
for (String adminAddressItem: adminAddresses.split(",")) {
if (adminAddressItem.trim().length()>0 && !adminAddressSet.contains(adminAddressItem)) {
if (adminAddressItem.trim().length()>0) {
adminAddressSet.add(adminAddressItem);
}
}
if (adminAddressSet==null || adminAddressSet.size()==0) {
adminAddressList = new ArrayList<String>(adminAddressSet);
}
adminAddressList = new ArrayList<String>(adminAddressSet);
}

// parse
allowCallApi = (adminAddressList!=null && adminAddressList.size()>0);
}
public static boolean allowCallApi(){
boolean allowCallApi = (adminAddressList!=null && adminAddressList.size()>0);
return allowCallApi;
}

public static ReturnT<String> callApiFailover(String subUrl, Object requestObj) throws Exception {

if (!allowCallApi) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "allowCallback fail.");
if (!allowCallApi()) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "allowCallApi fail.");
}

for (String adminAddress: adminAddressList) {
Expand Down

0 comments on commit 17e7dd5

Please sign in to comment.