2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.openflowplugin.test;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
14 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
15 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
28 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
29 import org.opendaylight.yangtools.concepts.ObjectRegistration;
30 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
31 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
32 import org.opendaylight.yangtools.yang.common.RpcResult;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
36 public class OpenflowpluginMeterTestServiceProvider implements AutoCloseable,
38 private static final Logger LOG = LoggerFactory
39 .getLogger(OpenflowpluginMeterTestServiceProvider.class);
40 private DataBroker dataService;
41 private RoutedRpcRegistration<SalMeterService> meterRegistration;
42 private NotificationProviderService notificationService;
45 * Gets the data service.
47 * @return {@link #dataService}
49 public DataBroker getDataService() {
50 return this.dataService;
54 * Sets the {@link #dataService}.
56 public void setDataService(final DataBroker dataService) {
57 this.dataService = dataService;
61 * Gets the meter registration.
63 * @return {@link #meterRegistration}
65 public RoutedRpcRegistration<SalMeterService> getMeterRegistration() {
66 return this.meterRegistration;
70 * Sets the {@link #meterRegistration}.
72 public void setMeterRegistration(
73 final RoutedRpcRegistration<SalMeterService> meterRegistration) {
74 this.meterRegistration = meterRegistration;
78 * Gets the notification service.
80 * @return {@link #notificationService}
82 public NotificationProviderService getNotificationService() {
83 return this.notificationService;
87 * Sets the {@link #notificationService}.
89 public void setNotificationService(
90 final NotificationProviderService notificationService) {
91 this.notificationService = notificationService;
95 OpenflowpluginMeterTestServiceProvider.LOG
96 .info("SalMeterServiceProvider Started.");
102 * @see java.lang.AutoCloseable#close()
105 public void close() {
106 OpenflowpluginMeterTestServiceProvider.LOG
107 .info("SalMeterServiceProvide stopped.");
108 meterRegistration.close();
115 * org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918
117 * #addMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter
118 * .service.rev130918.AddMeterInput)
121 public ListenableFuture<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
122 OpenflowpluginMeterTestServiceProvider.LOG.info("addMeter - {}", input);
130 * org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918
132 * #removeMeter(org.opendaylight.yang.gen.v1.urn.opendaylight
133 * .meter.service.rev130918.RemoveMeterInput)
136 public ListenableFuture<RpcResult<RemoveMeterOutput>> removeMeter(
137 final RemoveMeterInput input) {
138 OpenflowpluginMeterTestServiceProvider.LOG.info("removeMeter - {}", input);
146 * org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918
148 * #updateMeter(org.opendaylight.yang.gen.v1.urn.opendaylight
149 * .meter.service.rev130918.UpdateMeterInput)
152 public ListenableFuture<RpcResult<UpdateMeterOutput>> updateMeter(
153 final UpdateMeterInput input) {
154 OpenflowpluginMeterTestServiceProvider.LOG.info("updateMeter - {}", input);
158 public ObjectRegistration<OpenflowpluginMeterTestServiceProvider> register(
159 final RpcProviderRegistry rpcRegistry) {
161 RoutedRpcRegistration<SalMeterService> addRoutedRpcImplementation = rpcRegistry.addRoutedRpcImplementation(
162 SalMeterService.class, this);
164 setMeterRegistration(addRoutedRpcImplementation);
166 InstanceIdentifierBuilder<Nodes> builder1 = InstanceIdentifier
167 .<Nodes>builder(Nodes.class);
169 NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
170 NodeKey nodeKey = new NodeKey(nodeId);
172 InstanceIdentifierBuilder<Node> nodeIndentifier = builder1
173 .<Node, NodeKey>child(Node.class, nodeKey);
175 InstanceIdentifier<Node> instance = nodeIndentifier.build();
177 meterRegistration.registerPath(NodeContext.class, instance);
179 RoutedRpcRegistration<SalMeterService> meterRegistration1 = this
180 .getMeterRegistration();
182 return new AbstractObjectRegistration<OpenflowpluginMeterTestServiceProvider>(this) {
185 protected void removeRegistration() {
186 meterRegistration1.close();