/// <summary> /// Gets an application configuration tree for the particular named application on this host. /// This method traverses the whole region catalog and calculates the effective configuration tree for this host - /// the one that will get supplied into the application container process-wide. /// /// The traversal is done in the following order: MetabaseRoot->Role->App->[Regions]->NOC->[Zones]->Host. /// </summary> /// <param name="appName">Metabase application name which should resolve in App catalog</param> /// <param name="latest">Pass true to bypass the metabase cache on read so the config tree is recalculated</param> public IConfigSectionNode GetEffectiveAppConfig(string appName, bool latest = false) { IConfigSectionNode result = null; const string CACHE_TABLE = "EffectiveAppConfigs"; string CACHE_KEY = (this.RegionPath + "." + appName).ToLowerInvariant(); //1. Try to get from cache if (!latest) { result = Metabank.cacheGet(CACHE_TABLE, CACHE_KEY) as IConfigSectionNode; if (result != null) { return(result); } } try { result = calculateEffectiveAppConfig(appName); } catch (Exception error) { throw new MetabaseException(StringConsts.METABASE_EFFECTIVE_APP_CONFIG_ERROR.Args(appName, RegionPath, error.ToMessageWithType()), error); } Metabank.cachePut(CACHE_TABLE, CACHE_KEY, result); return(result); }
/// <summary> /// Gets host by name /// </summary> public SectionHost GetHost(string name) { string CACHE_KEY = ("ZN.h" + Path + name).ToLowerInvariant(); //1. Try to get from cache var result = Metabank.cacheGet(REG_CATALOG, CACHE_KEY) as SectionHost; if (result != null) { return(result); } var rdir = "{0}{1}".Args(name, RegCatalog.HST_EXT); var rpath = Metabank.JoinPaths(Path, rdir); result = Metabank.fsAccess("Zone[{0}].GetHost({1})".Args(m_Name, name), rpath, (session, dir) => new SectionHost(this, name, rpath, session) ); Metabank.cachePut(REG_CATALOG, CACHE_KEY, result); return(result); }
/// <summary> /// Gets the information for the best suitable binary packages on this host for the named app /// </summary> /// <param name="appName">Metabase application name which should resolve in App catalog</param> public IEnumerable <SectionApplication.AppPackage> GetAppPackages(string appName) { const string CACHE_TABLE = "AppPackages"; string CACHE_KEY = (this.RegionPath + "." + appName).ToLowerInvariant(); //1. Try to get from cache var result = Metabank.cacheGet(CACHE_TABLE, CACHE_KEY) as IEnumerable <SectionApplication.AppPackage>; if (result != null) { return(result); } try { result = this.calculateAppPackages(appName); } catch (Exception error) { throw new MetabaseException(StringConsts.METABASE_APP_PACKAGES_ERROR.Args(appName, RegionPath, error.ToMessageWithType()), error); } Metabank.cachePut(CACHE_TABLE, CACHE_KEY, result); return(result); }