use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.Notifications in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method registerAddressAndQuery.
// takes an address, packs it in a MapRegister, sends it, returns the
// MapReply
private MapReply registerAddressAndQuery(Eid eid) throws SocketTimeoutException {
mapService.addAuthenticationKey(eid, NULL_AUTH_KEY);
sleepForSeconds(1);
MapRegister mapRegister = MappingServiceIntegrationTestUtil.getDefaultMapRegisterBuilder(eid).build();
LOG.trace("Sending Map-Register via socket: {}", mapRegister);
sendMapRegister(mapRegister);
MapNotify mapNotify = receiveMapNotify();
LOG.trace("Received Map-Notify via socket: {}", mapNotify);
assertEquals(8, mapNotify.getNonce().longValue());
// wait for the notifications to propagate
sleepForSeconds(1);
MapRequest mapRequest = MappingServiceIntegrationTestUtil.getDefaultMapRequestBuilder(eid).build();
sendMapRequest(mapRequest);
return receiveMapReply();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.Notifications in project genius by opendaylight.
the class AlivenessMonitor method processReceivedMonitorKey.
private void processReceivedMonitorKey(final String monitorKey) {
Preconditions.checkNotNull(monitorKey, "Monitor Key required to process the state");
LOG.debug("Processing monitorKey: {} for received packet", monitorKey);
final Semaphore lock = lockMap.get(monitorKey);
LOG.debug("Acquiring lock for monitor key : {} to process monitor packet", monitorKey);
acquireLock(lock);
final ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
ListenableFuture<Optional<MonitoringState>> stateResult = tx.read(LogicalDatastoreType.OPERATIONAL, getMonitorStateId(monitorKey));
// READ Callback
Futures.addCallback(stateResult, new FutureCallback<Optional<MonitoringState>>() {
@Override
public void onSuccess(@Nonnull Optional<MonitoringState> optState) {
if (optState.isPresent()) {
final MonitoringState currentState = optState.get();
if (LOG.isTraceEnabled()) {
LOG.trace("OnPacketReceived : Monitoring state from ODS : {} ", currentState);
}
// Long responsePendingCount = currentState.getResponsePendingCount();
//
// Need to relook at the pending count logic to support N
// out of M scenarios
// if (currentState.getState() != LivenessState.Up) {
// //Reset responsePendingCount when state changes from DOWN
// to UP
// responsePendingCount = INITIAL_COUNT;
// }
//
// if (responsePendingCount > INITIAL_COUNT) {
// responsePendingCount =
// currentState.getResponsePendingCount() - 1;
// }
Long responsePendingCount = INITIAL_COUNT;
final boolean stateChanged = currentState.getState() == LivenessState.Down || currentState.getState() == LivenessState.Unknown;
final MonitoringState state = new MonitoringStateBuilder().setMonitorKey(monitorKey).setState(LivenessState.Up).setResponsePendingCount(responsePendingCount).build();
tx.merge(LogicalDatastoreType.OPERATIONAL, getMonitorStateId(monitorKey), state);
ListenableFuture<Void> writeResult = tx.submit();
// WRITE Callback
Futures.addCallback(writeResult, new FutureCallback<Void>() {
@Override
public void onSuccess(Void noarg) {
releaseLock(lock);
if (stateChanged) {
// send notifications
if (LOG.isTraceEnabled()) {
LOG.trace("Sending notification for monitor Id : {} with Current State: {}", currentState.getMonitorId(), LivenessState.Up);
}
publishNotification(currentState.getMonitorId(), LivenessState.Up);
} else {
if (LOG.isTraceEnabled()) {
LOG.trace("Successful in writing monitoring state {} to ODS", state);
}
}
}
@Override
public void onFailure(Throwable error) {
releaseLock(lock);
LOG.warn("Error in writing monitoring state : {} to Datastore", monitorKey, error);
if (LOG.isTraceEnabled()) {
LOG.trace("Error in writing monitoring state: {} to Datastore", state);
}
}
}, callbackExecutorService);
} else {
if (LOG.isTraceEnabled()) {
LOG.trace("Monitoring State not available for key: {} to process the Packet received", monitorKey);
}
// Complete the transaction
tx.submit();
releaseLock(lock);
}
}
@Override
public void onFailure(Throwable error) {
LOG.error("Error when reading Monitoring State for key: {} to process the Packet received", monitorKey, error);
// FIXME: Not sure if the transaction status is valid to cancel
tx.cancel();
releaseLock(lock);
}
}, callbackExecutorService);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.Notifications in project genius by opendaylight.
the class HwVtepTunnelsStateHandler method update.
@Override
public void update(@Nonnull Tunnels oldTunnelInfo, @Nonnull Tunnels updatedTunnelInfo) {
List<BfdStatus> oldBfdStatus = oldTunnelInfo.getBfdStatus();
List<BfdStatus> newBfdStatus = updatedTunnelInfo.getBfdStatus();
LivenessState oldTunnelOpState = getTunnelOpState(oldBfdStatus);
final LivenessState newTunnelOpState = getTunnelOpState(newBfdStatus);
if (oldTunnelOpState == newTunnelOpState) {
LOG.debug("Tunnel state of old tunnel {} and update tunnel {} are same", oldTunnelInfo, updatedTunnelInfo);
return;
}
updatedTunnelInfo.getTunnelUuid();
String interfaceName = "<TODO>";
// TODO: find out the corresponding interface using tunnelIdentifier or
// any attributes of tunnelInfo object
final String monitorKey = getBfdMonitorKey(interfaceName);
LOG.debug("Processing monitorKey: {} for received Tunnels update DCN", monitorKey);
final Semaphore lock = alivenessMonitor.getLock(monitorKey);
LOG.debug("Acquiring lock for monitor key : {} to process monitor DCN", monitorKey);
alivenessMonitor.acquireLock(lock);
final ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
ListenableFuture<Optional<MonitoringState>> stateResult = tx.read(LogicalDatastoreType.OPERATIONAL, getMonitorStateId(monitorKey));
Futures.addCallback(stateResult, new FutureCallback<Optional<MonitoringState>>() {
@Override
public void onSuccess(@Nonnull Optional<MonitoringState> optState) {
if (optState.isPresent()) {
final MonitoringState currentState = optState.get();
if (currentState.getState() == newTunnelOpState) {
return;
}
final boolean stateChanged = true;
final MonitoringState state = new MonitoringStateBuilder().setMonitorKey(monitorKey).setState(newTunnelOpState).build();
tx.merge(LogicalDatastoreType.OPERATIONAL, getMonitorStateId(monitorKey), state);
ListenableFuture<Void> writeResult = tx.submit();
// WRITE Callback
Futures.addCallback(writeResult, new FutureCallback<Void>() {
@Override
public void onSuccess(Void arg0) {
alivenessMonitor.releaseLock(lock);
if (stateChanged) {
// send notifications
LOG.info("Sending notification for monitor Id : {} with Current State: {}", currentState.getMonitorId(), newTunnelOpState);
alivenessMonitor.publishNotification(currentState.getMonitorId(), newTunnelOpState);
} else {
if (LOG.isTraceEnabled()) {
LOG.trace("Successful in writing monitoring state {} to ODS", state);
}
}
}
@Override
public void onFailure(@Nonnull Throwable error) {
alivenessMonitor.releaseLock(lock);
LOG.warn("Error in writing monitoring state : {} to Datastore", monitorKey, error);
if (LOG.isTraceEnabled()) {
LOG.trace("Error in writing monitoring state: {} to Datastore", state);
}
}
}, MoreExecutors.directExecutor());
} else {
LOG.warn("Monitoring State not available for key: {} to process the Packet received", monitorKey);
// Complete the transaction
tx.submit();
alivenessMonitor.releaseLock(lock);
}
}
@Override
public void onFailure(@Nonnull Throwable error) {
LOG.error("Error when reading Monitoring State for key: {} to process the Packet received", monitorKey, error);
// FIXME: Not sure if the transaction status is valid to cancel
tx.cancel();
alivenessMonitor.releaseLock(lock);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.Notifications in project netvirt by opendaylight.
the class Ipv6ServiceInterfaceEventListener method add.
@Override
public void add(InstanceIdentifier<Interface> key, Interface add) {
LOG.debug("Port add {}, {}", key, add);
List<String> ofportIds = add.getLowerLayerIf();
if (!L2vlan.class.equals(add.getType())) {
return;
}
// In ipv6service, we are only interested in the notification for NeutronPort, so we skip other notifications
if (ofportIds == null || ofportIds.isEmpty() || !isNeutronPort(add.getName())) {
return;
}
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface;
iface = ipv6ServiceUtils.getInterface(add.getName());
if (null != iface) {
LOG.debug("Port {} is a Neutron port", iface.getName());
NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
Uint64 dpId = Ipv6ServiceUtils.getDpnIdFromNodeConnectorId(nodeConnectorId);
if (!dpId.equals(Ipv6ServiceConstants.INVALID_DPID)) {
Uuid portId = new Uuid(iface.getName());
VirtualPort port = ifMgr.obtainV6Interface(portId);
if (port == null) {
LOG.info("Port {} does not include IPv6Address, skipping.", portId);
return;
}
Long ofPort = MDSALUtil.getOfPortNumberFromPortName(nodeConnectorId);
ifMgr.updateDpnInfo(portId, dpId, ofPort);
if (!ipv6ServiceEosHandler.isClusterOwner()) {
LOG.trace("Not a cluster Owner, skipping further IPv6 processing on this node.");
return;
}
VirtualPort routerPort = ifMgr.getRouterV6InterfaceForNetwork(port.getNetworkID());
if (routerPort == null) {
LOG.info("Port {} is not associated to a Router, skipping.", portId);
return;
}
// Check and program icmpv6 punt flows on the dpnID if its the first VM on the host.
String jobKey = Ipv6ServiceUtils.buildIpv6MonitorJobKey(portId.getValue());
jobCoordinator.enqueueJob(jobKey, () -> {
ifMgr.handleInterfaceStateEvent(port, dpId, routerPort, add.getIfIndex().intValue(), Ipv6ServiceConstants.ADD_FLOW);
if (!port.getServiceBindingStatus()) {
// Bind Service
Long elanTag = ifMgr.getNetworkElanTag(routerPort.getNetworkID());
ipv6ServiceUtils.bindIpv6Service(portId.getValue(), elanTag, NwConstants.IPV6_TABLE);
port.setServiceBindingStatus(true);
}
return Collections.emptyList();
}, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.Notifications in project controller by opendaylight.
the class MdsalLowLevelTestProvider method unsubscribeDtcl.
@Override
public ListenableFuture<RpcResult<UnsubscribeDtclOutput>> unsubscribeDtcl(final UnsubscribeDtclInput input) {
LOG.info("In unsubscribeDtcl");
if (idIntsListener == null || dtclReg == null) {
return RpcResultBuilder.<UnsubscribeDtclOutput>failed().withError(ErrorType.RPC, "data-missing", "No prior listener was registered").buildFuture();
}
long timeout = 120L;
try {
idIntsListener.tryFinishProcessing().get(timeout, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.error("Unable to finish notification processing", e);
return RpcResultBuilder.<UnsubscribeDtclOutput>failed().withError(ErrorType.APPLICATION, "Unable to finish notification processing in " + timeout + " seconds", e).buildFuture();
}
dtclReg.close();
dtclReg = null;
if (!idIntsListener.hasTriggered()) {
return RpcResultBuilder.<UnsubscribeDtclOutput>failed().withError(ErrorType.APPLICATION, "operation-failed", "id-ints listener has not received any notifications.").buildFuture();
}
try (DOMDataTreeReadTransaction rTx = domDataBroker.newReadOnlyTransaction()) {
final Optional<NormalizedNode> readResult = rTx.read(LogicalDatastoreType.CONFIGURATION, WriteTransactionsHandler.ID_INT_YID).get();
if (!readResult.isPresent()) {
return RpcResultBuilder.<UnsubscribeDtclOutput>failed().withError(ErrorType.APPLICATION, "data-missing", "No data read from id-ints list").buildFuture();
}
final boolean nodesEqual = idIntsListener.checkEqual(readResult.get());
if (!nodesEqual) {
LOG.error("Final read of id-int does not match IdIntsListener's copy. {}", idIntsListener.diffWithLocalCopy(readResult.get()));
}
return RpcResultBuilder.success(new UnsubscribeDtclOutputBuilder().setCopyMatches(nodesEqual)).buildFuture();
} catch (final InterruptedException | ExecutionException e) {
LOG.error("Final read of id-ints failed", e);
return RpcResultBuilder.<UnsubscribeDtclOutput>failed().withError(ErrorType.APPLICATION, "Final read of id-ints failed", e).buildFuture();
}
}
Aggregations