/*
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
context = new RaftActorContextImpl(this.getSelf(),
this.getContext(), id, new ElectionTermImpl(delegatingPersistenceProvider, id, LOG),
-1, -1, peerAddresses,
- (configParams.isPresent() ? configParams.get(): new DefaultConfigParamsImpl()), LOG);
+ (configParams.isPresent() ? configParams.get(): new DefaultConfigParamsImpl()),
+ delegatingPersistenceProvider, LOG);
context.setReplicatedLog(ReplicatedLogImpl.newInstance(context, delegatingPersistenceProvider, currentBehavior));
}
context.getConfigParams().getJournalRecoveryLogBatchSize());
super.preStart();
+
+ snapshotSupport = newRaftActorSnapshotMessageSupport();
}
@Override
@Override
public void handleRecover(Object message) {
if(raftRecovery == null) {
- raftRecovery = new RaftActorRecoverySupport(delegatingPersistenceProvider, context, currentBehavior,
- getRaftActorRecoveryCohort());
+ raftRecovery = newRaftActorRecoverySupport();
}
boolean recoveryComplete = raftRecovery.handleRecoveryMessage(message);
}
}
+ protected RaftActorRecoverySupport newRaftActorRecoverySupport() {
+ return new RaftActorRecoverySupport(delegatingPersistenceProvider, context, currentBehavior,
+ getRaftActorRecoveryCohort());
+ }
+
protected void initializeBehavior(){
changeCurrentBehavior(new Follower(context));
}
@Override
public void handleCommand(Object message) {
- if(snapshotSupport == null) {
- snapshotSupport = new RaftActorSnapshotMessageSupport(delegatingPersistenceProvider, context,
- currentBehavior, getRaftActorSnapshotCohort(), self());
- }
-
- boolean handled = snapshotSupport.handleSnapshotMessage(message);
- if(handled) {
- return;
- }
-
if (message instanceof ApplyState){
ApplyState applyState = (ApplyState) message;
);
} else if(message instanceof GetOnDemandRaftState) {
onGetOnDemandRaftStats();
- } else {
+ } else if(!snapshotSupport.handleSnapshotMessage(message)) {
reusableBehaviorStateHolder.init(getCurrentBehavior());
setCurrentBehavior(currentBehavior.handleMessage(getSender(), message));
}
}
+ protected RaftActorSnapshotMessageSupport newRaftActorSnapshotMessageSupport() {
+ return new RaftActorSnapshotMessageSupport(delegatingPersistenceProvider, context,
+ currentBehavior, getRaftActorSnapshotCohort());
+ }
+
private void onGetOnDemandRaftStats() {
// Debugging message to retrieve raft stats.
return getRaftActorContext().hasFollowers();
}
+ /**
+ * @deprecated Deprecated in favor of {@link org.opendaylight.controller.cluster.raft.base.messages.DeleteEntriesTest}
+ * whose type for fromIndex is long instead of int. This class was kept for backwards
+ * compatibility with Helium.
+ */
+ @Deprecated
static class DeleteEntries implements Serializable {
private static final long serialVersionUID = 1L;
private final int fromIndex;