public void When_Out_Of_Time_For_Join_Accept_Second_Window_Should_Resolve_Window_0(int delayInMs) { var target = new LoRaOperationTimeWatcher(RegionFactory.CreateEU868Region(), DateTimeOffset.UtcNow.Subtract(TimeSpan.FromMilliseconds(delayInMs))); var loRaDevice = new LoRaDevice("31312", "312321321", null); Assert.Equal(0, target.ResolveJoinAcceptWindowToUse(loRaDevice)); }
public void set_up() { var adapters = new IRegionAdapter[] { new StatusBarAdapter() }; var regionFactory = new RegionFactory(adapters); _regionManager = new RegionManager(regionFactory); }
public void chooses_most_specific_adapter() { var specificRegionAdapterMock = new Mock <IRegionAdapter>(); specificRegionAdapterMock .SetupGet(adapter => adapter.SupportedType) .Returns(typeof(FrameworkElement)); specificRegionAdapterMock .Setup(adapter => adapter.AdaptView(_view)) .Returns(_region); // no invocation expected var generalRegionAdapterMock = new Mock <IRegionAdapter>(MockBehavior.Strict); generalRegionAdapterMock .SetupGet(adapter => adapter.SupportedType) .Returns(typeof(DependencyObject)); var regionFactory = new RegionFactory(new[] { generalRegionAdapterMock.Object, specificRegionAdapterMock.Object }); var createdRegion = regionFactory.CreateRegion(_view); Assert.AreSame(_region, createdRegion); }
public void RunMultiuserSecurityExample() { // Create client's Authentication Intializer and Credentials using api ( Same can be set to gfcpp.properties & comment following code ). Properties <string, string> secProp = Properties <string, string> .Create <string, string>(); //By setting this property client will send credential in encrypted form. //to do this one need to setup OpenSSL. //secProp.Insert("security-client-dhalgo", "Blowfish:128"); // Connect to the GemFire Distributed System using the settings from the gfcpp.properties file by default. // Create a GemFire Cache. CacheFactory cacheFactory = CacheFactory.CreateCacheFactory(null) .AddServer("192.168.1.121", 40404); Cache cache = cacheFactory.SetMultiuserAuthentication(true).Create(); Console.WriteLine("Created the GemFire Cache"); RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY); IRegion <string, string> region = regionFactory.Create <string, string>("exampleRegion"); Console.WriteLine("Created the Region Programmatically."); runWithUserRoot(cache); runWithUserWriter(cache); runWithUserReader(cache); Console.In.ReadLine(); cache.Close(); Console.WriteLine("Client disconnected from the GemFire Distributed System"); }
public void After_One_Second_Join_First_Window_Should_Be_Greater_Than_3sec() { var target = new LoRaOperationTimeWatcher(RegionFactory.CreateEU868Region(), DateTimeOffset.UtcNow.Subtract(TimeSpan.FromSeconds(1))); var actual = target.GetRemainingTimeToJoinAcceptFirstWindow(); Assert.InRange(actual.TotalMilliseconds, 3500, 5000); }
public void TestItReturnsElementsInOrder() { OutputGroup group1 = new("1"); OutputGroup group2 = new("2"); outputGroups.AddGroupWithFiles(group1, new List <string> { "foo.txt" }); outputGroups.AddGroupWithFiles(group2, new List <string> { "goo.txt" }); Region first = RegionFactory.Make(definition: DefinitionFactory.Make("foo.txt")); Region second = RegionFactory.Make(definition: DefinitionFactory.Make("goo.txt")); Region third = RegionFactory.Make(definition: DefinitionFactory.Make("foo.txt")); sectorElements.Add(first); sectorElements.Add(second); sectorElements.Add(third); IEnumerable <ICompilableElementProvider> expected = new List <ICompilableElementProvider>() { first, third, second }; AssertCollectedItems(expected); }
public void RunFeeder() { // Create a Geode Cache Programmatically. CacheFactory cacheFactory = CacheFactory.CreateCacheFactory(); Cache cache = cacheFactory.SetSubscriptionEnabled(true).Create(); Console.WriteLine("Created the Geode Cache"); RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY); // Created the Region Programmatically. IRegion <string, string> region = regionFactory.Create <string, string>("exampleRegion"); Console.WriteLine("Created the Region Programmatically."); // create two keys with value string key1 = "Key-1"; string value1 = "Value-1"; region[key1] = value1; string key2 = "Key-2"; string value2 = "Value-2"; region[key2] = value2; Console.WriteLine("Created Key-1 and Key-2 in region. Durable interest was registered only for Key-1."); // Close the Geode Cache cache.Close(); Console.WriteLine("Closed the Geode Cache"); }
void RunFeeder1() { CacheFactory cacheFactory = CacheFactory.CreateCacheFactory(); Util.Log("Feeder connected to the Geode Distributed System"); Cache cache = cacheFactory.Create(); Util.Log("Created the Geode Cache"); RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY); Util.Log("Created the RegionFactory"); // Create the Region Programmatically. IRegion <object, object> region = regionFactory.Create <object, object>("DistRegionAck"); Util.Log("Created the Region Programmatically."); PendingEventCount(region, 0, true); for (int i = 10; i < 20; i++) { region[i] = i; } Thread.Sleep(10000); Util.Log("put on 10-20 keys done."); // Close the Geode Cache cache.Close(); Util.Log("Closed the Geode Cache"); }
public void TestItPassesOnValidColours() { sectorElements.Add(RegionFactory.Make("colour1")); sectorElements.Add(RegionFactory.Make("123")); AssertNoValidationErrors(); }
public void TestItFailsOnInvalidColours() { sectorElements.Add(RegionFactory.Make("colour2")); sectorElements.Add(RegionFactory.Make("-123")); AssertValidationErrors(4); }
public void set_up() { var adapters = new IRegionAdapter[] { new ItemsControlAdapter() }; var regionFactory = new RegionFactory(adapters); _regionManager = new RegionManager(regionFactory); }
private void set_up() { var adapters = new IRegionAdapter[] { new TabControlAdapter() }; var regionFactory = new RegionFactory(adapters); _regionManager = new RegionManager(regionFactory); }
private IRegion <object, object> CreateOverflowRegion(string regionName, string libraryName, string factoryFunctionName) { RegionFactory rf = CacheHelper.DCache.CreateRegionFactory(RegionShortcut.LOCAL); rf.SetCachingEnabled(true); rf.SetLruEntriesLimit(20); rf.SetInitialCapacity(1000); rf.SetDiskPolicy(DiskPolicyType.Overflows); Properties <string, string> sqliteProperties = new Properties <string, string>(); sqliteProperties.Insert("PageSize", "65536"); sqliteProperties.Insert("MaxFileSize", "512000000"); String sqlite_dir = "SqLiteDir" + Process.GetCurrentProcess().Id.ToString(); sqliteProperties.Insert("PersistenceDirectory", sqlite_dir); rf.SetPersistenceManager(libraryName, factoryFunctionName, sqliteProperties); CacheHelper.Init(); IRegion <object, object> region = CacheHelper.GetRegion <object, object>(regionName); if ((region != null) && !region.IsDestroyed) { region.GetLocalView().DestroyRegion(); Assert.IsTrue(region.IsDestroyed, "IRegion<object, object> {0} was not destroyed.", regionName); } region = rf.Create <object, object>(regionName); Assert.IsNotNull(region, "IRegion<object, object> was not created."); return(region); }
public void When_Missed_Both_Windows_Should_Resolve_Window_0(int delayInMs) { var target = new LoRaOperationTimeWatcher(RegionFactory.CreateEU868Region(), DateTimeOffset.UtcNow.Subtract(TimeSpan.FromMilliseconds(delayInMs))); var loRaDevice = new LoRaDevice("31312", "312321321", null); Assert.Equal(0, target.ResolveReceiveWindowToUse(loRaDevice)); }
public void NewAPI() { // 1. Create a cache CacheFactory cacheFactory = CacheFactory.CreateCacheFactory(); cacheFactory.SetSubscriptionEnabled(true); Cache cache = cacheFactory.Create(); GemStone.GemFire.Cache.PoolFactory poolFactory = GemStone.GemFire.Cache.PoolManager.CreateFactory(); poolFactory.AddServer("localhost", 40404); poolFactory.SetSubscriptionEnabled(true); poolFactory.Create("examplePool"); // 2. Create default region attributes using region factory RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.CACHING_PROXY); regionFactory.SetPoolName("examplePool"); // 3. Create region Region region = regionFactory.Create("exampleregion"); region.RegisterRegex("Keys-*", false, null, true); }
public void After_5_Seconds_Join_First_Window_Should_Be_Negative() { var target = new LoRaOperationTimeWatcher(RegionFactory.CreateEU868Region(), DateTimeOffset.UtcNow.Subtract(TimeSpan.FromSeconds(5))); var actual = target.GetRemainingTimeToJoinAcceptFirstWindow(); Assert.True(actual.TotalMilliseconds < 0, $"First window is over, value should be negative"); }
public void set_up() { var adapters = new IRegionAdapter[] { new ToolbarTrayAdapter() }; var regionFactory = new RegionFactory(adapters); _regionManager = new RegionManager(regionFactory); }
/// <summary> /// Process a raw message /// </summary> /// <param name="rxpk"><see cref="Rxpk"/> representing incoming message</param> /// <param name="startTimeProcessing">Starting time counting from the moment the message was received</param> /// <returns>A <see cref="DownlinkPktFwdMessage"/> if a message has to be sent back to device</returns> public async Task <DownlinkPktFwdMessage> ProcessMessageAsync(Rxpk rxpk, DateTime startTimeProcessing) { if (!LoRaPayload.TryCreateLoRaPayload(rxpk, out LoRaPayload loRaPayload)) { Logger.Log("There was a problem in decoding the Rxpk", LogLevel.Error); return(null); } if (this.loraRegion == null) { if (!RegionFactory.TryResolveRegion(rxpk)) { // log is generated in Region factory // move here once V2 goes GA return(null); } this.loraRegion = RegionFactory.CurrentRegion; } if (loRaPayload.LoRaMessageType == LoRaMessageType.JoinRequest) { return(await this.ProcessJoinRequestAsync(rxpk, (LoRaPayloadJoinRequest)loRaPayload, startTimeProcessing)); } else if (loRaPayload.LoRaMessageType == LoRaMessageType.UnconfirmedDataUp || loRaPayload.LoRaMessageType == LoRaMessageType.ConfirmedDataUp) { return(await this.ProcessDataMessageAsync(rxpk, (LoRaPayloadData)loRaPayload, startTimeProcessing)); } Logger.Log("Unknwon message type in rxpk, message ignored", LogLevel.Error); return(null); }
static void Main() { // Register the user-defined serializable type. Serializable.RegisterType(AccountHistory.CreateInstance); Serializable.RegisterType(BankAccount.CreateInstance); // Create a GemFire Cache Programmatically. CacheFactory cacheFactory = CacheFactory.CreateCacheFactory(null); Cache cache = cacheFactory.SetSubscriptionEnabled(true).Create(); Console.WriteLine("Created the GemFire Cache"); RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.LOCAL); Console.WriteLine("Created Region Factory"); // Create the example Region programmatically. Region region = regionFactory .Create("BankAccounts"); Console.WriteLine("Created the Region Programmatically."); // Place some instances of BankAccount cache region. BankAccount baKey = new BankAccount(2309, 123091); AccountHistory ahVal = new AccountHistory(); ahVal.AddLog("Created account"); region.Put(baKey, ahVal); Console.WriteLine("Put an AccountHistory in cache keyed with BankAccount."); // Display the BankAccount information. Console.WriteLine(baKey.ToString()); // Call custom behavior on instance of AccountHistory. ahVal.ShowAccountHistory(); // Get a value out of the region. AccountHistory history = region.Get(baKey) as AccountHistory; if (history != null) { Console.WriteLine("Found AccountHistory in the cache."); history.ShowAccountHistory(); history.AddLog("debit $1,000,000."); region.Put(baKey, history); Console.WriteLine("Updated AccountHistory in the cache."); } // Look up the history again. history = region.Get(baKey) as AccountHistory; if (history != null) { Console.WriteLine("Found AccountHistory in the cache."); history.ShowAccountHistory(); } // Close the cache. cache.Close(); }
public void TestItAddsRegions() { Region region = RegionFactory.Make(); collection.Add(region); Assert.Equal(region, collection.Regions[0]); }
public IRegion <int, string> getProductRegion() { Cache cache = this.getCache(); RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.CACHING_PROXY); IRegion <int, string> r = regionFactory.Create <int, string>("products"); return(r); }
public void When_Device_PreferredWindow1_In_Time_For_First_Window_Should_Get_Check_C2D_Avaible_Time_Correctly(int delayInMs, int expectedMinMs, int expectedMaxMs) { var target = new LoRaOperationTimeWatcher(RegionFactory.CreateEU868Region(), DateTimeOffset.UtcNow.Subtract(TimeSpan.FromMilliseconds(delayInMs))); var loRaDevice = new LoRaDevice("1111", "2222", null); // Will be around 1000 - delay - 400 Assert.InRange(target.GetAvailableTimeToCheckCloudToDeviceMessage(loRaDevice), TimeSpan.FromMilliseconds(expectedMinMs), TimeSpan.FromMilliseconds(expectedMaxMs)); }
void RunDurableClient(int expectedPendingQSize) { Properties <string, string> pp = Properties <string, string> .Create <string, string>(); pp.Insert("durable-client-id", "DurableClientId"); pp.Insert("durable-timeout", "30"); CacheFactory cacheFactory = CacheFactory.CreateCacheFactory(pp); Cache cache = cacheFactory.SetSubscriptionEnabled(true) .SetSubscriptionAckInterval(5000) .SetSubscriptionMessageTrackingTimeout(5000) .Create(); Util.Log("Created the Geode Cache Programmatically"); RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.CACHING_PROXY); IRegion <object, object> region = regionFactory.Create <object, object>("DistRegionAck"); Util.Log("Created the DistRegionAck Region Programmatically"); QueryService <object, object> qService = cache.GetQueryService <object, object>(); CqAttributesFactory <object, object> cqFac = new CqAttributesFactory <object, object>(); ICqListener <object, object> cqLstner = new MyCqListener1 <object, object>(); cqFac.AddCqListener(cqLstner); CqAttributes <object, object> cqAttr = cqFac.Create(); Util.Log("Attached CqListener"); String query = "select * from /DistRegionAck"; CqQuery <object, object> qry = qService.NewCq("MyCq", query, cqAttr, true); Util.Log("Created new CqQuery"); qry.Execute(); Util.Log("Executed new CqQuery"); Thread.Sleep(10000); PendingEventCount(region, expectedPendingQSize, false); //Send ready for Event message to Server( only for Durable Clients ). //Server will send queued events to client after recieving this. cache.ReadyForEvents(); Util.Log("Sent ReadyForEvents message to server"); Thread.Sleep(10000); // Close the Geode Cache with keepalive = true. Server will queue events for // durable registered keys and will deliver all events when client will reconnect // within timeout period and send "readyForEvents()" PendingEventCount(region, 0, true); cache.Close(true); Util.Log("Closed the Geode Cache with keepalive as true"); }
public void When_In_Time_For_First_Window_But_Device_Preferes_Seconds_Should_Resolve_Window_2(int delayInMs) { var target = new LoRaOperationTimeWatcher(RegionFactory.CreateEU868Region(), DateTimeOffset.UtcNow.Subtract(TimeSpan.FromMilliseconds(delayInMs))); var loRaDevice = new LoRaDevice("31312", "312321321", null) { PreferredWindow = 2, }; Assert.Equal(2, target.ResolveReceiveWindowToUse(loRaDevice)); }
public GameInit() { gameState = new GameState(); freeRoamState = new FreeRoamState(); regionFactory = new RegionFactory(); characterFactory = new CharacterFactory(); messageBlockFactory = new MessageBlockFactory(); bag = new Bag(); party = new Party(); }
public Region() { RegionFactory theFactory = new RegionFactory(); _repository = theFactory.createRepository(); if (_repository == null) { throw new NotImplementedException(); } }
public void When_Device_Out_Of_Time_For_C2D_Receive_Should_Return_TimeSpan_Zero(int delayInMs, int devicePreferredReceiveWindow) { var target = new LoRaOperationTimeWatcher(RegionFactory.CreateEU868Region(), DateTimeOffset.UtcNow.Subtract(TimeSpan.FromMilliseconds(delayInMs))); var loRaDevice = new LoRaDevice("1111", "2222", null) { PreferredWindow = devicePreferredReceiveWindow, }; Assert.Equal(TimeSpan.Zero, target.GetAvailableTimeToCheckCloudToDeviceMessage(loRaDevice)); }
public static IRegion <TKey, TVal> CreateRegion(string name, RegionFactory attrs) { Init(); DestroyRegion(name, true, false); IRegion <TKey, TVal> region = attrs.Create <TKey, TVal>(name); FwkAssert(region != null, "Region {0} was not created.", name); m_currRegion = region; return(region); }
public void RunDurableClient() { // Create durable client's properties using api. Properties <string, string> durableProp = Properties <string, string> .Create <string, string>(); durableProp.Insert("durable-client-id", "DurableClientId"); durableProp.Insert("durable-timeout", "300"); // Create a Geode Cache programmatically. CacheFactory cacheFactory = CacheFactory.CreateCacheFactory(durableProp); Cache cache = cacheFactory.SetSubscriptionEnabled(true) .Create(); Console.WriteLine("Created the Geode Cache"); // Create the example Region programmatically. RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.CACHING_PROXY); IRegion <string, string> region = regionFactory.Create <string, string>("exampleRegion"); Console.WriteLine("Created the generic Region programmatically."); // Plugin the CacheListener with afterRegionLive. "afterRegionLive()" will be called // after all the queued events are recieved by client AttributesMutator <string, string> attrMutator = region.AttributesMutator; attrMutator.SetCacheListener(new DurableCacheListener <string, string>()); Console.WriteLine("DurableCacheListener set to region."); // For durable Clients, Register Intrest can be durable or non durable ( default ), // Unregister Interest APIs remain same. string [] keys = new string[] { "Key-1" }; region.GetSubscriptionService().RegisterKeys(keys, true, true); Console.WriteLine("Called Register Interest for Key-1 with isDurable as true"); //Send ready for Event message to Server( only for Durable Clients ). //Server will send queued events to client after recieving this. cache.ReadyForEvents(); Console.WriteLine("Sent ReadyForEvents message to server"); //wait for some time to recieve events System.Threading.Thread.Sleep(1000); // Close the Geode Cache with keepalive = true. Server will queue events for // durable registered keys and will deliver all events when client will reconnect // within timeout period and send "readyForEvents()" cache.Close(true); Console.WriteLine("Closed the Geode Cache with keepalive as true"); }
public static Dictionary<SoundName, SoundEffect> LoadSoundsForRegion(ContentManager contentManager, RegionNames region) { var soundDictionary = new Dictionary<SoundName, SoundEffect>(); var sounds = RegionFactory.GetInfoForRegion(region).RegionSounds; foreach (var sound in sounds) soundDictionary.Add(sound, contentManager.Load<SoundEffect>(_soundFiles[sound])); return soundDictionary; }
/// <summary> /// Sets up the Region maps and groupings for the PickNextArea tests /// </summary> /// <param name="firstGrouping"></param> /// <param name="secondGrouping"></param> /// <param name="desertRegion"></param> private void PickNextArea_GroupingSetup_DesertGroupings(out MapGrouping <SubRegion, WorldSubRegion> firstGrouping, out MapGrouping <SubRegion, WorldSubRegion> secondGrouping, out Region desertRegion) { IRegionFactory regionFactory = new RegionFactory(_decisionManager); desertRegion = regionFactory.GetRegion(WorldRegion.Desert); MapManager mapManager = new MapManager(Globals.GroupingKeys); AreaMap <SubRegion, WorldSubRegion> desertMap = mapManager.GetSubRegionalMap(WorldRegion.Desert, desertRegion.SubRegions); firstGrouping = desertMap.MapPaths.First(p => p.From.AreaId == WorldSubRegion.DesertIntro).To; secondGrouping = desertMap.MapPaths.First(p => p.From.AreaId == WorldSubRegion.DesertCrypt).To; }
/// <summary> /// Builds a graph of regions based on the basic blocks of the code. /// </summary> /// <param name="proc"></param> /// <returns></returns> public Tuple<DirectedGraph<Region>, Region> BuildRegionGraph(Procedure proc) { var btor = new Dictionary<Block, Region>(); var regs = new DiGraph<Region>(); var regionFactory = new RegionFactory(); foreach (var b in proc.ControlGraph.Blocks) { var reg = regionFactory.Create(b); btor.Add(b, reg); regs.AddNode(reg); } foreach (var b in proc.ControlGraph.Blocks) { foreach (var s in b.Succ) { var from = btor[b]; var to = btor[s]; regs.AddEdge(from, to); } } return new Tuple<DirectedGraph<Region>, Region>(regs, btor[proc.EntryBlock]); }