예제 #1
0
        /// <summary>
        /// Initializes a cluster manager and starts the acquisition for all nodes.
        /// </summary>
        /// <param name="url">The url of the head-node.</param>
        /// <param name="username">The username to login.</param>
        /// <param name="password">The password to login.</param>
        /// <param name="platform">The platform of the cluster.</param>
        /// <param name="id">An ID for the cluster, to be able to have multiple clusters of one platform.</param>
        public void Initialize(object cred)
        {
            try
            {
                var credentials = (ClusterCredential)cred;

                timerJobs   = new List <TimerJobBase>();
                clusterType = (Platform)credentials.Platform;
                ID          = credentials.ID;

                if (!OUManager.Instance.Exists(clusterType.ToString() + ID))
                {
                    OUManager.Instance.CreateOU(clusterType.ToString() + ID, null, DateTime.Now);
                }
                using (var datacontext = DataContextFactory.CreateReadOnlyDataContext())
                {
                    var OU = (from p in datacontext.OrganizationalUnit
                              where p.FQDN.Equals(clusterType.ToString() + ID)
                              select p).First();
                    this.OUID = OU.ID;
                }

                switch (clusterType)
                {
                case Platform.Bright:
                    clusterConnection = new BrightClusterConnection();
                    clusterConnection.Init(credentials.HeadNodeUrl, credentials.Username, credentials.Password);
                    clusterNodes = clusterConnection.GetNodes();

                    if (PluginManager.Instance.BrightPlugins != null)
                    {
                        clusterPlugins = PluginManager.Instance.BrightPlugins.ToList();
                        this.AddNodes(clusterNodes);
                    }
                    break;

                case Platform.HPC:
                    clusterConnection = new HpcClusterConnection();
                    clusterConnection.Init(credentials.HeadNodeUrl, credentials.Username, credentials.Password);
                    clusterNodes = clusterConnection.GetNodes();
                    if (PluginManager.Instance.HPCPlugins != null)
                    {
                        clusterPlugins = PluginManager.Instance.HPCPlugins.ToList();
                        this.AddNodes(clusterNodes);
                    }
                    break;

                default:
                    // logging unsupported platform
                    var messageEx = new StringBuilder();
                    messageEx.Append("ClusterManager_AddNodes: ");
                    messageEx.Append("The platform " + clusterType.ToString());
                    messageEx.Append(" is not supported.");
                    MISD.Core.Logger.Instance.WriteEntry(messageEx.ToString(), LogType.Exception);
                    break;
                }

                // Register this cluster at the metacluster manager
                MetaClusterManager.Instance.AddCluster(this);
            }
            catch (Exception e)
            {
                Logger.Instance.WriteEntry("ClusterManager_Initialize: Problem initilizing cluster, " + e.ToString(), LogType.Exception);
            }
        }