2 * Copyright (c) 2015 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;
10 import java.util.concurrent.atomic.AtomicBoolean;
11 import org.opendaylight.ovsdb.lib.MonitorCallBack;
12 import org.opendaylight.ovsdb.lib.message.TableUpdates;
13 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
14 import org.opendaylight.ovsdb.southbound.transactions.md.OvsdbOperationalCommandAggregator;
15 import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 public class OvsdbMonitorCallback implements MonitorCallBack {
20 private static final Logger LOG = LoggerFactory.getLogger(OvsdbMonitorCallback.class);
22 private final InstanceIdentifierCodec instanceIdentifierCodec;
23 private TransactionInvoker txInvoker;
24 private OvsdbConnectionInstance key;
25 private AtomicBoolean intialUpdate = new AtomicBoolean(false);
27 OvsdbMonitorCallback(InstanceIdentifierCodec instanceIdentifierCodec, OvsdbConnectionInstance key,
28 TransactionInvoker txInvoker) {
29 this.instanceIdentifierCodec = instanceIdentifierCodec;
30 this.txInvoker = txInvoker;
35 public void update(TableUpdates result, DatabaseSchema dbSchema) {
36 boolean isFirstUpdate = intialUpdate.compareAndSet(false, true);
37 txInvoker.invoke(new OvsdbOperationalCommandAggregator(instanceIdentifierCodec, key, result,
38 dbSchema, isFirstUpdate));
39 LOG.trace("Updated dbSchema: {} and result: {}", dbSchema, result);
43 public void exception(Throwable exception) {
44 LOG.warn("exception", exception);