启动服务——有向无环图
我正在使用的框架由有状态的服务组成,这些服务依赖于其他服务,形成有向无环图 http: //en.wikipedia.org/wiki/Directed_acirclic_graph
我想尽可能高效地启动服务。这意味着在可能的情况下并行启动服务。例如,在维基百科链接上的图表中。我会同时启动 3、5 和 7,因为它们没有任何依赖关系。我见过拓扑排序,但仅凭这一点并不能告诉您可以并行启动什么。我正在寻找一个库/api来对服务进行分组,例如:
a b, c, d, e. f, g, h
这告诉我首先启动“a”,然后并行启动“b”、“c”和“d”,然后是“e”,依此类推在。
我找到了一些对顶点进行建模的库,但没有任何东西可以满足我正在寻找的分组。到目前为止,我已经找到了一些有向图的实现,但是,我需要一个宽松的许可证(例如非 gpl)。我找到了 ComputeNodeOrder http:// www.docjar.com/docs/api/org/eclipse/osgi/internal/resolver/ComputeNodeOrder.Digraph.html(来自Equinox org.eclipse.osgi_3.6.2.R36x_v20110210),Jgrapht(lgpl)http://www.jgrapht.org/javadoc/,Jung http://jung.sourceforge.net/index.html,Plexus http://plexus.codehaus.org/plexus-utils/apidocs/org/codehaus/plexus/util/dag/ DAG.html 但不确定其中任何/所有这些是否能满足我的需要。
The framework I'm working with consists of stateful services that have dependencies on other services, forming a directed acyclic graph http://en.wikipedia.org/wiki/Directed_acyclic_graph
I want to start the services as efficiently as possible. This means starting services in parallel, where possible. For example, in the graph on the wikipedia link. I would start 3, 5, and 7 at the same time, since they don't have any dependencies. I've seen topological sorts, but that alone doesn't tell you what can be started in parallel. I'm looking for a library/api to group services, something like:
a b, c, d, e. f, g, h
Where this tells me to start "a" first, then "b", "c", and "d" in parallel, then "e", and so on.
I've found a few libraries that model Vertices, but nothing does the grouping I'm looking for. So far I've found some implementations for directed graph, however, I need a permissive license (e.g. non gpl). I've found ComputeNodeOrder http://www.docjar.com/docs/api/org/eclipse/osgi/internal/resolver/ComputeNodeOrder.Digraph.html (from equinox org.eclipse.osgi_3.6.2.R36x_v20110210), Jgrapht (lgpl) http://www.jgrapht.org/javadoc/, Jung http://jung.sourceforge.net/index.html, Plexus http://plexus.codehaus.org/plexus-utils/apidocs/org/codehaus/plexus/util/dag/DAG.html but not sure if any/all of these will do what I need.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说,这听起来像是一棵使用广度优先搜索迭代的树。每个级别都有可以并行启动的服务;后面的依赖项在树中更靠下。
It sounds like a tree iterated using a breadth first search to me. Each level has the services that can be started in parallel; later dependencies are further down in the tree.