if (message instanceof ApplyState) {
ApplyState applyState = (ApplyState) message;
- long elapsedTime = (System.nanoTime() - applyState.getStartTime());
- if(elapsedTime >= APPLY_STATE_DELAY_THRESHOLD_IN_NANOS){
- LOG.warn("ApplyState took more time than expected. Elapsed Time = {} ms ApplyState = {}",
- TimeUnit.NANOSECONDS.toMillis(elapsedTime), applyState);
- }
+ long startTime = System.nanoTime();
if(LOG.isDebugEnabled()) {
LOG.debug("{}: Applying state for log index {} data {}",
applyState(applyState.getClientActor(), applyState.getIdentifier(),
applyState.getReplicatedLogEntry().getData());
+ long elapsedTime = System.nanoTime() - startTime;
+ if(elapsedTime >= APPLY_STATE_DELAY_THRESHOLD_IN_NANOS){
+ LOG.debug("ApplyState took more time than expected. Elapsed Time = {} ms ApplyState = {}",
+ TimeUnit.NANOSECONDS.toMillis(elapsedTime), applyState);
+ }
+
if (!hasFollowers()) {
// for single node, the capture should happen after the apply state
// as we delete messages from the persistent journal which have made it to the snapshot
private final ActorRef clientActor;
private final String identifier;
private final ReplicatedLogEntry replicatedLogEntry;
- private final long startTime;
public ApplyState(ActorRef clientActor, String identifier,
ReplicatedLogEntry replicatedLogEntry) {
this.clientActor = clientActor;
this.identifier = identifier;
this.replicatedLogEntry = replicatedLogEntry;
- this.startTime = System.nanoTime();
}
public ActorRef getClientActor() {
return replicatedLogEntry;
}
- public long getStartTime() {
- return startTime;
- }
-
@Override
public String toString() {
return "ApplyState{" +
"identifier='" + identifier + '\'' +
", replicatedLogEntry.index =" + replicatedLogEntry.getIndex() +
- ", startTime=" + startTime +
'}';
}
}