public static NodeExt[] ReorderToServerList(this NodeExt[] nodes, VBucketServerMap serverMap) { if (nodes == null) return null; var reordered = new NodeExt[nodes.Length]; var serversList = serverMap.ServerList; if (serversList == null || serversList.Length == 0) { reordered = nodes; } else { for (var i = 0; i < serversList.Length; i++) { var host = serversList[i].Split(':')[0]; foreach (var n in nodes.Where(n => n.Hostname != null && n.Hostname.Split(':')[0].Equals(host))) { reordered[i] = n; break; } } for (var i = 0; i < nodes.Length; i++) { var cur = nodes[i]; if (!reordered.Contains(cur)) { reordered[i] = cur; } } } return reordered; }
public static NodeExt[] ReorderToServerList(this NodeExt[] nodes, VBucketServerMap serverMap) { if (nodes == null) { return(null); } var reordered = new NodeExt[nodes.Length]; var serversList = serverMap.ServerList; if (serversList == null || serversList.Length == 0) { reordered = nodes; } else { for (var i = 0; i < serversList.Length; i++) { var host = serversList[i].Split(':')[0]; foreach (var n in nodes.Where(n => n.Hostname != null && n.Hostname.Split(':')[0].Equals(host))) { reordered[i] = n; break; } } } return(reordered); }
public NodeAdapter(Node node, NodeExt nodeExt) { _node = node; _nodeExt = nodeExt; //normalize the interfaces providing defaults where applicable Hostname = nodeExt == null ? node.Hostname : nodeExt.Hostname; Hostname = Hostname ?? node.Hostname; //strip off the admin port - we can use services if (Hostname.Contains(":")) { var hostAndPorts = Hostname.Split(':'); Hostname = hostAndPorts[0]; if (Hostname.Contains("$HOST")) { Hostname = "localhost"; } MgmtApi = int.Parse(hostAndPorts[1]); } if (_node != null) { CouchbaseApiBase = _node.CouchApiBase.Replace("$HOST", Hostname); CouchbaseApiBaseHttps = _node.CouchApiBaseHttps; } if (nodeExt == null) { MgmtApiSsl = node.Ports.HttpsMgmt; Moxi = node.Ports.Proxy; KeyValue = node.Ports.Direct; KeyValueSsl = node.Ports.SslDirect; ViewsSsl = node.Ports.HttpsCapi; Views = new Uri(CouchbaseApiBase).Port; } else { MgmtApi = _nodeExt.Services.Mgmt; MgmtApiSsl = _nodeExt.Services.MgmtSSL; Views = _nodeExt.Services.Capi; ViewsSsl = _nodeExt.Services.CapiSSL; Moxi = _nodeExt.Services.Moxi; KeyValue = _nodeExt.Services.KV; KeyValueSsl = _nodeExt.Services.KvSSL; Projector = _nodeExt.Services.Projector; IndexAdmin = _nodeExt.Services.IndexAdmin; IndexScan = _nodeExt.Services.IndexScan; IndexHttp = _nodeExt.Services.IndexHttp; IndexStreamInit = _nodeExt.Services.IndexStreamInit; IndexStreamCatchup = _nodeExt.Services.IndexStreamCatchup; IndexStreamMaint = _nodeExt.Services.IndexStreamMaint; N1QL = _nodeExt.Services.N1QL; N1QLSsl = _nodeExt.Services.N1QLSsl; Fts = _nodeExt.Services.Fts; } }
public static IPEndPoint GetEndPoint(NodeExt nodeExt, BucketConfiguration bucketConfig, IBucketConfig serverConfig) { var address = nodeExt.Hostname.Split(':').First(); IPAddress ipAddress; if (!IPAddress.TryParse(address, out ipAddress)) { var uri = new Uri(String.Format("http://{0}", address)); ipAddress = uri.GetIpAddress(ClientConfiguration.UseInterNetworkV6Addresses); if (ipAddress == null) { throw new ArgumentException("ipAddress"); } } var port = bucketConfig.UseSsl ? nodeExt.Services.KvSSL : nodeExt.Services.KV; return new IPEndPoint(ipAddress, port); }