66031ca6bf8ce90f947fea7fd4ec19ee4e4bc503
[ovsdb.git] / southbound / southbound-impl / src / main / java / org / opendaylight / ovsdb / southbound / ovsdb / transact / TransactInvokerImpl.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. 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.ovsdb.southbound.ovsdb.transact;
9
10 import java.util.List;
11
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;
18
19 import com.google.common.util.concurrent.ListenableFuture;
20
21 public class TransactInvokerImpl implements TransactInvoker {
22     private static final Logger LOG = LoggerFactory.getLogger(BridgeCreateCommand.class);
23     private OvsdbConnectionInstance connectionInstance;
24     private DatabaseSchema dbSchema;
25
26     public TransactInvokerImpl(OvsdbConnectionInstance connectionInstance, DatabaseSchema dbSchema) {
27         this.connectionInstance =connectionInstance;
28         this.dbSchema = dbSchema;
29     }
30
31     @Override
32     public void invoke(TransactCommand command) {
33         TransactionBuilder tb = new TransactionBuilder(connectionInstance, dbSchema);
34         command.execute(tb);
35         ListenableFuture<List<OperationResult>> result = tb.execute();
36         try {
37             List<OperationResult> got = result.get();
38             LOG.debug("Results of create bridge request",got);
39         } catch (Exception e){
40             LOG.warn("Transact execution exception: ",e);
41         }
42     }
43
44 }