当前位置: 首页>>代码示例>>C#>>正文


C# ClientConfig.GetNetworkConfig方法代码示例

本文整理汇总了C#中ClientConfig.GetNetworkConfig方法的典型用法代码示例。如果您正苦于以下问题:C# ClientConfig.GetNetworkConfig方法的具体用法?C# ClientConfig.GetNetworkConfig怎么用?C# ClientConfig.GetNetworkConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ClientConfig的用法示例。


在下文中一共展示了ClientConfig.GetNetworkConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();
            config.GetNetworkConfig().AddAddress("127.0.0.1");
            var client = HazelcastClient.NewHazelcastClient(config);

            var map = client.GetMap<string, string>("listener-example");

            var cdown = new CountdownEvent(2);
            map.AddEntryListener(new EntryAdapter<string, string>
            {
                Added = e =>
                {
                    Console.WriteLine("Key '{0}' with value ' {1}' was added.", e.GetKey(), e.GetValue());
                    cdown.Signal();
                },
                Removed = e =>
                {
                    Console.WriteLine("Key '{0}' with value ' {1}' was removed.", e.GetKey(), e.GetOldValue());
                    cdown.Signal();
                }
            }, true);

            map.Put("key", "value");
            map.Remove("key");

            cdown.Wait();
            map.Destroy();
        }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:32,代码来源:MapListenerExample.cs

示例2: Run

        public static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();
            config.GetNetworkConfig().AddAddress("127.0.0.1");
            var client = HazelcastClient.NewHazelcastClient(config);

            var semaphore = client.GetSemaphore("example-semaphore");
            semaphore.Init(1);
            var i = 0;
            Action increment = () =>
            {
                for (var j = 0; j < 100; j++)
                {
                    semaphore.Acquire();
                    try
                    {
                        i++;
                    }
                    finally
                    {
                        semaphore.Release();
                    }
                }
            };

            var task1 = Task.Factory.StartNew(increment);
            var task2 = Task.Factory.StartNew(increment);

            Task.WaitAll(task1, task2);
            Console.WriteLine("Final value: " + i);
            semaphore.Destroy();
        }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:35,代码来源:SemaphoreExample.cs

示例3: Run

        private static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();
            config.GetNetworkConfig().AddAddress("127.0.0.1");
            var client = HazelcastClient.NewHazelcastClient(config);

            var list = client.GetList<string>("collection-listener-example");
            var cdown = new CountdownEvent(3);
            list.AddItemListener(new ItemListener<string>
            {
                OnItemAdded = e =>
                {
                    Console.WriteLine("Item added: " + e.GetItem());
                    cdown.Signal();
                },
                OnItemRemoved = e =>
                {
                    Console.WriteLine("Item removed: " + e.GetItem());
                    cdown.Signal();
                }
            }, true);

            list.Add("item1");
            list.Add("item2");
            list.Remove("item1");

            cdown.Wait();
            list.Destroy();
            client.Shutdown();
        }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:33,代码来源:CollectionListenerExample.cs

示例4: Run

        public static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();
            config.GetNetworkConfig().AddAddress("127.0.0.1");
            var client = HazelcastClient.NewHazelcastClient(config);

            var generator = client.GetIdGenerator("example-id-generator");

            generator.Init(1000);

            Action generateId = () =>
            {
                for (var i = 0; i < 100; i++)
                {
                    Console.WriteLine("Generated id: " + generator.NewId());
                }
            };
            var task1 = Task.Factory.StartNew(generateId);
            var task2 = Task.Factory.StartNew(generateId);

            Task.WaitAll(task1, task2);
            generator.Destroy();
        }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:26,代码来源:IdGeneratorExample.cs

示例5: Run

        private static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();
            config.GetNetworkConfig().AddAddress("127.0.0.1");
            var client = HazelcastClient.NewHazelcastClient(config);

            var list = client.GetList<string>("list-example");

            list.Add("item1");
            list.Add("item2");
            list.Add("item3");

            Console.WriteLine("Get: " + list[0]);

            Console.WriteLine("Enumerator : " + string.Join(", ", list));

            Console.WriteLine("Contains: " + string.Join(", ", list.Contains("item2")));

            Console.WriteLine("Count: " + string.Join(", ", list.Count));

            Console.WriteLine("Sublist: " + string.Join(", ", list.SubList(0, 2)));

            list.Destroy();
            client.Shutdown();
        }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:28,代码来源:ListExample.cs

