/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015, 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.ovsdb.hwvtepsouthbound;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
import org.opendaylight.ovsdb.hwvtepsouthbound.transact.TransactCommand;
import org.opendaylight.ovsdb.hwvtepsouthbound.transact.TransactInvoker;
import org.opendaylight.ovsdb.hwvtepsouthbound.transact.TransactInvokerImpl;
import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.TransactionInvoker;
-import org.opendaylight.ovsdb.lib.EchoServiceCallbackFilters;
import org.opendaylight.ovsdb.lib.LockAquisitionCallback;
import org.opendaylight.ovsdb.lib.LockStolenCallback;
import org.opendaylight.ovsdb.lib.MonitorCallBack;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ListenableFuture;
-public class HwvtepConnectionInstance implements OvsdbClient{
+public class HwvtepConnectionInstance {
private static final Logger LOG = LoggerFactory.getLogger(HwvtepConnectionInstance.class);
private ConnectionInfo connectionInfo;
private OvsdbClient client;
private Entity connectedEntity;
private EntityOwnershipCandidateRegistration deviceOwnershipCandidateRegistration;
private HwvtepGlobalAugmentation initialCreatedData = null;
+ private HwvtepDeviceInfo deviceInfo;
+ private DataBroker dataBroker;
+ private final HwvtepConnectionManager hwvtepConnectionManager;
-
- HwvtepConnectionInstance (ConnectionInfo key,OvsdbClient client,
- InstanceIdentifier<Node> iid, TransactionInvoker txInvoker) {
+ HwvtepConnectionInstance (HwvtepConnectionManager hwvtepConnectionManager, ConnectionInfo key, OvsdbClient client,
+ InstanceIdentifier<Node> iid, TransactionInvoker txInvoker, DataBroker dataBroker) {
+ this.hwvtepConnectionManager = hwvtepConnectionManager;
this.connectionInfo = key;
this.client = client;
this.instanceIdentifier = iid;
this.txInvoker = txInvoker;
+ this.deviceInfo = new HwvtepDeviceInfo(this);
+ this.dataBroker = dataBroker;
}
- public void transact(TransactCommand command) {
+ public synchronized void transact(TransactCommand command) {
for (TransactInvoker transactInvoker: transactInvokers.values()) {
transactInvoker.invoke(command);
}
if (tables != null) {
List<MonitorRequest> monitorRequests = Lists.newArrayList();
for (String tableName : tables) {
- LOG.debug("HwvtepSouthbound monitoring table {} in {}", tableName, dbSchema.getName());
- GenericTableSchema tableSchema = dbSchema.table(tableName, GenericTableSchema.class);
- Set<String> columns = tableSchema.getColumns();
- MonitorRequestBuilder<GenericTableSchema> monitorBuilder = MonitorRequestBuilder.builder(tableSchema);
- for (String column : columns) {
- monitorBuilder.addColumn(column);
+ if (!HwvtepSouthboundConstants.SKIP_HWVTEP_TABLE.containsKey(tableName)) {
+ LOG.info("HwvtepSouthbound monitoring Hwvtep schema table {}", tableName);
+ GenericTableSchema tableSchema = dbSchema.table(tableName, GenericTableSchema.class);
+ Set<String> columns = new HashSet<>(tableSchema.getColumns());
+ List<String> skipColumns = HwvtepSouthboundConstants.SKIP_COLUMN_FROM_HWVTEP_TABLE.get(tableName);
+ if (skipColumns != null) {
+ LOG.info("HwvtepSouthbound NOT monitoring columns {} in table {}", skipColumns, tableName);
+ columns.removeAll(skipColumns);
+ }
+ monitorRequests.add(new MonitorRequestBuilder<>(tableSchema)
+ .addColumns(columns)
+ .with(new MonitorSelect(true, true, true, true)).build());
}
- monitorRequests.add(monitorBuilder.with(new MonitorSelect(true, true, true, true)).build());
}
- this.callback.update(monitor(dbSchema, monitorRequests, callback),dbSchema);
+ this.callback.update(monitor(dbSchema, monitorRequests, callback), dbSchema);
} else {
LOG.warn("No tables for schema {} for database {} for key {}",dbSchema,database,connectionInfo);
}
*/
}
+ public DataBroker getDataBroker() {
+ return dataBroker;
+ }
+
public ListenableFuture<List<String>> getDatabases() {
return client.getDatabases();
}
return client.monitor(schema, monitorRequests, callback);
}
- @Override
public <E extends TableSchema<E>> TableUpdates monitor(DatabaseSchema schema,
List<MonitorRequest> monitorRequests, MonitorHandle monitorHandle, MonitorCallBack callback) {
return null;
return client.unLock(lockId);
}
- public void startEchoService(EchoServiceCallbackFilters callbackFilters) {
- client.startEchoService(callbackFilters);
- }
-
- public void stopEchoService() {
- client.stopEchoService();
- }
-
- @Override
- public void echo() {
- client.echo();
- }
-
public OvsdbConnectionInfo getConnectionInfo() {
return client.getConnectionInfo();
}
public NodeKey getNodeKey() {
//TODO: What is the alternative here?
- return getInstanceIdentifier().firstKeyOf(Node.class, NodeKey.class);
+ return getInstanceIdentifier().firstKeyOf(Node.class);
}
public NodeId getNodeId() {
public void setInstanceIdentifier(InstanceIdentifier<Node> iid) {
this.instanceIdentifier = iid;
+ hwvtepConnectionManager.putConnectionInstance(instanceIdentifier, this);
}
public Entity getConnectedEntity() {
public void setHwvtepGlobalAugmentation(HwvtepGlobalAugmentation hwvtepGlobalData) {
this.initialCreatedData = hwvtepGlobalData;
}
+
+ public HwvtepGlobalAugmentation getHwvtepGlobalAugmentation() {
+ return this.initialCreatedData;
+ }
+ public HwvtepDeviceInfo getDeviceInfo() {
+ return this.deviceInfo;
+ }
+
+ public OvsdbClient getOvsdbClient() {
+ return client;
+ }
}