How to watch for creation of nodes two levels down using Apache Curator? - apache-zookeeper

My goal is, given a CuratorFramework that is decorated with a path to a root node, and a String, to watch for events two levels down any path to that String.
More specifically, I would like to watch for events on any path ROOT/<anything here>/INPUT_STRING. I also need to watch for nodes being added in the middle layer, but I am not interested in the contents of those middle nodes (only that they appeared, so I can watch for a child to be created for the INPUT_STRING).
My idea was to create a NodeCache for each path to ROOT/<added middle node>/INPUT_STRING whenever a middle node is added. I thought I could then watch for middle nodes being added using a PathChildrenCache, but that seems like overkill since I'm not interested in the contents of the middle nodes.
Is there some better way to create a NodeCache for the INPUT_STRING two levels down? Or should I be using a PathChildrenCache, even though I don't care about the contents of the middle nodes?

You can use TreeCache to cache/watch/listen to a tree of ZNodes. I believe that will do what you need. http://curator.apache.org/curator-recipes/tree-cache.html

Related

OR-Tools: Ensure group of nodes is visited by vehicles from the same depot

I would like to use OR-Tools to solve a CVRP where each node has a label, and all the nodes that have the same label have to be visited by vehicles that originate from the same starting location. It does not matter which this starting location is, the only requirement is that it is the same for all the nodes with the same label. Is there a way to model this using the routing library?
I suggest the use of "SetAllowedVehiclesForIndex" method.

Trasporters are jammed at a specific location in AnyLogic

I hope you are having a great day.
Recently, I tried to build an AnyLogic model with free-space transporters, but I encountered an unexpected situation as shown below.
I thought that there is no logical reason why all the transporters are jammed in a specific position. Is there any solution or possible reason for this situation? I have attached my model for your information.
Thank you for reading this question.
The problem with the traffic jam appears to be due to the fact that there are two few attractors available for the transporters to place the items and then they get stuck waiting for an attractor to become available...
When running your model as-is I get a jam in the stage one area
And in the logic blocks, I can see that the transports are stuck in the "Move By Transporter" block.
If I assume the attractors are set to 4 for a reason I would suggest the following logic - similar to what is described here
You create a list of all the attractors available. See the neat trick in AnyLogic where if you select a bunch of objects and then right-click on them you can automatically create a collection.
You can call it something like attractorsAvailabeStage1
And create a new map to store the WIP agents that will be occupying the attractors
And have a function that will provide the available attractors.
Change the move by transporter option to move to an attractor
And also return the attractor as available once it gets moved from its location
Now you only need to prevent mew agents from entering the area if there is no more attractors left or agents on their way to the attractors
I tested it and it works great for stage 1 you need to do it for all the stages.
On second thought....
seeing that you do have resource pools and service blocks. You can achieve the same logic I described by having resources first size the locations, then go to the transport block, and then be delayed
You first seize the space in the stage, then you move to the space, then you delay it.... then you wait, then seize the space in stage 2, then move there, then release stage 1.
I would go for the latter option

Avoiding collisions with other objects while moving an Agent to a specific destination

I have in my model some free-moving agents, which travel to specific nodes. I use the function...
moveTo(node)
...to specify the node an agent should visit. Using this function, the agent travels the shortest path to the node. However, the model layout contains areas (i.e. image files), which the agent should not pass. Right now, the agents may travel through these areas to reach their destination. Now I'm wondering, whether there is an easy way to permit an agent to enter specific areas in the model, when traveling to a node.
I already took a look at the example model "Wandering Elephants" where the elephants are permitted to walk through areas with water. The solution there is, that if an elephant meets water in the direction it's currently heading, it randomly searches for another direction, until it finds one without water. However, this approach doesn't really fit to my problem, as the elephants in the model wander around without any specific destination. I'm searching for a method, which works for an agent that travels to a specific point. In the best case, the agent would search the shortest path around the obstacle to reach its destination.
Edit 1: The following figure shows my problem in a nutshell. On the left side is my model structure, while on the right side the state chart of my custom agent. What is happening in the model: The 3 sources are producing agents, which will be delayed for an uncertain time (delay stops with stopDelay()). Everytime an agent enters a delay, the delay is added to the collection request. My customagent check requests in a loop until the collection contains at least one request. Then, the customagent randomly selects a request (i.e. delay object) to serve. Each delay is associated with a node (the collection processNodes maps delays to nodes). Now, I want to cast my customagent to a Transporter and move it to the corresponding node. The agent should avoid collisions with the stripped walls in the model. I want to avoid any seizing and releasing of resources. I just want to adapt the behaviour of the Transport agent from the material handling library to my agent.
Edit 2:
In my current testbed, my custom agent does not consider node 1 or node 2. For testing, the agent should only try to reach node without any collisions.
I found a sufficient work-around. Not exactly what I wanted, but it works. Against my initial intention, I use now seize and release for transports. However, I added a hold-block in front of each seized-block and only a resource, which decides to serve the process, is able to unblock the corresponding hold. The on-enter control of the unblocked hold ensures that the hold is directly blocked again as soon as a single agent flows through. For the case that other users are also interested in the solution, I attached the flow-chart of the process and the state-chart of the Transporter-Agent. The system structure is quite the same as in my initial question.
There is no build-in way unless you use transporters from the Material handling library (or pedestrians). These can do what you need.
So easiest might be to convert you agents to transporters temporarily.
Otherwise, you will have to code something yourself...

Is a SharedIndexInformer's Indexer's ThreadSafeStore ever emptied?

I'm carefully making my way through the Go code in the tools/cache package for what seems like the hundredth time.
From close-reading the code, when you create a new SharedIndexInformer, the following things happen:
SharedIndexInformer creates a new Indexer.
The Indexer so created creates a new ThreadSafeStore internally for holding representations of Kubernetes resources.
SharedIndexInformer.Run() creates a new DeltaFIFO with the new Indexer as its second parameter.
The Indexer supplied to the new DeltaFIFO therefore functions as its KeyLister
and its KeyGetter. (This is used to track "prior state" for deletions; i.e. if there's an object in it but the latest sync up with Kubernetes does not contain that object, then we know it has been deleted from the cluster.)
The HandleDeltas function is the one that the underlying controller will call when Kubernetes resources are added, updated or deleted.
The HandleDeltas function will call the Add, Update and Delete methods on the Indexer (and, by extension, on its underlying ThreadSafeStore).
Let's say I write a new controller using a SharedIndexInformer. Let's further say that it is watching for Pods. Let's finally say that there are 10 Pods in the cluster.
Does this mean that after the SharedIndexInformer's Run method has been called and some requisite amount of time has passed that there will be 10 JSON representations of Pods in the ThreadSafeStore, and, further, that none will be removed from this store until an actual deletion of one of the corresponding Pods occurs in Kubernetes?
Correct, except for the JSON part.
The Store contains native Object structs, deserialized from protobuf messages.

In MDriven Enterprise Information, why is there a Processes Hierarchy and also a Processes Tree?

In MDriven Enterprise Information, why is there a Processes Hierarchy and also a Processes Tree? Aren’t they the same thing? Is this not redundant duplication?
Processes are defined by their steps.
A Process step can make use of another processes - ie defining a sub-process.
To both have the complete list of processes and the resulting expanded tree of process and their sub-processes and even their sub-processes (infinity) we added two nodes.
First node is the complete straight list of existing processes regardless if they are sub-processes or not.
Second node is the constructed tree of whom uses who - and a sub-process can then show up multiple times in this tree.
Notice that ApproveNewBulk is re-used in 2 processes in the example below.