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