Beispiel #1
0
        /// <summary>
        /// Stops an application.
        /// </summary>
        public void Stop()
        {
            //first check if the application is all finished
            IManagerStorage        store = ManagerStorageFactory.ManagerStorage();
            ApplicationStorageView app   = store.GetApplication(_Id);

            if (app.State != ApplicationState.Stopped)
            {
                ThreadStorageView[] threads = store.GetThreads(_Id);

                foreach (ThreadStorageView thread in threads)
                {
                    if (thread.State != ThreadState.Dead && thread.State != ThreadState.Finished)
                    {
                        GManager.AbortThread(new ThreadIdentifier(_Id, thread.ThreadId), thread.ExecutorId);

                        // clean up the thread status
                        thread.State = ThreadState.Dead;
                        store.UpdateThread(thread);
                    }
                }

                //update the application
                app.State         = ApplicationState.Stopped;
                app.TimeCompleted = DateTime.Now;
                store.UpdateApplication(app);

                logger.Debug("Stopped the current application." + _Id);
            }
            else
            {
                logger.Debug(string.Format("Application {0} already stopped.", _Id));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Verify if the database is properly set up.
        ///
        /// </summary>
        /// <param name="id">application id</param>
        /// <returns>true if the application is set up in the database</returns>
        public bool VerifyApp(string id)
        {
            IManagerStorage store    = ManagerStorageFactory.ManagerStorage();
            bool            appSetup = true;

            //create directory can be repeated, and wont throw an error even if the dir already exists.
            this[id].CreateDataDirectory();

            ApplicationStorageView application = store.GetApplication(id);

            if (application == null)
            {
                appSetup = false;
            }
            else
            {
                //just make sure the status is set to ready, or else it may remain Stopped
                //in case of re-started multi-use apps.
                application.State = ApplicationState.Ready;
                store.UpdateApplication(application);
            }

            return(appSetup);
        }