简体   繁体   English

启动服务-有向无环图

[英]Starting Services — Directed Acyclic Graph

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 我正在使用的框架由有状态的服务组成,这些状态服务依赖于其他服务,形成有向无环图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. 例如,在Wikipedia链接上的图形中。 I would start 3, 5, and 7 at the same time, since they don't have any dependencies. 我将同时启动3、5和7,因为它们没有任何依赖性。 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: 我正在寻找用于对服务进行分组的库/ api,例如:

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. 这告诉我首先以“ a”开头,然后以“ b”,“ c”和“ d”开头,然后以“ e”开头,依此类推。

I've found a few libraries that model Vertices, but nothing does the grouping I'm looking for. 我发现了一些可以模拟Vertices的库,但是没有找到我想要的分组。 So far I've found some implementations for directed graph, however, I need a permissive license (eg non gpl). 到目前为止,我已经找到了有向图的一些实现,但是,我需要一个许可的许可证(例如,非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. 我找到了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,但不确定是否有这些/所有功能都能满足我的需求。

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. 以后的依赖关系在树中进一步下降。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM