本文整理汇总了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();
}
示例2: CraterInfo
public CraterInfo(Cluster c)
{
this.x1 = c.MinX;
this.y1 = c.MinY;
this.x2 = c.MaxX;
this.y2 = c.MaxY;
}
示例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);
}
示例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;
}
}
}
}
示例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
}
示例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);
}
}
示例7: SetRenderData
public void SetRenderData(Cluster cluster)
{
if (cluster.RenderTag == null)
cluster.RenderTag = new ClusterRenderer();
(cluster.RenderTag as ClusterRenderer).Update(cluster);
}
示例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);
});
}
示例9: Start
void Start()
{
cluster = gameObject.GetComponent<Cluster>();
stageScript = gameObject.GetComponent<Stage> ();
mouseDragged = Vector3.zero;
mousePressed = Vector3.zero;
}
示例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;
}
示例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();
}
示例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);
}
示例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);
});
}
}
}
}
示例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;
}
示例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"));
}