Use static Procedure callback for ApplyJournalEntries 70/16370/2
authorTom Pantelis <tpanteli@brocade.com>
Thu, 12 Mar 2015 00:12:42 +0000 (20:12 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Thu, 12 Mar 2015 00:33:06 +0000 (20:33 -0400)
Optimization in RaftActor to reuse a static Procedure callback instance
when persisting ApplyJournalEntries.

Change-Id: Id4b799b847191f9d7b31aca54d9926638407410e
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java

index 01787a849759d1462f138b2f866be1ae4240e019..eaa005e3efdf6911a7beadce66e427d68a89161e 100644 (file)
@@ -87,6 +87,13 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
 
     private static final long APPLY_STATE_DELAY_THRESHOLD_IN_NANOS = TimeUnit.MILLISECONDS.toNanos(50L); // 50 millis
 
+    private static final Procedure<ApplyJournalEntries> APPLY_JOURNAL_ENTRIES_PERSIST_CALLBACK =
+            new Procedure<ApplyJournalEntries>() {
+                @Override
+                public void apply(ApplyJournalEntries param) throws Exception {
+                }
+            };
+
     protected final Logger LOG = LoggerFactory.getLogger(getClass());
 
     /**
@@ -319,11 +326,8 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
             if(LOG.isDebugEnabled()) {
                 LOG.debug("{}: Persisting ApplyLogEntries with index={}", persistenceId(), applyEntries.getToIndex());
             }
-            persistence().persist(applyEntries, new Procedure<ApplyJournalEntries>() {
-                @Override
-                public void apply(ApplyJournalEntries param) throws Exception {
-                }
-            });
+
+            persistence().persist(applyEntries, APPLY_JOURNAL_ENTRIES_PERSIST_CALLBACK);
 
         } else if(message instanceof ApplySnapshot ) {
             Snapshot snapshot = ((ApplySnapshot) message).getSnapshot();