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;
12 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupConvertor;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder;
22 import org.opendaylight.yangtools.yang.common.RpcResult;
23 import org.slf4j.Logger;
24 import java.math.BigInteger;
25 import java.util.concurrent.Future;
27 public class SalGroupServiceImpl extends CommonService implements SalGroupService {
29 private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalGroupServiceImpl.class);
32 public Future<RpcResult<AddGroupOutput>> addGroup(final AddGroupInput input) {
33 return ServiceCallProcessingUtil.<AddGroupOutput, Void> handleServiceCall(rpcContext, PRIMARY_CONNECTION,
34 deviceContext, new Function<BigInteger,Future<RpcResult<Void>>>() {
37 public Future<RpcResult<Void>> apply(final BigInteger IDConnection) {
38 return convertAndSend(input, IDConnection);
44 public Future<RpcResult<UpdateGroupOutput>> updateGroup(final UpdateGroupInput input) {
45 return ServiceCallProcessingUtil.<UpdateGroupOutput, Void> handleServiceCall(rpcContext, PRIMARY_CONNECTION,
46 deviceContext, new Function<BigInteger,Future<RpcResult<Void>>>() {
49 public Future<RpcResult<Void>> apply(final BigInteger IDConnection) {
50 return convertAndSend(input.getUpdatedGroup(), IDConnection);
56 public Future<RpcResult<RemoveGroupOutput>> removeGroup(final RemoveGroupInput input) {
57 return ServiceCallProcessingUtil.<RemoveGroupOutput, Void> handleServiceCall(rpcContext, PRIMARY_CONNECTION,
58 deviceContext, new Function<BigInteger,Future<RpcResult<Void>>>() {
61 public Future<RpcResult<Void>> apply(final BigInteger IDConnection) {
62 return convertAndSend(input, IDConnection);
67 Future<RpcResult<Void>> convertAndSend(final Group iputGroup, final BigInteger IDConnection) {
68 final GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(iputGroup, version, datapathId);
69 ofGroupModInput.setXid(deviceContext.getNextXid().getValue());
70 return provideConnectionAdapter(IDConnection).groupMod(ofGroupModInput.build());