Skip to content

Commit

Permalink
fixed issue with local handlers in cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
purplefox committed Jul 22, 2012
1 parent aa59dc6 commit bda1173
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ public void handle(AsyncResult<ServerIDs> event) {
ServerIDs serverIDs = event.result;
if (!serverIDs.isEmpty()) {
sendToSubs(serverIDs, message);
} else {
receiveMessage(message);
}
} else {
log.error("Failed to send message", event.exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ public void testReply() {
}

@Test
public void testLocal() {
public void testLocal1() {
startTest(getMethodName());
}

@Test
public void testLocal2() {
startTest(getMethodName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,22 @@ public void handle(Message<Buffer> reply) {
}
}

public void testLocal() {
public void testLocal1() {
testLocal(true);
}

public void testLocal2() {
testLocal(false);
}

public void testLocal(boolean localMethod) {
final int numHandlers = 10;
final String address = UUID.randomUUID().toString();
final AtomicInteger count = new AtomicInteger(0);
final Buffer buff = TestUtils.generateRandomBuffer(1000);
for (int i = 0; i < numHandlers; i++) {
eb.registerHandler(address, new Handler<Message<Buffer>>() {

Handler<Message<Buffer>> handler = new Handler<Message<Buffer>>() {
boolean handled;

public void handle(Message<Buffer> msg) {
Expand All @@ -110,7 +119,12 @@ public void handle(Message<Buffer> msg) {
}
handled = true;
}
});
};
if (localMethod) {
eb.registerLocalHandler(address, handler);
} else {
eb.registerHandler(address, handler);
}
}

eb.publish(address, buff);
Expand Down

0 comments on commit bda1173

Please sign in to comment.