/// <summary>
        /// Execute job serializing result to the stream.
        /// </summary>
        /// <param name="cancel">Whether the job must be cancelled.</param>
        /// <param name="stream">Stream.</param>
        public void ExecuteRemote(PlatformMemoryStream stream, bool cancel)
        {
            // 1. Execute job.
            object res;
            bool   success;

            using (PeerAssemblyResolver.GetInstance(_ignite, Guid.Empty))
            {
                Execute0(cancel, out res, out success);
            }

            // 2. Try writing result to the stream.
            var writer = _ignite.Marshaller.StartMarshal(stream);

            try
            {
                // 3. Marshal results.
                BinaryUtils.WriteInvocationResult(writer, success, res);
            }
            finally
            {
                // 4. Process metadata.
                _ignite.Marshaller.FinishMarshal(writer);
            }
        }
예제 #2
0
        public void TestMissingAssemblyResolutionWithEnabledPeerLoadingFlag()
        {
            // We need to simulate two nodes that will be interacted with each other.
            Ignition.Start(GetConfig());
            var ignite = Ignition.Start(GetConfig());

            // Create separate thread in order to avoid program block due to the endless loop.
            var workerThread = new Thread(() =>
            {
                PeerAssemblyResolver.LoadAssemblyAndGetType("Unavailable.Assembly, unavailable, Ver=1",
                                                            (IIgniteInternal)ignite, Guid.Empty);
            });

            workerThread.Start();

            bool isAssemblyResolved = workerThread.Join(TimeSpan.FromSeconds(10));

            if (!isAssemblyResolved)
            {
                // Ignite instances should be disposed in TearDown method.
                workerThread.Abort();
            }

            Assert.IsTrue(isAssemblyResolved, "Execution cancelled by timeout.");
        }
예제 #3
0
        public static void ExecuteJobAndWriteResults <T>(IIgniteInternal ignite, PlatformMemoryStream stream, T job,
                                                         Func <T, object> execFunc)
        {
            Debug.Assert(stream != null);
            Debug.Assert(ignite != null);
            Debug.Assert(job != null);
            Debug.Assert(execFunc != null);

            // 0. Inject resources.
            InjectResources(ignite, job);

            // 1. Execute job.
            object res;
            bool   success;

            using (PeerAssemblyResolver.GetInstance(ignite, Guid.Empty))
            {
                try
                {
                    res     = execFunc(job);
                    success = true;
                }
                catch (Exception e)
                {
                    res     = e;
                    success = false;
                }
            }

            // 2. Try writing result to the stream.
            var writer = ignite.Marshaller.StartMarshal(stream);

            try
            {
                // 3. Marshal results.
                BinaryUtils.WriteInvocationResult(writer, success, res);
            }
            finally
            {
                // 4. Process metadata.
                ignite.Marshaller.FinishMarshal(writer);
            }
        }