Merge "Add generic arguments"
authorMoiz Raja <moraja@cisco.com>
Fri, 10 Apr 2015 16:08:56 +0000 (16:08 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 10 Apr 2015 16:08:57 +0000 (16:08 +0000)
1  2 
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java

index 77eaac2cfef076fd84959d0e9007fe6233413c9d,bafa116b55eb03e23fcc87279bcc245792b24787..5ab3f69bea994d60644cca47b9694205ae2ab039
@@@ -19,7 -19,6 +19,7 @@@ import java.io.ObjectInputStream
  import java.io.ObjectOutputStream;
  import java.util.HashMap;
  import java.util.Map;
 +import javax.annotation.Nonnull;
  import org.opendaylight.controller.cluster.example.messages.KeyValue;
  import org.opendaylight.controller.cluster.example.messages.KeyValueSaved;
  import org.opendaylight.controller.cluster.example.messages.PrintRole;
@@@ -27,8 -26,6 +27,8 @@@ import org.opendaylight.controller.clus
  import org.opendaylight.controller.cluster.notifications.RoleChangeNotifier;
  import org.opendaylight.controller.cluster.raft.ConfigParams;
  import org.opendaylight.controller.cluster.raft.RaftActor;
 +import org.opendaylight.controller.cluster.raft.RaftActorRecoveryCohort;
 +import org.opendaylight.controller.cluster.raft.RaftActorSnapshotCohort;
  import org.opendaylight.controller.cluster.raft.RaftState;
  import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply;
  import org.opendaylight.controller.cluster.raft.behaviors.Leader;
@@@ -37,9 -34,9 +37,9 @@@ import org.opendaylight.controller.clus
  /**
   * A sample actor showing how the RaftActor is to be extended
   */
 -public class ExampleActor extends RaftActor {
 +public class ExampleActor extends RaftActor implements RaftActorRecoveryCohort, RaftActorSnapshotCohort {
  
-     private final Map<String, String> state = new HashMap();
+     private final Map<String, String> state = new HashMap<>();
  
      private long persistIdentifier = 1;
      private final Optional<ActorRef> roleChangeNotifier;
          }
      }
  
 -    @Override protected void createSnapshot() {
 +    @Override
 +    public void createSnapshot(ActorRef actorRef) {
          ByteString bs = null;
          try {
              bs = fromObject(state);
          getSelf().tell(new CaptureSnapshotReply(bs.toByteArray()), null);
      }
  
 -    @Override protected void applySnapshot(byte [] snapshot) {
 +    @Override
 +    public void applySnapshot(byte [] snapshot) {
          state.clear();
          try {
-             state.putAll((HashMap) toObject(snapshot));
+             state.putAll((HashMap<String, String>) toObject(snapshot));
          } catch (Exception e) {
             LOG.error("Exception in applying snapshot", e);
          }
          if(LOG.isDebugEnabled()) {
-             LOG.debug("Snapshot applied to state : {}", ((HashMap) state).size());
+             LOG.debug("Snapshot applied to state : {}", ((HashMap<?, ?>) state).size());
          }
      }
  
      }
  
      @Override
 -    protected void startLogRecoveryBatch(int maxBatchSize) {
 +    @Nonnull
 +    protected RaftActorRecoveryCohort getRaftActorRecoveryCohort() {
 +        return this;
 +    }
 +
 +    @Override
 +    public void startLogRecoveryBatch(int maxBatchSize) {
 +    }
 +
 +    @Override
 +    public void appendRecoveredLogEntry(Payload data) {
      }
  
      @Override
 -    protected void appendRecoveredLogEntry(Payload data) {
 +    public void applyCurrentLogRecoveryBatch() {
      }
  
      @Override
 -    protected void applyCurrentLogRecoveryBatch() {
 +    public void onRecoveryComplete() {
      }
  
      @Override
 -    protected void onRecoveryComplete() {
 +    public void applyRecoverySnapshot(byte[] snapshot) {
      }
  
      @Override
 -    protected void applyRecoverySnapshot(byte[] snapshot) {
 +    protected RaftActorSnapshotCohort getRaftActorSnapshotCohort() {
 +        return this;
      }
  }