Пример #1
0
        public Tuple <TaskData, DateTime> GetTaskDataSnapshot()
        {
            Tuple <TaskData, DateTime> snapshot = null;

            try {
                snapshot = executor.GetTaskDataSnapshot();
                if (snapshot == null)
                {
                    return(Tuple.Create(originalTaskData, DateTime.Now));
                }
            }
            catch (Exception ex) {
                EventLogManager.LogException(ex);
            }
            return(snapshot);
        }
Пример #2
0
        /// <summary>
        /// Main method for the client
        /// </summary>
        public void Start()
        {
            abortRequested = false;
            EventLogManager.ServiceEventLog = ServiceEventLog;

            try {
                //start the client communication service (pipe between slave and slave gui)
                slaveComm = new ServiceHost(typeof(SlaveCommunicationService));

                try {
                    slaveComm.Open();
                }
                catch (AddressAlreadyInUseException ex) {
                    if (ServiceEventLog != null)
                    {
                        EventLogManager.LogException(ex);
                    }
                }

                // delete all left over task directories
                pluginManager.CleanPluginTemp();
                SlaveClientCom.Instance.LogMessage("Hive Slave started");

                wcfService = WcfService.Instance;
                RegisterServiceEvents();

                StartHeartbeats();      // Start heartbeats thread
                DispatchMessageQueue(); // dispatch messages until abortRequested
            }
            catch (Exception ex) {
                if (ServiceEventLog != null)
                {
                    EventLogManager.LogException(ex);
                }
                else
                {
                    //try to log with SlaveClientCom.Instance. if this works the user sees at least a message,
                    //else an exception will be thrown anyways.
                    SlaveClientCom.Instance.LogMessage(string.Format("Uncaught exception: {0} {1} Core is going to shutdown.", ex.ToString(), Environment.NewLine));
                }
                ShutdownCore();
            }
            finally {
                DeregisterServiceEvents();
                waitShutdownSem.Release();
            }
        }
Пример #3
0
        public TaskData GetTaskData()
        {
            TaskData data = null;

            try {
                data = executor.GetTaskData();
                //this means that there was a problem executing the task
                if (data == null)
                {
                    return(originalTaskData);
                }
            }
            catch (Exception ex) {
                EventLogManager.LogException(ex);
            }
            return(data);
        }
 public void StatusChanged(StatusCommons status)
 {
     try {
         subscribers.ForEach(delegate(ISlaveCommunicationCallbacks callback) {
             if (((ICommunicationObject)callback).State == CommunicationState.Opened)
             {
                 callback.OnStatusChanged(status);
             }
             else
             {
                 subscribers.Remove(callback);
             }
         });
     }
     catch (Exception ex) {
         EventLogManager.LogException(ex);
     }
 }
 public void LogMessage(string message)
 {
     try {
         subscribers.ForEach(delegate(ISlaveCommunicationCallbacks callback) {
             if (((ICommunicationObject)callback).State == CommunicationState.Opened)
             {
                 callback.OnMessageLogged(message);
             }
             else
             {
                 subscribers.Remove(callback);
             }
         });
     }
     catch (Exception ex) {
         EventLogManager.LogException(ex);
     }
 }
Пример #6
0
        public void DisposeAppDomain()
        {
            log.LogMessage(string.Format("Shutting down Appdomain for Task {0}", TaskId));
            StopExecutorMonitoringThread();

            if (executor != null)
            {
                try {
                    executor.Dispose();
                }
                catch (Exception ex) {
                    EventLogManager.LogException(ex);
                }
            }

            if (appDomain != null)
            {
                appDomain.UnhandledException -= new UnhandledExceptionEventHandler(AppDomain_UnhandledException);
                int repeat = Settings.Default.PluginDeletionRetries;
                while (repeat > 0)
                {
                    try {
                        waitForStartBeforeKillSem.WaitOne(Settings.Default.ExecutorSemTimeouts);
                        AppDomain.Unload(appDomain);
                        waitForStartBeforeKillSem.Dispose();
                        repeat = 0;
                    }
                    catch (CannotUnloadAppDomainException) {
                        log.LogMessage("Could not unload AppDomain, will try again in 1 sec.");
                        Thread.Sleep(Settings.Default.PluginDeletionTimeout);
                        repeat--;
                        if (repeat == 0)
                        {
                            throw; // rethrow and let app crash
                        }
                    }
                }
            }
            pluginManager.DeletePluginsForJob(TaskId);
            GC.Collect();
        }
Пример #7
0
        private void SetupClientCom()
        {
            DummyListener dummy = new DummyListener();

            try {
                pipeFactory = new DuplexChannelFactory <ISlaveCommunication>(dummy, Settings.Default.SlaveCommunicationServiceEndpoint);
            }
            catch {
                EventLogManager.LogMessage("Couldn't create pipe for SlaveClientCom with config!");

                try {
                    pipeFactory = new DuplexChannelFactory <ISlaveCommunication>(dummy, new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/HeuristicLabSlaveCom"));
                }
                catch {
                    EventLogManager.LogMessage("Couldn't create pipe for SlaveClientCom with fixed addresse!");
                    return;
                }
            }
            pipeFactory.Faulted += new System.EventHandler(pipeFactory_Faulted);

            ISlaveCommunication pipeProxy = pipeFactory.CreateChannel();

            ClientCom = pipeProxy;
        }