Prevent ConfigPusher from killing its thread
[controller.git] / opendaylight / md-sal / compatibility / sal-compatibility / src / main / java / org / opendaylight / controller / sal / compatibility / topology / TopologyTransaction.xtend
1 package org.opendaylight.controller.sal.compatibility.topology
2
3 import java.util.Collections
4 import java.util.List
5 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction
6 import org.opendaylight.controller.md.sal.common.api.data.DataModification
7 import org.opendaylight.controller.sal.binding.api.data.DataProviderService
8 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService
9 import org.opendaylight.controller.sal.topology.TopoEdgeUpdate
10 import org.opendaylight.yangtools.yang.binding.DataObject
11 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
12 import org.opendaylight.yangtools.yang.common.RpcResult
13 import org.slf4j.LoggerFactory
14
15 class TopologyTransaction implements DataCommitTransaction<InstanceIdentifier<?extends DataObject>, DataObject> {
16     static val LOG = LoggerFactory.getLogger(TopologyTransaction);
17     @Property
18     val DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification;
19     
20     @Property
21     IPluginOutTopologyService topologyPublisher;
22     
23     @Property
24     DataProviderService dataService;
25     @Property
26     List<TopoEdgeUpdate> edgeUpdates;
27     
28     new(DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification,IPluginOutTopologyService topologyPublisher,
29         DataProviderService dataService,List<TopoEdgeUpdate> edgeUpdates) {
30         _modification = modification;
31         _topologyPublisher = topologyPublisher
32         _dataService = dataService
33         _edgeUpdates = edgeUpdates
34     }
35     override finish() throws IllegalStateException {
36         
37         if(topologyPublisher != null && _edgeUpdates != null && !edgeUpdates.empty) {
38             topologyPublisher.edgeUpdate(edgeUpdates)
39         }
40          
41          return new RpcResultTo()
42     }
43     
44     override getModification() {
45         return _modification;
46     }
47     
48     override rollback() throws IllegalStateException {
49         // NOOP
50     }
51 }
52 class RpcResultTo implements RpcResult<Void> {
53     
54     override getErrors() {
55         return Collections.emptySet
56     }
57     
58     override getResult() {
59         return null;
60     }
61     
62     override isSuccessful() {
63         return true;
64     }
65     
66 }