public virtual void TestMapConfigWildcardMultipleAmbiguousConfigs()
 {
     NearCacheConfig nearCacheConfig1 = new NearCacheConfig().SetName("com.hazelcast*");
     NearCacheConfig nearCacheConfig2 = new NearCacheConfig().SetName("*com.hazelcast");
     ClientConfig config = new ClientConfig();
     config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
     config.AddNearCacheConfig(nearCacheConfig1);
     config.AddNearCacheConfig(nearCacheConfig2);
     config.GetNearCacheConfig("com.hazelcast");
 }
        public virtual void TestDuplicateConfig()
        {
            NearCacheConfig nearCacheConfig1 = new NearCacheConfig().SetName("com.hazelcast.*ap");
            NearCacheConfig nearCacheConfig2 = new NearCacheConfig().SetName("com.hazelcast*map");
            ClientConfig config = new ClientConfig();
            config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
            config.AddNearCacheConfig(nearCacheConfig1);
            config.AddNearCacheConfig(nearCacheConfig2);

            config.GetNearCacheConfig("com.hazelcast.map");
        }
        public virtual void TestMapConfigWildcardMultipleAmbiguousConfigs()
        {
            var nearCacheConfig1 = new NearCacheConfig().SetName("com.hazelcast*");
            var nearCacheConfig2 = new NearCacheConfig().SetName("*com.hazelcast");
            var config           = new ClientConfig();

            config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
            config.AddNearCacheConfig(nearCacheConfig1);
            config.AddNearCacheConfig(nearCacheConfig2);
            config.GetNearCacheConfig("com.hazelcast");
        }
        public virtual void TestNearCacheConfigWildcardOnlyMultipleConfigs()
        {
            var nearCacheConfig1 = new NearCacheConfig().SetName("*");
            var nearCacheConfig2 = new NearCacheConfig().SetName("com.hazelcast.*");
            var config           = new ClientConfig();

            config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
            config.AddNearCacheConfig(nearCacheConfig1);
            config.AddNearCacheConfig(nearCacheConfig2);
            // we should get the best matching result
            Assert.AreEqual(nearCacheConfig2, config.GetNearCacheConfig("com.hazelcast.myNearCache"));
        }
        public virtual void TestDuplicateConfig()
        {
            NearCacheConfig nearCacheConfig1 = new NearCacheConfig().SetName("com.hazelcast.*ap");
            NearCacheConfig nearCacheConfig2 = new NearCacheConfig().SetName("com.hazelcast*map");
            ClientConfig    config           = new ClientConfig();

            config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
            config.AddNearCacheConfig(nearCacheConfig1);
            config.AddNearCacheConfig(nearCacheConfig2);

            config.GetNearCacheConfig("com.hazelcast.map");
        }
        public void TestDuplicateConfig()
        {
            Assert.Throws <ConfigurationException>(() =>
            {
                var nearCacheConfig1 = new NearCacheConfig().SetName("com.hazelcast.*ap");
                var nearCacheConfig2 = new NearCacheConfig().SetName("com.hazelcast*map");
                var config           = new ClientConfig();
                config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
                config.AddNearCacheConfig(nearCacheConfig1);
                config.AddNearCacheConfig(nearCacheConfig2);

                config.GetNearCacheConfig("com.hazelcast.map");
            });
        }
 public virtual void TestSpecificNearCacheConfig_whenAsteriskAtTheBeginning()
 {
     var clientConfig = new ClientConfig();
     var genericNearCacheConfig = new NearCacheConfig();
     genericNearCacheConfig.SetName("*Map");
     clientConfig.AddNearCacheConfig(genericNearCacheConfig);
     var specificNearCacheConfig = new NearCacheConfig();
     specificNearCacheConfig.SetName("*MapStudent");
     clientConfig.AddNearCacheConfig(specificNearCacheConfig);
     var mapFoo = clientConfig.GetNearCacheConfig("fooMap");
     var mapStudentFoo = clientConfig.GetNearCacheConfig("fooMapStudent");
     Assert.AreEqual(genericNearCacheConfig, mapFoo);
     Assert.AreEqual(specificNearCacheConfig, mapStudentFoo);
 }
        protected override void ConfigureClient(ClientConfig config)
        {
            base.ConfigureClient(config);
            var nearCacheConfig = new NearCacheConfig().SetInMemoryFormat(InMemoryFormat.Object);

            config.AddNearCacheConfig("nearCachedMap*", nearCacheConfig);
        }
        public virtual void TestNearCacheConfigWildcardMatchingPointStartsWith()
        {
            NearCacheConfig nearCacheConfig1 = new NearCacheConfig().SetName("hazelcast.*");
            NearCacheConfig nearCacheConfig2 = new NearCacheConfig().SetName("hazelcast.test.*");
            NearCacheConfig nearCacheConfig3 = new NearCacheConfig().SetName("hazelcast.test.sub.*");
            ClientConfig    config           = new ClientConfig();

            config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
            config.AddNearCacheConfig(nearCacheConfig1);
            config.AddNearCacheConfig(nearCacheConfig2);
            config.AddNearCacheConfig(nearCacheConfig3);
            // we should not match any of the configs (startsWith)
            Assert.AreEqual(null, config.GetNearCacheConfig("com.hazelcast.myNearCache"));
            Assert.AreEqual(null, config.GetNearCacheConfig("com.hazelcast.test.myNearCache"));
            Assert.AreEqual(null, config.GetNearCacheConfig("com.hazelcast.test.sub.myNearCache"));
        }
        public virtual void TestNearCacheConfigWildcardMatchingPointEndsWith()
        {
            var nearCacheConfig1 = new NearCacheConfig().SetName("*.sub");
            var nearCacheConfig2 = new NearCacheConfig().SetName("*.test.sub");
            var nearCacheConfig3 = new NearCacheConfig().SetName("*.hazelcast.test.sub");
            var config           = new ClientConfig();

            config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
            config.AddNearCacheConfig(nearCacheConfig1);
            config.AddNearCacheConfig(nearCacheConfig2);
            config.AddNearCacheConfig(nearCacheConfig3);
            // we should not match any of the configs (endsWith)
            Assert.AreEqual(null, config.GetNearCacheConfig("com.hazelFast.Fast.sub.myNearCache"));
            Assert.AreEqual(null, config.GetNearCacheConfig("hazelFast.test.sub.myNearCache"));
            Assert.AreEqual(null, config.GetNearCacheConfig("test.sub.myNearCache"));
        }
 public virtual void TestNearCacheConfigWildcard3()
 {
     NearCacheConfig nearCacheConfig = new NearCacheConfig().SetName("com.hazelcast.test.*");
     ClientConfig config = new ClientConfig();
     config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
     config.AddNearCacheConfig(nearCacheConfig);
     Assert.AreEqual(nearCacheConfig, config.GetNearCacheConfig("com.hazelcast.test.myNearCache"));
 }
 protected override void ConfigureClient(ClientConfig config)
 {
     base.ConfigureClient(config);
     Environment.SetEnvironmentVariable("hazelcast.invalidation.max.tolerated.miss.count", "0");
     var defaultConfig = new NearCacheConfig().SetInvalidateOnChange(true).SetEvictionPolicy("None")
         .SetInMemoryFormat(InMemoryFormat.Binary);
     config.AddNearCacheConfig("nearCachedMap*", defaultConfig);
 }
        public virtual void TestSpecificNearCacheConfig_whenAsteriskAtTheBeginning()
        {
            var clientConfig           = new ClientConfig();
            var genericNearCacheConfig = new NearCacheConfig();

            genericNearCacheConfig.SetName("*Map");
            clientConfig.AddNearCacheConfig(genericNearCacheConfig);
            var specificNearCacheConfig = new NearCacheConfig();

            specificNearCacheConfig.SetName("*MapStudent");
            clientConfig.AddNearCacheConfig(specificNearCacheConfig);
            var mapFoo        = clientConfig.GetNearCacheConfig("fooMap");
            var mapStudentFoo = clientConfig.GetNearCacheConfig("fooMapStudent");

            Assert.AreEqual(genericNearCacheConfig, mapFoo);
            Assert.AreEqual(specificNearCacheConfig, mapStudentFoo);
        }
        public virtual void TestSpecificNearCacheConfig_whenAsteriskInTheMiddle()
        {
            var clientConfig           = new ClientConfig();
            var genericNearCacheConfig = new NearCacheConfig();

            genericNearCacheConfig.SetName("map*Bar");
            clientConfig.AddNearCacheConfig(genericNearCacheConfig);
            var specificNearCacheConfig = new NearCacheConfig();

            specificNearCacheConfig.SetName("mapStudent*Bar");
            clientConfig.AddNearCacheConfig(specificNearCacheConfig);
            var mapFoo        = clientConfig.GetNearCacheConfig("mapFooBar");
            var mapStudentFoo = clientConfig.GetNearCacheConfig("mapStudentFooBar");

            Assert.AreEqual(genericNearCacheConfig, mapFoo);
            Assert.AreEqual(specificNearCacheConfig, mapStudentFoo);
        }
        public virtual void TestNearCacheConfigWildcard3()
        {
            var nearCacheConfig = new NearCacheConfig().SetName("com.hazelcast.test.*");
            var config          = new ClientConfig();

            config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
            config.AddNearCacheConfig(nearCacheConfig);
            Assert.AreEqual(nearCacheConfig, config.GetNearCacheConfig("com.hazelcast.test.myNearCache"));
        }
        protected override void ConfigureClient(ClientConfig config)
        {
            base.ConfigureClient(config);

            var defaultConfig = new NearCacheConfig().SetInvalidateOnChange(false)
                                .SetInMemoryFormat(InMemoryFormat.Object).SetEvictionPolicy("None").SetMaxSize(MaxSize);

            config.AddNearCacheConfig("nearCachedMap*", defaultConfig);

            var invalidateConfig = new NearCacheConfig().SetInvalidateOnChange(true);

            config.AddNearCacheConfig("nearCacheMapInvalidate*", invalidateConfig);

            var lruConfig = new NearCacheConfig().SetEvictionPolicy("Lru").SetInvalidateOnChange(false)
                            .SetMaxSize(MaxSize);

            config.AddNearCacheConfig("nearCacheMapLru*", lruConfig);

            var lfuConfig = new NearCacheConfig().SetEvictionPolicy("Lfu").SetInvalidateOnChange(false)
                            .SetMaxSize(MaxSize);

            config.AddNearCacheConfig("nearCacheMapLfu*", lfuConfig);

            var ttlConfig = new NearCacheConfig().SetInvalidateOnChange(false).SetTimeToLiveSeconds(1);

            config.AddNearCacheConfig("nearCacheTtl*", ttlConfig);

            var idleConfig = new NearCacheConfig().SetInvalidateOnChange(false).SetMaxIdleSeconds(1);

            config.AddNearCacheConfig("nearCacheIdle*", idleConfig);
        }
        public virtual void TestNearCacheConfigWithoutWildcard()
        {
            var nearCacheConfig = new NearCacheConfig().SetName("someNearCache");
            var config          = new ClientConfig();

            config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
            config.AddNearCacheConfig(nearCacheConfig);
            Assert.AreEqual(nearCacheConfig, config.GetNearCacheConfig("someNearCache"));
            // non-matching name
            Assert.AreNotEqual(nearCacheConfig, config.GetNearCacheConfig("doesNotExist"));
            // non-matching case
            Assert.AreNotEqual(nearCacheConfig, config.GetNearCacheConfig("SomeNearCache"));
        }
        public static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();

            var nearCacheConfig = new NearCacheConfig();

            nearCacheConfig.SetMaxSize(1000)
            .SetInvalidateOnChange(true)
            .SetEvictionPolicy("Lru")
            .SetInMemoryFormat(InMemoryFormat.Binary);

            config.AddNearCacheConfig("nearcache-map-*", nearCacheConfig);
            config.GetNetworkConfig().AddAddress("127.0.0.1");

            var client = HazelcastClient.NewHazelcastClient(config);

            var map = client.GetMap <string, string>("nearcache-map-1");

            for (var i = 0; i < 1000; i++)
            {
                map.Put("key" + i, "value" + i);
            }

            var sw = new Stopwatch();

            sw.Start();
            for (var i = 0; i < 1000; i++)
            {
                map.Get("key" + i);
            }
            Console.WriteLine("Got values in " + sw.ElapsedMilliseconds + " millis");

            sw.Restart();
            for (var i = 0; i < 1000; i++)
            {
                map.Get("key" + i);
            }
            Console.WriteLine("Got cached values in " + sw.ElapsedMilliseconds + " millis");

            map.Destroy();
            client.Shutdown();
        }
