Bug 6185 - southbound system tests failing when
[ovsdb.git] / hwvtepsouthbound / hwvtepsouthbound-impl / src / main / java / org / opendaylight / ovsdb / hwvtepsouthbound / transact / TransactInvokerImpl.java
1 /*
2  * Copyright (c) 2015 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
9 package org.opendaylight.ovsdb.hwvtepsouthbound.transact;
10
11 import java.util.List;
12
13 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
14 import org.opendaylight.ovsdb.lib.operations.OperationResult;
15 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
16 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 import com.google.common.util.concurrent.ListenableFuture;
21
22 public class TransactInvokerImpl implements TransactInvoker {
23     private static final Logger LOG = LoggerFactory.getLogger(TransactInvokerImpl.class);
24     private HwvtepConnectionInstance connectionInstance;
25     private DatabaseSchema dbSchema;
26
27     public TransactInvokerImpl(HwvtepConnectionInstance connectionInstance, DatabaseSchema dbSchema) {
28         this.connectionInstance = connectionInstance;
29         this.dbSchema = dbSchema;
30     }
31
32     @Override
33     public void invoke(TransactCommand command) {
34         TransactionBuilder tb = new TransactionBuilder(connectionInstance.getOvsdbClient(), dbSchema);
35         command.execute(tb);
36         ListenableFuture<List<OperationResult>> result = tb.execute();
37         LOG.debug("invoke: command: {}, tb: {}", command, tb);
38         if (tb.getOperations().size() > 0) {
39             try {
40                 List<OperationResult> got = result.get();
41                 LOG.debug("OVSDB transaction result: {}", got);
42             } catch (Exception e) {
43                 LOG.warn("Transact execution exception: ", e);
44             }
45             LOG.trace("invoke exit command: {}, tb: {}", command, tb);
46         }
47     }
48
49 }