提交 c78841b1 编写于 作者: W william.liangf

DUBBO-20 解决设置delay属性导致服务一直处理禁用状态问题

git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@149 1a56cb94-b969-4eaa-88fa-be21384802f2
上级 f44972d1
......@@ -298,7 +298,7 @@ public class ProtocolConfig extends AbstractConfig {
this.status = status;
}
public Boolean getRegister() {
public Boolean isRegister() {
return register;
}
......
......@@ -41,7 +41,6 @@ import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.Protocol;
import com.alibaba.dubbo.rpc.ProxyFactory;
import com.alibaba.dubbo.rpc.RpcConstants;
import com.alibaba.dubbo.rpc.RpcStatus;
import com.alibaba.dubbo.rpc.service.GenericService;
/**
......@@ -189,10 +188,6 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
path = interfaceName;
}
doExportUrls();
for (URL url : urls) {
RpcStatus.getStatus(url).setReady(true);
}
doExportService();
exported = true;
}
......@@ -261,7 +256,6 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
if (unexported) {
return;
}
unexported = true;
if (exporters != null && exporters.size() > 0) {
for (Exporter<?> exporter : exporters) {
try {
......@@ -272,9 +266,12 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
}
exporters.clear();
}
unexported = true;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private void doExportUrls() {
List<URL> registryURLs = loadRegistries();
for (ProtocolConfig protocolConfig : protocols) {
String name = protocolConfig.getName();
if (name == null || name.length() == 0) {
......@@ -293,7 +290,6 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
logger.warn(e.getMessage(), e);
}
if (NetUtils.isInvalidLocalHost(host)) {
List<URL> registryURLs = loadRegistries();
if (registryURLs != null && registryURLs.size() > 0) {
for (URL registryURL : registryURLs) {
try {
......@@ -406,14 +402,6 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
contextPath = provider.getContextpath();
}
URL url = new URL(name, host, port, (contextPath == null || contextPath.length() == 0 ? "" : contextPath + "/") + path, map);
this.urls.add(url);
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private void doExportService() {
List<URL> registryURLs = loadRegistries();
for (URL url : urls) {
if (logger.isInfoEnabled()) {
logger.info("Export dubbo service " + interfaceClass.getName() + " to url " + url);
}
......@@ -437,6 +425,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
Exporter<?> exporter = protocol.export(invoker);
exporters.add(exporter);
}
this.urls.add(url);
}
}
......@@ -515,7 +504,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
this.path = path;
}
public Boolean getRegister() {
public Boolean isRegister() {
return register;
}
......
......@@ -30,7 +30,7 @@ public final class RpcConstants {
"consumercontext", "compatible", "deprecated", "collect", "genericimpl", "activelimit", "monitor", "future" }));
public static final List<String> DEFAULT_SERVICE_FILTERS = Collections.unmodifiableList(Arrays.asList(new String[] {
"ready", "context", "token", "exception", "echo", "generic", "accesslog", "trace", "classloader", "executelimit", "monitor" ,"timeout"}));
"context", "token", "exception", "echo", "generic", "accesslog", "trace", "classloader", "executelimit", "monitor" ,"timeout"}));
public static final List<String> DEFAULT_INVOKER_LISTENERS = Collections.unmodifiableList(Arrays.asList(new String[] {
"deprecated" }));
......
......@@ -151,8 +151,6 @@ public class RpcStatus {
private final AtomicLong succeededMaxElapsed = new AtomicLong();
private volatile boolean ready = true;
private RpcStatus() {}
/**
......@@ -303,21 +301,5 @@ public class RpcStatus {
public long getSucceededMaxElapsed() {
return succeededMaxElapsed.get();
}
/**
*
* @return
*/
public boolean isReady() {
return ready;
}
/**
*
* @param ready
*/
public void setReady(boolean ready) {
this.ready = ready;
}
}
\ No newline at end of file
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.rpc.filter;
import com.alibaba.dubbo.common.Extension;
import com.alibaba.dubbo.rpc.Filter;
import com.alibaba.dubbo.rpc.Invocation;
import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.Result;
import com.alibaba.dubbo.rpc.RpcException;
import com.alibaba.dubbo.rpc.RpcStatus;
/**
* ReadyFilter
*
* @author william.liangf
*/
@Extension("ready")
public class ReadyFilter implements Filter {
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
if (! RpcStatus.getStatus(invoker.getUrl()).isReady()) {
throw new RpcException("The service not ready! Limit by config <dubbo:service delay=\"...\" />, service: " + invoker.getInterface().getName() + ", url: " + invoker.getUrl());
}
if (! RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName()).isReady()) {
throw new RpcException("The service method not ready! Limit by config <dubbo:service><dubbo:method delay=\"...\" /></dubbo:service>, service: " + invoker.getInterface().getName() + ", url: " + invoker.getUrl() + ", method: " + invocation.getMethodName());
}
return invoker.invoke(invocation);
}
}
\ No newline at end of file
......@@ -11,5 +11,4 @@ com.alibaba.dubbo.rpc.filter.ExceptionFilter
com.alibaba.dubbo.rpc.filter.ExecuteLimitFilter
com.alibaba.dubbo.rpc.filter.DeprecatedFilter
com.alibaba.dubbo.rpc.filter.CompatibleFilter
com.alibaba.dubbo.rpc.filter.ReadyFilter
com.alibaba.dubbo.rpc.filter.TimeoutFilter
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册