mirror of
				https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
				synced 2025-11-03 20:17:53 +00:00 
			
		
		
		
	ovsdb interface for client dhcp attributes -- first drop -> register for status changes
This commit is contained in:
		@@ -2,7 +2,9 @@ package com.telecominfraproject.wlan.opensync.ovsdb;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import java.security.cert.X509Certificate;
 | 
					import java.security.cert.X509Certificate;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.HashMap;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
import java.util.Set;
 | 
					import java.util.Set;
 | 
				
			||||||
import java.util.concurrent.CompletableFuture;
 | 
					import java.util.concurrent.CompletableFuture;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -38,6 +40,7 @@ import com.vmware.ovsdb.protocol.methods.RowUpdate;
 | 
				
			|||||||
import com.vmware.ovsdb.protocol.methods.TableUpdate;
 | 
					import com.vmware.ovsdb.protocol.methods.TableUpdate;
 | 
				
			||||||
import com.vmware.ovsdb.protocol.methods.TableUpdates;
 | 
					import com.vmware.ovsdb.protocol.methods.TableUpdates;
 | 
				
			||||||
import com.vmware.ovsdb.protocol.operation.notation.Row;
 | 
					import com.vmware.ovsdb.protocol.operation.notation.Row;
 | 
				
			||||||
 | 
					import com.vmware.ovsdb.protocol.operation.notation.Value;
 | 
				
			||||||
import com.vmware.ovsdb.service.OvsdbClient;
 | 
					import com.vmware.ovsdb.service.OvsdbClient;
 | 
				
			||||||
