2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
3 * Copyright (c) 2024 PANTHEON.tech, s.r.o.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.impl.services.sal;
11 import com.google.common.util.concurrent.FutureCallback;
12 import com.google.common.util.concurrent.Futures;
13 import com.google.common.util.concurrent.ListenableFuture;
14 import com.google.common.util.concurrent.MoreExecutors;
15 import org.opendaylight.openflowplugin.api.openflow.FlowGroupStatus;
16 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
17 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
18 import org.opendaylight.openflowplugin.impl.util.ErrorUtil;
19 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroup;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput;
23 import org.opendaylight.yangtools.yang.common.RpcResult;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
27 public final class RemoveGroupImpl extends AbstractGroupRpc<RemoveGroupInput, RemoveGroupOutput>
28 implements RemoveGroup {
29 private static final Logger LOG = LoggerFactory.getLogger(RemoveGroupImpl.class);
31 public RemoveGroupImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext,
32 final ConvertorExecutor convertorExecutor) {
33 super(requestContextStack, deviceContext, convertorExecutor, RemoveGroupOutput.class);
37 public ListenableFuture<RpcResult<RemoveGroupOutput>> invoke(final RemoveGroupInput input) {
38 final var resultFuture = single.canUseSingleLayerSerialization() ? single.handleServiceCall(input)
39 : multi.handleServiceCall(input);
41 Futures.addCallback(resultFuture, new FutureCallback<>() {
43 public void onSuccess(final RpcResult<RemoveGroupOutput> result) {
44 if (result.isSuccessful()) {
45 if (LOG.isDebugEnabled()) {
46 LOG.debug("Group remove with id={} finished without error", input.getGroupId().getValue());
47 deviceContext.getDeviceGroupRegistry().appendHistoryGroup(input.getGroupId(),
48 input.getGroupType(), FlowGroupStatus.REMOVED);
51 LOG.warn("Group remove with id={} failed, errors={}", input.getGroupId().getValue(),
52 ErrorUtil.errorsToString(result.getErrors()));
53 LOG.debug("Group input={}", input);
58 public void onFailure(final Throwable throwable) {
59 LOG.warn("Service call for removing group={} failed", input.getGroupId().getValue(), throwable);
61 }, MoreExecutors.directExecutor());