2 * Copyright (c) 2015 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.impl.services;
10 import com.google.common.base.Function;
11 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterConvertor;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder;
21 import org.opendaylight.yangtools.yang.common.RpcResult;
22 import org.slf4j.Logger;
23 import java.math.BigInteger;
24 import java.util.concurrent.Future;
26 public class SalMeterServiceImpl extends CommonService implements SalMeterService {
28 private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalMeterServiceImpl.class);
31 public Future<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
32 return this.<AddMeterOutput, Void>handleServiceCall( PRIMARY_CONNECTION,
33 new Function<BigInteger,Future<RpcResult<Void>>>() {
35 public Future<RpcResult<Void>> apply(final BigInteger IDConnection) {
36 return convertAndSend(input, IDConnection);
42 public Future<RpcResult<UpdateMeterOutput>> updateMeter(final UpdateMeterInput input) {
43 return this.<UpdateMeterOutput, Void>handleServiceCall( PRIMARY_CONNECTION,
44 new Function<BigInteger,Future<RpcResult<Void>>>() {
46 public Future<RpcResult<Void>> apply(final BigInteger IDConnection) {
47 return convertAndSend(input.getUpdatedMeter(), IDConnection);
53 public Future<RpcResult<RemoveMeterOutput>> removeMeter(final RemoveMeterInput input) {
54 return this.<RemoveMeterOutput, Void>handleServiceCall( PRIMARY_CONNECTION,
55 new Function<BigInteger,Future<RpcResult<Void>>>() {
57 public Future<RpcResult<Void>> apply(final BigInteger IDConnection) {
58 return convertAndSend(input, IDConnection);
63 Future<RpcResult<Void>> convertAndSend(final Meter iputMeter, final BigInteger IDConnection) {
64 final MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(iputMeter, version);
65 ofMeterModInput.setXid(deviceContext.getNextXid().getValue());
66 return provideConnectionAdapter(IDConnection).meterMod(ofMeterModInput.build());