import com.vmware.ovsdb.service.OvsdbPassiveConnectionListener;
 | 
					import com.vmware.ovsdb.service.OvsdbPassiveConnectionListener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -78,6 +81,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
 | 
				
			|||||||
    public void listenForConnections() {
 | 
					    public void listenForConnections() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ConnectionCallback connectionCallback = new ConnectionCallback() {
 | 
					        ConnectionCallback connectionCallback = new ConnectionCallback() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            public void connected(OvsdbClient ovsdbClient) {
 | 
					            public void connected(OvsdbClient ovsdbClient) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -333,73 +337,156 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
 | 
				
			|||||||
        try {
 | 
					        try {
 | 
				
			||||||
            monitorAwlanNodeDbTable(ovsdbClient, key);
 | 
					            monitorAwlanNodeDbTable(ovsdbClient, key);
 | 
				
			||||||
        } catch (OvsdbClientException e) {
 | 
					        } catch (OvsdbClientException e) {
 | 
				
			||||||
            LOG.debug("Could not enable monitor for deletions to AWLAN_Node table. {}", e.getMessage());
 | 
					            LOG.debug("Could not enable monitor for AWLAN_Node table. {}", e.getMessage());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            monitorDhcpLeasedIpDbTable(ovsdbClient, key);
 | 
				
			||||||
 | 
					        } catch (OvsdbClientException e) {
 | 
				
			||||||
 | 
					            LOG.debug("Could not enable monitor for DHCP_leased_IP table. {}", e.getMessage());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        LOG.debug("Finished (re)setting monitors for AP {}", key);
 | 
					        LOG.debug("Finished (re)setting monitors for AP {}", key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void monitorAwlanNodeDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
 | 
					    private void monitorDhcpLeasedIpDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
 | 
				
			||||||
        CompletableFuture<TableUpdates> awCf = ovsdbClient
 | 
					 | 
				
			||||||
                .monitor(OvsdbDao.ovsdbName, OvsdbDao.awlanNodeDbTable + "_" + key,
 | 
					 | 
				
			||||||
                        new MonitorRequests(ImmutableMap.of(OvsdbDao.awlanNodeDbTable,
 | 
					 | 
				
			||||||
                                new MonitorRequest())),
 | 
					 | 
				
			||||||
                        new MonitorCallback() {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            @Override
 | 
					        CompletableFuture<TableUpdates> awCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
 | 
				
			||||||
                            public void update(TableUpdates tableUpdates) {
 | 
					                OvsdbDao.dhcpLeasedIpDbTable + "_" + key,
 | 
				
			||||||
                                LOG.info(OvsdbDao.awlanNodeDbTable + "_" + key + " monitor callback received {}",
 | 
					                new MonitorRequests(ImmutableMap.of(OvsdbDao.dhcpLeasedIpDbTable, new MonitorRequest())),
 | 
				
			||||||
                                        tableUpdates);
 | 
					                new MonitorCallback() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                extIntegrationInterface.awlanNodeDbTableUpdate(
 | 
					                    @Override
 | 
				
			||||||
                                        ovsdbDao.getOpensyncAWLANNode(tableUpdates, key, ovsdbClient), key);
 | 
					                    public void update(TableUpdates tableUpdates) {
 | 
				
			||||||
 | 
					                        LOG.info(OvsdbDao.dhcpLeasedIpDbTable + "_" + key + " monitor callback received {}",
 | 
				
			||||||
 | 
					                                tableUpdates);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        List<Map<String, String>> insert = new ArrayList<>();
 | 
				
			||||||
 | 
					                        List<Map<String, String>> delete = new ArrayList<>();
 | 
				
			||||||
 | 
					                        List<Map<String, String>> update = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
 | 
				
			||||||
 | 
					                            for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                if (rowUpdate.getNew() == null) {
 | 
				
			||||||
 | 
					                                    Map<String, String> rowMap = new HashMap<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    rowUpdate.getOld().getColumns().entrySet().stream().forEach(c -> {
 | 
				
			||||||
 | 
					                                        rowMap.put(c.getKey(), c.getValue().toString());
 | 
				
			||||||
 | 
					                                    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    delete.add(rowMap);
 | 
				
			||||||
 | 
					                                    // delete
 | 
				
			||||||
 | 
					                                } else if (rowUpdate.getOld() == null) {
 | 
				
			||||||
 | 
					                                    // insert
 | 
				
			||||||
 | 
					                                    Map<String, String> rowMap = new HashMap<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    rowUpdate.getNew().getColumns().entrySet().stream().forEach(c -> {
 | 
				
			||||||
 | 
					                                        rowMap.put(c.getKey(), c.getValue().toString());
 | 
				
			||||||
 | 
					                                    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    insert.add(rowMap);
 | 
				
			||||||
 | 
					                                } else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    // insert
 | 
				
			||||||
 | 
					                                    Map<String, String> rowMap = new HashMap<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    rowUpdate.getOld().getColumns().putAll(rowUpdate.getNew().getColumns());
 | 
				
			||||||
 | 
					                                    rowUpdate.getOld().getColumns().entrySet().stream().forEach(c -> {
 | 
				
			||||||
 | 
					                                        rowMap.put(c.getKey(), c.getValue().toString());
 | 
				
			||||||
 | 
					                                    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    update.add(rowMap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        });
 | 
					                        // -- mikehansen1970 --
 | 
				
			||||||
 | 
					                        //TODO: when AP has schema and functionality in place to support it's                       
 | 
				
			||||||
 | 
					                        // additional attributes this will be enhanced to either
 | 
				
			||||||
 | 
					                        // follow the same approach as the other table state
 | 
				
			||||||
 | 
					                        // changes, in which case an additional model will be
 | 
				
			||||||
 | 
					                        // defined in the opensync-ext-interface project along
 | 
				
			||||||
 | 
					                        // with appropriate interface methods to handle changes.
 | 
				
			||||||
 | 
					                        // Alternatively this may be handled in the events from
 | 
				
			||||||
 | 
					                        // the AP when that comes online.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        LOG.debug("insert {}", insert);
 | 
				
			||||||
 | 
					                        LOG.debug("delete {}", delete);
 | 
				
			||||||
 | 
					                        LOG.debug("modify {}", update);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        awCf.join();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void monitorAwlanNodeDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
 | 
				
			||||||
 | 
					        CompletableFuture<TableUpdates> awCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
 | 
				
			||||||
 | 
					                OvsdbDao.awlanNodeDbTable + "_" + key,
 | 
				
			||||||
 | 
					                new MonitorRequests(ImmutableMap.of(OvsdbDao.awlanNodeDbTable, new MonitorRequest())),
 | 
				
			||||||
 | 
					                new MonitorCallback() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    @Override
 | 
				
			||||||
 | 
					                    public void update(TableUpdates tableUpdates) {
 | 
				
			||||||
 | 
					                        LOG.info(OvsdbDao.awlanNodeDbTable + "_" + key + " monitor callback received {}", tableUpdates);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        extIntegrationInterface.awlanNodeDbTableUpdate(
 | 
				
			||||||
 | 
					                                ovsdbDao.getOpensyncAWLANNode(tableUpdates, key, ovsdbClient), key);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        awCf.join();
 | 
					        awCf.join();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void monitorWifiAssociatedClientsDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
 | 
					    private void monitorWifiAssociatedClientsDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
 | 
				
			||||||
        CompletableFuture<TableUpdates> acCf = ovsdbClient
 | 
					        CompletableFuture<TableUpdates> acCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
 | 
				
			||||||
                .monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiAssociatedClientsDbTable + "_" + key,
 | 
					                OvsdbDao.wifiAssociatedClientsDbTable + "_" + key,
 | 
				
			||||||
                        new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiAssociatedClientsDbTable,
 | 
					                new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiAssociatedClientsDbTable, new MonitorRequest())),
 | 
				
			||||||
                                new MonitorRequest())),
 | 
					                new MonitorCallback() {
 | 
				
			||||||
                        new MonitorCallback() {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            @Override
 | 
					                    @Override
 | 
				
			||||||
                            public void update(TableUpdates tableUpdates) {
 | 
					                    public void update(TableUpdates tableUpdates) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                LOG.info(OvsdbDao.wifiAssociatedClientsDbTable + "_" + key
 | 
					                        LOG.info(OvsdbDao.wifiAssociatedClientsDbTable + "_" + key + " monitor callback received {}",
 | 
				
			||||||
                                        + " monitor callback received {}", tableUpdates);
 | 
					                                tableUpdates);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                List<OpensyncWifiAssociatedClients> associatedClients = new ArrayList<>();
 | 
					                        List<OpensyncWifiAssociatedClients> associatedClients = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
 | 
					                        for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
                                    for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
 | 
					 | 
				
			||||||
                                        if ((rowUpdate.getOld() != null) && (rowUpdate.getNew() == null)) {
 | 
					 | 
				
			||||||
                                            Row row = rowUpdate.getOld();
 | 
					 | 
				
			||||||
                                            String deletedClientMac = row.getStringColumn("mac");
 | 
					 | 
				
			||||||
                                            // take care of the deletes as we go through the updates, as we want to delete before adding anyway.
 | 
					 | 
				
			||||||
                                            extIntegrationInterface.wifiAssociatedClientsDbTableDelete(deletedClientMac,
 | 
					 | 
				
			||||||
                                                    key);
 | 
					 | 
				
			||||||
                                        } else {
 | 
					 | 
				
			||||||
                                            associatedClients.addAll(ovsdbDao.getOpensyncWifiAssociatedClients(rowUpdate, key, ovsdbClient));
 | 
					 | 
				
			||||||
                                        }
 | 
					 | 
				
			||||||
                                    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
 | 
				
			||||||
 | 
					                                if ((rowUpdate.getOld() != null) && (rowUpdate.getNew() == null)) {
 | 
				
			||||||
 | 
					                                    Row row = rowUpdate.getOld();
 | 
				
			||||||
 | 
					                                    String deletedClientMac = row.getStringColumn("mac");
 | 
				
			||||||
 | 
					                                    // take care of the deletes as we go through
 | 
				
			||||||
 | 
					                                    // the updates, as we want to delete before
 | 
				
			||||||
 | 
					                                    // adding anyway.
 | 
				
			||||||
 | 
					                                    extIntegrationInterface.wifiAssociatedClientsDbTableDelete(deletedClientMac, key);
 | 
				
			||||||
 | 
					                                } else {
 | 
				
			||||||
 | 
					                                    associatedClients.addAll(
 | 
				
			||||||
 | 
					                                            ovsdbDao.getOpensyncWifiAssociatedClients(rowUpdate, key, ovsdbClient));
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
                                
 | 
					 | 
				
			||||||
                                
 | 
					 | 
				
			||||||
                                // now address the update/add
 | 
					 | 
				
			||||||
                                extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(associatedClients, key);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        });
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        // now address the update/add
 | 
				
			||||||
 | 
					                        extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(associatedClients, key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        acCf.join();
 | 
					        acCf.join();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -427,9 +514,11 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
 | 
				
			|||||||
                                    for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
 | 
					                                    for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                        if (rowUpdate.getNew() == null) {
 | 
					                                        if (rowUpdate.getNew() == null) {
 | 
				
			||||||
                                            inetStateDelete.addAll(ovsdbDao.getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient));
 | 
					                                            inetStateDelete.addAll(ovsdbDao
 | 
				
			||||||
 | 
					                                                    .getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient));
 | 
				
			||||||
                                        } else {
 | 
					                                        } else {
 | 
				
			||||||
                                            inetStateInsertOrUpdate.addAll(ovsdbDao.getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient));
 | 
					                                            inetStateInsertOrUpdate.addAll(ovsdbDao
 | 
				
			||||||
 | 
					                                                    .getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient));
 | 
				
			||||||
                                        }
 | 
					                                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                    }
 | 
					                                    }
 | 
				
			||||||
@@ -437,12 +526,10 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                // delete first
 | 
					                                // delete first
 | 
				
			||||||
                                extIntegrationInterface.wifiInetStateDbTableUpdate(
 | 
					                                extIntegrationInterface.wifiInetStateDbTableUpdate(inetStateDelete, key);
 | 
				
			||||||
                                        inetStateDelete, key);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                // now process updates and mutations
 | 
					                                // now process updates and mutations
 | 
				
			||||||
                                extIntegrationInterface.wifiInetStateDbTableUpdate(
 | 
					                                extIntegrationInterface.wifiInetStateDbTableUpdate(inetStateInsertOrUpdate, key);
 | 
				
			||||||
                                        inetStateInsertOrUpdate, key);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -453,75 +540,72 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private void monitorWifiRadioStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
 | 
					    private void monitorWifiRadioStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        CompletableFuture<TableUpdates> rsCf = ovsdbClient
 | 
					        CompletableFuture<TableUpdates> rsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
 | 
				
			||||||
                .monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiRadioStateDbTable + "_" + key,
 | 
					                OvsdbDao.wifiRadioStateDbTable + "_" + key,
 | 
				
			||||||
                        new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiRadioStateDbTable,
 | 
					                new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiRadioStateDbTable, new MonitorRequest())),
 | 
				
			||||||
                                new MonitorRequest())),
 | 
					                new MonitorCallback() {
 | 
				
			||||||
                        new MonitorCallback() {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            @Override
 | 
					                    @Override
 | 
				
			||||||
                            public void update(TableUpdates tableUpdates) {
 | 
					                    public void update(TableUpdates tableUpdates) {
 | 
				
			||||||
                                LOG.info(OvsdbDao.wifiRadioStateDbTable + "_" + key + " monitor callback received {}",
 | 
					                        LOG.info(OvsdbDao.wifiRadioStateDbTable + "_" + key + " monitor callback received {}",
 | 
				
			||||||
                                        tableUpdates);
 | 
					                                tableUpdates);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                extIntegrationInterface.wifiRadioStatusDbTableUpdate(
 | 
					                        extIntegrationInterface.wifiRadioStatusDbTableUpdate(
 | 
				
			||||||
                                        ovsdbDao.getOpensyncAPRadioState(tableUpdates, key, ovsdbClient), key);
 | 
					                                ovsdbDao.getOpensyncAPRadioState(tableUpdates, key, ovsdbClient), key);
 | 
				
			||||||
                            }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        });
 | 
					                });
 | 
				
			||||||
        rsCf.join();
 | 
					        rsCf.join();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void monitorWifiVifStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
 | 
					    private void monitorWifiVifStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        CompletableFuture<TableUpdates> vsCf = ovsdbClient
 | 
					        CompletableFuture<TableUpdates> vsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
 | 
				
			||||||
                .monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiVifStateDbTable + "_" + key,
 | 
					                OvsdbDao.wifiVifStateDbTable + "_" + key,
 | 
				
			||||||
                        new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable,
 | 
					                new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable, new MonitorRequest())),
 | 
				
			||||||
                                new MonitorRequest())),
 | 
					                new MonitorCallback() {
 | 
				
			||||||
                        new MonitorCallback() {
 | 
					 | 
				
			||||||
                            @Override
 | 
					 | 
				
			||||||
                            public void update(TableUpdates tableUpdates) {
 | 
					 | 
				
			||||||
                                LOG.info(OvsdbDao.wifiVifStateDbTable + "_" + key + " monitor callback received {}",
 | 
					 | 
				
			||||||
                                        tableUpdates);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                List<OpensyncAPVIFState> vifsToDelete = new ArrayList<>();
 | 
					                    @Override
 | 
				
			||||||
                                List<OpensyncAPVIFState> vifsToInsertOrUpdate = new ArrayList<>();
 | 
					                    public void update(TableUpdates tableUpdates) {
 | 
				
			||||||
                                for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
 | 
					                        LOG.info(OvsdbDao.wifiVifStateDbTable + "_" + key + " monitor callback received {}",
 | 
				
			||||||
 | 
					                                tableUpdates);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                    for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
 | 
					                        List<OpensyncAPVIFState> vifsToDelete = new ArrayList<>();
 | 
				
			||||||
 | 
					                        List<OpensyncAPVIFState> vifsToInsertOrUpdate = new ArrayList<>();
 | 
				
			||||||
 | 
					                        for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                        if (rowUpdate.getNew() == null) {
 | 
					                            for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
 | 
				
			||||||
                                            // this is a deletion
 | 
					 | 
				
			||||||
                                            vifsToDelete.addAll(
 | 
					 | 
				
			||||||
                                                    ovsdbDao.getOpensyncApVifStateForRowUpdate(rowUpdate, key, ovsdbClient));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                        } else {
 | 
					                                if (rowUpdate.getNew() == null) {
 | 
				
			||||||
                                            // either an insert or
 | 
					                                    // this is a deletion
 | 
				
			||||||
                                            // mutuate/update
 | 
					                                    vifsToDelete.addAll(
 | 
				
			||||||
                                            vifsToInsertOrUpdate.addAll(
 | 
					                                            ovsdbDao.getOpensyncApVifStateForRowUpdate(rowUpdate, key, ovsdbClient));
 | 
				
			||||||
                                                    ovsdbDao.getOpensyncApVifStateForRowUpdate(rowUpdate, key, ovsdbClient));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                        }
 | 
					                                } else {
 | 
				
			||||||
 | 
					                                    // either an insert or
 | 
				
			||||||
                                    }
 | 
					                                    // mutuate/update
 | 
				
			||||||
                                    
 | 
					                                    vifsToInsertOrUpdate.addAll(
 | 
				
			||||||
                                    // delete first, if required
 | 
					                                            ovsdbDao.getOpensyncApVifStateForRowUpdate(rowUpdate, key, ovsdbClient));
 | 
				
			||||||
                                    if (!vifsToDelete.isEmpty()) {
 | 
					 | 
				
			||||||
                                        extIntegrationInterface.wifiVIFStateDbTableDelete(vifsToDelete, key);
 | 
					 | 
				
			||||||
                                    }
 | 
					 | 
				
			||||||
                                    if (!vifsToInsertOrUpdate.isEmpty()) {
 | 
					 | 
				
			||||||
                                        extIntegrationInterface.wifiVIFStateDbTableUpdate(vifsToInsertOrUpdate, key);
 | 
					 | 
				
			||||||
                                    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                
 | 
					 | 
				
			||||||
             
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        });
 | 
					                            // delete first, if required
 | 
				
			||||||
 | 
					                            if (!vifsToDelete.isEmpty()) {
 | 
				
			||||||
 | 
					                                extIntegrationInterface.wifiVIFStateDbTableDelete(vifsToDelete, key);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (!vifsToInsertOrUpdate.isEmpty()) {
 | 
				
			||||||
 | 
					                                extIntegrationInterface.wifiVIFStateDbTableUpdate(vifsToInsertOrUpdate, key);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        vsCf.join();
 | 
					        vsCf.join();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user