Exemplo n.º 1
0
        //-----------------------------------------------------------------------------------------------
        // private methods
        //-----------------------------------------------------------------------------------------------

        /// <summary>
        /// Written by Abhishek Kumar on March 05, 2007
        /// purpose: to initiate the central Application Domain that
        /// all Grid Threads will be run on.
        ///
        /// Police and permissions will also be set.
        /// ADV: a crash in this App Domain(because of poor code in GThread)
        /// does not affect eduGRID's Framework i.e. the Alchemi executor is maintained steady even in error
        ///
        /// initially Alchemi created separate app domains for each Gthread it received.
        /// now, instead, we create 1 appdomain and run all gthreads on it
        /// the Bot Logic resides in this app domain.
        /// (this saves the overhead of initializing bot logic for every Gthread (or every query))
        /// </summary>
        private void initialize_GridThreadExecutor()
        {
            if (GridThreadExecutor == null)
            {
                string         appDir = GetApplicationDirectory(_CurTi.ApplicationId);
                AppDomainSetup info   = new AppDomainSetup();
                info.PrivateBinPath         = appDir;
                GridThreadApplicationDomain = AppDomain.CreateDomain("Central_AppDomain", null, info);

                // ***
                // http://www.dotnetthis.com/Articles/DynamicSandboxing.htm
                PolicyLevel            domainPolicy = PolicyLevel.CreateAppDomainLevel();
                AllMembershipCondition allCodeMC    = new AllMembershipCondition();
                // TODO: 'FullTrust' in the following line needs to be replaced with something like 'AlchemiGridThread'
                //        This permission set needs to be defined and set automatically as part of the installation.
                PermissionSet   internetPermissionSet   = domainPolicy.GetNamedPermissionSet("FullTrust");
                PolicyStatement internetPolicyStatement = new PolicyStatement(internetPermissionSet);
                CodeGroup       allCodeInternetCG       = new UnionCodeGroup(allCodeMC, internetPolicyStatement);
                domainPolicy.RootCodeGroup = allCodeInternetCG;
                GridThreadApplicationDomain.SetAppDomainPolicy(domainPolicy);

                GridThreadExecutor = (AppDomainExecutor)GridThreadApplicationDomain.CreateInstanceFromAndUnwrap(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Alchemi.Executor.dll"), "Alchemi.Executor.AppDomainExecutor");
            }

            if (!GridThreadExecutor.Initialized)
            {
                try
                {
                    GridThreadExecutor.initialize();
                }
                catch (Exception ex)
                {
                    throw new Exception("Error during initialization of GridThreadExecutor");
                }
            }
        }
Exemplo n.º 2
0
        //-----------------------------------------------------------------------------------------------

        /// <summary>
        /// Initialises a new instance of the GridAppDomain with the given AppDomain and AppDomainExecutor
        /// </summary>
        /// <param name="domain"></param>
        /// <param name="executor"></param>
        public GridAppDomain(AppDomain domain, AppDomainExecutor executor)
        {
            _Domain   = domain;
            _Executor = executor;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initialises a new instance of the GridAppDomain with the given AppDomain and AppDomainExecutor
 /// </summary>
 /// <param name="domain"></param>
 /// <param name="executor"></param>
 internal GridAppDomain(AppDomain domain, AppDomainExecutor executor)
 {
     _Domain   = domain;
     _Executor = executor;
 }
Exemplo n.º 4
0
        //-----------------------------------------------------------------------------------------------
        // private methods
        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Written by Abhishek Kumar on March 05, 2007
        /// purpose: to initiate the central Application Domain that
        /// all Grid Threads will be run on.
        /// 
        /// Police and permissions will also be set.
        /// ADV: a crash in this App Domain(because of poor code in GThread)
        /// does not affect eduGRID's Framework i.e. the Alchemi executor is maintained steady even in error
        /// 
        /// initially Alchemi created separate app domains for each Gthread it received.
        /// now, instead, we create 1 appdomain and run all gthreads on it
        /// the Bot Logic resides in this app domain.
        /// (this saves the overhead of initializing bot logic for every Gthread (or every query))
        /// </summary>
        private void initialize_GridThreadExecutor()
        {
            if (GridThreadExecutor == null)
            {
                string appDir = GetApplicationDirectory(_CurTi.ApplicationId);
                AppDomainSetup info = new AppDomainSetup();
                info.PrivateBinPath = appDir;
                GridThreadApplicationDomain = AppDomain.CreateDomain("Central_AppDomain", null, info);

                // ***
                // http://www.dotnetthis.com/Articles/DynamicSandboxing.htm
                PolicyLevel domainPolicy = PolicyLevel.CreateAppDomainLevel();
                AllMembershipCondition allCodeMC = new AllMembershipCondition();
                // TODO: 'FullTrust' in the following line needs to be replaced with something like 'AlchemiGridThread'
                //        This permission set needs to be defined and set automatically as part of the installation.
                PermissionSet internetPermissionSet = domainPolicy.GetNamedPermissionSet("FullTrust");
                PolicyStatement internetPolicyStatement = new PolicyStatement(internetPermissionSet);
                CodeGroup allCodeInternetCG = new UnionCodeGroup(allCodeMC, internetPolicyStatement);
                domainPolicy.RootCodeGroup = allCodeInternetCG;
                GridThreadApplicationDomain.SetAppDomainPolicy(domainPolicy);

                GridThreadExecutor = (AppDomainExecutor) GridThreadApplicationDomain.CreateInstanceFromAndUnwrap(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Alchemi.Executor.dll"), "Alchemi.Executor.AppDomainExecutor");
            }

            if (!GridThreadExecutor.Initialized)
            {
                try
                {
                    GridThreadExecutor.initialize();
                }
                catch (Exception ex)
                {
                    throw new Exception("Error during initialization of GridThreadExecutor");
                }
            }
        }
Exemplo n.º 5
0
 //-----------------------------------------------------------------------------------------------
 /// <summary>
 /// Initialises a new instance of the GridAppDomain with the given AppDomain and AppDomainExecutor
 /// </summary>
 /// <param name="domain"></param>
 /// <param name="executor"></param>
 public GridAppDomain(AppDomain domain, AppDomainExecutor executor)
 {
     _Domain = domain;
     _Executor = executor;
 }