예제 #19
0
        protected override void ConfigureClient(ClientConfig config)
        {
            Environment.SetEnvironmentVariable("hazelcast.client.statistics.enabled", "true");
            base.ConfigureClient(config);

            var nearCacheConfig = new NearCacheConfig()
                                  .SetInvalidateOnChange(false)
                                  .SetInMemoryFormat(InMemoryFormat.Object)
                                  .SetEvictionPolicy("LRU")
                                  .SetMaxIdleSeconds(1)
                                  .SetMaxSize(1000);

            config.AddNearCacheConfig("nearCachedMap*", nearCacheConfig);

            config.GetSerializationConfig().AddPortableFactory(1, new PortableFactory());
            config.GetSerializationConfig()
            .AddDataSerializableFactory(IdentifiedFactory.FactoryId, new IdentifiedFactory());
        }
        public static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();

            var nearCacheConfig = new NearCacheConfig();
            nearCacheConfig.SetMaxSize(1000)
                .SetInvalidateOnChange(true)
                .SetEvictionPolicy("Lru")
                .SetInMemoryFormat(InMemoryFormat.Binary);

            config.AddNearCacheConfig("nearcache-map-*", nearCacheConfig);
            config.GetNetworkConfig().AddAddress("127.0.0.1");

            var client = HazelcastClient.NewHazelcastClient(config);

            var map = client.GetMap<string, string>("nearcache-map-1");

            for (var i = 0; i < 1000; i++)
            {
                map.Put("key" + i, "value" + i);
            }

            var sw = new Stopwatch();

            sw.Start();
            for (var i = 0; i < 1000; i++)
            {
                map.Get("key" + i);
            }
            Console.WriteLine("Got values in " + sw.ElapsedMilliseconds + " millis");

            sw.Restart();
            for (var i = 0; i < 1000; i++)
            {
                map.Get("key" + i);
            }
            Console.WriteLine("Got cached values in " + sw.ElapsedMilliseconds + " millis");

            map.Destroy();
            client.Shutdown();
        }
