OPNFLWPLUG-983 Group and flow removal stats are not reported in order
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / AbstractSilentErrorService.java
1 /**
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.openflowplugin.impl.services;
10
11 import com.google.common.util.concurrent.Futures;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import java.util.function.Function;
14 import javax.annotation.Nonnull;
15 import javax.annotation.Nullable;
16 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
17 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
19 import org.opendaylight.yangtools.yang.binding.DataObject;
20 import org.opendaylight.yangtools.yang.common.RpcResult;
21 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
22
23 public abstract class AbstractSilentErrorService<I, O extends DataObject>
24         extends AbstractSimpleService<I, O> {
25
26     protected AbstractSilentErrorService(RequestContextStack requestContextStack,
27                                          DeviceContext deviceContext,
28                                          Class<O> clazz) {
29         super(requestContextStack, deviceContext, clazz);
30     }
31
32     @Override
33     public ListenableFuture<RpcResult<O>> handleServiceCall(@Nonnull I input,
34                                                             @Nullable final Function<OfHeader, Boolean> isComplete) {
35         return Futures.catching(
36             super.handleServiceCall(input, isComplete),
37             Throwable.class,
38             t -> RpcResultBuilder.<O>failed().build());
39     }
40 }