use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project openflowplugin by opendaylight.
the class ConnectionManagerImplTest method testOnSwitchConnected2.
/**
* Test method for
* {@link org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl#onSwitchConnected(
* org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter)}.
* invoking onHelloMessage, scenario:
* <ol>
* <li>receive hello from device (notification)</li>
* <li>send hello to device (rpc with void output)</li>
* <li>send getFeature to device (rpc with getFeatureOutput)</li>
* <li>wait for rpc to finish with getFeatureOutput</li>
* </ol>
*
* @throws InterruptedException - interrupted exception
*/
@Test
public void testOnSwitchConnected2() throws Exception {
connectionManagerImpl.onSwitchConnected(connection);
Mockito.verify(connection).setConnectionReadyListener(connectionReadyListenerAC.capture());
Mockito.verify(connection).setMessageListener(ofpListenerAC.capture());
// prepare void reply (hello rpc output)
final SettableFuture<RpcResult<Void>> voidResponseFx = SettableFuture.<RpcResult<Void>>create();
Mockito.when(connection.hello(Matchers.any(HelloInput.class))).thenReturn(voidResponseFx);
// prepare getFeature reply (getFeture rpc output)
final SettableFuture<RpcResult<GetFeaturesOutput>> featureResponseFx = SettableFuture.<RpcResult<GetFeaturesOutput>>create();
Mockito.when(connection.getFeatures(Matchers.any(GetFeaturesInput.class))).thenReturn(featureResponseFx);
// fire handshake - send hello reply
final HelloMessage hello = new HelloMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(1L).build();
ofpListenerAC.getValue().onHelloMessage(hello);
// notify about connection ready
connectionReadyListenerAC.getValue().onConnectionReady();
// deliver hello send output (void)
Thread.sleep(100L);
final RpcResult<Void> helloResponse = RpcResultBuilder.success((Void) null).build();
voidResponseFx.set(helloResponse);
// deliver getFeature output
Thread.sleep(100L);
final GetFeaturesOutput getFeatureOutput = new GetFeaturesOutputBuilder().setDatapathId(BigInteger.TEN).setVersion(OFConstants.OFP_VERSION_1_3).setXid(2L).setTables((short) 15).build();
final RpcResult<GetFeaturesOutput> rpcFeaturesOutput = RpcResultBuilder.success(getFeatureOutput).build();
featureResponseFx.set(rpcFeaturesOutput);
Mockito.verify(deviceConnectedHandler, Mockito.timeout(FINAL_STEP_TIMEOUT)).deviceConnected(Matchers.any(ConnectionContext.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project cxf by apache.
the class JmsPullPoint method getMessages.
@Override
protected List<NotificationMessageHolderType> getMessages(int max) throws ResourceUnknownFault, UnableToGetMessagesFault {
try {
if (max == 0) {
max = 256;
}
initSession();
List<NotificationMessageHolderType> messages = new ArrayList<>();
for (int i = 0; i < max; i++) {
final Message msg;
synchronized (consumerSession) {
msg = consumer.receiveNoWait();
}
if (msg == null) {
break;
}
TextMessage txtMsg = (TextMessage) msg;
StringReader reader = new StringReader(txtMsg.getText());
XMLStreamReader xreader = StaxUtils.createXMLStreamReader(reader);
Notify notify = (Notify) jaxbContext.createUnmarshaller().unmarshal(xreader);
try {
xreader.close();
} catch (XMLStreamException e) {
// ignoreable
}
messages.addAll(notify.getNotificationMessage());
}
return messages;
} catch (JMSException e) {
LOGGER.log(Level.INFO, "Error retrieving messages", e);
closeSession();
UnableToGetMessagesFaultType fault = new UnableToGetMessagesFaultType();
throw new UnableToGetMessagesFault("Unable to retrieve messages", fault, e);
} catch (JAXBException e) {
LOGGER.log(Level.INFO, "Error retrieving messages", e);
UnableToGetMessagesFaultType fault = new UnableToGetMessagesFaultType();
throw new UnableToGetMessagesFault("Unable to retrieve messages", fault, e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project cxf by apache.
the class NotificationBroker method notify.
public void notify(Referencable publisher, String topic, Object msg) {
getBroker();
if (this.context != null) {
try {
DOMResult result = new DOMResult();
context.createMarshaller().marshal(msg, result);
msg = result.getNode();
if (msg instanceof Document) {
msg = ((Document) msg).getDocumentElement();
}
} catch (JAXBException e) {
// ignore, we'll try and let the runtime handle it as is
}
}
Notify notify = new Notify();
NotificationMessageHolderType holder = new NotificationMessageHolderType();
if (publisher != null) {
holder.setProducerReference(publisher.getEpr());
}
if (topic != null) {
TopicExpressionType topicExp = new TopicExpressionType();
topicExp.getContent().add(topic);
holder.setTopic(topicExp);
}
holder.setMessage(new NotificationMessageHolderType.Message());
holder.getMessage().setAny(msg);
notify.getNotificationMessage().add(holder);
getBroker().notify(notify);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project cxf by apache.
the class JmsSubscription method onMessage.
public void onMessage(Message jmsMessage) {
try {
TextMessage text = (TextMessage) jmsMessage;
XMLStreamReader reader = StaxUtils.createXMLStreamReader(new StringReader(text.getText()));
Notify notify = (Notify) jaxbContext.createUnmarshaller().unmarshal(reader);
reader.close();
for (Iterator<NotificationMessageHolderType> ith = notify.getNotificationMessage().iterator(); ith.hasNext(); ) {
NotificationMessageHolderType h = ith.next();
Object content = h.getMessage().getAny();
if (!(content instanceof Element)) {
DocumentFragment doc = DOMUtils.getEmptyDocument().createDocumentFragment();
jaxbContext.createMarshaller().marshal(content, doc);
content = DOMUtils.getFirstElement(doc);
}
if (!doFilter((Element) content)) {
ith.remove();
} else {
h.setTopic(topic);
h.setSubscriptionReference(getEpr());
}
}
if (!notify.getNotificationMessage().isEmpty()) {
doNotify(notify);
}
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Error notifying consumer", e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project netvirt by opendaylight.
the class AclInterfaceStateListener method add.
@Override
public void add(InstanceIdentifier<Interface> key, Interface added) {
if (!L2vlan.class.equals(added.getType())) {
return;
}
if (aclInterfaceCache.get(added.getName()) == null) {
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = interfaceManager.getInterfaceInfoFromConfigDataStore(added.getName());
if (iface == null) {
LOG.error("No interface with name {} available in interfaceConfig, servicing interfaceState ADD" + "for ACL failed", added.getName());
return;
}
InterfaceAcl aclInPort = iface.augmentation(InterfaceAcl.class);
if (aclInPort == null) {
LOG.trace("Interface {} is not an ACL Interface, ignoring ADD interfaceState event", added.getName());
return;
}
aclInterfaceCache.addOrUpdate(added.getName(), (prevAclInterface, builder) -> {
builder.portSecurityEnabled(aclInPort.isPortSecurityEnabled()).interfaceType(aclInPort.getInterfaceType()).securityGroups(aclInPort.getSecurityGroups()).allowedAddressPairs(new ArrayList<AllowedAddressPairs>(aclInPort.nonnullAllowedAddressPairs().values())).subnetInfo(new ArrayList<SubnetInfo>(aclInPort.nonnullSubnetInfo().values()));
});
}
AclInterface aclInterface = aclInterfaceCache.addOrUpdate(added.getName(), (prevAclInterface, builder) -> {
builder.dpId(AclServiceUtils.getDpIdFromIterfaceState(added)).lPortTag(added.getIfIndex()).isMarkedForDelete(false);
if (AclServiceUtils.isOfInterest(prevAclInterface)) {
SortedSet<Integer> ingressRemoteAclTags = aclServiceUtils.getRemoteAclTags(prevAclInterface.getSecurityGroups(), DirectionIngress.class);
SortedSet<Integer> egressRemoteAclTags = aclServiceUtils.getRemoteAclTags(prevAclInterface.getSecurityGroups(), DirectionEgress.class);
builder.ingressRemoteAclTags(ingressRemoteAclTags).egressRemoteAclTags(egressRemoteAclTags);
}
});
if (AclServiceUtils.isOfInterest(aclInterface)) {
List<Uuid> aclList = aclInterface.getSecurityGroups();
if (aclList != null) {
aclDataUtil.addOrUpdateAclInterfaceMap(aclList, aclInterface);
}
if (aclInterface.getElanId() == null) {
LOG.debug("On Add event, skip ADD since ElanId is not updated");
return;
}
if (aclClusterUtil.isEntityOwner()) {
LOG.debug("On add event, notify ACL service manager to add ACL for interface: {}", aclInterface);
aclServiceManger.notify(aclInterface, null, Action.BIND);
if (aclList != null) {
aclServiceUtils.addAclPortsLookup(aclInterface, aclList, aclInterface.getAllowedAddressPairs());
}
aclServiceManger.notify(aclInterface, null, Action.ADD);
}
}
}
Aggregations