Skip to content

Commit

Permalink
Fix the provider config repeated export limit. (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjboy authored May 30, 2018
1 parent 1505813 commit 43f1430
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,24 @@ protected DefaultProviderBootstrap(ProviderConfig<T> providerConfig) {
/**
* 是否已发布
*/
protected transient volatile boolean exported;
protected transient volatile boolean exported;

/**
* 服务端Invoker对象
*/
protected transient Invoker providerProxyInvoker;
protected transient Invoker providerProxyInvoker;

/**
* 发布的服务配置
*/
protected final ConcurrentHashMap<String, AtomicInteger> EXPORTED_KEYS = new ConcurrentHashMap<String, AtomicInteger>();
protected final static ConcurrentHashMap<String, AtomicInteger> EXPORTED_KEYS = new ConcurrentHashMap<String, AtomicInteger>();

/**
* 延迟加载的线程名工厂
*/
private final ThreadFactory factory = new NamedThreadFactory("DELAY-EXPORT",
true);
private final ThreadFactory factory = new NamedThreadFactory(
"DELAY-EXPORT",
true);

@Override
public void export() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@

/**
* @author bystander
* @version $Id: DubooServerTest.java, v 0.1 2017年10月30日 下午9:23 bystander Exp $
*/
public class DubooServerTest extends BaseZkTest {
public class DubboServerTest extends BaseZkTest {

@Test
//同步调用,走配置中心
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.alipay.sofa.rpc.config.ProviderConfig;
import com.alipay.sofa.rpc.config.RegistryConfig;
import com.alipay.sofa.rpc.config.ServerConfig;
import com.alipay.sofa.rpc.test.ActivelyDestroyTest;
import org.junit.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -60,6 +59,7 @@ public void testWarmUp() throws InterruptedException {
.setRef(new WarmUpServiceImpl(22111))
.setServer(serverConfig2)
.setRegistry(registryConfig)
.setRepeatedExportLimit(-1)
.setWeight(0);

providerConfig.export();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public void refer() throws Exception {
.setTimeout(3000);
try {
consumerConfig3.refer();
Assert.fail();
} catch (Exception e) {
Assert.assertTrue(e instanceof SofaRpcRuntimeException);
}
Expand All @@ -85,6 +86,7 @@ public void refer() throws Exception {
.setTimeout(3000);
try {
consumerConfig5.refer();
Assert.fail();
} catch (Exception e) {
Assert.assertTrue(e instanceof SofaRpcRuntimeException);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void export() throws Exception {
.setRegister(false);
try {
providerConfig1.export();
Assert.fail();
} catch (Exception e) {
Assert.assertTrue(e instanceof SofaRpcRuntimeException);
}
Expand All @@ -72,7 +73,7 @@ public void export() throws Exception {
.setInterfaceId(HelloService.class.getName())
.setRef(new HelloServiceImpl(2000))
.setServer(serverConfig)
.setRepeatedExportLimit(3)
.setRepeatedExportLimit(2)
.setRegister(false);
providerConfig2.export();

Expand All @@ -81,10 +82,11 @@ public void export() throws Exception {
.setInterfaceId(HelloService.class.getName())
.setRef(new HelloServiceImpl(2000))
.setServer(serverConfig)
.setRepeatedExportLimit(3)
.setRepeatedExportLimit(2)
.setRegister(false);
try {
providerConfig3.export();
Assert.fail();
} catch (Exception e) {
Assert.assertTrue(e instanceof SofaRpcRuntimeException);
}
Expand Down

0 comments on commit 43f1430

Please # to comment.