diff --git a/motan-core/src/main/java/com/weibo/api/motan/transport/ProviderProtectedMessageRouter.java b/motan-core/src/main/java/com/weibo/api/motan/transport/ProviderProtectedMessageRouter.java
index 410c305e4..788dd4df2 100644
--- a/motan-core/src/main/java/com/weibo/api/motan/transport/ProviderProtectedMessageRouter.java
+++ b/motan-core/src/main/java/com/weibo/api/motan/transport/ProviderProtectedMessageRouter.java
@@ -16,10 +16,6 @@
package com.weibo.api.motan.transport;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
import com.weibo.api.motan.common.URLParamType;
import com.weibo.api.motan.exception.MotanErrorMsgConstant;
import com.weibo.api.motan.exception.MotanServiceException;
@@ -30,31 +26,32 @@
import com.weibo.api.motan.util.LoggerUtil;
import com.weibo.api.motan.util.MotanFrameworkUtil;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
/**
* TODO 可配置化策略
- *
+ *
* provider 消息处理分发:支持一定程度的自我防护
- *
+ *
*
- *
- *
- * 1) 如果接口只有一个方法,那么直接return true
+ *
+ * 1) 如果接口只有一个方法,那么直接return true
* 2) 如果接口有多个方法,那么如果单个method超过 maxThread / 2 && totalCount > (maxThread * 3 / 4),那么return false;
* 3) 如果接口有多个方法(4个),同时总的请求数超过 maxThread * 3 / 4,同时该method的请求数超过 maxThead * 1 / 4, 那么return false
* 4) 其他场景return true
- *
+ *
*
- *
+ *
* @author maijunsheng
* @version 创建时间:2013-6-7
- *
*/
public class ProviderProtectedMessageRouter extends ProviderMessageRouter {
protected ConcurrentMap requestCounters = new ConcurrentHashMap();
protected AtomicInteger totalCounter = new AtomicInteger(0);
-
public ProviderProtectedMessageRouter() {
super();
}
diff --git a/motan-registry-zookeeper/src/main/java/com/weibo/api/motan/registry/zookeeper/ZkNodeType.java b/motan-registry-zookeeper/src/main/java/com/weibo/api/motan/registry/zookeeper/ZkNodeType.java
index 8dfe8793b..c259623da 100644
--- a/motan-registry-zookeeper/src/main/java/com/weibo/api/motan/registry/zookeeper/ZkNodeType.java
+++ b/motan-registry-zookeeper/src/main/java/com/weibo/api/motan/registry/zookeeper/ZkNodeType.java
@@ -1,7 +1,17 @@
package com.weibo.api.motan.registry.zookeeper;
public enum ZkNodeType {
- AVAILABLE_SERVER,
- UNAVAILABLE_SERVER,
- CLIENT
+ AVAILABLE_SERVER("server"),
+ UNAVAILABLE_SERVER("unavailableServer"),
+ CLIENT("client");
+
+ private String value;
+
+ private ZkNodeType(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
}
diff --git a/motan-registry-zookeeper/src/main/java/com/weibo/api/motan/registry/zookeeper/ZkUtils.java b/motan-registry-zookeeper/src/main/java/com/weibo/api/motan/registry/zookeeper/ZkUtils.java
index 4e97389f1..94f78c6e0 100644
--- a/motan-registry-zookeeper/src/main/java/com/weibo/api/motan/registry/zookeeper/ZkUtils.java
+++ b/motan-registry-zookeeper/src/main/java/com/weibo/api/motan/registry/zookeeper/ZkUtils.java
@@ -1,7 +1,6 @@
package com.weibo.api.motan.registry.zookeeper;
import com.weibo.api.motan.common.MotanConstants;
-import com.weibo.api.motan.exception.MotanFrameworkException;
import com.weibo.api.motan.rpc.URL;
public class ZkUtils {
@@ -19,17 +18,7 @@ public static String toCommandPath(URL url) {
}
public static String toNodeTypePath(URL url, ZkNodeType nodeType) {
- String type;
- if (nodeType == ZkNodeType.AVAILABLE_SERVER) {
- type = "server";
- } else if (nodeType == ZkNodeType.UNAVAILABLE_SERVER) {
- type = "unavailableServer";
- } else if (nodeType == ZkNodeType.CLIENT) {
- type = "client";
- } else {
- throw new MotanFrameworkException(String.format("Failed to get nodeTypePath, url: %s type: %s", url, nodeType.toString()));
- }
- return toServicePath(url) + MotanConstants.PATH_SEPARATOR + type;
+ return toServicePath(url) + MotanConstants.PATH_SEPARATOR + nodeType.getValue();
}
public static String toNodePath(URL url, ZkNodeType nodeType) {
diff --git a/motan-springsupport/src/main/java/com/weibo/api/motan/config/springsupport/ServiceConfigBean.java b/motan-springsupport/src/main/java/com/weibo/api/motan/config/springsupport/ServiceConfigBean.java
index a1ce09259..bdb0ba639 100644
--- a/motan-springsupport/src/main/java/com/weibo/api/motan/config/springsupport/ServiceConfigBean.java
+++ b/motan-springsupport/src/main/java/com/weibo/api/motan/config/springsupport/ServiceConfigBean.java
@@ -16,33 +16,23 @@
package com.weibo.api.motan.config.springsupport;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
+import com.weibo.api.motan.common.MotanConstants;
+import com.weibo.api.motan.config.*;
+import com.weibo.api.motan.exception.MotanErrorMsgConstant;
+import com.weibo.api.motan.exception.MotanFrameworkException;
+import com.weibo.api.motan.util.CollectionUtil;
+import com.weibo.api.motan.util.MotanFrameworkUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.BeanFactoryAware;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.ListableBeanFactory;
-import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.*;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
-import com.weibo.api.motan.common.MotanConstants;
-import com.weibo.api.motan.config.BasicServiceInterfaceConfig;
-import com.weibo.api.motan.config.ConfigUtil;
-import com.weibo.api.motan.config.ProtocolConfig;
-import com.weibo.api.motan.config.RegistryConfig;
-import com.weibo.api.motan.config.ServiceConfig;
-import com.weibo.api.motan.exception.MotanErrorMsgConstant;
-import com.weibo.api.motan.exception.MotanFrameworkException;
-import com.weibo.api.motan.util.CollectionUtil;
-import com.weibo.api.motan.util.MotanFrameworkUtil;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
public class ServiceConfigBean extends ServiceConfig
implements
@@ -117,7 +107,7 @@ private void checkAndConfigBasicConfig() {
}
if (MotanNamespaceHandler.basicServiceConfigDefineNames.size() == 1) {
setBasicServiceConfig(biConfig);
- } else if (biConfig.isDefault() != null && biConfig.isDefault().booleanValue()) {
+ } else if (biConfig.isDefault() != null && biConfig.isDefault()) {
setBasicServiceConfig(biConfig);
}
}