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


C# Cluster类代码示例

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


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

示例1: PreStart

        protected override void PreStart()
        {
            _cluster = Cluster.Get(Context.System);
            _cancelStatusUpdates = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(2), Self, new SendState(), Self);

            base.PreStart();
        }
开发者ID:jurek333,项目名称:CoreWars,代码行数:7,代码来源:ClusterMonitor.cs

示例2: CraterInfo

 public CraterInfo(Cluster c)
 {
     this.x1 = c.MinX;
     this.y1 = c.MinY;
     this.x2 = c.MaxX;
     this.y2 = c.MaxY;
 }
开发者ID:NuzzIndustries,项目名称:TopCoderMarathon2,代码行数:7,代码来源:CraterLists.cs

示例3: Test_GetClusterDisplayLabel

 public void Test_GetClusterDisplayLabel() {
     FlagClusteringStrategy strategy = new FlagClusteringStrategy(typeof(TestFlagEnum));
     ICluster cluster = new Cluster(TestFlagEnum.FlagValue2);
     cluster.Count = 2;
     string result = strategy.GetClusterDisplayLabel(cluster);
     Assert.AreEqual("FlagValue2 (2 items)", result);
 }
开发者ID:xieguigang,项目名称:Reference_SharedLib,代码行数:7,代码来源:TestFlagClusteringStrategy.cs

示例4: When_InValid_Credentials_Provided_Bucket_Created_UnSuccesfully

        public void When_InValid_Credentials_Provided_Bucket_Created_UnSuccesfully()
        {
            try
            {
                var config = ClientConfigUtil.GetConfiguration();
                config.BucketConfigs = new Dictionary<string, BucketConfiguration>
                {
                    {
                        "authenticated",
                        new BucketConfiguration
                        {
                            BucketName = "authenticated"
                        }
                    }
                };

                var cluster = new Cluster(config);
                var bucket = cluster.OpenBucket("authenticated", "secretw");
                cluster.CloseBucket(bucket);
                Assert.IsNotNull(bucket);
            }
            catch (AggregateException e)
            {
                foreach (var exception in e.InnerExceptions)
                {
                    if (exception.GetType() == typeof (AuthenticationException))
                    {
                        throw exception;
                    }
                }
            }
        }
开发者ID:orangeloop,项目名称:couchbase-net-client,代码行数:32,代码来源:BucketAuthenticationTests.cs

示例5: ClusterMetricsCollector

        public ClusterMetricsCollector(IActorRef publisher)
        {
            _publisher = publisher;
            _cluster = Cluster.Get(Context.System);
            Collector = MetricsCollector.Get(Context.System.AsInstanceOf<ExtendedActorSystem>(), _cluster.Settings);
            LatestGossip = MetricsGossip.Empty;
            Nodes = ImmutableHashSet.Create<Address>();

            _metricsCancelable = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(
                _cluster.Settings.PeriodicTasksInitialDelay.Max(_cluster.Settings.MetricsInterval),
                _cluster.Settings.MetricsInterval, Self, InternalClusterAction.MetricsTick.Instance, Self);

            _gossipCancelable = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(
                _cluster.Settings.PeriodicTasksInitialDelay.Max(_cluster.Settings.GossipInterval), 
                _cluster.Settings.GossipInterval, Self, InternalClusterAction.GossipTick.Instance, Self);

            Receive<InternalClusterAction.GossipTick>(tick => Gossip());
            Receive<InternalClusterAction.MetricsTick>(tick => Collect());
            Receive<MetricsGossipEnvelope>(envelope => ReceiveGossip(envelope));
            Receive<ClusterEvent.CurrentClusterState>(state => ReceiveState(state));
            Receive<ClusterEvent.MemberUp>(up => AddMember(up.Member));
            Receive<ClusterEvent.MemberRemoved>(removed => RemoveMember(removed.Member));
            Receive<ClusterEvent.MemberExited>(exited => RemoveMember(exited.Member));
            Receive<ClusterEvent.UnreachableMember>(member => RemoveMember(member.Member));
            Receive<ClusterEvent.ReachableMember>(member =>
            {
                if (member.Member.Status == MemberStatus.Up) AddMember(member.Member);
            });
            Receive<ClusterEvent.IMemberEvent>(@event => { }); //not interested in other types of member event
        }
开发者ID:rogeralsing,项目名称:akka.net,代码行数:30,代码来源:ClusterMetricsCollector.cs

