Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Improve Shard logging output"
[controller.git]
/
opendaylight
/
md-sal
/
sal-akka-raft
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
cluster
/
raft
/
behaviors
/
AbstractRaftActorBehavior.java
diff --git
a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehavior.java
b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehavior.java
index f235221da940d4cb21c491e78b9624c2afa18a80..dbeafe9eb8b2fce467451eb4594c6c1be913797e 100644
(file)
--- a/
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehavior.java
+++ b/
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehavior.java
@@
-11,6
+11,8
@@
package org.opendaylight.controller.cluster.raft.behaviors;
import akka.actor.ActorRef;
import akka.actor.Cancellable;
import akka.event.LoggingAdapter;
import akka.actor.ActorRef;
import akka.actor.Cancellable;
import akka.event.LoggingAdapter;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.cluster.raft.ClientRequestTracker;
import org.opendaylight.controller.cluster.raft.RaftActorContext;
import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
import org.opendaylight.controller.cluster.raft.ClientRequestTracker;
import org.opendaylight.controller.cluster.raft.RaftActorContext;
import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
@@
-24,9
+26,6
@@
import org.opendaylight.controller.cluster.raft.messages.RequestVote;
import org.opendaylight.controller.cluster.raft.messages.RequestVoteReply;
import scala.concurrent.duration.FiniteDuration;
import org.opendaylight.controller.cluster.raft.messages.RequestVoteReply;
import scala.concurrent.duration.FiniteDuration;
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
/**
* Abstract class that represents the behavior of a RaftActor
* <p/>
/**
* Abstract class that represents the behavior of a RaftActor
* <p/>
@@
-95,8
+94,8
@@
public abstract class AbstractRaftActorBehavior implements RaftActorBehavior {
// 1. Reply false if term < currentTerm (§5.1)
if (appendEntries.getTerm() < currentTerm()) {
if(LOG.isDebugEnabled()) {
// 1. Reply false if term < currentTerm (§5.1)
if (appendEntries.getTerm() < currentTerm()) {
if(LOG.isDebugEnabled()) {
- LOG.debug("Cannot append entries because sender term {} is less than {}",
- appendEntries.getTerm(), currentTerm());
+ LOG.debug("
{}:
Cannot append entries because sender term {} is less than {}",
+
context.getId(),
appendEntries.getTerm(), currentTerm());
}
sender.tell(
}
sender.tell(
@@
-137,7
+136,7
@@
public abstract class AbstractRaftActorBehavior implements RaftActorBehavior {
RequestVote requestVote) {
if(LOG.isDebugEnabled()) {
RequestVote requestVote) {
if(LOG.isDebugEnabled()) {
- LOG.debug(
requestVote.toString()
);
+ LOG.debug(
"{}: Received {}", context.getId(), requestVote
);
}
boolean grantVote = false;
}
boolean grantVote = false;
@@
-202,7
+201,7
@@
public abstract class AbstractRaftActorBehavior implements RaftActorBehavior {
protected FiniteDuration electionDuration() {
long variance = new Random().nextInt(context.getConfigParams().getElectionTimeVariance());
return context.getConfigParams().getElectionTimeOutInterval().$plus(
protected FiniteDuration electionDuration() {
long variance = new Random().nextInt(context.getConfigParams().getElectionTimeVariance());
return context.getConfigParams().getElectionTimeOutInterval().$plus(
- new FiniteDuration(variance, TimeUnit.MILLISECONDS));
+
new FiniteDuration(variance, TimeUnit.MILLISECONDS));
}
/**
}
/**
@@
-351,12
+350,13
@@
public abstract class AbstractRaftActorBehavior implements RaftActorBehavior {
//if one index is not present in the log, no point in looping
// around as the rest wont be present either
LOG.warning(
//if one index is not present in the log, no point in looping
// around as the rest wont be present either
LOG.warning(
- "Missing index {} from log. Cannot apply state. Ignoring {} to {}", i, i, index);
+ "{}: Missing index {} from log. Cannot apply state. Ignoring {} to {}",
+ context.getId(), i, i, index);
break;
}
}
if(LOG.isDebugEnabled()) {
break;
}
}
if(LOG.isDebugEnabled()) {
- LOG.debug("
Setting last applied to {}"
, newLastApplied);
+ LOG.debug("
{}: Setting last applied to {}", context.getId()
, newLastApplied);
}
context.setLastApplied(newLastApplied);
}
context.setLastApplied(newLastApplied);
@@
-394,7
+394,7
@@
public abstract class AbstractRaftActorBehavior implements RaftActorBehavior {
try {
close();
} catch (Exception e) {
try {
close();
} catch (Exception e) {
- LOG.error(e, "
Failed to close behavior : {}"
, this.state());
+ LOG.error(e, "
{}: Failed to close behavior : {}", context.getId()
, this.state());
}
return behavior;
}
return behavior;