Permalink
Browse files

Make guard() receive a more specific type

  • Loading branch information...
1 parent c647ed4 commit 6415f0b7ea0742c5119802a83baa7ab7e7be18f4 @dgomezferro committed May 31, 2012
@@ -29,15 +29,15 @@
import com.yahoo.pasc.paxos.client.TimestampMessage;
import com.yahoo.pasc.paxos.client.messages.Received;
import com.yahoo.pasc.paxos.messages.AsyncMessage;
-import com.yahoo.pasc.paxos.messages.Reply;
public class AsyncMessageHandler implements MessageHandler<AsyncMessage, ClientState, Received.Descriptor> {
+ @SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(AsyncMessageHandler.class);
@Override
- public boolean guardPredicate(Message receivedMessage) {
- return receivedMessage instanceof AsyncMessage;
+ public boolean guardPredicate(AsyncMessage receivedMessage) {
+ return true;
}
@Override
@@ -28,8 +28,8 @@
public class HelloHandler implements MessageHandler<Hello, ClientState, Connected.Descriptor> {
@Override
- public boolean guardPredicate(Message receivedMessage) {
- return receivedMessage instanceof Hello;
+ public boolean guardPredicate(Hello receivedMessage) {
+ return true;
}
@Override
@@ -31,11 +31,12 @@
public class ReplyHandler implements MessageHandler<Reply, ClientState, Received.Descriptor> {
+ @SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(ReplyHandler.class);
@Override
- public boolean guardPredicate(Message receivedMessage) {
- return receivedMessage instanceof Reply;
+ public boolean guardPredicate(Reply receivedMessage) {
+ return true;
}
@Override
@@ -29,8 +29,8 @@
public class SubmitHandler implements MessageHandler<Submit, ClientState, Request> {
@Override
- public boolean guardPredicate(Message receivedMessage) {
- return receivedMessage instanceof Submit;
+ public boolean guardPredicate(Submit receivedMessage) {
+ return true;
}
@Override
@@ -28,8 +28,8 @@
public class TimeoutHandler implements MessageHandler<Timeout, ClientState, Request> {
@Override
- public boolean guardPredicate(Message receivedMessage) {
- return receivedMessage instanceof Timeout;
+ public boolean guardPredicate(Timeout receivedMessage) {
+ return true;
}
@Override
@@ -32,11 +32,6 @@
private static final Logger LOG = LoggerFactory.getLogger(DigestHandler.class);
@Override
- public boolean guardPredicate(Message receivedMessage) {
- return receivedMessage instanceof Digest;
- }
-
- @Override
public List<PaxosDescriptor> processMessage(Digest digest, PaxosState state) {
storeDigest(digest.getSenderId(), digest.getDigestId(), digest.getDigest(), state);
return null;
@@ -27,13 +27,6 @@
public class LeadershipHandler extends PaxosHandler<LeadershipChange> {
-// private static final Logger LOG = LoggerFactory.getLogger(LeadershipHandler.class);
-
- @Override
- public boolean guardPredicate(Message receivedMessage) {
- return receivedMessage instanceof LeadershipChange;
- }
-
@Override
public List<PaxosDescriptor> processMessage(LeadershipChange lc, PaxosState state) {
List<PaxosDescriptor> descriptors = null;
@@ -29,6 +29,11 @@
implements MessageHandler<M, PaxosState, PaxosDescriptor> {
@Override
+ public boolean guardPredicate(M receivedMessage) {
+ return true;
+ };
+
+ @Override
public List<Message> getSendMessages(PaxosState state, List<PaxosDescriptor> descriptors) {
if (descriptors == null)
return null;
@@ -38,11 +38,6 @@
private static final Logger LOG = LoggerFactory.getLogger(ProposerRequest.class);
@Override
- public boolean guardPredicate(Message receivedMessage) {
- return receivedMessage instanceof Accept;
- }
-
- @Override
public List<PaxosDescriptor> processMessage(Accept message, PaxosState state) {
if (state.getIsLeader())
return null;
@@ -37,11 +37,6 @@
private static final Logger LOG = LoggerFactory.getLogger(AcceptorPrepare.class);
@Override
- public boolean guardPredicate(Message receivedMessage) {
- return receivedMessage instanceof Prepare;
- }
-
- @Override
public List<PaxosDescriptor> processMessage(Prepare message, PaxosState state) {
// check that the leader is newer than the last one by looking at the ballot number
@@ -36,11 +36,6 @@
private static final Logger LOG = LoggerFactory.getLogger(Learner.class);
@Override
- public boolean guardPredicate(Message receivedMessage) {
- return receivedMessage instanceof Accepted;
- }
-
- @Override
public List<PaxosDescriptor> processMessage(Accepted message, PaxosState state) {
long iid = message.getIid();
long firstInstanceId = state.getFirstInstanceId();
@@ -38,11 +38,6 @@
private static final Logger LOG = LoggerFactory.getLogger(LearnerPreReply.class);
@Override
- public boolean guardPredicate(Message receivedMessage) {
- return receivedMessage instanceof PreReply;
- }
-
- @Override
public List<PaxosDescriptor> processMessage(PreReply message, PaxosState state) {
int clientId = message.getClientId();
long timestamp = message.getTimestamp();
@@ -42,11 +42,6 @@
private static final Logger LOG = LoggerFactory.getLogger(ProposerPrepared.class);
@Override
- public boolean guardPredicate(Message receivedMessage) {
- return receivedMessage instanceof Prepared;
- }
-
- @Override
public List<PaxosDescriptor> processMessage(Prepared receivedMessage, PaxosState state) {
if (!state.getIsLeader() || state.getBallotProposer() != receivedMessage.getReplyBallot()) {
@@ -23,7 +23,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.yahoo.pasc.Message;
import com.yahoo.pasc.paxos.handlers.PaxosHandler;
import com.yahoo.pasc.paxos.handlers.acceptor.AcceptorAccept;
import com.yahoo.pasc.paxos.messages.Accept;
@@ -43,11 +42,6 @@
private static final Logger LOG = LoggerFactory.getLogger(ProposerRequest.class);
@Override
- public boolean guardPredicate(Message receivedMessage) {
- return receivedMessage instanceof Request;
- }
-
- @Override
public List<PaxosDescriptor> processMessage(Request message, PaxosState state) {
long firstInstanceId = state.getFirstInstanceId();
int maxInstances = state.getMaxInstances();

0 comments on commit 6415f0b

Please sign in to comment.