示例6: TestFixtureSetUp

        public void TestFixtureSetUp()
        {
            _cluster = new Cluster("couchbaseClients/couchbase");

            using (var bucket = _cluster.OpenBucket())
            {
                bucket.Upsert(TestKeys.KeyWithInt32Value.Key, TestKeys.KeyWithInt32Value.Value);
                bucket.Upsert(TestKeys.KeyWithStringValue.Key, TestKeys.KeyWithStringValue.Value);

                // ISO-8601 and Microsoft JSON Date format:
                bucket.Upsert(TestKeys.KeyWithIsoDateValue.Key, TestKeys.KeyWithIsoDateValue.Value);
                bucket.Upsert(TestKeys.KeyWithIsoUtcDateValue.Key, TestKeys.KeyWithIsoUtcDateValue.Value);
                bucket.Upsert(TestKeys.KeyWithMsDateValue.Key, TestKeys.KeyWithMsDateValue.Value);

                // De-Serialize const JSON string into a Dictionary<string, dynamic> and write via bucket.Upsert(Couchbase.Document<dynamic>)
                var ADict = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(TestKeys.KeyWithJsonDocValueStr);
                var couchDoc = new Couchbase.Document<dynamic>()
                {
                    Id = TestKeys.KeyWithJsonDocKey,
                    Content = ADict
                };
                bucket.Upsert(couchDoc);


            }
        }
开发者ID:wpostma,项目名称:couchbase-net-client,代码行数:26,代码来源:GetOperationTests.cs

示例7: SetRenderData

        public void SetRenderData(Cluster cluster)
        {
            if (cluster.RenderTag == null)
                cluster.RenderTag = new ClusterRenderer();

            (cluster.RenderTag as ClusterRenderer).Update(cluster);
        }
开发者ID:JeffM2501,项目名称:HackSharp,代码行数:7,代码来源:Renderer.cs

示例8: PreStart

        /// <summary>
        /// Need to subscribe to cluster changes
        /// </summary>
        protected override void PreStart()
        {
            this.cluster = Cluster.Get(Context.System);
            this.cluster.Subscribe(
                this.Self,
                ClusterEvent.InitialStateAsEvents,
                new[] { typeof(ClusterEvent.IClusterDomainEvent) });

            Context.GetLogger().Debug(
                "{Type}: Cluster log up",
                this.GetType().Name);

            var seeds = Context.System.Settings.Config.GetStringList("akka.cluster.seed-nodes");
            if (seeds != null && seeds.Count > 0)
            {
                Context.GetLogger().Debug(
                "{Type}: Joining cluster",
                this.GetType().Name);
                this.cluster.JoinSeedNodes(seeds.Select(Address.Parse));
            }

            

            this.cluster.RegisterOnMemberUp(
                () =>
                    {
                        Context.GetLogger().Debug("{Type}: Cluster connection is up", this.GetType().Name);
                    });
        }
开发者ID:kantora,项目名称:ClusterKit,代码行数:32,代码来源:ClusterLoggingActor.cs

示例9: Start

 void Start()
 {
     cluster = gameObject.GetComponent<Cluster>();
     stageScript = gameObject.GetComponent<Stage> ();
     mouseDragged = Vector3.zero;
     mousePressed = Vector3.zero;
 }
开发者ID:dvdfu,项目名称:pixel-party,代码行数:7,代码来源:InputManager.cs

示例10: Estimate

        private bool Estimate(Cluster cluster)
        {
            var name = Guid.NewGuid().ToString("D");

            var value =
                (new DSet<int> { Name = name, Cluster = cluster })
                .SourceI(NumPartitions, i => Enumerable.Range(1, NumSamplesPerPartition).Select(j => i * NumSamplesPerPartition + j))
                .Select(i =>
                         {
                             var rnd = new Random(i);
                             var x = rnd.NextDouble();
                             var y = rnd.NextDouble();
                             if (x * x + y * y < 1.0)
                                 return 1.0;
                             else
                                 return 0.0;
                         }
                )
                .Aggregate((a, b) => a + b);

            var pi = (value * 4.0) / NumSamples;

            Console.WriteLine("Estimate Pi value: {0}", pi);
            return Math.Abs(pi - Math.PI) < 0.1;
        }
开发者ID:hongzhili,项目名称:Prajna,代码行数:25,代码来源:PiEstimation.cs

示例11: QueryRecordExecutor

 public QueryRecordExecutor(Cluster cluster, QueryPolicy policy, Statement statement)
     : base(cluster, policy, statement)
 {
     this.recordSet = new RecordSet(this, policy.recordQueueSize, cancel.Token);
     statement.Prepare(true);
     InitializeThreads();
 }
