Route entry condition in C++ - c++

I am using omnet++ to change a specific route entry for a multicast group address. Usually, a multicast route entry is added by using the best (shortest) route to the source of the message.
However what I need to do is to modify this behavior for a specific multicast address so that it does not take the shortest path to source condition but instead uses "first entry".
What I mean is that, if after flooding the multicast packet (with no multicast route entry before) received on a router via three interfaces with the time of arrival like this: 1.eth0 2.eth1 3.eth2, it automatically sets interface eth0 as the RPF and does not compute whether this is the best path.
The normal behavior was already coded into omnett but when I found the functions to add new routes I do not understand where are the conditions of adding a new route.
internalAddMulticastRoute
AddMulticastRoute

As far as I understand, the methods you posted don't actually check anything with regards to which interface is used: whenever a multicast route is added, it is simply stored and used. You might want to have a look at where addMulicastRoute is called; there might be code there that controls priorities. The code in internalAddMulticastRoute only organizes the routing table (which is kept sorted through upper_bound). If you want to control which interface is used, you'll need to modify the routing table entries. I'd recommend performing a check before calling addMulticastRoute.

Related

Get ActorRef of a mutiple akka Actor instances by path

I am creating a pool of instances of a same Actor
Later in my app, I want to be able to reference a specific instance of an actor "pool" by its unique path.
val instance1 = context.spawn(ActorA(), "actorA_1")
val instance2 = context.spawn(ActorA(), "actorA_2")
val instance3 = context.spawn(ActorA(), "actorA_3")
etc
This is done at the initialisation of the application and the goal is to allow any actor of the app to reference this instance if it knows its unique path...
I want to achieve something like that :
val actorRef = getActorByItsUniquePath(path)
actorRef ! sendMessage(...)
I don't know if I need to use the classic Actor Api or the typed API (receptionist) and/or if I need to store the unique path (path + UID) of each Actor instance on a HashMap and retrieve this path later.
I don't find any clear direction to implement that in the doc.
You are on the right path. In Classic Actors this is done by actor selection and Actor Path. Note that "unique path" potentially has to include the node in a clustered setup.
In typed Actors you would use the Receptionist and the ServiceKey acts as your "unique path".
So, you don't need to use one API or the other: you should use classic actors or typed actors as you prefer. Just choose the discovery method (ActorPath or Receptionist) based on which API you have chosen.
However, I will add one caveat. Generally it is preferred not to do this. You are effectively exposing an implementation detail to your client. And removing some flexibility/resiliency. This is discussed here in the docs: https://doc.akka.io/docs/akka/current/actors.html#identifying-actors-via-actor-selection under "It is always preferable to communicate with other Actors using their ActorRef instead of relying upon ActorSelection. Exceptions are:". This is not to say that you absolutely shouldn't do this, as the actor discovery APIs obviously exist for a reason. Just that you should "prefer" not to depending on looking up actors via unique path, and that you should have a good reason for not using something like a router instead.
EDIT TO REPLY TO COMMENT:
You say in the comment below that you will have actor instances with the same path, but this impossible. Actor paths are unique*; each instance has a unique path. It seems that you may think that the path is associated with the actor, but the path is the actor instance. See the docs and also see the section in the Classic docs about naming actors where it talks about the fact that you must give a unique name to each instance. If you don't explicitly give a unique name to your instance, the system will auto generate one. (e.g. /user/myactor/$1, /user/myactor/$2, ...)
If you do have a uid generated already, just specify it as the name of instance when you spawn it and you will end up with a path that looks like: akka://my-actorsystem#mynode:port/user/parentactor/youruid and you will be able to use that path to look it up.
You situation really isn't that unusual. This is a pretty common pattern to have many instances of the same actor, each maintaining state. This is also why I mention using a router pattern, because you have more flexibility with that design. In fact, this is also basically the pattern behind Akka Sharding. You may want to look into that as an option as well, especially if you are using clustering.
If you use a Receptionist and typed actors it's basically the exact example shown in the Receiptionist docs. Every time you create a new actor instance you would register it with the Receptionist with the register message and your uid key. Then you just look it up later with a Find message. It's a wee bit more complicated because Receptionists don't enforce uniqueness (unlike Paths) and because you have to be aware of types (and therefore adapt response types) but that's all the Receptionist really is: a key-value store of actor instances implemented as an actor you send messages to.
*Technically, actor paths are unique to living actor instances. You, in theory could create an actor /user/foo, stop it, and then create a second instance with the same name. But I didn't want to complicate the above explanation as I didn't think that detail was important here.

modeling self referencing nodes in EMF and edit them with ECP

