/// <summary>
        /// Acquires all available information of each cluster-node.
        /// </summary>
        /// <returns>List of WorkstationInfos conataining the node-information.</returns>
        public override List <WorkstationInfo> GetNodes()
        {
            List <Core.WorkstationInfo> nodes = new List <WorkstationInfo>();

            string utilityAddress = url.Substring(7, url.Length - 7);

            utilityAddress = utilityAddress.Split(':')[0];
            utilityAddress = utilityAddress.Split('.')[0];


            HpcPipelineObject           pipelineObject  = this.getPipeline();
            Dictionary <string, string> nodeInformation = HpcUtility.getSubnetInformation(utilityAddress, this);

            this.freePipeline(pipelineObject);


            Dictionary <string, NodeState> hpcNodesAvailability = new Dictionary <string, NodeState>();

            foreach (ISchedulerNode node in ((IScheduler)this.CopyConnection().GetConnection()).GetNodeList(null, null))
            {
                hpcNodesAvailability.Add(node.Name, node.State);
            }

            foreach (KeyValuePair <String, String> entry in nodeInformation)
            {
                if (hpcNodesAvailability.ContainsKey(entry.Key))
                {
                    WorkstationInfo workstationInfo = new WorkstationInfo();

                    workstationInfo.CurrentOS  = (MISD.Core.Platform.HPC).ToString();
                    workstationInfo.Name       = entry.Key;
                    workstationInfo.FQDN       = entry.Key + ".visus.uni-stuttgart.de";
                    workstationInfo.MacAddress = entry.Value;

                    NodeState availability;
                    hpcNodesAvailability.TryGetValue(entry.Key, out availability);
                    if (availability.ToString().Equals("Online"))
                    {
                        workstationInfo.IsAvailable = true;
                    }
                    else
                    {
                        workstationInfo.IsAvailable = false;
                    }

                    workstationInfo.State = MISD.Core.MappingState.OK;

                    nodes.Add(workstationInfo);
                }
            }
            return(nodes);
        }
        /// <summary>
        /// Closes and disposes Pipeline. Releases semaphore.
        /// </summary>
        /// <param name="pipelineObject"></param>
        public void freePipeline(HpcPipelineObject pipelineObject)
        {
            try
            {
                int pipelineNumber = pipelineObject.pipelineNumber;

                pipelineObject.Dispose();

                pipelineSemaphores[pipelineNumber].Release();
            }
            catch (Exception e)
            {
                Logger.Instance.WriteEntry("Failed to free pipeline", LogType.Exception);
            }
        }
Example #3
0
        /// <summary>
        /// Retrieves the subnet of the client, that the pipeline is connected to.
        /// </summary>
        /// <param name="pipeline">Pipeline that is connected to the server</param>
        /// <returns>the subnet-address</returns>
        private static string calculatePrivateSubNet(HpcClusterConnection hpcClusterConnection)
        {
            string ipAddress  = "";
            string subnetMask = "";
            string result     = "";

            //acquires ip and subnetmask
            HpcPipelineObject pipelineObject = hpcClusterConnection.getPipeline();

            pipelineObject.pipeline.Commands.AddScript("Add-PSSnapin Microsoft.Hpc");
            pipelineObject.pipeline.Commands.AddScript("Get-HpcNetworkInterface -Type Private");
            Collection <PSObject> results1 = pipelineObject.pipeline.Invoke();

            hpcClusterConnection.freePipeline(pipelineObject);

            PSObject obj = results1[0];

            subnetMask = obj.Properties["Subnetmask"].Value.ToString();
            ipAddress  = obj.Properties["IpAddress"].Value.ToString();

            string[] ipArray          = ipAddress.Split('.');
            string[] networkMaskArray = subnetMask.Split('.');

            string[] subnetArray = new String[4];

            for (int i = 0; i < 4; i++)
            {
                subnetArray[i] = (Convert.ToInt32(ipArray[i]) & Convert.ToInt32(networkMaskArray[i])).ToString();
            }

            for (int i = 0; i < subnetArray.Length; i++)
            {
                result += subnetArray[i];

                if (i != subnetArray.Length - 1)
                {
                    result += ".";
                }
            }
            return(result);
        }
        /// <summary>
        /// Creates a new Pipeline on one of the runspaces.
        /// </summary>
        /// <returns>New pipeline-object</returns>
        public HpcPipelineObject getPipeline()
        {
            getPipelineSemaphore.WaitOne();

            nextRunspaceForPipeline++;

            if (nextRunspaceForPipeline > amountOfRunspaces - 1)
            {
                nextRunspaceForPipeline = 0;
            }

            try
            {
                if (!this.pipelineSemaphores[nextRunspaceForPipeline].WaitOne(200))
                {
                    getPipelineSemaphore.Release();
                    return(getPipeline());
                }


                if (this.runspaces[nextRunspaceForPipeline].RunspaceStateInfo.State != RunspaceState.Opened)
                {
                    Logger.Instance.WriteEntry("Runspace #" + nextRunspaceForPipeline + " is not in the opened state. Refreshing..", LogType.Info);

                    try
                    {
                        this.runspaces[nextRunspaceForPipeline].Close();
                    }
                    catch (Exception)
                    {
                        //No Error handling neccessary
                    }

                    this.refreshRunspace(nextRunspaceForPipeline);
                    getPipelineSemaphore.Release();

                    Thread.Sleep(1000);

                    return(getPipeline());
                }

                var pipeline = this.runspaces[nextRunspaceForPipeline].CreatePipeline();
                getPipelineSemaphore.Release();

                HpcPipelineObject newPipelineObject = new HpcPipelineObject(nextRunspaceForPipeline, pipeline);

                return(newPipelineObject);
            }
            catch (Exception e)
            {
                var messageEx = new StringBuilder();
                messageEx.Append("HpcClusterConnection: ");
                messageEx.Append("Runspace no. (" + nextRunspaceForPipeline + ") seems to be corrupted. Reinitialising...");
                messageEx.Append(e.ToString());
                Logger.Instance.WriteEntry(messageEx.ToString(), LogType.Warning);

                refreshRunspace(nextRunspaceForPipeline);

                return(getPipeline());
            }
        }