Remove use of {String,UUID}Identifier
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardDataTreeNotificationPublisherActor.java
1 /*
2  * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.datastore;
9
10 import akka.actor.Props;
11 import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
12 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
13
14 /**
15  * Actor used to generate and publish data tree notifications. This is used to offload the potentially
16  * expensive notification generation from the Shard actor.
17  *
18  * @author Thomas Pantelis
19  */
20 public class ShardDataTreeNotificationPublisherActor extends AbstractUntypedActor {
21
22     @Override
23     protected void handleReceive(Object message) {
24         if(message instanceof PublishNotifications) {
25             ((PublishNotifications)message).publish();
26         }
27     }
28
29     static Props props() {
30         return Props.create(ShardDataTreeNotificationPublisherActor.class);
31     }
32
33     static class PublishNotifications {
34         private final ShardDataTreeNotificationPublisher publisher;
35         private final DataTreeCandidate candidate;
36         private final String logContext;
37
38         PublishNotifications(ShardDataTreeNotificationPublisher publisher, DataTreeCandidate candidate,
39                 String logContext) {
40             this.publisher = publisher;
41             this.candidate = candidate;
42             this.logContext = logContext;
43         }
44
45         private void publish() {
46             publisher.publishChanges(candidate, logContext);
47         }
48     }
49 }