use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.Counter in project netvirt by opendaylight.
the class ArpResponderUtil method getEgressActionsForInterface.
/**
* Get List of Egress Action for the VPN interface.
*
* @param ifaceMgrRpcService
* Interface Manager RPC reference that invokes API to retrieve
* Egress Action
* @param ifName
* VPN Interface for which Egress Action to be retrieved
* @param actionCounter
* Action Key
* @return List of Egress Actions
*/
public static List<Action> getEgressActionsForInterface(IInterfaceManager ifaceMgrRpcService, ItmRpcService itmRpcService, String ifName, int actionCounter, boolean isTunnelInterface) {
if (isTunnelInterface && ifaceMgrRpcService.isItmDirectTunnelsEnabled()) {
try {
RpcResult result = itmRpcService.getEgressActionsForTunnel(new GetEgressActionsForTunnelInputBuilder().setIntfName(ifName).build()).get();
Map<ActionKey, Action> listActions = new HashMap<ActionKey, Action>();
if (!result.isSuccessful()) {
LOG.error("getEgressActionsForInterface: RPC Call to Get egress actions for interface {} " + "returned with Errors {}", ifName, result.getErrors());
} else {
listActions = ((GetEgressActionsForTunnelOutput) result.getResult()).nonnullAction();
}
return new ArrayList<Action>(listActions.values());
} catch (InterruptedException | ExecutionException e) {
LOG.error("getEgressActionsForInterface: Exception when egress actions for interface {}", ifName, e);
}
} else {
List<ActionInfo> actionInfos = ifaceMgrRpcService.getInterfaceEgressActions(ifName);
AtomicInteger counter = new AtomicInteger(actionCounter);
return actionInfos.stream().map(v -> v.buildAction(counter.getAndIncrement())).collect(Collectors.toList());
}
return Collections.emptyList();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.Counter in project netvirt by opendaylight.
the class NaptManager method removeFromIpMapDS.
protected void removeFromIpMapDS(Uint32 segmentId, String internalIp) {
InstanceIdentifierBuilder<IpMap> idBuilder = InstanceIdentifier.builder(IntextIpMap.class).child(IpMapping.class, new IpMappingKey(segmentId)).child(IpMap.class, new IpMapKey(internalIp));
InstanceIdentifier<IpMap> id = idBuilder.build();
// Get externalIp and decrement the counter
String externalIp = null;
Optional<IpMap> ipMap = Optional.empty();
try {
ipMap = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
} catch (ExecutionException | InterruptedException e) {
LOG.error("removeFromIpMapDS: Exception while reading IpMap DS for the segmentId {} " + "internalIp {}", segmentId, internalIp, e);
}
if (ipMap.isPresent()) {
externalIp = ipMap.get().getExternalIp();
LOG.debug("removeFromIpMapDS : externalIP is {}", externalIp);
} else {
LOG.warn("removeFromIpMapDS : ipMap not present for the internal IP {}", internalIp);
}
if (externalIp != null) {
updateCounter(segmentId, externalIp, false);
// remove from ipmap DS
LOG.debug("removeFromIpMapDS : Removing ipmap from datastore");
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
} else {
LOG.warn("removeFromIpMapDS : externalIp not present for the internal IP {}", internalIp);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.Counter in project netvirt by opendaylight.
the class NaptManager method updateCounter.
public void updateCounter(Uint32 segmentId, String externalIp, boolean isAdd) {
short counter = 0;
InstanceIdentifier<ExternalIpCounter> id = InstanceIdentifier.builder(ExternalIpsCounter.class).child(ExternalCounters.class, new ExternalCountersKey(segmentId)).child(ExternalIpCounter.class, new ExternalIpCounterKey(externalIp)).build();
Optional<ExternalIpCounter> externalIpCounter = Optional.empty();
try {
externalIpCounter = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
} catch (ExecutionException | InterruptedException e) {
LOG.error("updateCounter: Exception while reading ExternalIpCounter DS for the segmentId {} externalIp {} ", segmentId, externalIp, e);
}
if (externalIpCounter.isPresent()) {
counter = externalIpCounter.get().getCounter().toJava();
if (isAdd) {
counter++;
LOG.debug("updateCounter : externalIp and counter after increment are {} and {}", externalIp, counter);
} else {
if (counter > 0) {
counter--;
}
LOG.debug("updateCounter : externalIp and counter after decrement are {} and {}", externalIp, counter);
}
} else if (isAdd) {
counter = 1;
}
// update the new counter value for this externalIp
ExternalIpCounter externalIpCounterData = new ExternalIpCounterBuilder().withKey(new ExternalIpCounterKey(externalIp)).setExternalIp(externalIp).setCounter(counter).build();
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, getExternalIpsIdentifier(segmentId, externalIp), externalIpCounterData);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.Counter in project bgpcep by opendaylight.
the class TopologyDataChangeCounter method putCount.
private void putCount(final long totalCount) {
final WriteTransaction wTx = this.transactionChain.newWriteOnlyTransaction();
final Counter counter = new CounterBuilder().setId(this.counterId).setCount(Uint32.valueOf(totalCount)).build();
wTx.put(LogicalDatastoreType.OPERATIONAL, this.counterInstanceId, counter);
wTx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.debug("Data change count update stored");
}
@Override
public void onFailure(final Throwable trw) {
LOG.error("Failed to store Data change count");
}
}, MoreExecutors.directExecutor());
}
Aggregations