package org.opendaylight.netvirt.vpnmanager;
import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
import java.math.BigInteger;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.ExecutionException;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AddDpnEvent;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AddInterfaceToDpnOnVpnEvent;
this.mdsalManager = mdsalManager;
}
+ @Override
public void onAddDpnEvent(AddDpnEvent notification) {
}
+ @Override
public void onRemoveDpnEvent(RemoveDpnEvent notification) {
RemoveEventData eventData = notification.getRemoveEventData();
if (flushDpnsOnVpn) {
WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
deleteDpn(vpnToDpnList, rd, writeTxn);
- CheckedFuture<Void, TransactionCommitFailedException> futures = writeTxn.submit();
try {
- futures.get();
+ writeTxn.submit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error removing dpnToVpnList for vpn {} ", vpnName);
throw new RuntimeException(e.getMessage());
/*
- * Copyright (c) 2015 - 2016 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.netvirt.vpnmanager;
import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
}
public static final FutureCallback<Void> DEFAULT_CALLBACK = new FutureCallback<Void>() {
+ @Override
public void onSuccess(Void result) {
LOG.debug("onSuccess: Success in Datastore operation");
}
+ @Override
public void onFailure(Throwable error) {
LOG.error("onFailure: Error in Datastore operation", error);
}
-
- ;
};
public static <T extends DataObject> Optional<T> read(DataBroker dataBroker, LogicalDatastoreType datastoreType,
- InstanceIdentifier<T> path) {
+ InstanceIdentifier<T> path) {
ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction();
LOG.debug("read: Error while reading data from path {}", path);
throw new RuntimeException(e);
}
-
return result;
}
public static <T extends DataObject> void asyncWrite(DataBroker dataBroker, LogicalDatastoreType datastoreType,
- InstanceIdentifier<T> path, T data,
- FutureCallback<Void> callback) {
+ InstanceIdentifier<T> path, T data, FutureCallback<Void> callback) {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.put(datastoreType, path, data, true);
Futures.addCallback(tx.submit(), callback);
}
public static <T extends DataObject> void syncWrite(DataBroker dataBroker, LogicalDatastoreType datastoreType,
- InstanceIdentifier<T> path,
- T data, FutureCallback<Void> callback) {
+ InstanceIdentifier<T> path, T data, FutureCallback<Void> callback) {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.put(datastoreType, path, data, WriteTransaction.CREATE_MISSING_PARENTS);
- CheckedFuture<Void, TransactionCommitFailedException> futures = tx.submit();
try {
- futures.get();
+ tx.submit().get();
} catch (InterruptedException | ExecutionException e) {
- LOG.error("syncWrite: Error writing VPN instance to ID info to datastore (path, data) : ({}, {})",
- path, data);
+ LOG.error("syncWrite: Error writing VPN instance to ID info to datastore (path, data) : ({}, {})", path,
+ data);
throw new RuntimeException(e.getMessage());
}
}
package org.opendaylight.netvirt.vpnmanager;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.ListenableFuture;
import java.math.BigInteger;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
import org.opendaylight.genius.datastoreutils.DataStoreJobCoordinator;
import org.opendaylight.netvirt.vpnmanager.api.VpnHelper;
vpnInterfaceManager.processVpnInterfaceAdjacencies(dpnId, lPortTag, vpnName, primaryRd,
vpnInterfaceName, vpnId, writeConfigTxn, writeOperTxn, writeInvTxn,
interfaceState);
- List<CheckedFuture<Void, TransactionCommitFailedException>> checkedFutures =
- Arrays.asList(writeOperTxn.submit(),
- writeConfigTxn.submit(),
- writeInvTxn.submit());
- futures.addAll(checkedFutures);
+ futures.add(writeOperTxn.submit());
+ futures.add(writeConfigTxn.submit());
+ futures.add(writeInvTxn.submit());
LOG.trace("add: Handled TEP {} add for VPN instance {} VPN interface {}",
tep.getInterfaceName(), vpnName, vpnInterfaceName);
return futures;
package org.opendaylight.netvirt.vpnmanager;
import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
-
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.netvirt.fibmanager.api.IFibManager;
import org.opendaylight.netvirt.vpnmanager.api.IVpnFootprintService;
import org.opendaylight.netvirt.vpnmanager.utilities.InterfaceUtils;
private final NotificationPublishService notificationPublishService;
public VpnFootprintService(final DataBroker dataBroker, final IFibManager fibManager,
- final OdlInterfaceRpcService ifaceRpcService, final NotificationPublishService notificationPublishService,
- final VpnOpDataSyncer vpnOpDataSyncer) {
+ final OdlInterfaceRpcService ifaceRpcService, final NotificationPublishService notificationPublishService,
+ final VpnOpDataSyncer vpnOpDataSyncer) {
this.dataBroker = dataBroker;
this.fibManager = fibManager;
this.vpnOpDataSyncer = vpnOpDataSyncer;
@Override
public void updateVpnToDpnMapping(BigInteger dpId, String vpnName, String primaryRd, String interfaceName,
- ImmutablePair<IpAddresses.IpAddressSource, String> ipAddressSourceValuePair,
- boolean add) {
+ ImmutablePair<IpAddresses.IpAddressSource, String> ipAddressSourceValuePair, boolean add) {
long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
if (dpId == null) {
dpId = InterfaceUtils.getDpnForInterface(ifaceMgrRpcService, interfaceName);
}
if (!dpId.equals(BigInteger.ZERO)) {
if (add) {
- // Considering the possibility of VpnInstanceOpData not being ready yet cause the VPN is
+ // Considering the possibility of VpnInstanceOpData not being ready yet cause
+ // the VPN is
// still in its creation process
if (vpnId == VpnConstants.INVALID_ID) {
LOG.error("updateVpnToDpnMapping: Operational data for vpn not ready. Waiting to update vpn"
+ " footprint for vpn {} on dpn {} interface {}", vpnName, dpId, interfaceName);
vpnOpDataSyncer.waitForVpnDataReady(VpnOpDataSyncer.VpnOpDataType.vpnInstanceToId, vpnName,
- VpnConstants.PER_VPN_INSTANCE_OPDATA_MAX_WAIT_TIME_IN_MILLISECONDS);
+ VpnConstants.PER_VPN_INSTANCE_OPDATA_MAX_WAIT_TIME_IN_MILLISECONDS);
vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
}
if (interfaceName != null) {
}
private void createOrUpdateVpnToDpnListForInterfaceName(long vpnId, String primaryRd, BigInteger dpnId,
- String intfName, String vpnName) {
+ String intfName, String vpnName) {
Boolean newDpnOnVpn = Boolean.FALSE;
synchronized (vpnName.intern()) {
writeTxn.put(LogicalDatastoreType.OPERATIONAL, id, vpnToDpnListBuilder.build(),
WriteTransaction.CREATE_MISSING_PARENTS);
- /* If earlier state was inactive, it is considered new DPN coming back to the
+ /*
+ * If earlier state was inactive, it is considered new DPN coming back to the
* same VPN
*/
if (vpnToDpnList.getDpnState() == VpnToDpnList.DpnState.Inactive) {
LOG.debug("createOrUpdateVpnToDpnList: Creating vpn footprint for vpn {} vpnId {} interface {}"
+ " on dpn {}", vpnName, vpnId, intfName, dpnId);
}
- CheckedFuture<Void, TransactionCommitFailedException> futures = writeTxn.submit();
try {
- futures.get();
+ writeTxn.submit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("createOrUpdateVpnToDpnList: Error adding to dpnToVpnList for vpn {} vpnId {} interface {}"
+ " dpn {}", vpnName, vpnId, intfName, dpnId, e);
LOG.info("createOrUpdateVpnToDpnList: Created/Updated vpn footprint for vpn {} vpnId {} interfacName{}"
+ " on dpn {}", vpnName, vpnId, intfName, dpnId);
/*
- * Informing the Fib only after writeTxn is submitted successfuly.
+ * Informing the FIB only after writeTxn is submitted successfully.
*/
if (newDpnOnVpn) {
- fibManager.populateFibOnNewDpn(dpnId, vpnId, primaryRd, new DpnEnterExitVpnWorker(dpnId, vpnName, primaryRd,
- true /* entered */));
+ fibManager.populateFibOnNewDpn(dpnId, vpnId, primaryRd,
+ new DpnEnterExitVpnWorker(dpnId, vpnName, primaryRd, true /* entered */));
LOG.info("createOrUpdateVpnToDpnList: Sent populateFib event for new dpn {} in VPN {} for interface {}",
dpnId, vpnName, intfName);
}
vpnToDpnListBuilder.setDpnState(VpnToDpnList.DpnState.Active).setIpAddresses(ipAddresses);
writeTxn.put(LogicalDatastoreType.OPERATIONAL, id, vpnToDpnListBuilder.build(), true);
- /* If earlier state was inactive, it is considered new DPN coming back to the
+ /*
+ * If earlier state was inactive, it is considered new DPN coming back to the
* same VPN
*/
if (vpnToDpnList.getDpnState() == VpnToDpnList.DpnState.Inactive) {
writeTxn.put(LogicalDatastoreType.OPERATIONAL, id, vpnToDpnListBuilder.build(), true);
newDpnOnVpn = Boolean.TRUE;
}
- CheckedFuture<Void, TransactionCommitFailedException> futures = writeTxn.submit();
try {
- futures.get();
+ writeTxn.submit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error adding to dpnToVpnList for vpn {} ipAddresses {} dpn {}", vpnName,
ipAddressSourceValuePair.getValue(), dpnId, e);
*/
if (newDpnOnVpn) {
LOG.debug("Sending populateFib event for new dpn {} in VPN {}", dpnId, vpnName);
- fibManager.populateFibOnNewDpn(dpnId, vpnId, primaryRd, new DpnEnterExitVpnWorker(dpnId, vpnName, primaryRd,
- true /* entered */));
+ fibManager.populateFibOnNewDpn(dpnId, vpnId, primaryRd,
+ new DpnEnterExitVpnWorker(dpnId, vpnName, primaryRd, true /* entered */));
}
}
private void removeOrUpdateVpnToDpnListForInterfaceName(long vpnId, String rd, BigInteger dpnId, String intfName,
- String vpnName) {
+ String vpnName) {
Boolean lastDpnOnVpn = Boolean.FALSE;
synchronized (vpnName.intern()) {
InstanceIdentifier<VpnToDpnList> id = VpnUtil.getVpnToDpnListIdentifier(rd, dpnId);
VpnToDpnList dpnInVpn = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id).orNull();
if (dpnInVpn == null) {
LOG.error("removeOrUpdateVpnToDpnList: Could not find DpnToVpn map for VPN=[name={} rd={} id={}]"
- + " and dpnId={}", vpnName, rd, id, dpnId);
+ + " and dpnId={}", vpnName, rd, id, dpnId);
return;
}
List<VpnInterfaces> vpnInterfaces = dpnInVpn.getVpnInterfaces();
if (vpnInterfaces == null) {
LOG.error("Could not find vpnInterfaces for DpnInVpn map for VPN=[name={} rd={} id={}] and dpnId={}",
- vpnName, rd, id, dpnId);
+ vpnName, rd, id, dpnId);
return;
}
WriteTransaction.CREATE_MISSING_PARENTS);
} else {
- writeTxn.delete(LogicalDatastoreType.OPERATIONAL, id.child(VpnInterfaces.class,
- new VpnInterfacesKey(intfName)));
+ writeTxn.delete(LogicalDatastoreType.OPERATIONAL,
+ id.child(VpnInterfaces.class, new VpnInterfacesKey(intfName)));
LOG.debug("removeOrUpdateVpnToDpnList: Updating vpn footprint for vpn {} vpnId {} interface {},"
+ " on dpn {}", vpnName, vpnName, intfName, dpnId);
}
- CheckedFuture<Void, TransactionCommitFailedException> futures = writeTxn.submit();
try {
- futures.get();
+ writeTxn.submit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("removeOrUpdateVpnToDpnList: Error removing from dpnToVpnList for vpn {} vpnId {}"
+ " interface {} dpn {}", vpnName, vpnId, intfName, dpnId, e);
+ " on dpn {}", vpnName, vpnName, intfName, dpnId);
if (lastDpnOnVpn) {
- fibManager.cleanUpDpnForVpn(dpnId, vpnId, rd, new DpnEnterExitVpnWorker(dpnId, vpnName, rd,
- false /* exited */));
- LOG.info("removeOrUpdateVpnToDpnList: Sent cleanup event for dpn {} in VPN {} vpnId {} interface {}",
- dpnId, vpnName, vpnId, intfName);
+ fibManager.cleanUpDpnForVpn(dpnId, vpnId, rd,
+ new DpnEnterExitVpnWorker(dpnId, vpnName, rd, false /* exited */));
+ LOG.info("removeOrUpdateVpnToDpnList: Sent cleanup event for dpn {} in VPN {} vpnId {} interface {}", dpnId,
+ vpnName, vpnId, intfName);
}
}
IpAddresses currIpAddress = new IpAddressesBuilder()
.setKey(new IpAddressesKey(ipAddressSourceValuePair.getValue()))
- .setIpAddressSource(ipAddressSourceValuePair.getKey())
- .build();
+ .setIpAddressSource(ipAddressSourceValuePair.getKey()).build();
if (ipAddresses.remove(currIpAddress)) {
WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
if (ipAddresses.isEmpty()) {
writeTxn.put(LogicalDatastoreType.OPERATIONAL, id, dpnInVpnBuilder.build(), true);
} else {
- writeTxn.delete(LogicalDatastoreType.OPERATIONAL, id.child(IpAddresses.class,
- new IpAddressesKey(ipAddressSourceValuePair.getValue())));
+ writeTxn.delete(LogicalDatastoreType.OPERATIONAL,
+ id.child(IpAddresses.class, new IpAddressesKey(ipAddressSourceValuePair.getValue())));
}
- CheckedFuture<Void, TransactionCommitFailedException> futures = writeTxn.submit();
try {
- futures.get();
+ writeTxn.submit().get();
} catch (InterruptedException | ExecutionException e) {
- LOG.error("Error removing from dpnToVpnList for vpn {} Ipaddress {} dpn {}",
- vpnName, ipAddressSourceValuePair.getValue(), dpnId, e);
+ LOG.error("Error removing from dpnToVpnList for vpn {} Ipaddress {} dpn {}", vpnName,
+ ipAddressSourceValuePair.getValue(), dpnId, e);
throw new RuntimeException(e.getMessage());
}
}
if (lastDpnOnVpn) {
LOG.debug("Sending cleanup event for dpn {} in VPN {}", dpnId, vpnName);
- fibManager.cleanUpDpnForVpn(dpnId, vpnId, rd, new DpnEnterExitVpnWorker(dpnId, vpnName, rd,
- false /* exited */));
+ fibManager.cleanUpDpnForVpn(dpnId, vpnId, rd,
+ new DpnEnterExitVpnWorker(dpnId, vpnName, rd, false /* exited */));
}
}
}
private void publishInterfaceAddedToVpnNotification(String interfaceName, BigInteger dpnId, String vpnName,
- Long vpnId) {
+ Long vpnId) {
LOG.debug("publishInterfaceAddedToVpnNotification: Sending notification for addition of interface {} on dpn {}"
+ " for vpn {}", interfaceName, dpnId, vpnName);
- AddInterfaceEventData data = new AddInterfaceEventDataBuilder().setInterfaceName(interfaceName)
- .setVpnId(vpnId).setDpnId(dpnId).build();
- AddInterfaceToDpnOnVpnEvent event = new AddInterfaceToDpnOnVpnEventBuilder()
- .setAddInterfaceEventData(data).build();
+ AddInterfaceEventData data = new AddInterfaceEventDataBuilder().setInterfaceName(interfaceName).setVpnId(vpnId)
+ .setDpnId(dpnId).build();
+ AddInterfaceToDpnOnVpnEvent event = new AddInterfaceToDpnOnVpnEventBuilder().setAddInterfaceEventData(data)
+ .build();
final ListenableFuture<?> eventFuture = notificationPublishService.offerNotification(event);
Futures.addCallback(eventFuture, new FutureCallback<Object>() {
@Override
}
private void publishInterfaceRemovedFromVpnNotification(String interfaceName, BigInteger dpnId, String vpnName,
- Long vpnId) {
+ Long vpnId) {
LOG.debug("publishInterfaceAddedToVpnNotification: Sending notification for removal of interface {}"
+ " from dpn {} for vpn {}", interfaceName, dpnId, vpnName);
RemoveInterfaceEventData data = new RemoveInterfaceEventDataBuilder().setInterfaceName(interfaceName)
Futures.addCallback(eventFuture, new FutureCallback<Object>() {
@Override
public void onFailure(Throwable error) {
- LOG.warn("publishInterfaceAddedToVpnNotification: Error in notifying listeners"
- + " for removing interface {} from dpn {} in vpn {} event ", interfaceName, dpnId, vpnName,
- error);
+ LOG.warn(
+ "publishInterfaceAddedToVpnNotification: Error in notifying listeners"
+ + " for removing interface {} from dpn {} in vpn {} event ",
+ interfaceName, dpnId, vpnName, error);
}
@Override
});
}
-
/**
- * JobCallback class is used as a future callback for
- * main and rollback workers to handle success and failure.
+ * JobCallback class is used as a future callback for main and rollback workers
+ * to handle success and failure.
*/
private class DpnEnterExitVpnWorker implements FutureCallback<List<Void>> {
private final Logger log = LoggerFactory.getLogger(DpnEnterExitVpnWorker.class);
}
/**
- * This implies that all the future instances have returned success. -- TODO: Confirm this
+ * This implies that all the future instances have returned success. -- TODO:
+ * Confirm this
*/
@Override
public void onSuccess(List<Void> voids) {
if (entered) {
publishAddNotification(dpnId, vpnName, rd);
- log.info("onSuccess: FootPrint established for vpn {} rd {} on dpn {}", vpnName,
- rd, dpnId);
+ log.info("onSuccess: FootPrint established for vpn {} rd {} on dpn {}", vpnName, rd, dpnId);
} else {
publishRemoveNotification(dpnId, vpnName, rd);
- log.info("onSuccess: FootPrint cleared for vpn {} rd {} on dpn {}", vpnName,
- rd, dpnId);
+ log.info("onSuccess: FootPrint cleared for vpn {} rd {} on dpn {}", vpnName, rd, dpnId);
}
}
/**
- * This method is used to handle failure callbacks.
- * If more retry needed, the retrycount is decremented and mainworker is executed again.
- * After retries completed, rollbackworker is executed.
- * If rollbackworker fails, this is a double-fault. Double fault is logged and ignored.
+ * This method is used to handle failure callbacks. If more retry needed, the
+ * retrycount is decremented and mainworker is executed again. After retries
+ * completed, rollbackworker is executed. If rollbackworker fails, this is a
+ * double-fault. Double fault is logged and ignored.
*/
@Override
public void onFailure(Throwable throwable) {
- log.error("onFailure: Failed to establish/clear footprint for vpn {} rd {} on dpn {} ",
- vpnName, rd, dpnId, throwable);
+ log.error("onFailure: Failed to establish/clear footprint for vpn {} rd {} on dpn {} ", vpnName, rd, dpnId,
+ throwable);
}
}
package org.opendaylight.netvirt.vpnmanager;
import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
import org.opendaylight.genius.datastoreutils.DataStoreJobCoordinator;
import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
InstanceIdentifier<VpnInstanceOpDataEntry> id = VpnUtil.getVpnInstanceOpDataIdentifier(primaryRd);
WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
writeTxn.merge(LogicalDatastoreType.OPERATIONAL, id, builder.build());
- List<ListenableFuture<Void>> futures = new ArrayList<>();
- futures.add(writeTxn.submit());
+
LOG.info("{} call: Operational status set to PENDING_DELETE for vpn {} with rd {}",
LOGGING_PREFIX_DELETE, vpnName, primaryRd);
- return futures;
+ return Collections.singletonList(writeTxn.submit());
}, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
}
}
WriteTransaction writeConfigTxn = broker.newWriteOnlyTransaction();
WriteTransaction writeOperTxn = broker.newWriteOnlyTransaction();
addVpnInstance(vpnInstance, writeConfigTxn, writeOperTxn);
- CheckedFuture<Void, TransactionCommitFailedException> checkFutures = writeOperTxn.submit();
+
try {
- checkFutures.get();
+ writeOperTxn.submit().get();
} catch (InterruptedException | ExecutionException e) {
log.error("{} call: Error creating vpn {} ", LOGGING_PREFIX_ADD, vpnInstance.getVpnInstanceName());
throw new RuntimeException(e.getMessage());
*/
VpnAfConfig config = vpnInstance.getIpv4Family();
List<String> rd = config.getRouteDistinguisher();
- if ((rd == null) || addBgpVrf(voids)) {
+ if (rd == null || addBgpVrf(voids)) {
notifyTask();
vpnInterfaceManager.vpnInstanceIsReady(vpnName);
}
//Advertise all the rds and check if primary Rd advertisement fails
long primaryRdAddFailed = rds.parallelStream().filter(rd -> {
try {
- LayerType layerType = (vpnInstance.getType() == VpnInstance.Type.L2) ? LayerType.LAYER2 :
+ LayerType layerType = vpnInstance.getType() == VpnInstance.Type.L2 ? LayerType.LAYER2 :
LayerType.LAYER3;
bgpManager.addVrf(rd, irtList, ertList, layerType);
} catch (Exception e) {
}
}
-
return tunnelInterfaceNameList;
}
return VpnConstants.FLOWID_PREFIX + dpnId + NwConstants.FLOWID_SEPARATOR + tableId
+ NwConstants.FLOWID_SEPARATOR + vpnName + NwConstants.FLOWID_SEPARATOR + priority;
}
-
}
package org.opendaylight.netvirt.vpnmanager;
import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.genius.datastoreutils.DataStoreJobCoordinator;
import org.opendaylight.genius.mdsalutil.FlowEntity;
import org.opendaylight.genius.mdsalutil.FlowEntityBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class VpnUtil {
+public final class VpnUtil {
private static final Logger LOG = LoggerFactory.getLogger(VpnUtil.class);
private static final int DEFAULT_PREFIX_LENGTH = 32;
private static final String PREFIX_SEPARATOR = "/";
+ private VpnUtil() {
+ }
+
static InstanceIdentifier<VpnInterface> getVpnInterfaceIdentifier(String vpnInterfaceName) {
return InstanceIdentifier.builder(VpnInterfaces.class)
.child(VpnInterface.class, new VpnInterfaceKey(vpnInterfaceName)).build();
if (rpcResult == null) {
return null;
}
-
interfaceFromIfIndexOutput = rpcResult.getResult();
- String interfaceName = interfaceFromIfIndexOutput.getInterfaceName();
- return interfaceName;
+ return interfaceFromIfIndexOutput.getInterfaceName();
}
static AllocatedRdsBuilder getRdsBuilder(String nexthop, String rd) {
public static InstanceIdentifier<IdPool> getPoolId(String poolName) {
InstanceIdentifier.InstanceIdentifierBuilder<IdPool> idBuilder =
InstanceIdentifier.builder(IdPools.class).child(IdPool.class, new IdPoolKey(poolName));
- InstanceIdentifier<IdPool> id = idBuilder.build();
- return id;
+ return idBuilder.build();
}
static InstanceIdentifier<VpnInterfaces> getVpnInterfacesIdentifier() {
InstanceIdentifier<T> path, T data) {
WriteTransaction tx = broker.newWriteOnlyTransaction();
tx.put(datastoreType, path, data, WriteTransaction.CREATE_MISSING_PARENTS);
- CheckedFuture<Void, TransactionCommitFailedException> futures = tx.submit();
+
try {
- futures.get();
+ tx.submit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("syncWrite: Error writing to datastore (path, data) : ({}, {})", path, data);
throw new RuntimeException(e.getMessage());
InstanceIdentifier<T> path, T data) {
WriteTransaction tx = broker.newWriteOnlyTransaction();
tx.merge(datastoreType, path, data, true);
- CheckedFuture<Void, TransactionCommitFailedException> futures = tx.submit();
+
try {
- futures.get();
+ tx.submit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("syncUpdate: Error writing to datastore (path, data) : ({}, {})", path, data);
throw new RuntimeException(e.getMessage());
}
static InstanceIdentifier<NetworkMap> buildNetworkMapIdentifier(Uuid networkId) {
- InstanceIdentifier<NetworkMap> id = InstanceIdentifier.builder(NetworkMaps.class).child(NetworkMap.class, new
+ return InstanceIdentifier.builder(NetworkMaps.class).child(NetworkMap.class, new
NetworkMapKey(networkId)).build();
- return id;
}
static InstanceIdentifier<SubnetOpDataEntry> buildSubnetOpDataEntryInstanceIdentifier(Uuid subnetId) {
- InstanceIdentifier<SubnetOpDataEntry> subOpIdentifier = InstanceIdentifier.builder(SubnetOpData.class)
+ return InstanceIdentifier.builder(SubnetOpData.class)
.child(SubnetOpDataEntry.class, new SubnetOpDataEntryKey(subnetId)).build();
- return subOpIdentifier;
}
static InstanceIdentifier<VpnPortipToPort> buildVpnPortipToPortIdentifier(String vpnName, String fixedIp) {
- InstanceIdentifier<VpnPortipToPort> id =
- InstanceIdentifier.builder(NeutronVpnPortipPortData.class).child(VpnPortipToPort.class,
+ return InstanceIdentifier.builder(NeutronVpnPortipPortData.class).child(VpnPortipToPort.class,
new VpnPortipToPortKey(fixedIp, vpnName)).build();
- return id;
}
public static VpnPortipToPort getNeutronPortFromVpnPortFixedIp(DataBroker broker, String vpnName, String fixedIp) {
}
static InstanceIdentifier<Routers> buildRouterIdentifier(String routerId) {
- InstanceIdentifier<Routers> routerInstanceIndentifier =
- InstanceIdentifier.builder(ExtRouters.class).child(Routers.class, new RoutersKey(routerId)).build();
- return routerInstanceIndentifier;
+ return InstanceIdentifier.builder(ExtRouters.class).child(Routers.class, new RoutersKey(routerId)).build();
}
static Networks getExternalNetwork(DataBroker dataBroker, Uuid networkId) {
}
String flowId = getL3VpnGatewayFlowRef(NwConstants.L3_GW_MAC_TABLE, dpId, vpnId, gwMacAddress);
- FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_GW_MAC_TABLE,
- flowId, 20, flowId, 0, 0, NwConstants.COOKIE_L3_GW_MAC_TABLE, mkMatches, mkInstructions);
- return flowEntity;
+
+ return MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_GW_MAC_TABLE,
+ flowId, 20, flowId, 0, 0, NwConstants.COOKIE_L3_GW_MAC_TABLE, mkMatches, mkInstructions);
}
private static String getL3VpnGatewayFlowRef(short l3GwMacTable, BigInteger dpId, long vpnId, String gwMacAddress) {
public static boolean isEligibleForBgp(String rd, String vpnName, BigInteger dpnId, String networkName) {
if (rd != null) {
- if ((vpnName != null) && (rd.equals(vpnName))) {
+ if (vpnName != null && rd.equals(vpnName)) {
return false;
}
- if ((dpnId != null) && (rd.equals(dpnId.toString()))) {
+ if (dpnId != null && rd.equals(dpnId.toString())) {
return false;
}
- if ((networkName != null) && (rd.equals(networkName))) {
+ if (networkName != null && rd.equals(networkName)) {
return false;
}
return true;
package org.opendaylight.netvirt.vpnmanager.intervpnlink;
import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.ListenableFuture;
import java.math.BigInteger;
import java.util.ArrayList;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.netvirt.vpnmanager.VpnFootprintService;
import org.opendaylight.netvirt.vpnmanager.VpnUtil;
private boolean shouldConfigureLinkIntoDpn(InterVpnLinkState interVpnLinkState, int numberOfDpns) {
- if ((interVpnLinkState.getFirstEndpointState().getDpId() == null
- || interVpnLinkState.getFirstEndpointState().getDpId().isEmpty())
- || (interVpnLinkState.getSecondEndpointState().getDpId() == null
- || interVpnLinkState.getSecondEndpointState().getDpId().isEmpty())) {
+ if (interVpnLinkState.getFirstEndpointState().getDpId() == null
+ || interVpnLinkState.getFirstEndpointState().getDpId().isEmpty()
+ || interVpnLinkState.getSecondEndpointState().getDpId() == null
+ || interVpnLinkState.getSecondEndpointState().getDpId().isEmpty()) {
return true;
} else if (!interVpnLinkState.getFirstEndpointState().getDpId().contains(dpnId)
&& !interVpnLinkState.getSecondEndpointState().getDpId().contains(dpnId)
- && (interVpnLinkState.getFirstEndpointState().getDpId().size() < numberOfDpns)) {
+ && interVpnLinkState.getFirstEndpointState().getDpId().size() < numberOfDpns) {
return true;
} else {
return false;
}
}
- private CheckedFuture<Void, TransactionCommitFailedException>
+ private ListenableFuture<Void>
updateInterVpnLinkState(InterVpnLinkState interVpnLinkState, List<BigInteger> firstDpnList,
List<BigInteger> secondDpnList, int numberOfDpns) {
secondDpnList);
}
}
-
}
/*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016, 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.netvirt.vpnmanager.intervpnlink.tasks;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.ListenableFuture;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class InterVpnLinkRemoverTask implements Callable<List<ListenableFuture<Void>>> {
-
private static final Logger LOG = LoggerFactory.getLogger(InterVpnLinkRemoverTask.class);
private final InstanceIdentifier<InterVpnLink> interVpnLinkIid;
@Override
public List<ListenableFuture<Void>> call() throws Exception {
LOG.debug("Removing InterVpnLink {} from storage", interVpnLinkName);
- List<ListenableFuture<Void>> result = new ArrayList<>();
WriteTransaction removeTx = dataBroker.newWriteOnlyTransaction();
removeTx.delete(LogicalDatastoreType.CONFIGURATION, this.interVpnLinkIid);
- CheckedFuture<Void, TransactionCommitFailedException> removalFuture = removeTx.submit();
- result.add(removalFuture);
- return result;
- }
+ return Collections.singletonList(removeTx.submit());
+ }
}