示例6: Run

        private static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();
            config.GetNetworkConfig().AddAddress("127.0.0.1");
            var client = HazelcastClient.NewHazelcastClient(config);

            var map = client.GetMap<string, string>("simple-example");

            map.Put("key", "value");
            map.Put("key2", "value2");

            Console.WriteLine("Key: " + map.Get("key"));

            Console.WriteLine("Values : " + string.Join(", ", map.Values()));

            Console.WriteLine("KeySet: " + string.Join(", ", map.KeySet()));

            Console.WriteLine("Size: " + string.Join(", ", map.Size()));

            Console.WriteLine("EntrySet: " + string.Join(", ", map.EntrySet()));

            Console.WriteLine("ContainsKey: " + string.Join(", ", map.ContainsKey("key")));

            Console.WriteLine("ContainsValue: " + string.Join(", ", map.ContainsValue("value")));

            map.Destroy();
            client.Shutdown();
        }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:31,代码来源:MapSimpleExample.cs

示例7: Run

        private static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();
            config.GetNetworkConfig().AddAddress("127.0.0.1");
            var client = HazelcastClient.NewHazelcastClient(config);

            var topic = client.GetTopic<string>("topic-example");

            var countdown = new CountdownEvent(100);
            topic.AddMessageListener(m =>
            {
                Console.WriteLine("Got message: " + m.GetMessageObject());
                countdown.Signal();
            });

            var publisher = Task.Factory.StartNew(() =>
            {
                for (var i = 0; i < 100; i++)
                {
                    topic.Publish("Message " + i);
                }
            });

            countdown.Wait();

            topic.Destroy();
            client.Shutdown();
        }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:31,代码来源:TopicExample.cs

示例8: Run

        private static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();
            config.GetNetworkConfig().AddAddress("127.0.0.1");
            var client = HazelcastClient.NewHazelcastClient(config);

            var map = client.GetMap<string, string>("map-lock-example");

            map.Put("key", "value");

            map.Lock("key");
            var task = Task.Factory.StartNew(() =>
            {
                map.Put("key", "newValue");
                Console.WriteLine("Put new value");
            });
            try
            {
                var value = map.Get("key");
                //do something with the value..
                Thread.Sleep(5000);
            }
            finally
            {
                map.Unlock("key");
            }
            task.Wait();

            Console.WriteLine("New value: " + map.Get("key"));
        }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:33,代码来源:MapLockExample.cs

示例9: Run

        public static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();
            
            config.GetNetworkConfig().AddAddress("127.0.0.1");
            config.GetSerializationConfig()
                .AddDataSerializableFactory(ExampleDataSerializableFactory.FactoryId,
                    new ExampleDataSerializableFactory());

            var client = HazelcastClient.NewHazelcastClient(config);

            var map = client.GetMap<int, Employee>("identified-data-serializable-example");

            var employee = new Employee { Id = 1, Name = "the employee"};

            Console.WriteLine("Adding employee: " + employee);

            map.Put(employee.Id, employee);

            var e = map.Get(employee.Id);

            Console.WriteLine("Gotten employee: " + e);

            client.Shutdown();
        }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:28,代码来源:MapIdentifiedDataSerializableExample.cs

示例10: Run

        private static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();
            config.GetNetworkConfig().AddAddress("127.0.0.1");
            var client = HazelcastClient.NewHazelcastClient(config);

            var options = new TransactionOptions();
            options.SetTransactionType(TransactionOptions.TransactionType.OnePhase);
            var ctx = client.NewTransactionContext(options);
            ctx.BeginTransaction();
            try
            {
                var txMap = ctx.GetMap<string, string>("txn-map");
                txMap.Put("foo", "bar");
                ctx.CommitTransaction();
            }
            catch
            {
                ctx.RollbackTransaction();
            }

            var map = client.GetMap<string, string>("txn-map");
            Console.WriteLine("Value of foo is " + map.Get("key"));
            map.Destroy();
            client.Shutdown();
        }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:29,代码来源:SimpleTransactionExample.cs

