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.List;
12 import java.util.concurrent.Callable;
13 import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
14 import org.opendaylight.netvirt.elan.utils.ElanUtils;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 public class InterfaceAddWorkerOnElan implements Callable<List<? extends ListenableFuture<?>>> {
22 private static final Logger LOG = LoggerFactory.getLogger(InterfaceAddWorkerOnElan.class);
24 private final String key;
25 private final ElanInterface elanInterface;
26 private final ElanInstance elanInstance;
27 private final InterfaceInfo interfaceInfo;
28 private final ElanInterfaceManager dataChangeListener;
30 public InterfaceAddWorkerOnElan(String key, ElanInterface elanInterface, InterfaceInfo interfaceInfo,
31 ElanInstance elanInstance, ElanInterfaceManager dataChangeListener) {
33 this.elanInterface = elanInterface;
34 this.interfaceInfo = interfaceInfo;
35 this.elanInstance = elanInstance;
36 this.dataChangeListener = dataChangeListener;
40 public String toString() {
41 return "InterfaceAddWorkerOnElan [key=" + key + ", elanInterface=" + elanInterface + ", elanInstance="
42 + elanInstance + ", interfaceInfo=" + interfaceInfo + "]";
47 @SuppressWarnings("checkstyle:IllegalCatch")
48 public List<ListenableFuture<Void>> call() {
49 LOG.info("InterfaceAddWorkerOnElan: Handling elan interface add for elan interface: {} and elan instance: {} ",
50 elanInterface.getName(), elanInstance.getElanInstanceName());
52 return dataChangeListener.addElanInterface(elanInterface, interfaceInfo, elanInstance);
53 } catch (RuntimeException e) {
54 return ElanUtils.returnFailedListenableFutureIfTransactionCommitFailedExceptionCauseOrElseThrow(e);