2 * Copyright (c) 2015 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
9 package org.opendaylight.ovsdb.hwvtepsouthbound.transact;
11 import java.util.List;
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;
20 import com.google.common.util.concurrent.ListenableFuture;
22 public class TransactInvokerImpl implements TransactInvoker {
23 private static final Logger LOG = LoggerFactory.getLogger(TransactInvokerImpl.class);
24 private HwvtepConnectionInstance connectionInstance;
25 private DatabaseSchema dbSchema;
27 public TransactInvokerImpl(HwvtepConnectionInstance connectionInstance, DatabaseSchema dbSchema) {
28 this.connectionInstance = connectionInstance;
29 this.dbSchema = dbSchema;
33 public void invoke(TransactCommand command) {
34 TransactionBuilder tb = new TransactionBuilder(connectionInstance.getOvsdbClient(), dbSchema);
36 ListenableFuture<List<OperationResult>> result = tb.execute();
37 LOG.debug("invoke: command: {}, tb: {}", command, tb);
38 if (tb.getOperations().size() > 0) {
40 List<OperationResult> got = result.get();
41 LOG.debug("OVSDB transaction result: {}", got);
42 } catch (Exception e) {
43 LOG.warn("Transact execution exception: ", e);
45 LOG.trace("invoke exit command: {}, tb: {}", command, tb);