<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jun 13, 2011, at 9:12 AM, Banibrata Dutta wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote"><div><br>Well, I haven't. In fact, starting with a small set of possible patterns, seems to be the most intuitive approach. When I bring in the thought of permitting non-programmers to write "something" (e.g. natural language rules, or a simple DSL snippet), and then such a thing modifying the FSM, without me having to code anything further in Erlang, is when I am hitting a mental roadblock. I've coded fairly complex FSM's in C/C++ using the table-based approach. Does gen_fsm take a similar approach ? Will it be a good, natural fit ? Maybe a rather naive question for people extremely familiar with Erlang, but I'm still very much on the learning curve's positive vector.<br>
</div></div></blockquote><div><br></div><div>Erlang gen_fsms are quite simple and standard, they define a bunch of states and use pattern matching to select actions for each state/event combination. Pretty much equivalent to a table-based fsm, only there's no distinct table to speak of. </div><div><br></div><br><blockquote type="cite"><div class="gmail_quote"><div> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;"><div>however you might want to make them a bit more flexible. Maybe have a bunch of processes running pattern recognizers, say one process per pattern or class of patterns. </div>
</div></blockquote><div><br>My natural tendency was to think more in terms of 1 process per source, e.g. 1st event from a source causes an Erlang process to be created, which then embodies the entire possible FSM. The main issue with pattern based processes (if I understood it correctly), is determining the right process to hand-off the event to, and once handed-off, backtracking would mean extra work.<br>
 <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;"><div>Maybe you can filter events based on source so certain recognizers will only get certain events.</div>
</div></blockquote><div><br>Yes, that was the starting point, as I had imagined.<br></div></div></blockquote><div><br></div><div>Event forwarding based on source is technically easy in Erlang, just use a process registry (proc, grpoc, even the built in process registrar) and use sources as keys.</div><div>The problem with this approach is you might have at least some correlation between sources. Events originating from different sources but belonging to the same pattern (i.e. server going black due to switch failing in some other room, due to power outage and the like).</div><br><blockquote type="cite"><div class="gmail_quote"><div> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div style="word-wrap: break-word;"><div> If you have a low correlation between event sources maybe you can even design your system to distribute the processing of unrelated events to different nodes in a cluster (big scalability gain if you can do that). </div>
</div></blockquote><div><br>Excellent thought... indeed. Source based sharding.<br> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div style="word-wrap: break-word;"><div>Another way of approaching this would be to duplicate the event stream to multiple nodes in your cluster and have each node only look for certain subsets of patterns.  </div></div>
</blockquote><div><br>Actually, my bad, I should've mentioned, I wanted to do all this in Real-Time. So I don't really have a pattern-string, so to say. I don't, without that I can really take this approach. Or can I ?<br></div></div></blockquote><div><br></div><div>I think you can. If your patterns are independent, or at least can be grouped in independent categories, what would prevent you from assigning sets of independent patterns to different nodes? Not saying you need to do that, but it might be helpful if you find out that recognizing and processing thousands of patterns take up too much cpu.</div><div><br></div><div>Mihai</div></div><br></body></html>