Example #1
0
        public static IDisposable LoadForTest(SystemApplicationType appType, Metabank mbase, string host, string dynamicHostNameSuffix = null)
        {
            SetDomainInvariantCulture();
            s_Loaded = true;
            s_SystemApplicationType = appType;
            s_Metabase = mbase;
            s_HostName = host;

            if (dynamicHostNameSuffix.IsNotNullOrWhiteSpace())
            {
                s_DynamicHostNameSuffix = Metabank.HOST_DYNAMIC_SUFFIX_SEPARATOR + dynamicHostNameSuffix;
            }
            else
            {
                var sh = mbase.CatalogReg.NavigateHost(host);
                if (sh.Dynamic)
                {
                    s_DynamicHostNameSuffix = thisMachineDynamicNameSuffix();
                }
            }

            if (s_DynamicHostNameSuffix.IsNotNullOrWhiteSpace())
            {
                s_HostName = s_HostName + s_DynamicHostNameSuffix;
            }

            SystemVarResolver.Bind();

            Configuration.ProcesswideConfigNodeProviderType = typeof(Metabase.MetabankFileConfigNodeProvider);

            return(new TestDisposer());
        }
Example #2
0
        internal BootConfLoader(IApplication bootApp, SystemApplicationType appType, Metabank mbase, string host, string dynamicHostNameSuffix = null)
        {
            Platform.Abstraction.PlatformAbstractionLayer.SetProcessInvariantCulture();

            m_BootApplication       = bootApp;
            m_SystemApplicationType = appType;
            m_Metabase = mbase;
            m_HostName = host;

            if (dynamicHostNameSuffix.IsNotNullOrWhiteSpace())
            {
                m_DynamicHostNameSuffix = Metabank.HOST_DYNAMIC_SUFFIX_SEPARATOR + dynamicHostNameSuffix;
            }
            else
            {
                var sh = mbase.CatalogReg.NavigateHost(host);
                if (sh.Dynamic)
                {
                    m_DynamicHostNameSuffix = thisMachineDynamicNameSuffix();
                }
            }

            if (m_DynamicHostNameSuffix.IsNotNullOrWhiteSpace())
            {
                m_HostName = m_HostName + m_DynamicHostNameSuffix;
            }

            SystemVarResolver.Bind();

            Configuration.ProcesswideConfigNodeProviderType = typeof(Sky.Metabase.MetabankFileConfigNodeProvider);
        }
Example #3
0
        /// <summary>
        /// Loads initial application container configuration (app container may re-read it in future using metabase) per supplied local one also connecting the metabase
        /// </summary>
        public Configuration Load(string[] cmdArgs, Configuration bootConfig)
        {
            if (Loaded)
            {
                throw new SkyException(Sky.StringConsts.APP_LOADER_ALREADY_LOADED_ERROR);
            }

            SystemVarResolver.Bind();

            Configuration.ProcesswideConfigNodeProviderType = typeof(Sky.Metabase.MetabankFileConfigNodeProvider);

            try
            {
                Configuration result = null;

                //init Boot app container
                m_BootApplication = new AzosApplication(cmdArgs, bootConfig.Root);

                writeLog(MessageType.Info, "Entering Sky app bootloader...");

                determineHostName();

                Message.DefaultHostName = m_HostName;

                mountMetabank();

                Metabank.SectionHost zoneGov;
                bool isDynamicHost;
                result = getEffectiveAppConfigAndZoneGovernor(out zoneGov, out isDynamicHost);

                if (zoneGov != null)
                {
                    m_ParentZoneGovernorPrimaryHostName = zoneGov.RegionPath;
                }

                if (isDynamicHost)
                {
                    writeLog(MessageType.Info, "The meatabase host '{0}' is dynamic".Args(m_HostName));
                    m_DynamicHostNameSuffix = thisMachineDynamicNameSuffix();
                    writeLog(MessageType.Info, "Obtained actual host dynamic suffix: '{0}' ".Args(m_DynamicHostNameSuffix));
                    m_HostName = m_HostName + m_DynamicHostNameSuffix;//no spaces between
                    writeLog(MessageType.Info, "The actual dynamic instance host name is: '{0}'".Args(m_HostName));

                    Message.DefaultHostName = m_HostName;
                }


                writeLog(MessageType.Info, "...exiting Sky app bootloader");

                return(result);
            }
            catch (Exception error)
            {
                m_LoadException = error;
                throw new SkyException(Sky.StringConsts.APP_LOADER_ERROR + error.ToMessageWithType(), error);
            }
        }
