use of org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction in project netvirt by opendaylight.
the class StatisticsImpl method initializeCountrsConfigDataSrore.
private void initializeCountrsConfigDataSrore() {
ReadWriteTransaction transaction = db.newReadWriteTransaction();
CheckedFuture<Optional<IngressElementCountersRequestConfig>, ReadFailedException> iecrc = transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.IECRC_IDENTIFIER);
CheckedFuture<Optional<EgressElementCountersRequestConfig>, ReadFailedException> eecrc = transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.EECRC_IDENTIFIER);
try {
Optional<IngressElementCountersRequestConfig> iecrcOpt = iecrc.get();
if (!iecrcOpt.isPresent()) {
creatIngressEelementCountersContainerInConfig(transaction, CountersServiceUtils.IECRC_IDENTIFIER);
}
Optional<EgressElementCountersRequestConfig> eecrcOpt = eecrc.get();
if (!eecrcOpt.isPresent()) {
creatEgressEelementCountersContainerInConfig(transaction, CountersServiceUtils.EECRC_IDENTIFIER);
}
transaction.submit();
} catch (InterruptedException | ExecutionException e) {
StatisticsPluginImplCounters.failed_creating_counters_config.inc();
LOG.warn("failed creating counters config data structure in DB");
}
}
use of org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction in project netvirt by opendaylight.
the class NodeConnectedHandlerTest method testD1Connect.
@Test
public void testD1Connect() throws Exception {
ReadWriteTransaction tx = this.dataBroker.newReadWriteTransaction();
handlerUtils.addPsNode(d1PsNodePath, d1NodePath, DataProvider.getPortNameListD1(), tx).checkedGet();
tx = this.dataBroker.newReadWriteTransaction();
handlerUtils.addNode(d1NodePath, d1PsNodePath, DataProvider.getLogicalSwitchDataD1(), DataProvider.getLocalUcasMacDataD1(), DataProvider.getLocalMcastDataD1(), DataProvider.getRemoteMcastDataD1(), DataProvider.getRemoteUcasteMacDataD1(), DataProvider.getGlobalTerminationPointIpD1(), tx).checkedGet();
readNodes();
tx = this.dataBroker.newReadWriteTransaction();
nodeConnectedHandler.handleNodeConnected(d1GlobalOpNode.get(), d1NodePath, haNodePath, haGlobalConfigNode, haPsConfigNode, tx);
tx.submit().checkedGet();
readNodes();
// verify global ha manager config should have ha_children
Assert.assertTrue(haGlobalConfigNode.isPresent() && d1GlobalOpNode.isPresent());
TestUtil.verifyHAconfigNode(haGlobalConfigNode.get(), d1GlobalOpNode.get());
Assert.assertTrue(d1GlobalOpNode.isPresent() && haGlobalOpNode.isPresent() && d1PsOpNode.isPresent() && haPsOpNode.isPresent());
TestUtil.verifyHAOpNode(d1GlobalOpNode.get(), haGlobalOpNode.get(), d1PsOpNode.get(), haPsOpNode.get(), haNodePath, d1PsNodePath, haPsNodePath, haNodeId, this.dataBroker);
}
use of org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction in project netvirt by opendaylight.
the class L2GatewayListener method remove.
@Override
protected void remove(final InstanceIdentifier<L2gateway> identifier, final L2gateway input) {
LOG.info("Removing L2gateway with ID: {}", input.getUuid());
List<L2gatewayConnection> connections = l2gwService.getL2GwConnectionsByL2GatewayId(input.getUuid());
try {
ReadWriteTransaction tx = this.dataBroker.newReadWriteTransaction();
for (L2gatewayConnection connection : connections) {
InstanceIdentifier<L2gatewayConnection> iid = InstanceIdentifier.create(Neutron.class).child(L2gatewayConnections.class).child(L2gatewayConnection.class, connection.getKey());
tx.delete(LogicalDatastoreType.CONFIGURATION, iid);
}
tx.submit().checkedGet();
} catch (TransactionCommitFailedException e) {
LOG.error("Failed to delete associated l2gwconnection while deleting l2gw {} with id beacause of {}", input.getUuid(), e.getLocalizedMessage());
// TODO :retry
}
List<Devices> l2Devices = input.getDevices();
for (Devices l2Device : l2Devices) {
LOG.trace("Removing L2gateway device: {}", l2Device);
removeL2Device(l2Device, input);
}
}
use of org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction in project netvirt by opendaylight.
the class L2GatewayListener method update.
@Override
protected void update(InstanceIdentifier<L2gateway> identifier, L2gateway original, L2gateway update) {
LOG.trace("Updating L2gateway : key: {}, original value={}, update value={}", identifier, original, update);
List<L2gatewayConnection> connections = l2gwService.getAssociatedL2GwConnections(Sets.newHashSet(update.getUuid()));
if (connections == null) {
LOG.warn("There are no connections associated with l2 gateway uuid {} name {}", update.getUuid(), update.getName());
return;
}
if (original.getDevices() == null) {
connections.forEach((connection) -> l2gwService.addL2GatewayConnection(connection));
return;
}
jobCoordinator.enqueueJob("l2gw.update", () -> {
ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
DeviceInterfaces updatedDeviceInterfaces = new DeviceInterfaces(update);
List<ListenableFuture<Void>> fts = new ArrayList<>();
original.getDevices().stream().filter((originalDevice) -> originalDevice.getInterfaces() != null).forEach((originalDevice) -> {
String deviceName = originalDevice.getDeviceName();
L2GatewayDevice l2GwDevice = l2GatewayCache.get(deviceName);
NodeId physicalSwitchNodeId = HwvtepSouthboundUtils.createManagedNodeId(new NodeId(l2GwDevice.getHwvtepNodeId()), deviceName);
originalDevice.getInterfaces().stream().filter((intf) -> !updatedDeviceInterfaces.containsInterface(deviceName, intf.getInterfaceName())).forEach((intf) -> {
connections.forEach((connection) -> {
Integer vlanId = connection.getSegmentId();
if (intf.getSegmentationIds() != null && !intf.getSegmentationIds().isEmpty()) {
for (Integer vlan : intf.getSegmentationIds()) {
HwvtepUtils.deleteVlanBinding(transaction, physicalSwitchNodeId, intf.getInterfaceName(), vlan);
}
} else {
LOG.debug("Deleting vlan binding {} {} {}", physicalSwitchNodeId, intf.getInterfaceName(), vlanId);
HwvtepUtils.deleteVlanBinding(transaction, physicalSwitchNodeId, intf.getInterfaceName(), vlanId);
}
});
});
});
fts.add(transaction.submit());
Futures.addCallback(fts.get(0), new FutureCallback<Void>() {
@Override
public void onSuccess(Void success) {
LOG.debug("Successfully deleted vlan bindings for l2gw update {}", update);
connections.forEach((l2GwConnection) -> l2gwService.addL2GatewayConnection(l2GwConnection, null, update));
}
@Override
public void onFailure(Throwable throwable) {
LOG.error("Failed to delete vlan bindings as part of l2gw udpate {}", update);
}
}, MoreExecutors.directExecutor());
return fts;
}, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
}
use of org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction in project controller by opendaylight.
the class Bug1333DataChangeListenerTest method writeTopWithListItem.
public void writeTopWithListItem(final LogicalDatastoreType store) {
ReadWriteTransaction tx = getDataBroker().newReadWriteTransaction();
Top topItem = top(topLevelList(TOP_FOO_KEY, complexUsesAugment(USES_ONE_KEY, USES_TWO_KEY)));
tx.put(store, TOP_PATH, topItem);
assertCommit(tx.submit());
}
Aggregations