protected IRegion <TKey, TVal> GetRegion(string regionName) { IRegion <TKey, TVal> region; if (regionName == null) { regionName = GetStringValue("regionName"); } if (regionName == null) { region = (IRegion <TKey, TVal>)GetRootRegion(); if (region == null) { IRegion <TKey, TVal>[] rootRegions = CacheHelper <TKey, TVal> .DCache.RootRegions <TKey, TVal>(); if (rootRegions != null && rootRegions.Length > 0) { region = rootRegions[Util.Rand(rootRegions.Length)]; } } } else { region = CacheHelper <TKey, TVal> .GetRegion(regionName); } return(region); }
public override void DoCreateRegion() { FwkInfo("In DoCreateRegion() Durable"); ClearCachedKeys(); string rootRegionData = GetStringValue("regionSpec"); string tagName = GetStringValue("TAG"); string endpoints = Util.BBGet(JavaServerBB, EndPointTag + tagName) as string; if (rootRegionData != null && rootRegionData.Length > 0) { string rootRegionName; rootRegionName = GetRegionName(rootRegionData); if (rootRegionName != null && rootRegionName.Length > 0) { IRegion <TKey, TVal> region; if ((region = CacheHelper <TKey, TVal> .GetRegion(rootRegionName)) == null) { bool isDC = GetBoolValue("isDurable"); string m_isPool = null; try { // Check if this is a thin-client region; if so set the endpoints int redundancyLevel = 0; if (endpoints != null && endpoints.Length > 0) { redundancyLevel = GetUIntValue(RedundancyLevelKey); if (redundancyLevel < 0) { redundancyLevel = 0; } if (redundancyLevel < 0) { redundancyLevel = 0; } string conflateEvents = GetStringValue(ConflateEventsKey); string durableClientId = ""; int durableTimeout = 300; if (isDC) { durableTimeout = GetUIntValue("durableTimeout"); bool isFeeder = GetBoolValue("isFeeder"); if (isFeeder) { durableClientId = "Feeder"; // VJR: Setting FeederKey because listener cannot read boolean isFeeder // FeederKey is used later on by Verify task to identify feeder's key in BB Util.BBSet("DURABLEBB", "FeederKey", "ClientName_" + Util.ClientNum + "_Count"); } else { durableClientId = String.Format("ClientName_{0}", Util.ClientNum); } } FwkInfo("DurableClientID is {0} and DurableTimeout is {1}", durableClientId, durableTimeout); ResetKey("sslEnable"); bool isSslEnable = GetBoolValue("sslEnable"); CacheHelper <TKey, TVal> .InitConfigForPoolDurable(durableClientId, durableTimeout, conflateEvents, isSslEnable); } RegionFactory rootAttrs = CacheHelper <TKey, TVal> .DCache.CreateRegionFactory(RegionShortcut.PROXY); SetRegionAttributes(rootAttrs, rootRegionData, ref m_isPool); rootAttrs = CreatePool(rootAttrs, redundancyLevel); region = CacheHelper <TKey, TVal> .CreateRegion(rootRegionName, rootAttrs); Apache.Geode.Client.RegionAttributes <TKey, TVal> regAttr = region.Attributes; FwkInfo("Region attributes for {0}: {1}", rootRegionName, CacheHelper <TKey, TVal> .RegionAttributesToString(regAttr)); } catch (Exception ex) { FwkSevere("Caught Exception: {0}", ex); } } } else { FwkSevere("DoCreateRegion() failed to create region"); } } FwkInfo("DoCreateRegion() complete."); }