Beispiel #1
0
        /// <summary>
        /// Send shutdown message to the launched child nodes.
        /// </summary>
        private void SendShutdownRequests(Node.NodeShutdownLevel nodeShutdownLevel)
        {
            for (int i = 0; i < nodeData.Length; i++)
            {
                // If there is a node launch in progress wait for it complete or fail
                // before shutting down the node
                while (nodeData[i].NodeState == NodeState.LaunchInProgress && !nodeData[i].CommunicationFailed)
                {
                    Thread.Sleep(500);
                }

                if (nodeData[i].NodeState == NodeState.Launched)
                {
                    if (!nodeData[i].CommunicationFailed)
                    {
                        bool exitProcess = !enableNodeReuse;
                        // If we are shutting down due to a BuildComplete then dont kill the nodes as this method will be called again in the engine shutdown method
                        if (nodeShutdownLevel == Node.NodeShutdownLevel.BuildCompleteSuccess || nodeShutdownLevel == Node.NodeShutdownLevel.BuildCompleteFailure)
                        {
                            exitProcess = false;
                        }
                        // Signal to the node to shutdown
                        LocalCallDescriptorForShutdownNode callDescriptor =
                            new LocalCallDescriptorForShutdownNode(nodeShutdownLevel, exitProcess);
                        nodeData[i].NodeCommandQueue.Enqueue(callDescriptor);
                    }
                    else
                    {
                        TerminateChildNode(nodeData[i].ProcessId);
                    }

                    if (nodeShutdownLevel != Node.NodeShutdownLevel.BuildCompleteSuccess &&
                        nodeShutdownLevel != Node.NodeShutdownLevel.BuildCompleteFailure)
                    {
                        nodeData[i].NodeState = NodeState.NotLaunched;
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// This method first reads the objectId as an int from the stream,
        /// this int should be found in the "ObjectType" enumeration. This
        /// objectId informs the method what kind of object should be
        /// deserialized and returned from the method. The objectId is an
        /// output parameter. This parameter is also returned so it can be
        /// used in the read and write methods to determine if
        /// a frame or end marker was found.
        /// </summary>
        private object DeserializeFromStream(out int objectId)
        {
            object objectRead = null;

            objectId = readStream.ReadByte();
            switch ((ObjectType)objectId)
            {
            case ObjectType.NetSerialization:
                objectRead = binaryFormatter.Deserialize(readStream);
                break;

            case ObjectType.FrameMarker:
                objectRead = binaryReader.ReadInt32();
                break;

            case ObjectType.PostBuildResult:
                objectRead = new LocalCallDescriptorForPostBuildResult();
                ((LocalCallDescriptorForPostBuildResult)objectRead).CreateFromStream(binaryReader);
                break;

            case ObjectType.PostBuildRequests:
                objectRead = new LocalCallDescriptorForPostBuildRequests();
                ((LocalCallDescriptorForPostBuildRequests)objectRead).CreateFromStream(binaryReader);
                break;

            case ObjectType.PostLoggingMessagesToHost:
                objectRead = new LocalCallDescriptorForPostLoggingMessagesToHost();
                ((LocalCallDescriptorForPostLoggingMessagesToHost)objectRead).CreateFromStream(binaryReader, loggingTypeCache);
                break;

            case ObjectType.InitializeNode:
                objectRead = new LocalCallDescriptorForInitializeNode();
                ((LocalCallDescriptorForInitializeNode)objectRead).CreateFromStream(binaryReader);
                break;

            case ObjectType.InitializationComplete:
                objectRead = new LocalCallDescriptorForInitializationComplete();
                ((LocalCallDescriptorForInitializationComplete)objectRead).CreateFromStream(binaryReader);
                break;

            case ObjectType.UpdateNodeSettings:
                objectRead = new LocalCallDescriptorForUpdateNodeSettings();
                ((LocalCallDescriptorForUpdateNodeSettings)objectRead).CreateFromStream(binaryReader);
                break;

            case ObjectType.RequestStatus:
                objectRead = new LocalCallDescriptorForRequestStatus();
                ((LocalCallDescriptorForRequestStatus)objectRead).CreateFromStream(binaryReader);
                break;

            case ObjectType.PostCacheEntriesToHost:
                objectRead = new LocalCallDescriptorForPostingCacheEntriesToHost();
                ((LocalCallDescriptorForPostingCacheEntriesToHost)objectRead).CreateFromStream(binaryReader);
                break;

            case ObjectType.GetCacheEntriesFromHost:
                objectRead = new LocalCallDescriptorForGettingCacheEntriesFromHost();
                ((LocalCallDescriptorForGettingCacheEntriesFromHost)objectRead).CreateFromStream(binaryReader);
                break;

            case ObjectType.ShutdownComplete:
                objectRead = new LocalCallDescriptorForShutdownComplete();
                ((LocalCallDescriptorForShutdownComplete)objectRead).CreateFromStream(binaryReader);
                break;

            case ObjectType.ShutdownNode:
                objectRead = new LocalCallDescriptorForShutdownNode();
                ((LocalCallDescriptorForShutdownNode)objectRead).CreateFromStream(binaryReader);
                break;

            case ObjectType.PostIntrospectorCommand:
                objectRead = new LocalCallDescriptorForPostIntrospectorCommand(null, null);
                ((LocalCallDescriptorForPostIntrospectorCommand)objectRead).CreateFromStream(binaryReader);
                break;

            case ObjectType.GenericSingleObjectReply:
                objectRead = new LocalReplyCallDescriptor();
                ((LocalReplyCallDescriptor)objectRead).CreateFromStream(binaryReader);
                break;

            case ObjectType.PostStatus:
                objectRead = new LocalCallDescriptorForPostStatus();
                ((LocalCallDescriptorForPostStatus)objectRead).CreateFromStream(binaryReader);
                break;

            case ObjectType.EndMarker:
                return(null);

            default:
                ErrorUtilities.VerifyThrow(false, "Should not be here, ObjectId:" + objectId + "Next:" + readStream.ReadByte());
                break;
            }
            return(objectRead);
        }