Example #4
0
        internal BootConfLoader(ISkyApplication application,
                                IApplication bootApplication,
                                SystemApplicationType appType,
                                IFileSystem metabaseFileSystem,
                                FileSystemSessionConnectParams metabaseFileSystemSessionParams,
                                string metabaseFileSystemRootPath,
                                string thisHostName,
                                string[] cmdArgs,
                                ConfigSectionNode rootConfig,
                                string dynamicHostNameSuffix = null)
        {
            Platform.Abstraction.PlatformAbstractionLayer.SetProcessInvariantCulture();
            SystemVarResolver.Bind();//todo: Refactor to use ~App. app var resolver instead
            Configuration.ProcesswideConfigNodeProviderType = typeof(MetabankFileConfigNodeProvider);

            m_SystemApplicationType = appType;

            m_Application = application.NonNull(nameof(application));

            //1. Init boot app container
            m_BootApplication = bootApplication;

            if (m_BootApplication == null)
            {
                m_BootApplication        = new AzosApplication(allowNesting: true, cmdArgs: cmdArgs, rootConfig: rootConfig);
                m_IsBootApplicationOwner = true;
            }

            writeLog(MessageType.Trace, "Entering Sky app bootloader...");

            //2. what host is this?
            m_HostName = determineHostName(thisHostName);

            //Sets cluster host name in all log messages
            if (m_HostName.IsNotNullOrWhiteSpace())
            {
                Message.DefaultHostName = m_HostName;
            }

            //3. Mount metabank
            var mNode = m_BootApplication.ConfigRoot[CONFIG_SKY_SECTION][CONFIG_METABASE_SECTION];

            ensureMetabaseAppName(mNode);

            m_Metabase          = new Metabank(m_BootApplication, m_Application, metabaseFileSystem, metabaseFileSystemSessionParams, metabaseFileSystemRootPath);
            m_IsMetabaseFSOwner = false;//externally supplied

            writeLog(MessageType.Trace, "...exiting Sky app bootloader");
        }
Example #5
0
        internal BootConfLoader(ISkyApplication application,
                                IApplication bootApplication,
                                SystemApplicationType appType,
                                string [] cmdArgs,
                                ConfigSectionNode rootConfig)
        {
            Platform.Abstraction.PlatformAbstractionLayer.SetProcessInvariantCulture();
            SystemVarResolver.Bind();//todo: Refactor to use ~App. app var resolver instead
            Configuration.ProcesswideConfigNodeProviderType = typeof(MetabankFileConfigNodeProvider);

            m_SystemApplicationType = appType;

            m_Application = application.NonNull(nameof(application));



            //1. Init boot app container
            m_BootApplication = bootApplication;

            if (m_BootApplication == null)
            {
                m_BootApplication        = new AzosApplication(allowNesting: true, cmdArgs: cmdArgs, rootConfig: rootConfig);
                m_IsBootApplicationOwner = true;
            }

            writeLog(MessageType.Trace, "Entering Sky app bootloader...");

            //2. what host is this?
            m_HostName = determineHostName(null);

            //Sets cluster host name in all log messages
            if (m_HostName.IsNotNullOrWhiteSpace())
            {
                Message.DefaultHostName = m_HostName;
            }

            //3. Mount Metabank
            m_Metabase = mountMetabank();

            writeLog(MessageType.Trace, "...exiting Sky app bootloader");
        }
Example #6
0
 public void Prologue(Runner runner, FID id) => SystemVarResolver.Bind();
Example #7
0
        /// <summary>
        /// Loads initial application container configuration (app container may re-read it in future using metabase) per supplied local one also connecting the metabase
        /// </summary>
        public static Configuration Load(string[] cmdArgs, Configuration bootConfig)
        {
            if (s_Loaded)
            {
                throw new AgniException(StringConsts.APP_LOADER_ALREADY_LOADED_ERROR);
            }

            SetDomainInvariantCulture();

            SystemVarResolver.Bind();

            Configuration.ProcesswideConfigNodeProviderType = typeof(Metabase.MetabankFileConfigNodeProvider);

            try
            {
                Configuration result = null;

                //init Boot app container
                using (var bootApp = new ServiceBaseApplication(cmdArgs, bootConfig.Root))
                {
                    bootApp.writeLog(NFX.Log.MessageType.Info, "Entering agni app bootloader...");

                    determineHostName(bootApp);

                    NFX.Log.Message.DefaultHostName = s_HostName;

                    mountMetabank(bootApp);

                    Metabank.SectionHost zoneGov;
                    bool isDynamicHost;
                    result = getEffectiveAppConfigAndZoneGovernor(bootApp, out zoneGov, out isDynamicHost);

                    if (zoneGov != null)
                    {
                        s_ParentZoneGovernorPrimaryHostName = zoneGov.RegionPath;
                    }

                    if (isDynamicHost)
                    {
                        bootApp.writeLog(NFX.Log.MessageType.Info, "The meatabase host '{0}' is dynamic".Args(s_HostName));
                        s_DynamicHostNameSuffix = thisMachineDynamicNameSuffix();
                        bootApp.writeLog(NFX.Log.MessageType.Info, "Obtained actual host dynamic suffix: '{0}' ".Args(s_DynamicHostNameSuffix));
                        s_HostName = s_HostName + s_DynamicHostNameSuffix;//no spaces between
                        bootApp.writeLog(NFX.Log.MessageType.Info, "The actual dynamic instance host name is: '{0}'".Args(s_HostName));

                        NFX.Log.Message.DefaultHostName = s_HostName;
                    }


                    bootApp.writeLog(NFX.Log.MessageType.Info, "...exiting agni app bootloader");
                }

                return(result);
            }
            catch (Exception error)
            {
                s_LoadException = error;
                throw new AgniException(StringConsts.APP_LOADER_ERROR + error.ToMessageWithType(), error);
            }
            finally
            {
                s_Loaded = true;
            }
        }