2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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.netvirt.elan.internal;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.ArrayList;
12 import java.util.List;
13 import java.util.concurrent.Callable;
15 import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
16 import org.opendaylight.netvirt.elan.utils.ElanUtils;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 public class InterfaceRemoveWorkerOnElanInterface implements Callable<List<ListenableFuture<Void>>> {
23 private static final Logger LOG = LoggerFactory.getLogger(InterfaceRemoveWorkerOnElanInterface.class);
25 private final String interfaceName;
26 private final ElanInstance elanInfo;
27 private final InterfaceInfo interfaceInfo;
28 private final ElanInterfaceManager dataChangeListener;
29 private final boolean isLastElanInterface;
31 public InterfaceRemoveWorkerOnElanInterface(String interfaceName, ElanInstance elanInfo,
32 InterfaceInfo interfaceInfo, ElanInterfaceManager dataChangeListener, boolean isLastElanInterface) {
33 this.interfaceName = interfaceName;
34 this.elanInfo = elanInfo;
35 this.interfaceInfo = interfaceInfo;
36 this.dataChangeListener = dataChangeListener;
37 this.isLastElanInterface = isLastElanInterface;
41 public String toString() {
42 return "InterfaceRemoveWorkerOnElanInterface [key=" + interfaceName + ", elanInfo=" + elanInfo
43 + ", interfaceInfo=" + interfaceInfo + ", isLastElanInterface=" + isLastElanInterface + "]";
47 @SuppressWarnings("checkstyle:IllegalCatch")
48 public List<ListenableFuture<Void>> call() {
49 List<ListenableFuture<Void>> futures = new ArrayList<>();
51 futures.addAll(dataChangeListener.removeEntriesForElanInterface(elanInfo, interfaceInfo, interfaceName,
52 isLastElanInterface));
53 } catch (RuntimeException e) {
54 LOG.error("Error while processing for interface {} and elan {}", interfaceName, elanInfo, e);
55 ElanUtils.addToListenableFutureIfTxException(e, futures);