public Partitioner(CancellationToken token, CloudIndex idx, INameService namesvc, ITaskQueue taskqueue, ReplicationMode replicationMode, int minimalRedundancy) { Log.WriteLine($"{nameof(Partitioner)}: Initializing. ReplicationMode={replicationMode}, MinimumReplica={minimalRedundancy}"); m_cancel = token; m_idx = idx; m_namesvc = namesvc; m_taskqueue = taskqueue; m_repmode = replicationMode; m_minreplicas = minimalRedundancy; m_partitionerproc = Utils.Daemon(m_cancel, "PartitionerProc", 10000, PartitionerProc); }
public HealthMonitor(CancellationToken token, INameService namesvc, CloudIndex idx, IHealthManager healthmgr, int redundancy) { m_cancel = token; m_namesvc = namesvc; m_healthmgr = healthmgr; m_idx = idx; m_redundancy = redundancy; m_mc = DynamicMemoryCloud.Instance; m_part_ev = new AsyncManualResetEvent(false); m_cloud_ev = new AsyncManualResetEvent(false); m_parthealthproc = Utils.Daemon(m_cancel, "PartitionHealthMonitor", 20000, PartitionHealthMonitorProc); m_rephealthproc = Utils.Daemon(m_cancel, "ReplicaHealthMonitor", 20000, ReplicaHealthMonitorProc); m_cloudhealthproc = Utils.Daemon(m_cancel, "MemoryCloudHealthMonitor", 20000, MemoryCloudHealthMonitorProc); }
private void InitCloudIndex(bool isMaster, int partitionCount, int resolvePartition, Func <int, Partition> ptable = null) { CancellationTokenSource tsrc = new CancellationTokenSource(); var namesvc = Mock.Of <INameService>(); var ctable = Mock.Of <IChunkTable>(); Guid id = Guid.NewGuid(); Mock.Get(namesvc).Setup(svc => svc.IsMaster).Returns(isMaster); Mock.Get(namesvc).Setup(svc => svc.PartitionCount).Returns(partitionCount); Mock.Get(namesvc).Setup(svc => svc.InstanceId).Returns(id); Mock.Get(namesvc).Setup(svc => svc.ResolvePartition(resolvePartition)) .ReturnsAsync(new List <ReplicaInformation> { new ReplicaInformation("localhost", 9999, id, 0) }); CloudIndex _ci = new CloudIndex(tsrc.Token, namesvc, ctable, null, "myname", ptable); ci = _ci; }
public async Task CloudIndexProbesNameservice() { CancellationTokenSource tsrc = new CancellationTokenSource(); var namesvc = Mock.Of <INameService>(); var ctable = Mock.Of <IChunkTable>(); Guid id = Guid.NewGuid(); Mock.Get(namesvc).Setup(svc => svc.IsMaster).Returns(true); Mock.Get(namesvc).Setup(svc => svc.PartitionCount).Returns(1); Mock.Get(namesvc).Setup(svc => svc.InstanceId).Returns(id); Mock.Get(namesvc).Setup(svc => svc.ResolvePartition(0)) .ReturnsAsync(new List <ReplicaInformation> { new ReplicaInformation("localhost", 9999, id, 0) }); CloudIndex ci = new CloudIndex(tsrc.Token, namesvc, ctable, null, "myname", _ => null); await Task.Delay(1000); Mock.Get(namesvc).Verify(_ => _.PartitionCount, Times.AtLeastOnce); Mock.Get(namesvc).Verify(_ => _.ResolvePartition(It.IsAny <int>()), Times.AtLeastOnce); }