예제 #21
0
        private static void Run(string[] args)
        {
            //This will enable client statistics
            Environment.SetEnvironmentVariable("hazelcast.client.statistics.enabled", "true");

            //set the statistics send period, default value is 3 seconds
            Environment.SetEnvironmentVariable("hazelcast.client.statistics.period.seconds", "3");

            var config = new ClientConfig();

            config.GetNetworkConfig().AddAddress("127.0.0.1");

            var nearCacheConfig = new NearCacheConfig();

            nearCacheConfig.SetMaxSize(1000)
            .SetInvalidateOnChange(true)
            .SetEvictionPolicy("Lru")
            .SetInMemoryFormat(InMemoryFormat.Binary);

            config.AddNearCacheConfig("myMap", nearCacheConfig);

            var client = HazelcastClient.NewHazelcastClient(config);

            //Let's generate some statistics
            var map  = client.GetMap <string, string>("myMap");
            var task = Task.Factory.StartNew(() =>
            {
                for (var i = 0; i < 100000; i++)
                {
                    map.Put("key-" + i, "value-" + i);
                    Thread.Sleep(500);
                }
            });

            //After client connected you can use Management Center to visualize client statistics
            task.Wait();
            client.Shutdown();
        }
 protected override void ConfigureClient(ClientConfig config)
 {
     base.ConfigureClient(config);
     var nearCacheConfig = new NearCacheConfig().SetInMemoryFormat(InMemoryFormat.Object);
     config.AddNearCacheConfig("nearCachedMap*", nearCacheConfig);
 }
 public virtual void TestNearCacheConfigWildcardMatchingPointStartsWith()
 {
     var nearCacheConfig1 = new NearCacheConfig().SetName("hazelcast.*");
     var nearCacheConfig2 = new NearCacheConfig().SetName("hazelcast.test.*");
     var nearCacheConfig3 = new NearCacheConfig().SetName("hazelcast.test.sub.*");
     var config = new ClientConfig();
     config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
     config.AddNearCacheConfig(nearCacheConfig1);
     config.AddNearCacheConfig(nearCacheConfig2);
     config.AddNearCacheConfig(nearCacheConfig3);
     // we should not match any of the configs (startsWith)
     Assert.AreEqual(null, config.GetNearCacheConfig("com.hazelcast.myNearCache"));
     Assert.AreEqual(null, config.GetNearCacheConfig("com.hazelcast.test.myNearCache"));
     Assert.AreEqual(null, config.GetNearCacheConfig("com.hazelcast.test.sub.myNearCache"));
 }
 public virtual void TestNearCacheConfigWildcardOnlyMultipleConfigs()
 {
     NearCacheConfig nearCacheConfig1 = new NearCacheConfig().SetName("*");
     NearCacheConfig nearCacheConfig2 = new NearCacheConfig().SetName("com.hazelcast.*");
     ClientConfig config = new ClientConfig();
     config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
     config.AddNearCacheConfig(nearCacheConfig1);
     config.AddNearCacheConfig(nearCacheConfig2);
     // we should get the best matching result
     Assert.AreEqual(nearCacheConfig2, config.GetNearCacheConfig("com.hazelcast.myNearCache"));
 }
 public virtual void TestNearCacheConfigWithoutWildcard()
 {
     NearCacheConfig nearCacheConfig = new NearCacheConfig().SetName("someNearCache");
     ClientConfig config = new ClientConfig();
     config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
     config.AddNearCacheConfig(nearCacheConfig);
     Assert.AreEqual(nearCacheConfig, config.GetNearCacheConfig("someNearCache"));
     // non-matching name
     Assert.AreNotEqual(nearCacheConfig, config.GetNearCacheConfig("doesNotExist"));
     // non-matching case
     Assert.AreNotEqual(nearCacheConfig, config.GetNearCacheConfig("SomeNearCache"));
 }
 public virtual void TestSpecificNearCacheConfig_whenAsteriskInTheMiddle()
 {
     var clientConfig = new ClientConfig();
     var genericNearCacheConfig = new NearCacheConfig();
     genericNearCacheConfig.SetName("map*Bar");
     clientConfig.AddNearCacheConfig(genericNearCacheConfig);
     var specificNearCacheConfig = new NearCacheConfig();
     specificNearCacheConfig.SetName("mapStudent*Bar");
     clientConfig.AddNearCacheConfig(specificNearCacheConfig);
     var mapFoo = clientConfig.GetNearCacheConfig("mapFooBar");
     var mapStudentFoo = clientConfig.GetNearCacheConfig("mapStudentFooBar");
     Assert.AreEqual(genericNearCacheConfig, mapFoo);
     Assert.AreEqual(specificNearCacheConfig, mapStudentFoo);
 }
 public virtual void TestNearCacheConfigWildcardMatchingPointEndsWith()
 {
     NearCacheConfig nearCacheConfig1 = new NearCacheConfig().SetName("*.sub");
     NearCacheConfig nearCacheConfig2 = new NearCacheConfig().SetName("*.test.sub");
     NearCacheConfig nearCacheConfig3 = new NearCacheConfig().SetName("*.hazelcast.test.sub");
     ClientConfig config = new ClientConfig();
     config.SetConfigPatternMatcher(new MatchingPointConfigPatternMatcher());
     config.AddNearCacheConfig(nearCacheConfig1);
     config.AddNearCacheConfig(nearCacheConfig2);
     config.AddNearCacheConfig(nearCacheConfig3);
     // we should not match any of the configs (endsWith)
     Assert.AreEqual(null, config.GetNearCacheConfig("com.hazelFast.Fast.sub.myNearCache"));
     Assert.AreEqual(null, config.GetNearCacheConfig("hazelFast.test.sub.myNearCache"));
     Assert.AreEqual(null, config.GetNearCacheConfig("test.sub.myNearCache"));
 }