private static NodeInfo ToNode(IActorRef actor) { var node = new NodeInfo() { Path = actor.Path.ToString(), Name = actor.Path.Name }; var internalRef = actor as IInternalActorRef; if (internalRef != null) { node.IsLocal = internalRef.IsLocal; node.IsTerminated = internalRef.IsTerminated; } var local = actor as LocalActorRef; if (local != null) { node.Type = local.Cell.Props.Type.FullName; node.TypeName = local.Cell.Props.Type.Name; node.NoOfMessages = local.Cell.NumberOfMessages; var config = local.Cell.Props.RouterConfig; config.ToString(); } var router = actor as Router; if (router != null) { var routerInfo = new RouterInfo(); node.Router = routerInfo; var fa = FieldAccessorCache.Get(typeof(Router), "_routerProps"); var routerProps = fa.Get(router) as Props; var pool = routerProps.RouterConfig as Pool; if (pool != null) { routerInfo.Pool = true; routerInfo.Type = pool.GetType().Name.UpTo("Pool"); routerInfo.NrOfInstances = pool.NrOfInstances; } else { var group = routerProps.RouterConfig as Group; if (group != null) { routerInfo.Pool = false; routerInfo.Type = group.GetType().Name.UpTo("Group"); } } } return(node); }
private static NodeInfo ToNode(IActorRef actor) { var node = new NodeInfo() { Path = actor.Path.ToString(), Name = actor.Path.Name }; var internalRef = actor as IInternalActorRef; if (internalRef != null) { node.IsLocal = internalRef.IsLocal; node.IsTerminated = internalRef.IsTerminated; } var local = actor as LocalActorRef; if (local != null) { node.Type = local.Cell.Props.Type.FullName; node.TypeName = local.Cell.Props.Type.Name; node.NoOfMessages = local.Cell.NumberOfMessages; var config = local.Cell.Props.RouterConfig; config.ToString(); } var repointable = actor as RepointableActorRef; if (repointable != null) { var fa = FieldAccessorCache.Get(repointable.GetType(), "Props"); var props = (Props)fa.Get(repointable); var pool = props.RouterConfig as Pool; if (pool != null) { node.Router = new RouterInfo { Pool = true, Type = pool.GetType().Name.UpTo("Pool"), NrOfInstances = pool.NrOfInstances }; } else { var group = props.RouterConfig as Group; if (group != null) { node.Router = new RouterInfo { Pool = true, Type = group.GetType().Name.UpTo("Group"), }; } } } return(node); }