Beispiel #1
0
        private void fmMain_Load(object sender, EventArgs e)
        {
            //
            // Check to see if we have a valid database
            while (!GPDatabaseUtils.IsDatabaseValid)
            {
                String msg = "The currently configured database is invalid.  Please use the ";
                msg += "Preferences dialog to select a valid GP Studio database.";
                MessageBox.Show(msg, GPEnums.APPLICATON_NAME, MessageBoxButtons.OK);

                MenuPreferences_Click(sender, e);
            }

            //
            // Create the batch processing manager
            fmMain.BatchManager = new BatchProcessingManager();

            //
            // Create remote client sponsor server
            fmMain.SponsorServer = new SponsorThread();

            //
            // Create the server manager and go ahead and add a reference
            // to the local service.
            ServerManager = new ServerManagerSingleton();
            if (!ServerManager.RegisterServer(
                    ServerManagerSingleton.LOCALHOST,
                    ServerManagerSingleton.LOCALPORT,
                    GPEnums.CHANNEL_TCP, "Local Computer"))
            {
                String msg = "The local GP Server service is not running.  ";
                msg += "This service is required for GP Studio to correctly run.  ";
                msg += "Please refer to the User Guide or the online knowledge base for ";
                msg += "details on how to troubleshoot this problem.  After you press OK, ";
                msg += "GP Studio will close.";
                MessageBox.Show(msg, GPEnums.APPLICATON_NAME, MessageBoxButtons.OK);

                Application.Exit();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Prepares the configuration settings at each server.
        ///		*Training Data
        ///		*UDFs
        ///		*Fitness Function
        ///		*Everything else
        /// This method builds a list of modeler interfaces at each server.  Remember,
        /// each time the Modeler property is used from IGPServer, a NEW modeler is
        /// created...so only want to do this once for each modeling session; hence,
        /// have to access it and keep track of it on the client side.
        /// </summary>
        /// <param name="ServerManager"></param>
        /// <param name="Modelers"></param>
        /// <param name="Training"></param>
        /// <returns>True/False upon success or failure</returns>
        private bool InitializeServers(ServerManagerSingleton ServerManager, ref List <IGPModeler> Modelers, ref GPModelingData Training)
        {
#if GPLOG
            GPLog.ReportLine("Initializing Distributed Servers...", true);
#endif
            //
            // Create a modeler sponsor
            m_FunctionSetSponsor = fmMain.SponsorServer.Create("FunctionSet");
            m_ModelerSponsor     = fmMain.SponsorServer.Create("Modeler");

            //
            // Build a list of modeler interfaces
#if GPLOG
            GPLog.ReportLine("Number of GPServers: " + ServerManager.Count, true);
#endif
            if (m_DELReportStatus != null)
            {
                m_DELReportStatus("Enumerating distributed servers...");
            }
            List <IGPServer> Servers = new List <IGPServer>(ServerManager.Count);
            Modelers = new List <IGPModeler>(ServerManager.Count);
            foreach (IGPServer iServer in ServerManager)
            {
                Modelers.Add(iServer.Modeler);

                //
                // We also keep track of the servers so we set the right function set
                // with the right server.
                Servers.Add(iServer);
            }
            m_Modelers = Modelers;

            //
            // Based upon the selected topology, send interfaces to the connected
            // servers.
            switch (m_Profile.ModelingProfile.DistributedTopology)
            {
            case GPEnums.DistributedTopology.Ring:
                InitializeServersTopologyRing(Modelers);
                break;

            case GPEnums.DistributedTopology.Star:
                InitializeServersTopologyStar(Modelers);
                break;
            }

            //
            // Report the list of servers to the UI - they're ordered the same as the interfaces,
            // so the foreach is a safe way to do it.
            foreach (String Description in ServerManager.Descriptions.Values)
            {
#if GPLOG
                GPLog.ReportLine("Server Description: " + Description, true);
#endif
                //
                // Report back to the UI we have a new valid server to record data for
                if (m_DELValidatedServer != null)
                {
                    m_DELValidatedServer(Description);
                }
            }

            //
            // Transimit the training data
#if GPLOG
            GPLog.Report("Loading training data...", true);
#endif
            if (m_DELReportStatus != null)
            {
                m_DELReportStatus("Loading training data...");
            }
            Training = new GPModelingData();
            Training.LoadFromDB(m_TrainingID, null, null);

#if GPLOG
            GPLog.ReportLine("...Complete", false);
#endif

            //
            // Asynchronously call initialization on each modeler
            List <DEL_InitializeModeler> DelegateList = new List <DEL_InitializeModeler>(Servers.Count);
            List <IAsyncResult>          ResultList   = new List <IAsyncResult>(Servers.Count);
            for (int ServerIndex = 0; ServerIndex < Servers.Count; ServerIndex++)
            {
                //
                // Make an asynchronous call to initialize
                DEL_InitializeModeler delInit = new DEL_InitializeModeler(InitializeModeler);
                IAsyncResult          ar      = delInit.BeginInvoke(Servers[ServerIndex], Modelers[ServerIndex], Training, null, null);

                DelegateList.Add(delInit);
                ResultList.Add(ar);
            }

            //
            // Go into a loop to wait for all the method calls to complete
            for (int Delegate = 0; Delegate < DelegateList.Count; Delegate++)
            {
                DelegateList[Delegate].EndInvoke(ResultList[Delegate]);
            }

            return(true);
        }