Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Simplify code using Java 8 features
[controller.git]
/
opendaylight
/
md-sal
/
sal-distributed-datastore
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
cluster
/
datastore
/
ShardDataTreeNotificationPublisherActor.java
diff --git
a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeNotificationPublisherActor.java
b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeNotificationPublisherActor.java
index 81023562801926fb0aa05c394afb9014c4be5240..c22bc3bd98930c2e561a7b4f9b06083da1dfb8d0 100644
(file)
--- a/
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeNotificationPublisherActor.java
+++ b/
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeNotificationPublisherActor.java
@@
-7,7
+7,6
@@
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
-import akka.actor.Props;
import com.google.common.base.Stopwatch;
import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
import com.google.common.base.Stopwatch;
import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
@@
-19,31
+18,43
@@
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
*
* @author Thomas Pantelis
*/
*
* @author Thomas Pantelis
*/
-public class ShardDataTreeNotificationPublisherActor extends AbstractUntypedActor {
+public class ShardDataTreeNotificationPublisherActor<T extends ShardDataTreeNotificationPublisher>
+ extends AbstractUntypedActor {
+ private final T publisher;
private final Stopwatch timer = Stopwatch.createUnstarted();
private final String name;
private final Stopwatch timer = Stopwatch.createUnstarted();
private final String name;
+ private final String logContext;
- private ShardDataTreeNotificationPublisherActor(String name) {
+ protected ShardDataTreeNotificationPublisherActor(final T publisher, final String name, final String logContext) {
+ this.publisher = publisher;
this.name = name;
this.name = name;
+ this.logContext = logContext;
+ }
+
+ protected T publisher() {
+ return publisher;
+ }
+
+ protected String logContext() {
+ return logContext;
}
@Override
protected void handleReceive(Object message) {
}
@Override
protected void handleReceive(Object message) {
- if(message instanceof PublishNotifications) {
- PublishNotifications
publisher
= (PublishNotifications)message;
+ if
(message instanceof PublishNotifications) {
+ PublishNotifications
toPublish
= (PublishNotifications)message;
timer.start();
try {
timer.start();
try {
- publisher.publish
(
);
+ publisher.publish
Changes(toPublish.candidate
);
} finally {
long elapsedTime = timer.elapsed(TimeUnit.MILLISECONDS);
} finally {
long elapsedTime = timer.elapsed(TimeUnit.MILLISECONDS);
- if(elapsedTime >= ShardDataTreeNotificationPublisher.PUBLISH_DELAY_THRESHOLD_IN_MS) {
+ if
(elapsedTime >= ShardDataTreeNotificationPublisher.PUBLISH_DELAY_THRESHOLD_IN_MS) {
LOG.warn("{}: Generation of change events for {} took longer than expected. Elapsed time: {}",
LOG.warn("{}: Generation of change events for {} took longer than expected. Elapsed time: {}",
-
publisher.
logContext, name, timer);
+ logContext, name, timer);
} else {
} else {
- LOG.debug("{}: Elapsed time for generation of change events for {}: {}", publisher.logContext,
- name, timer);
+ LOG.debug("{}: Elapsed time for generation of change events for {}: {}", logContext, name, timer);
}
timer.reset();
}
timer.reset();
@@
-51,24
+62,11
@@
public class ShardDataTreeNotificationPublisherActor extends AbstractUntypedActo
}
}
}
}
- static Props props(String notificationType) {
- return Props.create(ShardDataTreeNotificationPublisherActor.class, notificationType);
- }
-
static class PublishNotifications {
static class PublishNotifications {
- private final ShardDataTreeNotificationPublisher publisher;
private final DataTreeCandidate candidate;
private final DataTreeCandidate candidate;
- private final String logContext;
- PublishNotifications(ShardDataTreeNotificationPublisher publisher, DataTreeCandidate candidate,
- String logContext) {
- this.publisher = publisher;
+ PublishNotifications(DataTreeCandidate candidate) {
this.candidate = candidate;
this.candidate = candidate;
- this.logContext = logContext;
- }
-
- private void publish() {
- publisher.publishChanges(candidate, logContext);
}
}
}
}
}
}