Convert itm-impl to use mdsal-binding-util
[genius.git] / itm / itm-impl / src / main / java / org / opendaylight / genius / itm / confighelpers / OvsdbTepAddWorker.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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 package org.opendaylight.genius.itm.confighelpers;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.List;
12 import java.util.concurrent.Callable;
13 import org.opendaylight.mdsal.binding.api.DataBroker;
14 import org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner;
15 import org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 public class OvsdbTepAddWorker implements Callable<List<? extends ListenableFuture<?>>> {
20
21     private static final Logger LOG = LoggerFactory.getLogger(OvsdbTepAddWorker.class) ;
22
23     private final String tepIp;
24     private final String strDpid;
25     private final String tzName;
26     private final boolean ofTunnel;
27     private final DataBroker dataBroker;
28     private final ManagedNewTransactionRunner txRunner;
29
30     public OvsdbTepAddWorker(String tepIp, String strDpnId, String tzName,  boolean ofTunnel, DataBroker broker) {
31         this.tepIp = tepIp;
32         this.strDpid = strDpnId;
33         this.tzName = tzName;
34         this.ofTunnel = ofTunnel;
35         this.dataBroker = broker;
36         this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
37     }
38
39     @Override
40     public List<? extends ListenableFuture<?>> call() throws Exception {
41         LOG.trace("Add TEP task is picked from DataStoreJobCoordinator for execution.");
42         // add TEP received from southbound OVSDB into ITM config DS.
43         return OvsdbTepAddConfigHelper.addTepReceivedFromOvsdb(tepIp, strDpid, tzName, ofTunnel, dataBroker, txRunner);
44     }
45 }