2 * Copyright (c) 2015, 2017 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
8 package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
10 import java.util.ArrayList;
11 import java.util.List;
12 import java.util.NoSuchElementException;
13 import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
14 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
15 import org.opendaylight.ovsdb.lib.message.TableUpdates;
16 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 public class HwvtepOperationalCommandAggregator implements TransactionCommand {
22 private static final Logger LOG = LoggerFactory.getLogger(HwvtepOperationalCommandAggregator.class);
23 private List<TransactionCommand> commands = new ArrayList<>();
24 private final HwvtepConnectionInstance connectionInstance;
26 public HwvtepOperationalCommandAggregator(HwvtepConnectionInstance key,TableUpdates updates,
27 DatabaseSchema dbSchema) {
28 this.connectionInstance = key;
29 commands.add(new GlobalUpdateCommand(key, updates, dbSchema));
30 commands.add(new HwvtepPhysicalSwitchUpdateCommand(key, updates, dbSchema));
31 commands.add(new HwvtepPhysicalSwitchRemoveCommand(key, updates, dbSchema));
32 commands.add(new HwvtepManagerUpdateCommand(key, updates, dbSchema));
33 commands.add(new HwvtepManagerRemoveCommand(key, updates, dbSchema));
34 commands.add(new HwvtepLogicalSwitchUpdateCommand(key, updates, dbSchema));
35 commands.add(new HwvtepPhysicalPortUpdateCommand(key, updates, dbSchema));
36 commands.add(new HwvtepPhysicalPortRemoveCommand(key, updates, dbSchema));
37 commands.add(new HwvtepPhysicalLocatorUpdateCommand(key, updates, dbSchema));
38 commands.add(new HwvtepTunnelUpdateCommand(key, updates, dbSchema));
39 commands.add(new HwvtepTunnelRemoveCommand(key, updates, dbSchema));
40 commands.add(new HwvtepPhysicalLocatorRemoveCommand(key, updates, dbSchema));
41 commands.add(new HwvtepUcastMacsLocalUpdateCommand(key, updates, dbSchema));
42 commands.add(new HwvtepUcastMacsRemoteUpdateCommand(key, updates, dbSchema));
43 commands.add(new HwvtepMcastMacsLocalUpdateCommand(key, updates, dbSchema));
44 commands.add(new HwvtepMcastMacsRemoteUpdateCommand(key, updates, dbSchema));
45 commands.add(new HwvtepMacEntriesRemoveCommand(key, updates, dbSchema));
46 commands.add(new HwvtepLogicalSwitchRemoveCommand(key, updates, dbSchema));
47 commands.add(new HwvtepLogicalRouterUpdateCommand(key, updates, dbSchema));
48 commands.add(new HwvtepLogicalRouterRemoveCommand(key, updates, dbSchema));
52 public void execute(ReadWriteTransaction transaction) {
53 for (TransactionCommand command: commands) {
55 // This may be noisy, can be silenced if needed.
56 LOG.trace("Executing command {}", command);
57 command.execute(transaction);
58 } catch (NullPointerException | NoSuchElementException | ClassCastException e) {
59 LOG.error("Execution of command {} failed with the following exception."
60 + " Continuing the execution of remaining commands", command, e);
64 connectionInstance.getDeviceInfo().onOperDataAvailable();