示例11: Run

        private static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();
            config.GetNetworkConfig().AddAddress("127.0.0.1");
            var client = HazelcastClient.NewHazelcastClient(config);

            var ringbuffer = client.GetRingbuffer<string>("ringbuffer-example");

            var writer = Task.Factory.StartNew(() =>
            {
                for (var i = 0; i < 100; i++)
                {
                    ringbuffer.Add("item " + i);
                }
            });

            var reader = Task.Factory.StartNew(() =>
            {
                var sequence = ringbuffer.HeadSequence();
                while (sequence < 100)
                {
                    var item = ringbuffer.ReadOne(sequence++);
                    Console.WriteLine("Reading value " + item);
                }
            });

            Task.WaitAll(reader, writer);
            ringbuffer.Destroy();
            client.Shutdown();
        }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:33,代码来源:RingbufferExample.cs

示例12: Run

        public static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();
            config.GetNetworkConfig().AddAddress("127.0.0.1");
            var client = HazelcastClient.NewHazelcastClient(config);

            var latch = client.GetCountDownLatch("countdown-latch-example");

            latch.TrySetCount(2);

            var task1 = Task.Factory.StartNew(() =>
            {
                //do some work
                Thread.Sleep(5000);
                latch.CountDown();
            });

            var task2 = Task.Factory.StartNew(() =>
            {
                //do some work
                Thread.Sleep(10000);
                latch.CountDown();
            });

            latch.Await(20, TimeUnit.Seconds);
            Console.WriteLine("Tasks completed");
            latch.Destroy();
        }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:31,代码来源:CountdownLatchExample.cs

示例13: Run

        private static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();
            config.GetNetworkConfig().AddAddress("127.0.0.1");
            var client = HazelcastClient.NewHazelcastClient(config);

            var queue = client.GetQueue<string>("queue-example");

            var producer = Task.Factory.StartNew(() =>
            {
                for (var i = 0; i < 100; i++)
                {
                    queue.Offer("value " + i);
                }
            });

            var consumer = Task.Factory.StartNew(() =>
            {
                var nConsumed = 0;
                string e;
                while (nConsumed++ < 100 && (e = queue.Take()) != null)
                {
                    Console.WriteLine("Consuming " + e);
                }
            });

            Task.WaitAll(producer, consumer);
            queue.Destroy();
            client.Shutdown();
        }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:33,代码来源:QueueExample.cs

示例14: Mainwq

        //    static HazelcastInstance second;
        /// <exception cref="System.Exception"></exception>
        public static void Mainwq(string[] args)
        {
            var config = new ClientConfig();
            config.GetNetworkConfig().AddAddress("127.0.0.1");
            var client = HazelcastClient.NewHazelcastClient(config);

            q = client.GetQueue<object>("test");
            Test1();
        }
开发者ID:ihsandemir,项目名称:hazelcast-csharp-client,代码行数:11,代码来源:ClientQueuePerformanceTest.cs

示例15: Main2

        static void Main2(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var clientConfig = new ClientConfig();
            clientConfig.GetNetworkConfig().AddAddress("127.0.0.1");
            var hc = HazelcastClient.NewHazelcastClient(clientConfig);
            var listener1 = new EntryAdapter<string, string>(
                @event => Console.WriteLine("ADD"),
                @event => Console.WriteLine("REMOVE"),
                @event => Console.WriteLine("UPDATE"),
                @event => Console.WriteLine("EVICTED"));

            var map = hc.GetMap<string, string>("default");
            string reg1 = map.AddEntryListener(listener1, false);
        }
开发者ID:hasancelik,项目名称:hazelcast-csharp-client,代码行数:16,代码来源:ListenerApp.cs


注:本文中的ClientConfig.GetNetworkConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。