I'm trying to model a network with EMF.
The network should be made up of nodes connected to each other.
Each node should have one or many connections to the others, like a mesh network.
The model should be editable by the EMF Client Platforms (ECP) Demo Application.
When the user creates nodes, in ECPs model-explorer, he/she can set the connections to the other nodes, preferably in a list.
First try was a self-reference, but the problem is there are no bidirectional self-references. This results in, not seeing the connection from the opposite node.
My next idea was to use an intermediate connection class, which leads to another problem. I would like to create this connection automatically without a connection class appearing in the model-explorer. Which would be possible to achieve in the generated EMF viewer, but not in the ECP demo application I'm using.
Third Idea: The only way I can think of solving the last idea, is using a tableControl in the view of the node, to edit the connection class in there. But then the problem with hiding the connection class in the model-explorer remains and the connection class appears in the project folder (highest level) and not in their containing class (in my case a network class).
Doe's anyone have some ideas, how to solve any of my problems?
edit: additional information
The connections between the nodes are by definition full duplex.
And the graph should afterwards be used as input for a shortest path algorithm.
Your first try is the good one. Actually, you can model opposite in Ecore. To do so, you have to model two EReferences towards the same object (so two reflexives references), then set the property eOpposite of one of your EReference to the other one.
Here is a simple metamodel with the eOpposite set: https://repository.genmymodel.com/vincent.aranega/NodeGraph
In the Ecore-XMI, it looks like this (note the eOpposite value):
<eStructuralFeatures xsi:type="ecore:EReference" xmi:id="_pwXZhv1pEeW9zv77lynsJg"
name="references" upperBound="-1" eType="#_pwXZg_1pEeW9zv77lynsJg" eOpposite="#_pwXZiv1pEeW9zv77lynsJg"/>
<eStructuralFeatures xsi:type="ecore:EReference" xmi:id="_pwXZiv1pEeW9zv77lynsJg"
name="relatives" upperBound="-1" eType="#_pwXZg_1pEeW9zv77lynsJg" eOpposite="#_pwXZhv1pEeW9zv77lynsJg" />
With this metamodel, you are able to create a Graph that contains many Node. Each node can reference other nodes. If a Node A as a reference to another named B, the relatives collection of B is automatically updated with A.

REST API - Update of single resource changes multiple others

I'm looking for a way how to deal with a following problem:
Imagine you modify a resource and that subsequently causes update of other resources.
E.g. you issue a PUT to, say /api/orders/1234, which by definition changes state of all other Orders of given user. There may be UI clients that display the table of Orders and they should know that not only single item in the table was updated, but eventually other as well.
Now, is there any standard way how inform a clients about such a situation?
So far I can only think of sending back the 205 Reset Content HTTP status code to inform the client that he should refresh the state, as not just a single thing was changed.
There are multiple solutions.
You can define specific resources as non-cacheable, so the client does not cache them at all. (no-store)
You can try giving a max-age of 0, so the client will have to re-validate those resources always. In this case you might have to implement ETags and conditional GETs, but it will be easier on the server than option 1.
Some push method like WebSockets.
If you really want to "notify" potentially multiple clients of a change, then it sounds like you would need option 3.
However, correctly configured caching is normally good enough. For example you could mark not-yet-executed orders as not cached (max-age=0), but as soon as it is executed, you might mark it to be cached indefinitely, since it can not change anymore.

biztalk: using first node xml file to decide what map to use

I have a problem in my project i have to create orchestration and base o first node of xml file i have to decide what map will be use. Any idea how to do it?
I try to use decide shape and in decide shape use xslt query to find first node equal particular node decide shape will send it to particular map.
is that a good approach?
Here's some suggestions:
If the schema can be resolved by the XmlDisassembler, the engine will apply the matching Map on the Receive Port automatically.
If the number of different Maps is manageable, say 4 or 5, and very unlikely to change, then sure, the decide shape is a workable approach.
Be sure to carefully examine the differences in the Maps. I've had times when the planners believed the maps were significantly more different then in reality. If the difference is a handful of differing codes or conditional fields, maybe one Map can handle all cases.
Another option that would use a receive location for each type of message would be to use a Listen shape in the orchestration. Each branch of the listen would be expecting a different message type (or root node as you put it) and you could apply the appropriate map. Then, assuming you are mapping to a canonical schema, the rest of the orchestration would be the same regardless of input message type.
In the image the orchestration is using a listen shape to listen for 3 types of message. It's mostly for replay-ability for when the orchestration fails at different stages, I can inject it back into the flow after a fix is made.

TMG SF_NOTIFY_POLICY_CHECK_COMPLETED Event

According to http://msdn.microsoft.com/en-us/library/ff823993%28v=VS.85%29.aspx, during this event the web filter can request GUID of the matching rule. I am assuming that is done by performing a GetServerVariable with type of SELECTED_RULE_GUID, since I could find no other readily identifiable means of doing so.
My problem comes from the fact that I want to see if the rule is allowing or blocking the request. If it's being blocked then my filter doesn't have to take any action, but if it's being allowed I need to do some work. SF_NOTIFY_POLICY_CHECK_COMPLETED seems to be the best event to watch, since it occurs last enough that authentication and various ms_auth traffic has been handled, but just before the request either gets routed or fetched from cache.
I had thought that perhaps I needed to use COM and the IFPC interfaces (following along with example code for registering Web Filters to TMG) to get details on the rule. However, going down via FPC -> FPCArray -> FPCArrayPolicy -> FPCPolicyRules, the only element-returning function takes either an index or a name.
Which is problematic given that I only have a GUID.
The FPCPolicyRule object (singular) doesn't seem have any field related to GUID either, which eliminates just iterating over the collection for it.
So my question boils down to, from the SF_NOTIFY_POLICY_CHECK_COMPLETED event, how would a web filter determine if the request has been allowed or denied?
After more investigation and testing, the GUID is accessible via the PersistentName of the FPCPolicyRule object. Since FPCPolicyRules->Item member only works on either Name or Index, I had to iterate through its items comparing each PersistentName against the GUID.
Apologies if this was obvious, took me a good day to work out :)