Beispiel #1
0
        /// <summary>
        /// Opens metabase from the specified file system instance at the specified metabase root path
        /// </summary>
        /// <param name="bootApplication">IApplication chassis which this metabank boots from</param>
        /// <param name="skyApplication">ISkyApplication chassis which this metabank installs in</param>
        /// <param name="fileSystem">
        /// An instance of a file system that stores the metabase files
        /// Note: This file system is typically a component of Boot application, not the sky app which is being mounted.
        /// Metabank does NOT dispose the FS, as it is an external resource relative to metabank
        /// </param>
        /// <param name="fsSessionParams">File system connection parameter</param>
        /// <param name="rootPath">A path to the directory within the file system that contains metabase root data</param>
        internal Metabank(IApplication bootApplication,
                          ISkyApplication skyApplication,
                          IFileSystem fileSystem,
                          FileSystemSessionConnectParams fsSessionParams,
                          string rootPath) : base(bootApplication.NonNull(nameof(bootApplication)))
        {
            this.m_SkyApplication = skyApplication.NonNull(nameof(skyApplication));

            if (fileSystem is LocalFileSystem && fsSessionParams == null)
            {
                fsSessionParams = new FileSystemSessionConnectParams();
            }

            if (fileSystem == null || fsSessionParams == null)
            {
                throw new MetabaseException(StringConsts.ARGUMENT_ERROR + "Metabank.ctor(fileSystem|fsSessionParams==null)");
            }

            using (var session = ctorFS(fileSystem, fsSessionParams, rootPath))
            {
                m_CommonLevelConfig = getConfigFromFile(session, CONFIG_COMMON_FILE).Root;

                m_RootConfig = getConfigFromFile(session, CONFIG_SECTION_LEVEL_FILE).Root;
                includeCommonConfig(m_RootConfig);
                m_RootConfig.ResetModified();

                m_RootAppConfig  = getConfigFromFile(session, CONFIG_SECTION_LEVEL_ANY_APP_FILE).Root;
                m_PlatformConfig = getConfigFromFile(session, CONFIG_PLATFORMS_FILE).Root;
                m_NetworkConfig  = getConfigFromFile(session, CONFIG_NETWORKS_FILE).Root;
                m_ContractConfig = getConfigFromFile(session, CONFIG_CONTRACTS_FILE).Root;
            }
            m_Catalogs = new Registry <Catalog>();
            var cacheStore = new CacheStore(this, "AC.Metabank");

            //No app available - nowhere to configure: //cacheStore.Configure(null);

            /*
             * cacheStore.TableOptions.Register( new TableOptions(APP_CATALOG, 37, 3) );
             * cacheStore.TableOptions.Register( new TableOptions(BIN_CATALOG, 37, 7) );
             * cacheStore.TableOptions.Register( new TableOptions(REG_CATALOG, 37, 17) );
             * superseded by the cacheStore.DefaultTableOptions below:
             */
            cacheStore.DefaultTableOptions = new TableOptions("*", 37, 17);
            //reg catalog needs more space
            cacheStore.TableOptions.Register(new TableOptions(REG_CATALOG, 571, 37));

            cacheStore.InstrumentationEnabled = false;

            m_Cache = new ComplexKeyHashingStrategy(cacheStore);

            new AppCatalog(this);
            new BinCatalog(this);
            new SecCatalog(this);
            new RegCatalog(this);

            ConfigAttribute.Apply(this, m_RootConfig);
        }
Beispiel #2
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");
        }
Beispiel #3
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");
        }