public ClusterNodesTest() { this.log = new Mock <ILogger>(); this.config = new Mock <IServicesConfig>(); this.clusteringConfig = new Mock <IClusteringConfig>(); this.enginesFactory = new Mock <IEngines>(); this.clusterNodesStorage = new Mock <IEngine>(); this.clusterNodesStorage.Setup(x => x.BuildRecord(It.IsAny <string>(), It.IsAny <string>())) .Returns((string id, string json) => new DataRecord { Id = id, Data = json }); this.clusterNodesStorage.Setup(x => x.BuildRecord(It.IsAny <string>())) .Returns((string id) => new DataRecord { Id = id }); this.mainStorage = new Mock <IEngine>(); this.mainStorage.Setup(x => x.BuildRecord(It.IsAny <string>(), It.IsAny <string>())) .Returns((string id, string json) => new DataRecord { Id = id, Data = json }); this.clusteringConfig.SetupGet(x => x.NodeRecordMaxAgeSecs).Returns(12045); this.SetupStorageMocks(); this.target = this.GetNewInstance(); }
/// <summary> /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider" /// /> and <see cref="ignoreCase" /> /// </summary> /// <param name="sourceValue">the value to convert into an instance of <see cref="ClusterNodes" />.</param> /// <returns> /// an instance of <see cref="ClusterNodes" />, or <c>null</c> if there is no suitable conversion. /// </returns> public static object ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return(null); } try { ClusterNodes.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString()); } catch { // Unable to use JSON pattern } try { return(new ClusterNodes { HypervisorServerList = sourceValue.HypervisorServerList, }); } catch { } return(null); }
public ClusterNodesTest() { this.log = new Mock <ILogger>(); this.config = new Mock <IServicesConfig>(); this.clusteringConfig = new Mock <IClusteringConfig>(); this.factory = new Mock <IFactory>(); this.clusterNodesStorage = new Mock <IStorageRecords>(); this.mainStorage = new Mock <IStorageRecords>(); this.clusteringConfig.SetupGet(x => x.NodeRecordMaxAgeSecs).Returns(12045); this.SetupStorageMocks(); this.target = this.GetNewInstance(); }
public static Map <ProcessName, ClusterNode> Nodes(ProcessId leaf) => ClusterNodes.Filter(node => node.Role == leaf.Take(1).GetName());