Update Hazelcast registry to check for duplicate endpoints
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@925745 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
07cfae8bfa
commit
238ecf66b3
2 changed files with 33 additions and 0 deletions
|
@ -155,6 +155,11 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E
|
|||
}
|
||||
|
||||
public void addEndpoint(Endpoint endpoint) {
|
||||
if (findEndpoint(endpoint.getURI()).size() > 0) {
|
||||
Member m = getOwningMember(endpoint.getURI());
|
||||
throw new IllegalStateException("Endpoint " + endpoint.getURI() + " already exists in domain " + configURI.getDomainName() + " at " + m.getInetSocketAddress());
|
||||
}
|
||||
|
||||
String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString();
|
||||
String endpointURI = endpoint.getURI();
|
||||
Transaction txn = hazelcastInstance.getTransaction();
|
||||
|
|
|
@ -108,6 +108,34 @@ public class MultiRegTestCase {
|
|||
System.out.println("done");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDuplicates() throws Exception {
|
||||
HazelcastEndpointRegistry reg1 = new HazelcastEndpointRegistry(extensionPoints, null, "tuscany:foo?listen=127.0.0.1:9876&multicast=off", "bar");
|
||||
reg1.start();
|
||||
RuntimeEndpoint ep1 = createEndpoint("ep1uri");
|
||||
ep1.bind(extensionPoints, reg1);
|
||||
reg1.addEndpoint(ep1);
|
||||
|
||||
HazelcastEndpointRegistry reg2 = new HazelcastEndpointRegistry(extensionPoints, null, "tuscany:foo?listen=127.0.0.1:9877&multicast=off&remotes=127.0.0.1:9876", "bar");
|
||||
reg2.start();
|
||||
|
||||
try {
|
||||
reg2.addEndpoint(ep1);
|
||||
Assert.fail();
|
||||
} catch (IllegalStateException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
reg1.stop();
|
||||
|
||||
Thread.sleep(200);
|
||||
|
||||
// now it should work
|
||||
reg2.addEndpoint(ep1);
|
||||
|
||||
reg2.stop();
|
||||
}
|
||||
|
||||
private Endpoint assertExists(HazelcastEndpointRegistry reg, String uri) throws InterruptedException {
|
||||
Endpoint ep = reg.getEndpoint(uri);
|
||||
Assert.assertNotNull(ep);
|
||||
|
|
Loading…
Reference in a new issue