예제 #1
0
 /// <summary>
 /// Performs computation ignoring leaving nodes.
 /// </summary>
 private static AssemblyRequestResult ComputeApplySafe(ICompute compute, GetAssemblyFunc func,
                                                       AssemblyRequest req)
 {
     try
     {
         return(compute.Apply(func, req));
     }
     catch (ClusterGroupEmptyException)
     {
         // Normal situation: node has left.
         return(null);
     }
     catch (AggregateException aex)
     {
         // Normal situation: node has left.
         aex.Handle(e => e is ClusterGroupEmptyException);
         return(null);
     }
 }
예제 #2
0
        /// <summary>
        /// Gets the assembly from remote nodes.
        /// </summary>
        /// <param name="assemblyName">Name of the assembly.</param>
        /// <param name="ignite">Ignite.</param>
        /// <param name="originNodeId">The origin node identifier.</param>
        /// <returns>
        /// Successful result or null.
        /// </returns>
        /// <exception cref="IgniteException"></exception>
        private static AssemblyRequestResult RequestAssembly(string assemblyName, IIgniteInternal ignite,
                                                             Guid originNodeId)
        {
            Debug.Assert(assemblyName != null);
            Debug.Assert(ignite != null);

            if (ignite.Configuration.PeerAssemblyLoadingMode == PeerAssemblyLoadingMode.Disabled)
            {
                return(null);
            }

            Debug.WriteLine("Requesting assembly from other nodes: " + assemblyName);

            // New nodes are not tracked during the loop, since some of the existing nodes caused this call.
            var func = new GetAssemblyFunc();
            var req  = new AssemblyRequest(assemblyName);

            foreach (var node in GetDotNetNodes(ignite.GetIgnite(), originNodeId))
            {
                var compute = ignite.GetIgnite().GetCluster().ForNodeIds(node).GetCompute();
                var result  = ComputeApplySafe(compute, func, req);

                if (result != null)
                {
                    if (result.AssemblyBytes != null)
                    {
                        return(result);
                    }

                    if (result.Message != null)
                    {
                        throw new IgniteException(result.Message);
                    }
                }
            }

            return(null);
        }