开发者ID:Caldas,项目名称:aerospike-client-csharp,代码行数:7,代码来源:QueryRecordExecutor.cs

示例12: Test

        public void Test()
        {
            var keyValues = new Dictionary<string, string>();
            using (var cluster = new Cluster())
            {
                using (var bucket = cluster.OpenBucket())
                {
                    for (int i = 0; i <10; i++)
                    {
                        var key = "MGETKEY" + i;
                        var value = "{\"val:\"MGETVALUE" + i +"\"}";
                        bucket.Upsert(key, value);
                        keyValues.Add(key, value);
                    }

                    foreach (var keyValue in keyValues)
                    {
                        Console.WriteLine(bucket.Get<dynamic>(keyValue.Key).Value);
                    }
                }
            }

            var operations = new ConcurrentDictionary<uint, IOperation>();
            foreach (var keyValue in keyValues)
            {
                var getk = new GetK<dynamic>(keyValue.Key, GetVBucket(), Converter, Transcoder);
                operations.TryAdd(getk.Opaque, getk);
            }
            var noop = new Noop(Converter);
            operations.TryAdd(noop.Opaque, noop);

            var results = IOStrategy.Execute<dynamic>(operations);
        }
开发者ID:orangeloop,项目名称:couchbase-net-client,代码行数:33,代码来源:MultiGetTests.cs

示例13: Test_Timed_Execution_Parallel_Client

        public void Test_Timed_Execution_Parallel_Client()
        {
            var options = new ParallelOptions { MaxDegreeOfParallelism = 4 };
            var n = 1000;//set to a higher # if needed

            using (var cluster = new Cluster("couchbaseClients/couchbase"))
            {
                using (var bucket = cluster.OpenBucket())
                {
                    using (new OperationTimer())
                    {
                        var temp = bucket;
                        Parallel.For(0, n, options, i =>
                        {
                            var key = string.Format("key{0}", i);
                            var value = (int?) i;
                            var result = temp.Upsert(key, value);
                            Assert.IsTrue(result.Success);

                            var result1 = temp.Get<int?>(key);
                            Assert.IsTrue(result1.Success);
                            Assert.AreEqual(i, result1.Value);
                        });
                    }
                }
            }
        }
开发者ID:orangeloop,项目名称:couchbase-net-client,代码行数:27,代码来源:GetSetPerformanceTests.cs

示例14: GetBucketForKey

        public IBucket GetBucketForKey(string key)
        {
            var config = new ClientConfiguration();
            var fakeServer = new FakeServer(_connectionPool, null, null, _endPoint,
                new FakeIOService(_endPoint, _connectionPool, false));

            var mockVBucket = new Mock<IVBucket>();
            mockVBucket.Setup(x => x.LocatePrimary()).Returns(fakeServer);

            var mockKeyMapper = new Mock<IKeyMapper>();
            mockKeyMapper.Setup(x => x.MapKey(key, It.IsAny<uint>())).Returns(mockVBucket.Object);

            var mockConfigInfo = new Mock<IConfigInfo>();
            mockConfigInfo.Setup(x => x.GetKeyMapper()).Returns(mockKeyMapper.Object);
            mockConfigInfo.Setup(x => x.BucketConfig).Returns(_bucketConfig);
            mockConfigInfo.Setup(x => x.GetServer()).Returns(fakeServer);
            mockConfigInfo.Setup(x => x.IsDataCapable).Returns(true);
            mockConfigInfo.Setup(x => x.ClientConfig).Returns(new ClientConfiguration());

            var mockController = new Mock<IClusterController>();
            mockController.Setup(x => x.Configuration).Returns(config);
            mockController.Setup(x => x.CreateBucket("default", "", null))
                .Returns(new CouchbaseBucket(mockController.Object, "default", _converter, _transcoder, null));

            var cluster = new Cluster(config, mockController.Object);
            var bucket = cluster.OpenBucket("default", "");

            //simulate a config event
            ((IConfigObserver)bucket).NotifyConfigChanged(mockConfigInfo.Object);

            return bucket;
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:32,代码来源:CouchbaseBucket_Async_Tests.cs

示例15: When_Bucket_Is_Not_Open_IsOpen_Returns_False

 public void When_Bucket_Is_Not_Open_IsOpen_Returns_False()
 {
     var cluster = new Cluster("couchbaseClients/couchbase");
     var bucket = cluster.OpenBucket("default");
     cluster.CloseBucket(bucket);
     Assert.IsFalse(cluster.IsOpen("default"));
 }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:7,代码来源:ClusterTests.cs


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