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


C# ClientConfig类代码示例

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


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

示例1: 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

示例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 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

示例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 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

示例4: 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

示例5: Main

        static void Main(string[] args)
        {
            try
            {
                if (!File.Exists(FileName))
                {
                    var newRegistry = ProjectGenerator.GenRegistry(3, 10);
                    newRegistry.Save(FileName);
                }

                var registry = XmlRegistry.Load(FileName);

                // Валидация реестра - урлы в проектах и словах
                XmlRegistry.ValidateRegistry(registry);

                //------

                var apiKey = ConfigurationManager.AppSettings["apikey"];
                if (string.IsNullOrEmpty(apiKey))
                {
                    throw new InvalidOperationException(
                        "Invalid 'apikey' setting in application config.");
                }

                var config = new ClientConfig(apiKey);
                var client = new ApiClient(config);

                var syncClient = new SyncClient(client);

                Console.Write("Project's data loading...");
                syncClient.LoadSyncObjects();

                Console.WriteLine();
                Console.Write("Project's synchronization...");
                syncClient.SyncProjects(registry.Projects);

                Console.WriteLine();
                Console.Write("Groups's synchronization...");
                syncClient.SyncGroups(registry.Projects);

                Console.WriteLine();
                Console.Write("Keywords's synchronization...");
                syncClient.SyncKeywords(registry.Projects);

                Console.WriteLine();
                Console.Write("Synchronization completed, press any key...");
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine();
                Console.WriteLine("Error:");
                Console.WriteLine(ex.ToString());
                Console.ResetColor();

                Console.Write("Press any key...");
                Console.ReadKey();
            }
        }
开发者ID:anynomuz,项目名称:topvisor-api,代码行数:60,代码来源:Program.cs

示例6: Sign

 public abstract void Sign(
     IRequest request,
     ClientConfig clientConfig,
     RequestMetrics metrics,
     string awsAccessKeyId,
     string awsSecretAccessKey,
     SecureString secureKey);
开发者ID:shaunbowe,项目名称:aws-sdk-net,代码行数:7,代码来源:AbstractAWSSigner.cs

示例7: 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

示例8: CreateStarted

        /// <summary>
        /// Creates a started client runner.
        /// </summary>
        public static IClientRunner CreateStarted(ClientConfig config)
        {
            Logger.Debug("ClientConfig: {0}", config);

            if (config.AsyncClientThreads != 0)
            {
                Logger.Warning("ClientConfig.AsyncClientThreads is not supported for C#. Ignoring the value");
            }
            if (config.CoreLimit != 0)
            {
                Logger.Warning("ClientConfig.CoreLimit is not supported for C#. Ignoring the value");
            }
            if (config.CoreList.Count > 0)
            {
                Logger.Warning("ClientConfig.CoreList is not supported for C#. Ignoring the value");
            }

            var channels = CreateChannels(config.ClientChannels, config.ServerTargets, config.SecurityParams);

            return new ClientRunnerImpl(channels,
                config.ClientType,
                config.RpcType,
                config.OutstandingRpcsPerChannel,
                config.LoadParams,
                config.PayloadConfig,
                config.HistogramParams,
                () => GetNextProfiler());
        }
开发者ID:ConfusedReality,项目名称:pkg_network_grpc,代码行数:31,代码来源:ClientRunners.cs

示例9: SelectSigner

        /// <summary>
        /// Inspects the supplied evidence to return the signer appropriate for the operation and
        /// precomputes the body hash for the request if AWS4 protocol is selected.
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        private AbstractAWSSigner SelectSigner(ClientConfig config)
        {
            if (UseV4Signing(_useSigV4, config))
                return AWS4SignerInstance;

            return this;
        }
开发者ID:rossmas,项目名称:aws-sdk-net,代码行数:13,代码来源:S3Signer.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 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

示例11: UseV4Signing

        /// <summary>
        /// Inspects the supplied evidence to return the signer appropriate for the operation
        /// </summary>
        /// <param name="useSigV4Setting">Global setting for the service</param>
        /// <param name="config">Configuration for the client</param>
        /// <returns>True if signature v4 request signing should be used</returns>
        protected static bool UseV4Signing(bool useSigV4Setting, ClientConfig config)
        {
            if (useSigV4Setting || config.SignatureVersion == "4")
                return true;

            // do a cascading series of checks to try and arrive at whether we have
            // a recognisable region; this is required to use the AWS4 signer
            RegionEndpoint r = null;
            if (!string.IsNullOrEmpty(config.AuthenticationRegion))
                r = RegionEndpoint.GetBySystemName(config.AuthenticationRegion);

            if (r == null && !string.IsNullOrEmpty(config.ServiceURL))
            {
                var parsedRegion = AWSSDKUtils.DetermineRegion(config.ServiceURL);
                if (!string.IsNullOrEmpty(parsedRegion))
                    r = RegionEndpoint.GetBySystemName(parsedRegion);
            }

            if (r == null && config.RegionEndpoint != null)
                r = config.RegionEndpoint;

            if (r != null)
            {
                var endpoint = r.GetEndpointForService(config.RegionEndpointServiceName);
                if (endpoint != null && endpoint.SignatureVersionOverride == "4")
                    return true;
            }

            return false;
        }
开发者ID:rossmas,项目名称:aws-sdk-net,代码行数:36,代码来源:AbstractAWSSigner.cs

示例12: 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

示例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 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

示例14: 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

示例15: 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


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