2 using System.Collections.Generic;
3 using System.Text.RegularExpressions;
6 namespace kinetica.Utils
38 IDictionary<string, string> system_properties = db.showSystemProperties().property_map;
41 string multi_head_ingestion_param;
42 system_properties.TryGetValue(ShowSystemPropertiesResponse.PropertyMap.CONF_ENABLE_WORKER_HTTP_SERVERS, out multi_head_ingestion_param);
43 if (multi_head_ingestion_param == null)
45 bool is_multi_head_ingest_enabled = multi_head_ingestion_param.Equals(ShowSystemPropertiesResponse.PropertyMap.TRUE);
48 if (!is_multi_head_ingest_enabled)
56 string worker_urls_str;
57 system_properties.TryGetValue(
"conf.worker_http_server_urls", out worker_urls_str);
58 if ( worker_urls_str.Length > 0 )
63 string[] worker_url_lists = worker_urls_str.Split(
';');
67 for (
int i = 1; i < worker_url_lists.Length; ++i)
69 string url_list = worker_url_lists[i];
72 string[] urls = url_list.Split(
',');
74 bool matching_url_found =
false;
77 foreach (
string url_str
in urls)
84 matching_url_found = ip_regex.IsMatch(url_str);
86 matching_url_found =
true;
88 if (matching_url_found)
90 Uri url =
new Uri( url_str );
103 if (!matching_url_found)
110 string worker_ips_str, worker_ports_str;
111 system_properties.TryGetValue(ShowSystemPropertiesResponse.PropertyMap.CONF_WORKER_HTTP_SERVER_IPS, out worker_ips_str);
112 system_properties.TryGetValue(ShowSystemPropertiesResponse.PropertyMap.CONF_WORKER_HTTP_SERVER_PORTS, out worker_ports_str);
115 if (worker_ips_str.Length == 0)
117 if (worker_ports_str.Length == 0)
123 string[] worker_ip_lists = worker_ips_str.Split(
';');
124 string[] worker_ports = worker_ports_str.Split(
';');
127 if (worker_ip_lists.Length != worker_ports.Length)
134 for (
int i = 1; i < worker_ip_lists.Length; ++i)
136 string ip_list = worker_ip_lists[i];
139 string[] ips = ip_list.Split(
',');
141 bool matching_ip_found =
false;
144 foreach (
string ip
in ips)
150 if (ip_regex != null)
151 matching_ip_found = ip_regex.IsMatch(ip);
153 matching_ip_found =
true;
155 if (matching_ip_found)
157 UriBuilder uri_builder =
new UriBuilder( db.
URL.Scheme,
158 ip, Int32.Parse(worker_ports[i]) );
159 Uri url = uri_builder.Uri;
172 if (!matching_ip_found)
A list of worker URLs to use for multi-head ingest.
A set of results returned by Kinetica.showSystemProperties(IDictionary{string, string}).
Uri URL
URL for Kinetica Server (including "http:" and port)
WorkerList()
Creates an empty WorkerList that can be populated manually with worker URLs to support multi-head ing...
WorkerList(Kinetica db, Regex ip_regex=null)
Creates a WorkerList object and automatically populates it with the worker URLs from GPUdb to support...
API to talk to Kinetica Database