Skip to content

Commit

Permalink
(issue #29) adapting tie-break test to slow servers
Browse files Browse the repository at this point in the history
  • Loading branch information
bluestreak01 committed Jan 22, 2015
1 parent 15b5d58 commit 236a26f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
package com.nfsdb.exceptions;

public class ClusterLossException extends JournalNetworkException {
public ClusterLossException() {
private final int instance;

public ClusterLossException(int instance) {
super("Cluster loss");
this.instance = instance;
}

public int getInstance() {
return instance;
}
}
2 changes: 1 addition & 1 deletion nfsdb-core/src/main/java/com/nfsdb/net/JournalServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public void run() {
break;
} catch (ClusterLossException e) {
haltServer = true;
LOGGER.info("Server lost cluster vote to " + holder.socketAddress);
LOGGER.info("Server lost cluster vote to %s [%s]", e.getInstance(), holder.socketAddress);
break;
} catch (JournalNetworkException e) {
if (running.get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ public void process(ByteChannel channel) throws JournalNetworkException {
checkAuthorized(channel);
intResponseConsumer.read(channel);
if (intResponseConsumer.isComplete()) {
boolean loss = intResponseConsumer.getValue() > server.getServerInstance();
int inst = intResponseConsumer.getValue();
boolean loss = inst > server.getServerInstance();
intResponseConsumer.reset();
commandConsumer.reset();

if (loss) {
ok(channel);
throw new ClusterLossException();
throw new ClusterLossException(inst);
} else {
error(channel, "WIN");
}
Expand Down

0 comments on commit 236a26f

Please sign in to comment.