/* Copyright (c) Microsoft Corporation All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. */ //------------------------------------------------------------------------------ // // Vertex Service contracts // //------------------------------------------------------------------------------ namespace Microsoft.Research.Dryad { using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Runtime.Serialization; using System.ServiceModel; using System.Diagnostics; /// /// Holds property information /// [DataContract] public class ProcessPropertyInfo { [DataMember] public string propertyLabel; [DataMember] public ulong propertyVersion; [DataMember] public string propertyString; [DataMember] public byte[] propertyBlock; } /// /// Keeps track of vertex host process information /// [DataContract] public class VertexProcessInfo { [DataMember] public int DryadId; [DataMember] public string commandLine; [DataMember] public ProcessState State; } /// /// Keeps track of CPU and memory info for vertex host process /// [DataContract] public class VertexStatus { [DataMember] public bool serviceIsAlive = false; [DataMember] public Dictionary freeDiskSpaces = new Dictionary(); [DataMember] public ulong freeVirtualMemory = 0; [DataMember] public ulong freePhysicalMemory = 0; [DataMember] public uint runningProcessCount = 0; [DataMember] public List vps = new List(); } [DataContract(Namespace = "http://hpc.microsoft.com/dryadvertex/")] [Serializable] public class VertexServiceError { public const string Action = "http://hpc.microsoft.com/dryadvertex/VertexServiceError"; /// /// Stores the Operation /// [DataMember] private string operation; /// /// Stores the Reason /// [DataMember] private string reason; /// /// Initializes a new instance of the VertexServiceError class /// /// The operation that failed /// The detailed reason for the failure (exception.ToString()) public VertexServiceError(string operation, string reason) { this.operation = operation; this.reason = reason; } /// /// The detailed reason for the failure /// public string Reason { get { return this.reason; } } /// /// The operation that failed /// public string Operation { get { return this.operation; } } } [DataContract(Namespace = "http://hpc.microsoft.com/dryadvertex/")] [Serializable] public class UnknownProcessError { public const string Action = "http://hpc.microsoft.com/dryadvertex/UnknownProcessError"; /// /// Stores the ProcessId /// [DataMember] private int processId; /// /// Initializes a new instance of the UnknownProcessError class /// /// Id of the unknown process public UnknownProcessError(int id) { this.processId = id; } /// /// The process id which was not found /// public int Processid { get { return this.processId; } } } /// /// Dryad Vertex Service Contract - allows GM to schedule vertices and VH to report status /// [ServiceContract(Name = "IDryadVertexService", Namespace = "http://hpc.microsoft.com/dryadvertex/", SessionMode = SessionMode.Allowed)] public partial interface IDryadVertexService { [OperationContract(IsOneWay=true, Action = "http://hpc.microsoft.com/dryadvertex/cancelscheduleprocess")] void CancelScheduleProcess(int processId); // TODO: Deprecated. [OperationContract(Action = "http://hpc.microsoft.com/dryadvertex/checkstatus")] VertexStatus CheckStatus(); [OperationContract(IsOneWay = true, Action = "http://hpc.microsoft.com/dryadvertex/initialize")] void Initialize(StringDictionary vertexEndpointAddresses); [OperationContract(IsOneWay=true, Action = "http://hpc.microsoft.com/dryadvertex/releaseprocess")] void ReleaseProcess(int processId); [OperationContract(Action = "http://hpc.microsoft.com/dryadvertex/scheduleprocess")] [FaultContract(typeof(VertexServiceError), Action = VertexServiceError.Action)] bool ScheduleProcess(string replyUri, int processId, string commandLine, StringDictionary environment); [OperationContract(Action = "http://hpc.microsoft.com/dryadvertex/setgetprops")] [FaultContract(typeof(VertexServiceError), Action = VertexServiceError.Action)] [FaultContract(typeof(UnknownProcessError), Action = UnknownProcessError.Action)] bool SetGetProps(string replyUri, int processId, ProcessPropertyInfo[] infos, string blockOnLabel, ulong blockOnVersion, long maxBlockTime, string getPropLabel, bool ProcessStatistics); [OperationContract(IsOneWay=true, Action = "http://hpc.microsoft.com/dryadvertex/shutdown")] void Shutdown(uint ShutdownCode); } }