2 * Copyright (c) 2014 Cisco Systems, Inc. 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.ovsdb.southbound.ovsdb.transact;
10 import java.util.List;
12 import org.opendaylight.ovsdb.lib.operations.OperationResult;
13 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
14 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
15 import org.opendaylight.ovsdb.southbound.OvsdbConnectionInstance;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 import com.google.common.util.concurrent.ListenableFuture;
21 public class TransactInvokerImpl implements TransactInvoker {
22 private static final Logger LOG = LoggerFactory.getLogger(BridgeUpdateCommand.class);
23 private OvsdbConnectionInstance connectionInstance;
24 private DatabaseSchema dbSchema;
26 public TransactInvokerImpl(OvsdbConnectionInstance connectionInstance, DatabaseSchema dbSchema) {
27 this.connectionInstance = connectionInstance;
28 this.dbSchema = dbSchema;
32 public void invoke(TransactCommand command) {
33 TransactionBuilder tb = new TransactionBuilder(connectionInstance, dbSchema);
35 ListenableFuture<List<OperationResult>> result = tb.execute();
36 LOG.debug("invoke: command: {}, tb: {}", command, tb);
37 if (tb.getOperations().size() > 0) {
39 List<OperationResult> got = result.get();
40 LOG.debug("OVSDB transaction result: {}", got);
41 } catch (Exception e) {
42 LOG.warn("Transact execution exception: ", e);
44 LOG.trace("invoke exit command: {}, tb: {}", command, tb);