コード例 #1
0
        /// <summary>
        /// Generate endpoint address by scheme from epr list
        /// </summary>
        /// <param name="eprList">indicating the epr list</param>
        /// <param name="scheme">indicating the scheme</param>
        /// <returns>endpoint address</returns>
        private static EndpointAddress GenerateEndpointAddress(string[] eprList, TransportScheme scheme, bool secure, bool internalChannel)
        {
            int    index = (int)Math.Log((int)scheme, 2);
            string epr   = eprList[index];

            return(SoaHelper.CreateEndpointAddress(new Uri(epr), secure, internalChannel));
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the DataClient class
 /// </summary>
 /// <param name="headNode">head node name</param>
 /// <param name="dataClientId">data client id</param>
 /// <param name="info">data client info</param>
 /// <param name="readOnly">a flag indicating whether the DataClient instance is readonly or not</param>
 /// <param name="userName">user name</param>
 /// <param name="password">the password name</param>
 private DataClient(string headNode, string dataClientId, DataClientInfo info, bool readOnly, TransportScheme scheme, string userName = null, string password = null)
     : this(dataClientId, info, readOnly)
 {
     this.headNode = headNode;
     this.userName = userName;
     this.password = password;
     this.scheme   = scheme;
 }
コード例 #3
0
        /// <summary>
        /// Set the frontend info for a certain transport scheme
        /// </summary>
        /// <param name="info">indicating the frontend info</param>
        /// <param name="scheme">indicating the transport scheme</param>
        public void SetFrontendInfo(FrontendInfo info, TransportScheme scheme)
        {
            int index = (int)Math.Log((int)scheme, 2);

            this.frontendUriList[index]    = info.FrontEnd.ListenUri;
            this.controllerUriList[index]  = info.ControllerUri;
            this.getResponseUriList[index] = info.GetResponseUri;
            this.frontendList[index]       = info.FrontEnd;
            this.serviceHostList[index]    = info.ControllerFrontend;

            // If any frontend does not support addressing or not http binding,
            // the session would be treated as not available for Message Details View.
            if (info.Binding.MessageVersion.Addressing == AddressingVersion.None && !(info.Binding is BasicHttpBinding))
            {
                this.supportsMessageDetails = false;
            }

            if (info.MaxMessageSize > this.maxMessageSize)
            {
                this.maxMessageSize = info.MaxMessageSize;
            }

            if (this.readerQuotas == null)
            {
                this.readerQuotas = info.ReaderQuotas;
            }
            else
            {
                if (info.ReaderQuotas.MaxArrayLength > this.readerQuotas.MaxArrayLength)
                {
                    this.readerQuotas.MaxArrayLength = info.ReaderQuotas.MaxArrayLength;
                }

                if (info.ReaderQuotas.MaxBytesPerRead > this.readerQuotas.MaxBytesPerRead)
                {
                    this.readerQuotas.MaxBytesPerRead = info.ReaderQuotas.MaxBytesPerRead;
                }

                if (info.ReaderQuotas.MaxDepth > this.readerQuotas.MaxDepth)
                {
                    this.readerQuotas.MaxDepth = info.ReaderQuotas.MaxDepth;
                }

                if (info.ReaderQuotas.MaxNameTableCharCount > this.readerQuotas.MaxNameTableCharCount)
                {
                    this.readerQuotas.MaxNameTableCharCount = info.ReaderQuotas.MaxNameTableCharCount;
                }

                if (info.ReaderQuotas.MaxStringContentLength > this.readerQuotas.MaxStringContentLength)
                {
                    this.readerQuotas.MaxStringContentLength = info.ReaderQuotas.MaxStringContentLength;
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Delete the DataClient with the specified ID
        /// </summary>
        /// <param name="headNode">cluster head node name</param>
        /// <param name="dataClientId">ID of the DataClient to be deleted</param>
        /// <param name="scheme">the transport scheme</param>
        /// <param name="userName">user name</param>
        /// <param name="password">the password name</param>
        private static void DeleteInternal(string headNode, string dataClientId, TransportScheme scheme, string userName, string password)
        {
            Utility.ValidateHeadNode(headNode);
            Utility.ValidateDataClientId(dataClientId);

            IDataService dsagent = GetDataServiceAgent(headNode, scheme, userName, password);

            InvokeDataOperation <bool>(
                dsagent,
                delegate(IDataService agent)
            {
                agent.DeleteDataClient(dataClientId);
                return(true);
            });
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the BrokerFrontendFactory class
        /// </summary>
        /// <param name="clientId">indicating the client id</param>
        /// <param name="binding">indicating the binding</param>
        /// <param name="info">indicating the session info</param>
        /// <param name="scheme">indicating the scheme</param>
        /// <param name="responseCallback">indicating the response callback</param>
        public WSBrokerFrontendFactory(string clientId, Binding binding, SessionInfo info, TransportScheme scheme, IResponseServiceCallback responseCallback)
            : base(clientId, responseCallback)
        {
            this.info             = info;
            this.schedulerOnAzure = SoaHelper.IsSchedulerOnAzure(this.info.BrokerLauncherEpr, this.info.UseInprocessBroker);
            this.schedulerOnIaaS  = SoaHelper.IsSchedulerOnIaaS(this.info.Headnode);

            this.binding = binding;
            this.scheme  = scheme;
            if (info.UseInprocessBroker)
            {
                this.brokerFrontend         = this.info.InprocessBrokerAdapter.GetBrokerFrontend(responseCallback);
                this.sendRequestClient      = new SendRequestAdapter(this.brokerFrontend);
                this.brokerControllerClient = this.brokerFrontend;
                this.responseServiceClient  = this.brokerFrontend;
            }
        }
コード例 #6
0
        /// <summary>
        /// Get agent for talking to data service or data proxy
        /// </summary>
        /// <param name="headNode">head node name</param>
        /// <param name="scheme">the transport scheme</param>
        /// <param name="userName">user name</param>
        /// <param name="password">the password name</param>
        /// <returns>agent to talk to data service or data proxy </returns>
        private static IDataService GetDataServiceAgent(string headNode, TransportScheme scheme = TransportScheme.NetTcp, string userName = null, string password = null)
        {
            if (Microsoft.Hpc.Scheduler.Session.Internal.SoaHelper.IsOnAzure() && !Microsoft.Hpc.Scheduler.Session.Internal.SoaHelper.IsSchedulerOnAzure())
            {
                // Azure burst scenario. should talk to data proxy
                return(new DataProxyAgent());
            }
            else
            {
                DataServiceAgent agent = new DataServiceAgent(headNode, scheme);
                if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password))
                {
                    agent.SetCredential(userName, password);
                }

                return(agent);
            }
        }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the BrokerFrontendFactory class
        /// </summary>
        /// <param name="clientId">indicating the client id</param>
        /// <param name="binding">indicating the binding</param>
        /// <param name="info">indicating the session info</param>
        /// <param name="scheme">indicating the scheme</param>
        /// <param name="responseCallback">indicating the response callback</param>
        public HttpBrokerFrontendFactory(string clientId, Binding binding, SessionBase session, TransportScheme scheme, IResponseServiceCallback responseCallback) : base(clientId, responseCallback)
        {
            this.info    = session.Info as SessionInfo;
            this.binding = binding;
            this.scheme  = scheme;
            if (this.info.UseAzureStorage == true)
            {
                this.useAzureQueue   = true;
                this.azureQueueProxy = session.AzureQueueProxy;
            }

            if (this.info.UseInprocessBroker)
            {
                this.brokerFrontend         = this.info.InprocessBrokerAdapter.GetBrokerFrontend(responseCallback);
                this.sendRequestClient      = new SendRequestAdapter(this.brokerFrontend);
                this.brokerControllerClient = this.brokerFrontend;
                this.responseServiceClient  = this.brokerFrontend;
            }
        }
コード例 #8
0
        /// <summary>
        /// Open a DataClient with the specified data client id
        /// </summary>
        /// <param name="headNode">head node name</param>
        /// <param name="dataClientId">data client id</param>
        /// <param name="scheme">the transport scheme</param>
        /// <param name="location">the data location</param>
        /// <param name="userName">the user name</param>
        /// <param name="password">the password</param>
        /// <returns>data store path</returns>
        private static DataClientInfo OpenInternal(string headNode, string dataClientId, DataLocation location, TransportScheme scheme, string userName, string password)
        {
            IDataService dataAgent = GetDataServiceAgent(headNode, scheme, userName, password);

            return(InvokeDataOperation <DataClientInfo>(
                       dataAgent,
                       delegate(IDataService agent)
            {
                return agent.OpenDataClientV4(dataClientId, location);
            }));
        }
コード例 #9
0
        /// <summary>
        /// Create a DataClient instance with the specified data client id
        /// </summary>
        /// <param name="headNode">head node name</param>
        /// <param name="dataClientId">data client id</param>
        /// <param name="allowedUsers">privileged users who has read permission to the data client</param>
        /// <param name="scheme">the transport scheme</param>
        /// <param name="location">the data location</param>
        /// <param name="userName">the user name</param>
        /// <param name="password">the password</param>
        /// <returns>a new DataClient instance</returns>
        private static DataClient CreateInternal(string headNode, string dataClientId, string[] allowedUsers, TransportScheme scheme, DataLocation location, string userName, string password)
        {
            if (allowedUsers != null)
            {
                foreach (string allowedUser in allowedUsers)
                {
                    Microsoft.Hpc.Scheduler.Session.Internal.Utility.ThrowIfNullOrEmpty(allowedUser, "allowed user");
                }
            }

            IDataService dataAgent = GetDataServiceAgent(headNode, scheme, userName, password);

            DataClientInfo info = InvokeDataOperation <DataClientInfo>(
                dataAgent,
                delegate(IDataService agent)
            {
                return(agent.CreateDataClientV4(dataClientId, allowedUsers, location));
            });

            Debug.Assert(!string.IsNullOrEmpty(info.PrimaryDataPath), "primaryDataPath");
            return(new DataClient(headNode, dataClientId, info, /*readOnly = */ false, scheme, userName, password));
        }
コード例 #10
0
        /// <summary>
        /// Gets the available broker eprs.
        /// </summary>
        /// <param name="durable">true if the session is durable.</param>
        /// <param name="endpointPrefix">the prefix of the endpoint</param>
        /// <param name="needFqdn">true if need FQDN</param>
        /// <param name="nodesOnly">the node info</param>
        /// <param name="incrementIndex">true to increment the round robin index.</param>
        /// <returns>the EPRs of the brokers.</returns>
        public string[] GetAvailableBrokerEPRs(bool durable, string endpointPrefix, bool needFqdn, ChannelTypes type, TransportScheme scheme, out List <NodeInfo> nodesOnly, bool incrementIndex = true)
        {
            if (string.IsNullOrEmpty(endpointPrefix))
            {
                endpointPrefix = BrokerNodesManager.NettcpPrefix;
            }

            List <NodeInfo> availableNonHABrokerNodes = null;
            List <NodeInfo> availableHABrokerNodes    = null;

            // Get a reference to the current lists atomically
            // This is safe because:
            // 1. Read-only access of List<T> is thread-safe.
            // 2. We don't write to those List<T>, but only create new List<T> and assign them to available*BrokerNode variables.
            lock (this.brokerEPRsLock)
            {
                availableNonHABrokerNodes = this.availableNonHABrokerNodes;
                availableHABrokerNodes    = this.availableHABrokerNodes;
            }

            int           step = 0;
            List <string> availableBrokerEprs = new List <string>();

            nodesOnly = new List <NodeInfo>();

            // If caller requires a nondurable session or failover BNs arent enabled, add the non HA BNs
            if (!durable || (0 == GetFailoverClusterCount()))
            {
                if (incrementIndex)
                {
                    step = Interlocked.Increment(ref this.seedNonHA);
                    TraceHelper.TraceInfo(0, "[BrokerNodesMananger] .GetAvailableAzureBrokerEPRs: Incremented SeedNonHA = {0}", step);
                }

                for (int i = 0; i < availableNonHABrokerNodes.Count; i++)
                {
                    NodeInfo nodeInfo = availableNonHABrokerNodes[(i + step) % availableNonHABrokerNodes.Count];

                    // availableBrokerEprs.Add( isInternal ?
                    //     GenerateBrokerLauncherInternalEpr(endpointPrefix, needFqdn ? nodeInfo.FQDN : nodeInfo.Name):
                    //     GenerateBrokerLauncherEpr(endpointPrefix, needFqdn ? nodeInfo.FQDN : nodeInfo.Name, scheme));

                    switch (type)
                    {
                    case ChannelTypes.AzureAD:
                        availableBrokerEprs.Add(GenerateBrokerLauncherAadEpr(endpointPrefix, needFqdn ? nodeInfo.FQDN : nodeInfo.Name));
                        break;

                    case ChannelTypes.LocalAD:
                        availableBrokerEprs.Add(GenerateBrokerLauncherEpr(endpointPrefix, needFqdn ? nodeInfo.FQDN : nodeInfo.Name, scheme));
                        break;

                    case ChannelTypes.Certificate:
                        availableBrokerEprs.Add(GenerateBrokerLauncherInternalEpr(endpointPrefix, needFqdn ? nodeInfo.FQDN : nodeInfo.Name));
                        break;

                    default:
                        throw new NotSupportedException($"Type {type} is not a supported broker channel type.");
                    }

                    nodesOnly.Add(nodeInfo);
                }
            }

            // If caller wants durable or non-durable sessions and failover BNs are enabled, add HA BNs. If
            // the caller asked for non-durable, add durable EPRs to the end of the list as a fallback in
            // case the non-HA BNs are busy
            if (0 != GetFailoverClusterCount())
            {
                // If the caller wants nondurable add HA BNs next. If call wants durable, return HA BNs only
                if (incrementIndex)
                {
                    step = Interlocked.Increment(ref this.seedHA);
                    TraceHelper.TraceInfo(0, "[BrokerNodesMananger] .GetAvailableAzureBrokerEPRs: Incremented SeedHA = {0}", step);
                }

                for (int i = 0; i < availableHABrokerNodes.Count; i++)
                {
                    NodeInfo nodeInfo = availableHABrokerNodes[(i + step) % availableHABrokerNodes.Count];

                    switch (type)
                    {
                    case ChannelTypes.AzureAD:
                        availableBrokerEprs.Add(GenerateBrokerLauncherAadEpr(endpointPrefix, needFqdn ? nodeInfo.FQDN : nodeInfo.Name));
                        break;

                    case ChannelTypes.LocalAD:
                        availableBrokerEprs.Add(GenerateBrokerLauncherEpr(endpointPrefix, needFqdn ? nodeInfo.FQDN : nodeInfo.Name, scheme));
                        break;

                    case ChannelTypes.Certificate:
                        availableBrokerEprs.Add(GenerateBrokerLauncherInternalEpr(endpointPrefix, needFqdn ? nodeInfo.FQDN : nodeInfo.Name));
                        break;

                    default:
                        throw new NotSupportedException($"Type {type} is not a supported broker channel type.");
                    }

                    nodesOnly.Add(nodeInfo);
                }
            }

            return(availableBrokerEprs.ToArray());
        }
コード例 #11
0
        /// <summary>
        /// Generate broker launcher epr
        /// </summary>
        /// <param name="machineName">machine name</param>
        /// <returns>broker launcher epr</returns>
        internal static string GenerateBrokerLauncherEpr(string endpointPrefix, string machineName, TransportScheme scheme)
        {
            if (endpointPrefix.Equals(HttpsPrefix, StringComparison.InvariantCultureIgnoreCase))
            {
                return(SoaHelper.GetBrokerLauncherAddress(machineName, scheme));
            }
            else if (endpointPrefix.Equals(NettcpPrefix, StringComparison.InvariantCultureIgnoreCase))
            {
                return(SoaHelper.GetBrokerLauncherAddress(machineName));
            }

            throw new ArgumentException();
        }
コード例 #12
0
        /// <summary>
        /// Generate endpoint address by scheme from epr list
        /// </summary>
        /// <param name="eprList">indicating the epr list</param>
        /// <param name="scheme">indicating the scheme</param>
        /// <returns>endpoint address</returns>
        private static EndpointAddress GenerateEndpointAddress(string[] eprList, TransportScheme scheme)
        {
            int index = (int)Math.Log((int)scheme, 2);

            return(new EndpointAddress(eprList[index]));
        }
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the DataServiceAgent class
 /// </summary>
 /// <param name="headNode">cluster head node name</param>
 public DataServiceAgent(string headNode, TransportScheme scheme)
     : this(new Uri(SoaHelper.GetDataServiceAddress(headNode, scheme)))
 {
     this.scheme = scheme;
 }