Пример #1
0
        /// <summary>
        /// Return an execution from the cluster and give it back to the correct domain.
        /// </summary>
        /// <param name="result">The Result object of the execution.</param>
        public static void ReturnExecution(ExecutionResult result)
        {
            DomainProxy proxy    = proxies[result.DomainKey];
            Node        executor = Nodes.GetNodeByID(result.ExecutingNodeID);

            proxy.ReturnExecution(result.ContextID, executor, result.Result);
        }
Пример #2
0
        /// <summary>
        /// Unloads and destroys the domain with the specified Key. Also deletes any assemblies associated with the domain.
        /// </summary>
        /// <param name="domainKey">The Key of the domain to be destroyed.</param>
        /// <param name="instanceSignal">Specefies whether or not the Destroy domain signal came from a local instance.</param>
        public static void DestroyDomain(string domainKey, bool instanceSignal = false)
        {
            if (!domains.ContainsKey(domainKey))
            {
                return;
            }
            AppDomain   domain = domains[domainKey];
            DomainProxy proxy  = proxies[domainKey];

            if (instanceSignal)
            {
                Nodes.UnloadDomain(domainKey, proxy.GetAssemblyNames());
                return;
            }
            foreach (string assem in proxy.GetAssemblyNames())
            {
                if (assemblies.ContainsKey(assem))
                {
                    assemblies.Remove(assem);
                }
            }
            proxies.Remove(domainKey);
            domains.Remove(domainKey);
            Action <AppDomain> final = finalUnload;

            final.BeginInvoke(domain, null, null);
        }
Пример #3
0
        /// <summary>
        /// Tells whether the assembly with the given name is loaded into the domain with the given Key.
        /// Will return false if the given domain Key does not correspond to a currently loaded domain.
        /// </summary>
        /// <param name="domainKey">The Key of the domain to check in.</param>
        /// <param name="assemblyName">The name of the assembly to check for.</param>
        /// <returns>Whether or not the domain has the assembly.</returns>
        public static bool DomainHasAssembly(string domainKey, string assemblyName)
        {
            if (!HasDomain(domainKey))
            {
                return(false);
            }
            DomainProxy proxy = proxies[domainKey];

            return(proxy.HasAssembly(assemblyName));
        }
Пример #4
0
        /// <summary>
        /// Startup an assembly into the specefied domain.
        /// </summary>
        /// <param name="domainKey">The string Key of the domain to be loaded into.</param>
        /// <param name="assemblyStream">The COFF byte array of the assembly.</param>
        public static void LoadAssemblyIntoDomain(string domainKey, byte[] assemblyStream)
        {
            DomainProxy proxy        = proxies[domainKey];
            string      assemblyName = proxy.LoadAssembly(assemblyStream);

            if (assemblies.ContainsKey(assemblyName))
            {
                assemblies.Remove(assemblyName);
            }
            assemblies.Add(assemblyName, assemblyStream);
        }
Пример #5
0
 /// <summary>
 /// Delivers a user sent message to the correct domain. If the correct domain is not valid, an error is logged.
 /// </summary>
 /// <param name="message">The UserMessage object for the message.</param>
 public static void DeliverMessage(UserMessage message)
 {
     if (domains.ContainsKey(message.DomainKey))
     {
         DomainProxy proxy = proxies[message.DomainKey];
         Node        node  = Nodes.GetNodeByID(message.Sender);
         proxy.DeliverMessage(message.Message, node);
     }
     else
     {
         Log.Error("No domain with Key: " + message.DomainKey + " was found to deliver message: \"" + message.Message + "\" from: NodeID: " + message.Sender);
     }
 }
Пример #6
0
        /// <summary>
        /// Retrieve the COFF based images of all assemblies loaded into a domain along with the assemblies full names as keys.
        /// </summary>
        /// <param name="domainKey">The domain key associated with the requested domain.</param>
        /// <returns>The COFF based images of all assemblies loaded into a domain along with their full names as keys.</returns>
        public static Dictionary <string, byte[]> GetDomainAssemblies(string domainKey)
        {
            Dictionary <string, byte[]> assemblyListing = new Dictionary <string, byte[]>();

            if (!HasDomain(domainKey))
            {
                return(assemblyListing);
            }
            DomainProxy proxy = proxies[domainKey];

            string[] assemblyNames = proxy.GetAssemblyNames();
            foreach (string name in assemblyNames)
            {
                if (assemblies.ContainsKey(name))
                {
                    assemblyListing.Add(name, assemblies[name]);
                }
            }
            return(assemblyListing);
        }
Пример #7
0
        /// <summary>
        /// Creates a new application domain, and adds it to the store. If the domain already exists, does nothing.
        /// </summary>
        public static void CreateDomain(string domainKey)
        {
            //if we already have the domain it doesnt need to be created.
            if (domains.ContainsKey(domainKey))
            {
                return;
            }
            AppDomain newDomain = AppDomain.CreateDomain(domainKey);

            //preload assemblies
            foreach (string item in Config.DomainPreloads)
            {
                newDomain.Load(item);
            }
            //create the domain proxy
            DomainProxy proxy = (DomainProxy)newDomain.CreateInstanceAndUnwrap(typeof(DomainProxy).Assembly.FullName, typeof(DomainProxy).FullName);
            //create the cluster proxy
            ClusterProxy cproxy = new ClusterProxy();

            proxy.ConfigureCluster(cproxy, domainKey);
            //add the data to the lookup tables
            proxies.Add(domainKey, proxy);
            domains.Add(domainKey, newDomain);
        }
Пример #8
0
        /// <summary>
        /// Execute an incoming job according to the passed in execution context.
        /// </summary>
        /// <param name="context">The context of the job.</param>
        /// <returns>The result of the job serialized for transport.</returns>
        public static byte[] ExecuteIncoming(ExecutionContext context)
        {
            DomainProxy proxy = proxies[context.DomainKey];

            return(proxy.ExecuteIncoming(context.MethodName, context.TypeName, context.AssemblyName, context.Parameter));
        }
Пример #9
0
        /// <summary>
        /// Execute the startup procedure on the presto instance in the specefied domain.
        /// </summary>
        /// <param name="domainKey">The Key of the domain to execute in.</param>
        public static void ExecuteStartup(string domainKey)
        {
            DomainProxy proxy = proxies[domainKey];

            proxy.ExecuteInstance();
        }