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
8 package org.opendaylight.openflowplugin.test;
10 import com.google.common.collect.ImmutableSet;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.mdsal.binding.api.DataBroker;
13 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
14 import org.opendaylight.mdsal.binding.api.RpcProviderService;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
26 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
27 import org.opendaylight.yangtools.concepts.ObjectRegistration;
28 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
29 import org.opendaylight.yangtools.yang.common.RpcResult;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
33 public class OpenflowpluginMeterTestServiceProvider implements AutoCloseable,
35 private static final Logger LOG = LoggerFactory
36 .getLogger(OpenflowpluginMeterTestServiceProvider.class);
37 private DataBroker dataService;
38 private ObjectRegistration<SalMeterService> meterRegistration;
39 private NotificationPublishService notificationService;
42 * Gets the data service.
44 * @return {@link #dataService}
46 public DataBroker getDataService() {
47 return this.dataService;
51 * Sets the {@link #dataService}.
53 public void setDataService(final DataBroker dataService) {
54 this.dataService = dataService;
58 * Gets the meter registration.
60 * @return {@link #meterRegistration}
62 public ObjectRegistration<SalMeterService> getMeterRegistration() {
63 return this.meterRegistration;
67 * Sets the {@link #meterRegistration}.
69 public void setMeterRegistration(final ObjectRegistration<SalMeterService> meterRegistration) {
70 this.meterRegistration = meterRegistration;
74 * Gets the notification service.
76 * @return {@link #notificationService}
78 public NotificationPublishService getNotificationService() {
79 return this.notificationService;
83 * Sets the {@link #notificationService}.
85 public void setNotificationService(final NotificationPublishService notificationService) {
86 this.notificationService = notificationService;
90 OpenflowpluginMeterTestServiceProvider.LOG
91 .info("SalMeterServiceProvider Started.");
97 * @see java.lang.AutoCloseable#close()
100 public void close() {
101 OpenflowpluginMeterTestServiceProvider.LOG
102 .info("SalMeterServiceProvide stopped.");
103 meterRegistration.close();
110 * org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918
112 * #addMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter
113 * .service.rev130918.AddMeterInput)
116 public ListenableFuture<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
117 OpenflowpluginMeterTestServiceProvider.LOG.info("addMeter - {}", input);
125 * org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918
127 * #removeMeter(org.opendaylight.yang.gen.v1.urn.opendaylight
128 * .meter.service.rev130918.RemoveMeterInput)
131 public ListenableFuture<RpcResult<RemoveMeterOutput>> removeMeter(
132 final RemoveMeterInput input) {
133 OpenflowpluginMeterTestServiceProvider.LOG.info("removeMeter - {}", input);
141 * org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918
143 * #updateMeter(org.opendaylight.yang.gen.v1.urn.opendaylight
144 * .meter.service.rev130918.UpdateMeterInput)
147 public ListenableFuture<RpcResult<UpdateMeterOutput>> updateMeter(
148 final UpdateMeterInput input) {
149 OpenflowpluginMeterTestServiceProvider.LOG.info("updateMeter - {}", input);
153 public ObjectRegistration<OpenflowpluginMeterTestServiceProvider> register(final RpcProviderService rpcRegistry) {
154 setMeterRegistration(rpcRegistry.registerRpcImplementation(SalMeterService.class, this, ImmutableSet.of(
155 InstanceIdentifier.create(Nodes.class)
156 .child(Node.class, new NodeKey(new NodeId(OpenflowpluginTestActivator.NODE_ID))))));
158 return new AbstractObjectRegistration<OpenflowpluginMeterTestServiceProvider>(this) {
161 protected void removeRegistration() {
162 meterRegistration.close();