public void Info(String info, Dictionary<String, NameValuePair> map, bool merge) { /* type=device;objects=0;master-objects=0;prole-objects=0;expired-objects=0;evicted-objects=0; \ set-deleted-objects=0;set-evicted-objects=0;used-bytes-memory=18688;data-used-bytes-memory=0; \ index-used-bytes-memory=0;sindex-used-bytes-memory=18688;free-pct-memory=99;max-void-time=0; \ min-evicted-ttl=0;max-evicted-ttl=0;non-expirable-objects=0;current-time=137899728; \ stop-writes=false;hwm-breached=false;available-bin-names=32767;ldt_reads=0;ldt_read_success=0; \ ldt_deletes=0;ldt_delete_success=0;ldt_writes=0;ldt_write_success=0;ldt_updates=0;ldt_errors=0; \ used-bytes-disk=0;free-pct-disk=100;available_pct=99;sets-enable-xdr=true;memory-size=4294967296; \ low-water-pct=0;high-water-disk-pct=50;high-water-memory-pct=60;evict-tenths-pct=5; \ stop-writes-pct=90;cold-start-evict-ttl=4294967295;repl-factor=1;default-ttl=2592000;max-ttl=0; \ conflict-resolution-policy=generation;allow_versions=false;single-bin=false;enable-xdr=false; \ disallow-null-setname=false;total-bytes-memory=4294967296;total-bytes-disk=4294967296; \ defrag-period=10;defrag-max-blocks=4000;defrag-lwm-pct=45;write-smoothing-period=0; \ defrag-startup-minimum=10;max-write-cache=67108864;min-avail-pct=5;post-write-queue=0; \ data-in-memory=true;load-at-startup=true;file=/opt/aerospike/test.data;filesize=4294967296; \ writethreads=1;writecache=67108864;obj-size-hist-max=100 */ if (map == null) return; if (info.Length == 0) return; String[] parts = info.Split (';'); foreach (String part in parts) { String[] kv = part.Split ('='); String key = kv [0]; String value = kv [1]; NameValuePair storedValue = null; if (!map.TryGetValue (key, out storedValue)) { storedValue = new NameValuePair (this, key, value); map [key] = storedValue; } else { if (merge && !dontMerge.Contains (key)) { try { long newValue = Int64.Parse (value); long oldValue = Int64.Parse (storedValue.value.ToString ()); storedValue.value = (oldValue + newValue); } catch (FormatException) { storedValue.value = value; } } else { storedValue.value = value; } } } }
public void Info(String info) { //ns_name=test:set_name=demo:n_objects=1:set-stop-write-count=0:set-evict-hwm-count=0:set-enable-xdr=use-default:set-delete=false if (info.Length > 0){ String[] parts = info.Split(':'); if (values == null){ values = new Dictionary<String, NameValuePair>(); } foreach (String part in parts){ String[] kv = part.Split('='); String key = kv[0]; String value = kv[1]; NameValuePair storedValue = null; if (!values.TryGetValue(key, out storedValue)){ storedValue = new NameValuePair(this, key, value); values.Add(key, storedValue); } else { storedValue.value = value; } } this.name = (String) values["set_name"].value; } }
public List<NameValuePair> GetValues() { List<NameValuePair> result = new List<NameValuePair>(); foreach(var item in this.values) { String value = this.values[item.Key]; NameValuePair nvp = new NameValuePair(this, item.Key, value); result.Add(nvp); } return result; }
public void MergeSetInfo(String info) { //ns_name=test:set_name=demo:n_objects=1:set-stop-write-count=0:set-evict-hwm-count=0:set-enable-xdr=use-default:set-delete=false if (info.Length > 0){ String[] parts = info.Split(':'); if (values == null){ values = new Dictionary<String, NameValuePair>(); } foreach (String part in parts){ String[] kv = part.Split('='); String key = kv[0]; String value = kv[1]; NameValuePair storedValue = null; if (values.TryGetValue(key, out storedValue)){ long newValue = 0; long oldValue = 0; if (Int64.TryParse(value, out newValue) && Int64.TryParse(storedValue.value.ToString(), out oldValue)) { storedValue.value = (oldValue + newValue).ToString(); storedValue.value = value; } } else { storedValue = new NameValuePair(this, key, value); values[key] = storedValue; } } this.name = null; NameValuePair nameVal; if (values.TryGetValue("set_name", out nameVal)){ this.name = nameVal.Value.ToString(); } else { this.name = ""; } } }
public static List<NameValuePair> ToNameValuePair(Object parent, Dictionary<String, String> map) { List<NameValuePair> list = new List<NameValuePair>(); foreach (KeyValuePair<string, string> pair in map) { NameValuePair nvp = new NameValuePair(parent, pair.Key, pair.Value); list.Add(nvp); } return list; }