forked from sofastack/sofa-rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix sofastack/issues/367
- Loading branch information
1 parent
01ae847
commit 3e8bbf6
Showing
13 changed files
with
176 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
core/api/src/test/java/com/alipay/sofa/rpc/ext/RejectionLB1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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.alipay.sofa.rpc.ext; | ||
|
||
import com.alipay.sofa.rpc.bootstrap.ConsumerBootstrap; | ||
import com.alipay.sofa.rpc.client.LoadBalancer; | ||
import com.alipay.sofa.rpc.client.ProviderInfo; | ||
import com.alipay.sofa.rpc.core.exception.SofaRpcException; | ||
import com.alipay.sofa.rpc.core.request.SofaRequest; | ||
|
||
import java.util.List; | ||
|
||
@Extension(value = "lb1", order = 1) | ||
public class RejectionLB1 extends LoadBalancer { | ||
public RejectionLB1(ConsumerBootstrap consumerBootstrap) { | ||
super(consumerBootstrap); | ||
} | ||
|
||
@Override | ||
public ProviderInfo select(SofaRequest request, List<ProviderInfo> providerInfos) throws SofaRpcException { | ||
return null; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
core/api/src/test/java/com/alipay/sofa/rpc/ext/RejectionLB2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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.alipay.sofa.rpc.ext; | ||
|
||
import com.alipay.sofa.rpc.bootstrap.ConsumerBootstrap; | ||
import com.alipay.sofa.rpc.client.LoadBalancer; | ||
import com.alipay.sofa.rpc.client.ProviderInfo; | ||
import com.alipay.sofa.rpc.core.exception.SofaRpcException; | ||
import com.alipay.sofa.rpc.core.request.SofaRequest; | ||
|
||
import java.util.List; | ||
|
||
@Extension(value = "lb2", order = 2, rejection = { "lb1", "lb3" }) | ||
public class RejectionLB2 extends LoadBalancer { | ||
public RejectionLB2(ConsumerBootstrap consumerBootstrap) { | ||
super(consumerBootstrap); | ||
} | ||
|
||
@Override | ||
public ProviderInfo select(SofaRequest request, List<ProviderInfo> providerInfos) throws SofaRpcException { | ||
return null; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
core/api/src/test/java/com/alipay/sofa/rpc/ext/RejectionLB3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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.alipay.sofa.rpc.ext; | ||
|
||
import com.alipay.sofa.rpc.bootstrap.ConsumerBootstrap; | ||
import com.alipay.sofa.rpc.client.LoadBalancer; | ||
import com.alipay.sofa.rpc.client.ProviderInfo; | ||
import com.alipay.sofa.rpc.core.exception.SofaRpcException; | ||
import com.alipay.sofa.rpc.core.request.SofaRequest; | ||
|
||
import java.util.List; | ||
|
||
@Extension(value = "lb3", order = 3) | ||
public class RejectionLB3 extends LoadBalancer { | ||
public RejectionLB3(ConsumerBootstrap consumerBootstrap) { | ||
super(consumerBootstrap); | ||
} | ||
|
||
@Override | ||
public ProviderInfo select(SofaRequest request, List<ProviderInfo> providerInfos) throws SofaRpcException { | ||
return null; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
core/api/src/test/java/com/alipay/sofa/rpc/ext/TestRejectionOrder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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.alipay.sofa.rpc.ext; | ||
|
||
import com.alipay.sofa.rpc.client.LoadBalancer; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* 测试 https://github.com/alipay/sofa-rpc/issues/367 | ||
*/ | ||
public class TestRejectionOrder { | ||
|
||
@Test | ||
public void testRejection() { | ||
boolean error = true; | ||
ExtensionLoader<LoadBalancer> loader = new ExtensionLoader<LoadBalancer>(LoadBalancer.class, false, null); | ||
loader.loadFromFile("META-INF/ext5/"); | ||
try { | ||
loader.getExtension("lb3"); | ||
} catch (Exception e) { | ||
error = false; | ||
} | ||
Assert.assertTrue(error); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
core/api/src/test/resources/META-INF/ext5/com.alipay.sofa.rpc.client.LoadBalancer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
lb1=com.alipay.sofa.rpc.ext.RejectionLB1 | ||
lb3=com.alipay.sofa.rpc.ext.RejectionLB3 | ||
lb2=com.alipay.sofa.rpc.ext.RejectionLB2 |