if(shardInformation != null && shardInformation.getActor() != null) {
shardInformation.getActor().tell(
- new SwitchBehavior(RaftState.valueOf(message.getNewState()), message.getTerm()), getSelf());
+ new SwitchBehavior(message.getNewState(), message.getTerm()), getSelf());
} else {
LOG.warn("Could not switch the behavior of shard {} to {} - shard is not yet available",
message.getShardName(), message.getNewState());
Preconditions.checkArgument(localShards.contains(shardName), shardName + " is not local");
Preconditions.checkArgument(ACCEPTABLE_STATES.contains(newState));
- shardManager.getSelf().tell(new SwitchShardBehavior(shardName, newState, term), ActorRef.noSender());
+ shardManager.getSelf().tell(new SwitchShardBehavior(shardName, RaftState.valueOf(newState), term),
+ ActorRef.noSender());
}
public void setSyncStatus(boolean syncStatus){
package org.opendaylight.controller.cluster.datastore.messages;
-public class SwitchShardBehavior {
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.cluster.raft.RaftState;
+
+public final class SwitchShardBehavior {
private final String shardName;
- private final String newState;
+ private final RaftState newState;
private final long term;
- public SwitchShardBehavior(String shardName, String newState, long term) {
- this.shardName = shardName;
- this.newState = newState;
+ public SwitchShardBehavior(String shardName, RaftState newState, long term) {
+ this.shardName = Preconditions.checkNotNull(shardName);
+ this.newState = Preconditions.checkNotNull(newState);
this.term = term;
}
return shardName;
}
- public String getNewState() {
+ public RaftState getNewState() {
return newState;
}
shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
shardManager.tell(new ActorInitialized(), mockShardActor);
- shardManager.tell(new SwitchShardBehavior(mockShardName, "Leader", 1000), getRef());
+ shardManager.tell(new SwitchShardBehavior(mockShardName, RaftState.Leader, 1000), getRef());
SwitchBehavior switchBehavior = MessageCollectorActor.expectFirstMatching(mockShardActor, SwitchBehavior.class);