/// <summary> /// Spawn a new instance. /// </summary> /// <param name="fullName"></param> /// <returns></returns> public INode CreateInstance(NodeInfo info) { var handler = GetHandlerForRMITypeName(info.RMITypeName); if (handler == null){ log.Debug("Cannot find an instance for "+info.RMITypeName);return null;} info.RMIResolvedType = handler.ComponentModel.Implementation; log.Debug("Launching a new instance: [RMI] "+info.RMITypeName+" [IMPL] "+handler.ComponentModel.Implementation.FullName); return (INode)handler.Resolve(CreationContext.CreateEmpty()); }
/// <summary> /// Launch a new node based on info. /// </summary> /// <param name="info"></param> public void LaunchNode(NodeInfo info) { var instance = NodeManager.Instance.CreateInstance(info); instance.Initialize(new MatrixPortal(HostClient.Instance, info.Id)); Nodes.Add(info, instance); }
public void ShutdownNode(NodeInfo nodeInfo) { var nodeInstance = Nodes.Keys.FirstOrDefault(e => e.Id == nodeInfo.Id); if (nodeInstance == null) return; var instance = Nodes[nodeInstance]; instance.Shutdown(); Nodes.Remove(nodeInstance); }
/// <summary> /// Route a RMI request to the host with the target node /// </summary> /// <param name="rmi"></param> /// <param name="destoNode"> </param> public void RouteRMIRequest(NodeRMI rmi, NodeInfo destoNode) { if(destoNode.HostID.Length == 1) { rmi.SerializeReturnValue(destoNode.RMIResolvedType.GetMethod(rmi.MethodName).Invoke(controller, rmi.DeserializeArguments())); RouteRMIResponse(rmi); return; } var destoHost = HostCache.FindHost(destoNode.HostID); SendTo(destoHost.Info, destoHost.BuildMessage(MessageIdentifier.RMIInvoke, rmi.Serialize())); }