Bump versions by x.(y+1).z
[ovsdb.git] / hwvtepsouthbound / hwvtepsouthbound-impl / src / main / java / org / opendaylight / ovsdb / hwvtepsouthbound / transactions / md / HwvtepOperationalCommandAggregator.java
1 /*
2  * Copyright (c) 2015, 2017 Ericsson India Global Services Pvt Ltd. 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.hwvtepsouthbound.transactions.md;
9
10 import java.util.ArrayList;
11 import java.util.List;
12 import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
13 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
14 import org.opendaylight.ovsdb.lib.message.TableUpdates;
15 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 public final class HwvtepOperationalCommandAggregator implements TransactionCommand {
20     private static final Logger LOG = LoggerFactory.getLogger(HwvtepOperationalCommandAggregator.class);
21
22     private List<TransactionCommand> commands = new ArrayList<>();
23     private final HwvtepConnectionInstance connectionInstance;
24
25     public HwvtepOperationalCommandAggregator(HwvtepConnectionInstance key,TableUpdates updates,
26             DatabaseSchema dbSchema) {
27         this.connectionInstance = key;
28         commands.add(new GlobalUpdateCommand(key, updates, dbSchema));
29         commands.add(new HwvtepPhysicalSwitchUpdateCommand(key, updates, dbSchema));
30         commands.add(new HwvtepPhysicalSwitchRemoveCommand(key, updates, dbSchema));
31         commands.add(new HwvtepManagerUpdateCommand(key, updates, dbSchema));
32         commands.add(new HwvtepManagerRemoveCommand(key, updates, dbSchema));
33         commands.add(new HwvtepLogicalSwitchUpdateCommand(key, updates, dbSchema));
34         commands.add(new HwvtepPhysicalPortUpdateCommand(key, updates, dbSchema));
35         commands.add(new HwvtepPhysicalPortRemoveCommand(key, updates, dbSchema));
36         commands.add(new HwvtepPhysicalLocatorUpdateCommand(key, updates, dbSchema));
37         commands.add(new HwvtepTunnelUpdateCommand(key, updates, dbSchema));
38         commands.add(new HwvtepTunnelRemoveCommand(key, updates, dbSchema));
39         commands.add(new HwvtepPhysicalLocatorRemoveCommand(key, updates, dbSchema));
40         commands.add(new HwvtepUcastMacsLocalUpdateCommand(key, updates, dbSchema));
41         commands.add(new HwvtepUcastMacsRemoteUpdateCommand(key, updates, dbSchema));
42         commands.add(new HwvtepMcastMacsLocalUpdateCommand(key, updates, dbSchema));
43         commands.add(new HwvtepMcastMacsRemoteUpdateCommand(key, updates, dbSchema));
44         commands.add(new HwvtepMacEntriesRemoveCommand(key, updates, dbSchema));
45         commands.add(new HwvtepLogicalSwitchRemoveCommand(key, updates, dbSchema));
46         commands.add(new HwvtepLogicalRouterUpdateCommand(key, updates, dbSchema));
47         commands.add(new HwvtepLogicalRouterRemoveCommand(key, updates, dbSchema));
48     }
49
50     @Override
51     public void execute(ReadWriteTransaction transaction) {
52         for (TransactionCommand command: commands) {
53             // This may be noisy, can be silenced if needed.
54             LOG.trace("Executing command {}", command);
55             command.execute(transaction);
56         }
57         connectionInstance.getDeviceInfo().onOperDataAvailable();
58     }
59
60     @Override
61     public void onSuccess() {
62
63         for (TransactionCommand command : commands) {
64             command.onSuccess();
65         }
66     }
67
68     @Override
69     public void onFailure() {
70         for (TransactionCommand command : commands) {
71             command.onFailure();
72         }
73     }
74
75 }