Beispiel #1
0
        /// <summary>
        /// Creates an instance of the GExecutor with the given end points 
        /// (one for itself, and one for the manager), credentials and other options.
        /// </summary>
        /// <param name="managerEP">Manager end point</param>
        /// <param name="ownEP">Own end point</param>
        /// <param name="id">executor id</param>
        /// <param name="dedicated">Specifies whether the executor is dedicated</param>
        /// <param name="sc">Security credentials</param>
        /// <param name="baseDir">Working directory for the executor</param>
        public GExecutor(EndPoint managerEP, EndPoint ownEP, string id, bool dedicated, bool autoRevertToNDE, SecurityCredentials sc, string baseDir)
            : base(managerEP, ownEP, sc)
        {
            _AutoRevertToNDE = autoRevertToNDE;
            _Dedicated = dedicated;
            _Id = id;

            if (String.IsNullOrEmpty(_Id))
            {
                logger.Info("Registering new executor");
                _Id = Manager.Executor_RegisterNewExecutor(this.Credentials, null, this.Info);
                logger.Info("Successfully Registered new executor:" + _Id);
            }

            _GridAppDomains = new Dictionary<string, GridAppDomain>();
            _ActiveWorkers = new Dictionary<ThreadIdentifier, ExecutorWorker>();

            //handle exception since we want to connect to the manager
            //even if it doesnt succeed the first time.
            //that is, we need to handle InvalidExecutor and ConnectBack Exceptions.
            //WCF requires this to execute in another thread.
            Thread t = new Thread(new ThreadStart(DoConnectThread));
            t.Start();
            t.Join();
        }
Beispiel #2
0
        /// <summary>
        /// Connect to an executor which is in non-dedicated mode.
        /// This is called by a non-dedicated executor using its reference to this manager.
        /// </summary>
        /// <param name="sc">security credentials to verify if the executor has permission to perform this operation 
        /// (i.e connect non-dedicated, which is associated with the ExecuteThread permission)</param>
        /// <param name="executorId">executor id</param>
        /// Returns the exception that ocured.
        public Exception Executor_ConnectNonDedicatedExecutor(SecurityCredentials sc, string executorId, EndPoint executorEP)
        {
            Exception ret = null;

            try
            {
                logger.Debug("Executor called: ConnectNonDedicated");
                AuthenticateUser(sc);
                EnsurePermission(sc, Permission.ExecuteThread);

                _Executors[executorId].ConnectNonDedicated(executorEP);

                logger.Debug("Connected to executor non-dedicated: " + executorId);
                _Executors[executorId].HeartbeatUpdate(new HeartbeatInfo(0, 0, 0));
            }
            catch (Exception ex)
            {
                ret = new RemoteException(ex.Message, ex);
            }

            return ret;
        }
        /// <summary>
        /// Initialise the properties of this executor collection.
        /// This involves verfiying  the connection to all the dedicated executors in the database.
        /// </summary>
        public void Init()
        {
            logger.Debug("Init-ing executor collection from db");

            ExecutorStorageView[] executors = ManagerStorageFactory.ManagerStorage().GetExecutors(TriStateBoolean.True);

            logger.Debug("# of dedicated executors = " + executors.Length);

            foreach (ExecutorStorageView executor in executors)
            {
                string executorId = executor.ExecutorId;
                EndPoint ep = new EndPoint(executor.HostName, executor.Port, RemotingMechanism.TcpBinary);
                MExecutor me = new MExecutor(executorId);
                try
                {
                    logger.Debug("Creating a MExecutor and connecting-dedicated to it");
                    me.ConnectDedicated(ep);
                }
                catch (Exception)
                {
                    logger.Debug("Exception while init-ing exec.collection. Continuing with other executors...");
                }
            }

            logger.Debug("Executor collection init done");
        }
Beispiel #4
0
        /// <summary>
        /// Connect to an executor which is in dedicated mode.
        /// This method is called by the remote executor using its reference to this manager.
        /// </summary>
        /// <param name="sc">security credentials to verify if the executor has permission to perform this operation 
        /// (i.e connect dedicated, which is associated with the ExecuteThread permission)</param>
        /// <param name="executorId">executor id</param>
        /// <param name="executorEP">end point of the executor</param>
        /// <returns>Returns the exception that ocured.</returns>
        public Exception Executor_ConnectDedicatedExecutor(SecurityCredentials sc, string executorId, EndPoint executorEP)
        {
            Exception ret = null;
            try
            {
                logger.Debug("Executor called: ConnectDedicated: Authenticate,EnsurePermission,Connect,Set DedicatedScheduler");
                AuthenticateUser(sc);
                EnsurePermission(sc, Permission.ExecuteThread);

                try
                {
                    _Executors[executorId].ConnectDedicated(executorEP);
                    InternalShared.Instance.DedicatedSchedulerActive.Set();
                }
                catch (ExecutorCommException ece)
                {
                    logger.Error("Couldnt connect back to the supplied executor", ece);
                    throw new ConnectBackException("Couldn't connect back to the supplied Executor", ece);
                }
            }
            catch (Exception ex)
            {
                ret = new RemoteException(ex.Message, ex);
            }

            return ret;
        }
        public void StartTcpBinary(EndPointConfiguration epc)
        {
            EndPoint ownEP = new EndPoint(epc.Port, RemotingMechanism.TcpBinary);

            logger.Debug("Configuring remoting...");

            RemotingConfiguration.Configure(
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory, RemotingConfigFile), false);

            //TODO: for hierarchical grids
            //				RemoteEndPoint managerEP = null;
            //				if (Config.Intermediate)
            //				{
            //					managerEP = new RemoteEndPoint(
            //						Config.ManagerHost,
            //						Config.ManagerPort,
            //						RemotingMechanism.TcpBinary
            //						);
            //				}

            logger.Debug("Registering tcp channel on port: " + ownEP.Port);

            _Chnl = new TcpChannel(epc.Port);
            ChannelServices.RegisterChannel(_Chnl, false);

            //since this is a single call thing, thread safety isnt an issue

            logger.Debug("Registering well known service type");

            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(GManager), "Alchemi_Node",
                WellKnownObjectMode.SingleCall);

            // TODO: hierarchical grids ignored until after v1.0.0
            /*
            _Dedicated = dedicated;
            _Id = id;

            if (Manager != null)
            {
                if (_Id == "")
                {
                    Log("Registering new executor ...");
                    _Id = Manager.Executor_RegisterNewExecutor(null, new ExecutorInfo);
                    Log("New ExecutorID = " + _Id);
                }

                try
                {
                    try
                    {
                        ConnectToManager();
                    }
                    catch (InvalidExecutorException)
                    {
                        Log("Invalid executor! Registering new executor ...");
                        _Id = Manager.Executor_RegisterNewExecutor(null, new ExecutorInfo);
                        Log("New ExecutorID = " + _Id);
                        ConnectToManager();
                    }
                }
                catch (ConnectBackException)
                {
                    Log("Couldn't connect as dedicated executor. Reverting to non-dedicated executor.");
                    _Dedicated = false;
                    ConnectToManager();
                }
            }
            */
        }