<commit_before>// isDefined tests
test("cluster creating", function() {
	var state = JSON.parse('{"cluster_name":"elasticsearch","version":20,"master_node":"ijZWlj2cSfOecB8IXY2P4g","blocks":{"indices":{"qux":{"4":{"description":"index closed","retryable":false,"levels":["read","write"]}}}},"nodes":{"bisY7wgCSa67QMba_NOR4Q":{"name":"Ringleader","transport_address":"inet[/192.168.2.106:9301]","attributes":{}},"ijZWlj2cSfOecB8IXY2P4g":{"name":"Metal Master","transport_address":"inet[/192.168.2.106:9300]","attributes":{}}},"metadata":{"templates":{},"indices":{"foobaz":{"state":"open","settings":{"index":{"uuid":"2mYPJXfDSv63IL6KO8HutQ","analysis":{"analyzer":{"index_inc_search":{"filter":["lowercase"],"tokenizer":"whitespace"}}},"number_of_replicas":"2","number_of_shards":"1","version":{"created":"1030099"}}},"mappings":{"baz":{"properties":{"id":{"type":"long"},"content":{"path":"just_name","type":"string","fields":{"content.raw":{"type":"string"}}}}},"bar":{"properties":{"id":{"type":"long"},"content":{"type":"string","fields":{"content.raw":{"type":"string"}}}}}},"aliases":[]},"foobar":{"state":"open","settings":{"index":{"uuid":"TBNjcNOpSYmhl3Lt7MOZkQ","analysis":{"analyzer":{"index_inc_search":{"filter":["lowercase"],"tokenizer":"whitespace"}}},"number_of_replicas":"0","number_of_shards":"2","version":{"created":"1030099"}}},"mappings":{"baz":{"properties":{"id":{"type":"long"},"content":{"path":"just_name","type":"string","fields":{"content.raw":{"type":"string"}}}}},"bar":{"properties":{"id":{"type":"long"},"content":{"type":"string","fields":{"content.raw":{"type":"string"}}}}}},"aliases":[]},"qux":{"state":"close","settings":{"index":{"uuid":"hml0-oIYQnaoayWgjrC3Cw","analysis":{"analyzer":{"index_inc_search":{"filter":["lowercase"],"tokenizer":"whitespace"}}},"number_of_replicas":"2","number_of_shards":"1","version":{"created":"1030099"}}},"mappings":{"baz":{"properties":{"id":{"type":"long"},"content":{"path":"just_name","type":"string","fields":{"content.raw":{"type":"string"}}}}},"bar":{"properties":{"id":{"type":"long"},"content":{"type":"string","fields":{"content.raw":{"type":"string"}}}}}},"aliases":[]}}},"routing_table":{"indices":{"foobar":{"shards":{"0":[{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobar"}],"1":[{"state":"STARTED","primary":true,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":1,"index":"foobar"}]}},"foobaz":{"shards":{"0":[{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobaz"},{"state":"STARTED","primary":false,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":0,"index":"foobaz"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":0,"index":"foobaz"}]}}}},"routing_nodes":{"unassigned":[{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":0,"index":"foobaz"}],"nodes":{"bisY7wgCSa67QMba_NOR4Q":[{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobar"},{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobaz"}],"ijZWlj2cSfOecB8IXY2P4g":[{"state":"STARTED","primary":true,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":1,"index":"foobar"},{"state":"STARTED","primary":false,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":0,"index":"foobaz"}]}},"allocations":[]}');
	var status = JSON.parse('{"_shards":{"total":5,"successful":4,"failed":0},"indices":{"foobar":{"index":{"primary_size_in_bytes":6136,"size_in_bytes":6136},"translog":{"operations":8},"docs":{"num_docs":8,"max_doc":8,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":4,"total_time_in_millis":152},"flush":{"total":0,"total_time_in_millis":0},"shards":{"0":[{"routing":{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobar"},"state":"STARTED","index":{"size_in_bytes":3068},"translog":{"id":1401527904013,"operations":4},"docs":{"num_docs":4,"max_doc":4,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":78},"flush":{"total":0,"total_time_in_millis":0}}],"1":[{"routing":{"state":"STARTED","primary":true,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":1,"index":"foobar"},"state":"STARTED","index":{"size_in_bytes":3068},"translog":{"id":1401527904175,"operations":4},"docs":{"num_docs":4,"max_doc":4,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":74},"flush":{"total":0,"total_time_in_millis":0}}]}},"foobaz":{"index":{"primary_size_in_bytes":123,"size_in_bytes":210},"translog":{"operations":0},"docs":{"num_docs":0,"max_doc":0,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":3,"total_time_in_millis":0},"flush":{"total":0,"total_time_in_millis":0},"shards":{"0":[{"routing":{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobaz"},"state":"STARTED","index":{"size_in_bytes":123},"translog":{"id":1401527904397,"operations":0},"docs":{"num_docs":0,"max_doc":0,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":0},"flush":{"total":0,"total_time_in_millis":0}},{"routing":{"state":"STARTED","primary":false,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":0,"index":"foobaz"},"state":"STARTED","index":{"size_in_bytes":87},"translog":{"id":1401527904397,"operations":0},"docs":{"num_docs":0,"max_doc":0,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":1,"total_time_in_millis":0},"flush":{"total":0,"total_time_in_millis":0}}]}}}}');
	var stats = JSON.parse('{"cluster_name":"elasticsearch","nodes":{"bisY7wgCSa67QMba_NOR4Q":{"timestamp":1401527906054,"name":"Ringleader","transport_address":"inet[/192.168.2.106:9301]","host":"localhost","ip":["inet[/192.168.2.106:9301]","NONE"],"indices":{"docs":{"count":4,"deleted":0},"store":{"size_in_bytes":3191,"throttle_time_in_millis":0},"indexing":{"index_total":4,"index_time_in_millis":46,"index_current":0,"delete_total":0,"delete_time_in_millis":0,"delete_current":0},"get":{"total":0,"time_in_millis":0,"exists_total":0,"exists_time_in_millis":0,"missing_total":0,"missing_time_in_millis":0,"current":0},"search":{"open_contexts":0,"query_total":0,"query_time_in_millis":0,"query_current":0,"fetch_total":0,"fetch_time_in_millis":0,"fetch_current":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":4,"total_time_in_millis":78},"flush":{"total":0,"total_time_in_millis":0},"warmer":{"current":0,"total":6,"total_time_in_millis":4},"filter_cache":{"memory_size_in_bytes":0,"evictions":0},"id_cache":{"memory_size_in_bytes":0},"fielddata":{"memory_size_in_bytes":0,"evictions":0},"percolate":{"total":0,"time_in_millis":0,"current":0,"memory_size_in_bytes":-1,"memory_size":"-1b","queries":0},"completion":{"size_in_bytes":0},"segments":{"count":1,"memory_in_bytes":449},"translog":{"operations":4,"size_in_bytes":0},"suggest":{"total":0,"time_in_millis":0,"current":0}},"os":{"timestamp":1401527906060,"uptime_in_millis":623,"load_average":[1.478515625,1.7685546875,1.11083984375],"cpu":{"sys":1,"user":5,"idle":93,"usage":6,"stolen":0},"mem":{"free_in_bytes":2524221440,"used_in_bytes":6065713152,"free_percent":45,"used_percent":54,"actual_free_in_bytes":3930902528,"actual_used_in_bytes":4659032064},"swap":{"used_in_bytes":0,"free_in_bytes":1073741824}},"process":{"timestamp":1401527906060,"open_file_descriptors":258,"cpu":{"percent":8,"sys_in_millis":367,"user_in_millis":4740,"total_in_millis":5107},"mem":{"resident_in_bytes":210161664,"share_in_bytes":-1,"total_virtual_in_bytes":3938201600}},"jvm":{"timestamp":1401527906060,"uptime_in_millis":34407,"mem":{"heap_used_in_bytes":67887416,"heap_used_percent":6,"heap_committed_in_bytes":259522560,"heap_max_in_bytes":1037959168,"non_heap_used_in_bytes":34037248,"non_heap_committed_in_bytes":35520512,"pools":{"young":{"used_in_bytes":44759328,"max_in_bytes":286326784,"peak_used_in_bytes":71630848,"peak_max_in_bytes":286326784},"survivor":{"used_in_bytes":7839960,"max_in_bytes":35782656,"peak_used_in_bytes":8912888,"peak_max_in_bytes":35782656},"old":{"used_in_bytes":15288128,"max_in_bytes":715849728,"peak_used_in_bytes":15288128,"peak_max_in_bytes":715849728}}},"threads":{"count":74,"peak_count":74},"gc":{"collectors":{"young":{"collection_count":3,"collection_time_in_millis":42},"old":{"collection_count":0,"collection_time_in_millis":0}}},"buffer_pools":{"direct":{"count":76,"used_in_bytes":15729901,"total_capacity_in_bytes":15729901},"mapped":{"count":0,"used_in_bytes":0,"total_capacity_in_bytes":0}}},"thread_pool":{"generic":{"threads":2,"queue":0,"active":0,"rejected":0,"largest":2,"completed":28},"index":{"threads":4,"queue":0,"active":0,"rejected":0,"largest":4,"completed":4},"snapshot_data":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"bench":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"get":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"snapshot":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"merge":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":1},"suggest":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"bulk":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"optimize":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"warmer":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":4},"flush":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"search":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"percolate":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"management":{"threads":2,"queue":0,"active":1,"rejected":0,"largest":2,"completed":2},"refresh":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":2}},"network":{"tcp":{"active_opens":912,"passive_opens":98,"curr_estab":187,"in_segs":52310,"out_segs":28960,"retrans_segs":6,"estab_resets":48,"attempt_fails":25,"in_errs":2,"out_rsts":-1}},"fs":{"timestamp":1401527906061,"total":{"total_in_bytes":249804886016,"free_in_bytes":105004523520,"available_in_bytes":104742379520,"disk_reads":0,"disk_writes":0,"disk_io_op":0,"disk_read_size_in_bytes":0,"disk_write_size_in_bytes":0,"disk_io_size_in_bytes":0},"data":[{"path":"/Users/leonardo.menezes/Downloads/elasticsearch-1.3.0-SNAPSHOT/data/elasticsearch/nodes/1","mount":"/","dev":"/dev/disk1","total_in_bytes":249804886016,"free_in_bytes":105004523520,"available_in_bytes":104742379520,"disk_reads":0,"disk_writes":0,"disk_io_op":0,"disk_read_size_in_bytes":0,"disk_write_size_in_bytes":0,"disk_io_size_in_bytes":0}]},"transport":{"server_open":26,"rx_count":111,"rx_size_in_bytes":16986,"tx_count":110,"tx_size_in_bytes":6607},"http":{"current_open":0,"total_opened":0},"fielddata_breaker":{"maximum_size_in_bytes":622775500,"maximum_size":"593.9mb","estimated_size_in_bytes":0,"estimated_size":"0b","overhead":1.03,"tripped":0}},"ijZWlj2cSfOecB8IXY2P4g":{"timestamp":1401527906054,"name":"Metal Master","transport_address":"inet[/192.168.2.106:9300]","host":"localhost","ip":["inet[/192.168.2.106:9300]","NONE"],"indices":{"docs":{"count":4,"deleted":0},"store":{"size_in_bytes":3155,"throttle_time_in_millis":0},"indexing":{"index_total":4,"index_time_in_millis":41,"index_current":0,"delete_total":0,"delete_time_in_millis":0,"delete_current":0},"get":{"total":0,"time_in_millis":0,"exists_total":0,"exists_time_in_millis":0,"missing_total":0,"missing_time_in_millis":0,"current":0},"search":{"open_contexts":0,"query_total":0,"query_time_in_millis":0,"query_current":0,"fetch_total":0,"fetch_time_in_millis":0,"fetch_current":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":4,"total_time_in_millis":74},"flush":{"total":0,"total_time_in_millis":0},"warmer":{"current":0,"total":6,"total_time_in_millis":1},"filter_cache":{"memory_size_in_bytes":0,"evictions":0},"id_cache":{"memory_size_in_bytes":0},"fielddata":{"memory_size_in_bytes":0,"evictions":0},"percolate":{"total":0,"time_in_millis":0,"current":0,"memory_size_in_bytes":-1,"memory_size":"-1b","queries":0},"completion":{"size_in_bytes":0},"segments":{"count":1,"memory_in_bytes":449},"translog":{"operations":4,"size_in_bytes":0},"suggest":{"total":0,"time_in_millis":0,"current":0}},"os":{"timestamp":1401527906059,"uptime_in_millis":623,"load_average":[1.478515625,1.7685546875,1.11083984375],"cpu":{"sys":1,"user":5,"idle":93,"usage":6,"stolen":0},"mem":{"free_in_bytes":2524221440,"used_in_bytes":6065713152,"free_percent":45,"used_percent":54,"actual_free_in_bytes":3930902528,"actual_used_in_bytes":4659032064},"swap":{"used_in_bytes":0,"free_in_bytes":1073741824}},"process":{"timestamp":1401527906059,"open_file_descriptors":259,"cpu":{"percent":7,"sys_in_millis":422,"user_in_millis":5091,"total_in_millis":5513},"mem":{"resident_in_bytes":215416832,"share_in_bytes":-1,"total_virtual_in_bytes":3953086464}},"jvm":{"timestamp":1401527906059,"uptime_in_millis":44852,"mem":{"heap_used_in_bytes":90400736,"heap_used_percent":8,"heap_committed_in_bytes":259522560,"heap_max_in_bytes":1037959168,"non_heap_used_in_bytes":34782576,"non_heap_committed_in_bytes":36306944,"pools":{"young":{"used_in_bytes":66651328,"max_in_bytes":286326784,"peak_used_in_bytes":71630848,"peak_max_in_bytes":286326784},"survivor":{"used_in_bytes":8199352,"max_in_bytes":35782656,"peak_used_in_bytes":8912888,"peak_max_in_bytes":35782656},"old":{"used_in_bytes":15550056,"max_in_bytes":715849728,"peak_used_in_bytes":15550056,"peak_max_in_bytes":715849728}}},"threads":{"count":76,"peak_count":76},"gc":{"collectors":{"young":{"collection_count":3,"collection_time_in_millis":42},"old":{"collection_count":0,"collection_time_in_millis":0}}},"buffer_pools":{"direct":{"count":85,"used_in_bytes":20448493,"total_capacity_in_bytes":20448493},"mapped":{"count":0,"used_in_bytes":0,"total_capacity_in_bytes":0}}},"thread_pool":{"generic":{"threads":3,"queue":0,"active":0,"rejected":0,"largest":3,"completed":50},"index":{"threads":4,"queue":0,"active":0,"rejected":0,"largest":4,"completed":4},"snapshot_data":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"bench":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"get":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"snapshot":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"merge":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":1},"suggest":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"bulk":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"optimize":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"warmer":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":4},"flush":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"search":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"percolate":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"management":{"threads":2,"queue":0,"active":1,"rejected":0,"largest":2,"completed":5},"refresh":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":2}},"network":{"tcp":{"active_opens":912,"passive_opens":98,"curr_estab":187,"in_segs":52310,"out_segs":28960,"retrans_segs":6,"estab_resets":48,"attempt_fails":25,"in_errs":2,"out_rsts":-1}},"fs":{"timestamp":1401527906061,"total":{"total_in_bytes":249804886016,"free_in_bytes":105004523520,"available_in_bytes":104742379520,"disk_reads":0,"disk_writes":0,"disk_io_op":0,"disk_read_size_in_bytes":0,"disk_write_size_in_bytes":0,"disk_io_size_in_bytes":0},"data":[{"path":"/Users/leonardo.menezes/Downloads/elasticsearch-1.3.0-SNAPSHOT/data/elasticsearch/nodes/0","mount":"/","dev":"/dev/disk1","total_in_bytes":249804886016,"free_in_bytes":105004523520,"available_in_bytes":104742379520,"disk_reads":0,"disk_writes":0,"disk_io_op":0,"disk_read_size_in_bytes":0,"disk_write_size_in_bytes":0,"disk_io_size_in_bytes":0}]},"transport":{"server_open":26,"rx_count":110,"rx_size_in_bytes":6607,"tx_count":111,"tx_size_in_bytes":16986},"http":{"current_open":1,"total_opened":23},"fielddata_breaker":{"maximum_size_in_bytes":622775500,"maximum_size":"593.9mb","estimated_size_in_bytes":0,"estimated_size":"0b","overhead":1.03,"tripped":0}}}}');
	var settings = JSON.parse('{"_shards":{"total":5,"successful":4,"failed":0},"indices":{"foobar":{"index":{"primary_size_in_bytes":6136,"size_in_bytes":6136},"translog":{"operations":8},"docs":{"num_docs":8,"max_doc":8,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":4,"total_time_in_millis":152},"flush":{"total":0,"total_time_in_millis":0},"shards":{"0":[{"routing":{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobar"},"state":"STARTED","index":{"size_in_bytes":3068},"translog":{"id":1401527904013,"operations":4},"docs":{"num_docs":4,"max_doc":4,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":78},"flush":{"total":0,"total_time_in_millis":0}}],"1":[{"routing":{"state":"STARTED","primary":true,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":1,"index":"foobar"},"state":"STARTED","index":{"size_in_bytes":3068},"translog":{"id":1401527904175,"operations":4},"docs":{"num_docs":4,"max_doc":4,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":74},"flush":{"total":0,"total_time_in_millis":0}}]}},"foobaz":{"index":{"primary_size_in_bytes":123,"size_in_bytes":210},"translog":{"operations":0},"docs":{"num_docs":0,"max_doc":0,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":3,"total_time_in_millis":0},"flush":{"total":0,"total_time_in_millis":0},"shards":{"0":[{"routing":{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobaz"},"state":"STARTED","index":{"size_in_bytes":123},"translog":{"id":1401527904397,"operations":0},"docs":{"num_docs":0,"max_doc":0,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":0},"flush":{"total":0,"total_time_in_millis":0}},{"routing":{"state":"STARTED","primary":false,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":0,"index":"foobaz"},"state":"STARTED","index":{"size_in_bytes":87},"translog":{"id":1401527904397,"operations":0},"docs":{"num_docs":0,"max_doc":0,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":1,"total_time_in_millis":0},"flush":{"total":0,"total_time_in_millis":0}}]}}}}');
	var cluster = new Cluster(state, status, stats, settings);
	
	var size_pattern = /\d+\.\d+\w{1,2}/;
	var number_pattern = /\d+/;
	
	// check clustercluster properties
	equal(cluster.num_docs, 8, "Number of documents");
	//equal(cluster.total_size == '16.49KB', "Checking total size");
	equal(cluster.unassigned_shards, 1, "Unassigned shards");
	equal(cluster.shards, 5, "Number of shards");
	equal(cluster.failed_shards, 0, "Failed shards");
	equal(cluster.total_indices, 3, "Number of indices");
	var master_node = cluster.master_node;
	
	// index info
	ok(cluster.indices.length, 3, "Indices list length");
	
	var indices = cluster.indices;
	indices.forEach(function(index) {
		ok(index.state == 'open' || index.state == 'close', "Checking index state: [" + index.state + "]");
		ok(number_pattern.test(index.size), "Checking primary size: [" + index.size + "]");
		ok(number_pattern.test(index.total_size), "Checking total size: [" + index.total_size + "]");
		if (index.state == 'open') {
			ok(size_pattern.test(index.size_in_bytes), "Checking primary size: [" + index.size_in_bytes + "]");
			ok(size_pattern.test(index.total_size_in_bytes), "Checking total size: [" + index.total_size_in_bytes + "]");
		}
		ok(number_pattern.test(index.num_docs), "Checking num docs: [" + index.num_docs + "]");
		ok(number_pattern.test(index.max_doc), "Checking max doc: [" + index.max_doc + "]");
		ok(number_pattern.test(index.deleted_docs), "Checking deleted docs: [" + index.deleted_docs + "]");
		ok(index.name.length > 0, "Checking index name: [" + index.name + "]");
		ok(number_pattern.test(index.num_of_shards), "Checking number of shards: [" + index.num_of_shards + "]");
		ok(number_pattern.test(index.num_of_replicas), "Checking number of replicas: [" + index.num_of_replicas + "]");
		var node_ids = cluster.getNodes('', true, true, true).map(function(node) { return node.id; });
		node_ids.forEach(function(node_id) {
			if (index.shards[node_id] !== undefined) {
				index.shards[node_id].forEach(function(shard) {
					ok(shard.primary == true || shard.primary == false, "Checking primary status: [" + shard.primary +"]");
					equal(shard.node, node_id, "Shards should have referece to correct node");
					ok(shard.state == 'STARTED', "Shards should be started: [" + shard.state + "]");
				});
			}
		});
		
		equal(index.getTypes().length , 2, "Checking types length");
		index.getTypes().forEach(function(type) {
			// id is not analyzable, so its not on the list
			equal(index.getFields(type).length, 2, "Checking fields length for " + type);
		});
		
		equal(index.getAnalyzers().length, 1, "Checking analyzers length");
	});

	// check nodes
	var nodes = cluster.getNodes('', true, true, true);
	equal(nodes.length, 2, "Unfiltered node list");
	var master_nodes = 0;
	nodes.forEach(function(node) {
		ok(size_pattern.test(node.disk_total), "Checking disk total [" + node.disk_total + "]");
		ok(size_pattern.test(node.disk_free), "Checking free disk [" + node.disk_total + "]");
		ok(node.disk_used_percent >= 0 && node.disk_used_percent <= 100, "Checking disk usage in percent [" + node.disk_used_percent + "]");
		ok(size_pattern.test(node.size), "Checking node sotre size [" + node.size + "]");
		ok(size_pattern.test(node.heap_used), "Checking node heap used [" + node.heap_used + "]");
		ok(size_pattern.test(node.heap_committed), "Checking node heap commited [" + node.heap_committed + "]");
		ok(size_pattern.test(node.heap_max), "Checking max heap size [" + node.heap_max + "]");
		ok(node.heap_used_percent >= 0 && node.heap_used_percent <= 100, "Checking heap used percent [" + node.heap_used_percent + "]");
		ok(node.cpu_user >= 0 && number_pattern.test(node.cpu_user), "Checking os user cpu [" + node.cpu_user + "]");
		ok(node.cpu_sys >= 0 && number_pattern.test(node.cpu_sys), "Checking os sys cpu [" + node.cpu_sys + "]");
		equal(node.id.length, 22, "Checking node id length");
		ok(number_pattern.test(node.docs), "Checking number of documents per node " + node.docs);
		if (node.current_master) {
			master_nodes += 1;
			equal(master_node, node.id, "Checking current master");
		}
		// should find at least current node
		var matchingNodes = cluster.getNodes(node.name, true, true, true);
		ok(matchingNodes.length >= 1, "Should find at least node with that name: [" + matchingNodes.length + "]");
		// should not find at least the current node
		var nonMatchingNodes = cluster.getNodes(node.name + "a", true, true, true);
		ok(nonMatchingNodes.length < matchingNodes.length, "Should find at least one less node with that name");
		ok(node.transport_address.length > 0, "Checking node transport address");	
	});
	equal(master_nodes, 1, "There should be exactly one master node");
});

test("computing cluster changes", function() {
	var state = JSON.parse('{"cluster_name":"kopf_cluster","master_node":"JvYCtd57Tne-fxlK1GVHRw","blocks":{},"nodes":{"JvYCtd57Tne-fxlK1GVHRw":{"name":"Black Dragon","transport_address":"inet[/192.168.2.104:9300]","attributes":{}}},"metadata":{"templates":{},"indices":{"kopf_test":{"state":"open","settings":{"index":{"uuid":"7yDVKjHeS7uKbQuQbs3VNw","analysis":{"analyzer":{"kopf_analyzer_1":{"type":"custom","tokenizer":"whitespace"},"kopf_analyzer_2":{"type":"custom","tokenizer":"whitespace"}}},"number_of_replicas":"1","number_of_shards":"5","version":{"created":"1000051"}}},"mappings":{"kopf":{"properties":{"id":{"type":"long"},"content_2":{"type":"string","fields":{"content_2_raw":{"type":"string"}}},"content_1":{"path":"just_name","type":"string","fields":{"content_1_raw":{"type":"string"}}}}}},"aliases":["kopf_alias_2","kopf_alias_1"]}}},"routing_table":{"indices":{"kopf_test":{"shards":{"2":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":2,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":2,"index":"kopf_test"}],"0":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":0,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":0,"index":"kopf_test"}],"3":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":3,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":3,"index":"kopf_test"}],"1":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":1,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":1,"index":"kopf_test"}],"4":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":4,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":4,"index":"kopf_test"}]}}}},"routing_nodes":{"unassigned":[{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":2,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":0,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":3,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":1,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":4,"index":"kopf_test"}],"nodes":{"JvYCtd57Tne-fxlK1GVHRw":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":2,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":0,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":3,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":1,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":4,"index":"kopf_test"}]}},"allocations":[]}');
	var status = JSON.parse('{"_shards":{"total":10,"successful":5,"failed":0},"indices":{"kopf_test":{"index":{"primary_size_in_bytes":16887,"size_in_bytes":16887},"translog":{"operations":8},"docs":{"num_docs":6,"max_doc":6,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":13,"total_time_in_millis":125},"flush":{"total":0,"total_time_in_millis":0},"shards":{"0":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":0,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853127,"operations":1},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":15},"flush":{"total":0,"total_time_in_millis":0}}],"1":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":1,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853155,"operations":1},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":16},"flush":{"total":0,"total_time_in_millis":0}}],"2":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":2,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":5563},"translog":{"id":1390857853170,"operations":2},"docs":{"num_docs":2,"max_doc":2,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":3,"total_time_in_millis":43},"flush":{"total":0,"total_time_in_millis":0}}],"3":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":3,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853142,"operations":3},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":4,"total_time_in_millis":35},"flush":{"total":0,"total_time_in_millis":0}}],"4":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":4,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853204,"operations":1},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":16},"flush":{"total":0,"total_time_in_millis":0}}]}}}}');
	var stats = JSON.parse('{"cluster_name":"kopf_cluster","nodes":{"JvYCtd57Tne-fxlK1GVHRw":{"timestamp":1390858085598,"name":"<NAME>","transport_address":"inet[/192.168.2.104:9300]","host":"leo.local","ip":["inet[/192.168.2.104:9300]","NONE"],"indices":{"docs":{"count":6,"deleted":0},"store":{"size_in_bytes":16887,"throttle_time_in_millis":0},"indexing":{"index_total":11,"index_time_in_millis":194,"index_current":0,"delete_total":2,"delete_time_in_millis":2,"delete_current":0},"get":{"total":0,"time_in_millis":0,"exists_total":0,"exists_time_in_millis":0,"missing_total":0,"missing_time_in_millis":0,"current":0},"search":{"open_contexts":0,"query_total":20,"query_time_in_millis":31,"query_current":0,"fetch_total":0,"fetch_time_in_millis":0,"fetch_current":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":65,"total_time_in_millis":295},"flush":{"total":2,"total_time_in_millis":16},"warmer":{"current":0,"total":12,"total_time_in_millis":4},"filter_cache":{"memory_size_in_bytes":0,"evictions":0},"id_cache":{"memory_size_in_bytes":0},"fielddata":{"memory_size_in_bytes":0,"evictions":0},"percolate":{"total":0,"time_in_millis":0,"current":0,"memory_size_in_bytes":0,"memory_size":"0b","queries":0},"completion":{"size_in_bytes":0},"segments":{"count":6,"memory_in_bytes":0},"translog":{"operations":8,"size_in_bytes":113}},"os":{"timestamp":1390858084866,"uptime_in_millis":693508,"load_average":[1.42822265625,1.63525390625,1.88037109375],"cpu":{"sys":11,"user":18,"idle":69,"usage":29,"stolen":0},"mem":{"free_in_bytes":495689728,"used_in_bytes":8094244864,"free_percent":41,"used_percent":58,"actual_free_in_bytes":3530981376,"actual_used_in_bytes":5058953216},"swap":{"used_in_bytes":0,"free_in_bytes":1073741824}},"process":{"timestamp":1390858084866,"open_file_descriptors":148,"cpu":{"percent":0,"sys_in_millis":63331,"user_in_millis":113294,"total_in_millis":176625},"mem":{"resident_in_bytes":324427776,"share_in_bytes":-1,"total_virtual_in_bytes":3883094016}},"jvm":{"timestamp":1390858084867,"uptime_in_millis":182268477,"mem":{"heap_used_in_bytes":102054072,"heap_used_percent":9,"heap_committed_in_bytes":251002880,"heap_max_in_bytes":1056309248,"non_heap_used_in_bytes":38337328,"non_heap_committed_in_bytes":38666240,"pools":{"young":{"used_in_bytes":83487440,"max_in_bytes":139591680,"peak_used_in_bytes":139591680,"peak_max_in_bytes":139591680},"survivor":{"used_in_bytes":2591784,"max_in_bytes":17432576,"peak_used_in_bytes":17432576,"peak_max_in_bytes":17432576},"old":{"used_in_bytes":15974848,"max_in_bytes":899284992,"peak_used_in_bytes":15974848,"peak_max_in_bytes":899284992}}},"threads":{"count":49,"peak_count":50},"gc":{"collectors":{"young":{"collection_count":9,"collection_time_in_millis":299},"old":{"collection_count":0,"collection_time_in_millis":0}}},"buffer_pools":{"direct":{"count":37,"used_in_bytes":9392421,"total_capacity_in_bytes":9392421},"mapped":{"count":0,"used_in_bytes":0,"total_capacity_in_bytes":0}}},"thread_pool":{"generic":{"threads":4,"queue":0,"active":0,"rejected":0,"largest":5,"completed":17733},"index":{"threads":2,"queue":0,"active":0,"rejected":0,"largest":2,"completed":13},"get":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"snapshot":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":13},"merge":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":13},"suggest":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"bulk":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"optimize":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"warmer":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":86},"flush":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":2},"search":{"threads":6,"queue":0,"active":0,"rejected":0,"largest":6,"completed":20},"percolate":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"management":{"threads":5,"queue":0,"active":2,"rejected":0,"largest":5,"completed":19932},"refresh":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":13}},"network":{"tcp":{"active_opens":26842,"passive_opens":1470,"curr_estab":53,"in_segs":1812321,"out_segs":1561574,"retrans_segs":2190,"estab_resets":1395,"attempt_fails":4109,"in_errs":16,"out_rsts":-1}},"fs":{"timestamp":1390858084868,"total":{"total_in_bytes":255200755712,"free_in_bytes":82445713408,"available_in_bytes":82183569408,"disk_reads":578277,"disk_writes":854240,"disk_io_op":1432517,"disk_read_size_in_bytes":9500736512,"disk_write_size_in_bytes":15133154304,"disk_io_size_in_bytes":24633890816},"data":[{"path":"/Users/leo/Downloads/elasticsearch-1.0.0.RC1/data/kopf_cluster/nodes/0","mount":"/","dev":"/dev/disk0s2","total_in_bytes":255200755712,"free_in_bytes":82445713408,"available_in_bytes":82183569408,"disk_reads":578277,"disk_writes":854240,"disk_io_op":1432517,"disk_read_size_in_bytes":9500736512,"disk_write_size_in_bytes":15133154304,"disk_io_size_in_bytes":24633890816}]},"transport":{"server_open":13,"rx_count":27,"rx_size_in_bytes":2753,"tx_count":27,"tx_size_in_bytes":3409},"http":{"current_open":6,"total_opened":139},"fielddata_breaker":{"maximum_size_in_bytes":845047398,"maximum_size":"805.8mb","estimated_size_in_bytes":0,"estimated_size":"0b","overhead":1.03}}}}');
	var settings = JSON.parse('{"persistent":{},"transient":{"cluster":{"routing":{"allocation":{"disable_allocation":"false"}}}}}');
	var cluster = new Cluster(state, status, stats, settings);

	var state2 = JSON.parse('{"cluster_name":"kopf_cluster","master_node":"JvYCtd57Tn-fxlK1GVHRw","blocks":{},"nodes":{"JvYCtd57Tn-fxlK1GVHRw":{"name":"<NAME>","transport_address":"inet[/192.168.2.104:9300]","attributes":{}}},"metadata":{"templates":{},"indices":{"kopf_test":{"state":"open","settings":{"index":{"uuid":"7yDVKjHeS7uKbQuQbs3VNw","analysis":{"analyzer":{"kopf_analyzer_1":{"type":"custom","tokenizer":"whitespace"},"kopf_analyzer_2":{"type":"custom","tokenizer":"whitespace"}}},"number_of_replicas":"1","number_of_shards":"5","version":{"created":"1000051"}}},"mappings":{"kopf":{"properties":{"id":{"type":"long"},"content_2":{"type":"string","fields":{"content_2_raw":{"type":"string"}}},"content_1":{"path":"just_name","type":"string","fields":{"content_1_raw":{"type":"string"}}}}}},"aliases":["kopf_alias_2","kopf_alias_1"]}}},"routing_table":{"indices":{"kopf_test":{"shards":{"2":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":2,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":2,"index":"kopf_test"}],"0":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":0,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":0,"index":"kopf_test"}],"3":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":3,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":3,"index":"kopf_test"}],"1":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":1,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":1,"index":"kopf_test"}],"4":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":4,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":4,"index":"kopf_test"}]}}}},"routing_nodes":{"unassigned":[{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":2,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":0,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":3,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":1,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":4,"index":"kopf_test"}],"nodes":{"JvYCtd57Tn-fxlK1GVHRw":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":2,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":0,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":3,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":1,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":4,"index":"kopf_test"}]}},"allocations":[]}');
	var status2 = JSON.parse('{"_shards":{"total":10,"successful":5,"failed":0},"indices":{"kopf_test":{"index":{"primary_size_in_bytes":19887,"size_in_bytes":19887},"translog":{"operations":8},"docs":{"num_docs":7,"max_doc":7,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":13,"total_time_in_millis":125},"flush":{"total":0,"total_time_in_millis":0},"shards":{"0":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":0,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853127,"operations":1},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":15},"flush":{"total":0,"total_time_in_millis":0}}],"1":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":1,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853155,"operations":1},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":16},"flush":{"total":0,"total_time_in_millis":0}}],"2":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":2,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":5563},"translog":{"id":1390857853170,"operations":2},"docs":{"num_docs":2,"max_doc":2,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":3,"total_time_in_millis":43},"flush":{"total":0,"total_time_in_millis":0}}],"3":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":3,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853142,"operations":3},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":4,"total_time_in_millis":35},"flush":{"total":0,"total_time_in_millis":0}}],"4":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":4,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853204,"operations":1},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":16},"flush":{"total":0,"total_time_in_millis":0}}]}}}}');
	var stats2 = JSON.parse('{"cluster_name":"kopf_cluster","nodes":{"JvYCtd57Tn-fxlK1GVHRw":{"timestamp":1390858085598,"name":"<NAME>","transport_address":"inet[/192.168.2.104:9300]","host":"leo.local","ip":["inet[/192.168.2.104:9300]","NONE"],"indices":{"docs":{"count":6,"deleted":0},"store":{"size_in_bytes":16887,"throttle_time_in_millis":0},"indexing":{"index_total":11,"index_time_in_millis":194,"index_current":0,"delete_total":2,"delete_time_in_millis":2,"delete_current":0},"get":{"total":0,"time_in_millis":0,"exists_total":0,"exists_time_in_millis":0,"missing_total":0,"missing_time_in_millis":0,"current":0},"search":{"open_contexts":0,"query_total":20,"query_time_in_millis":31,"query_current":0,"fetch_total":0,"fetch_time_in_millis":0,"fetch_current":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":65,"total_time_in_millis":295},"flush":{"total":2,"total_time_in_millis":16},"warmer":{"current":0,"total":12,"total_time_in_millis":4},"filter_cache":{"memory_size_in_bytes":0,"evictions":0},"id_cache":{"memory_size_in_bytes":0},"fielddata":{"memory_size_in_bytes":0,"evictions":0},"percolate":{"total":0,"time_in_millis":0,"current":0,"memory_size_in_bytes":0,"memory_size":"0b","queries":0},"completion":{"size_in_bytes":0},"segments":{"count":6,"memory_in_bytes":0},"translog":{"operations":8,"size_in_bytes":113}},"os":{"timestamp":1390858084866,"uptime_in_millis":693508,"load_average":[1.42822265625,1.63525390625,1.88037109375],"cpu":{"sys":11,"user":18,"idle":69,"usage":29,"stolen":0},"mem":{"free_in_bytes":495689728,"used_in_bytes":8094244864,"free_percent":41,"used_percent":58,"actual_free_in_bytes":3530981376,"actual_used_in_bytes":5058953216},"swap":{"used_in_bytes":0,"free_in_bytes":1073741824}},"process":{"timestamp":1390858084866,"open_file_descriptors":148,"cpu":{"percent":0,"sys_in_millis":63331,"user_in_millis":113294,"total_in_millis":176625},"mem":{"resident_in_bytes":324427776,"share_in_bytes":-1,"total_virtual_in_bytes":3883094016}},"jvm":{"timestamp":1390858084867,"uptime_in_millis":182268477,"mem":{"heap_used_in_bytes":102054072,"heap_used_percent":9,"heap_committed_in_bytes":251002880,"heap_max_in_bytes":1056309248,"non_heap_used_in_bytes":38337328,"non_heap_committed_in_bytes":38666240,"pools":{"young":{"used_in_bytes":83487440,"max_in_bytes":139591680,"peak_used_in_bytes":139591680,"peak_max_in_bytes":139591680},"survivor":{"used_in_bytes":2591784,"max_in_bytes":17432576,"peak_used_in_bytes":17432576,"peak_max_in_bytes":17432576},"old":{"used_in_bytes":15974848,"max_in_bytes":899284992,"peak_used_in_bytes":15974848,"peak_max_in_bytes":899284992}}},"threads":{"count":49,"peak_count":50},"gc":{"collectors":{"young":{"collection_count":9,"collection_time_in_millis":299},"old":{"collection_count":0,"collection_time_in_millis":0}}},"buffer_pools":{"direct":{"count":37,"used_in_bytes":9392421,"total_capacity_in_bytes":9392421},"mapped":{"count":0,"used_in_bytes":0,"total_capacity_in_bytes":0}}},"thread_pool":{"generic":{"threads":4,"queue":0,"active":0,"rejected":0,"largest":5,"completed":17733},"index":{"threads":2,"queue":0,"active":0,"rejected":0,"largest":2,"completed":13},"get":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"snapshot":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":13},"merge":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":13},"suggest":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"bulk":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"optimize":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"warmer":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":86},"flush":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":2},"search":{"threads":6,"queue":0,"active":0,"rejected":0,"largest":6,"completed":20},"percolate":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"management":{"threads":5,"queue":0,"active":2,"rejected":0,"largest":5,"completed":19932},"refresh":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":13}},"network":{"tcp":{"active_opens":26842,"passive_opens":1470,"curr_estab":53,"in_segs":1812321,"out_segs":1561574,"retrans_segs":2190,"estab_resets":1395,"attempt_fails":4109,"in_errs":16,"out_rsts":-1}},"fs":{"timestamp":1390858084868,"total":{"total_in_bytes":255200755712,"free_in_bytes":82445713408,"available_in_bytes":82183569408,"disk_reads":578277,"disk_writes":854240,"disk_io_op":1432517,"disk_read_size_in_bytes":9500736512,"disk_write_size_in_bytes":15133154304,"disk_io_size_in_bytes":24633890816},"data":[{"path":"/Users/leo/Downloads/elasticsearch-1.0.0.RC1/data/kopf_cluster/nodes/0","mount":"/","dev":"/dev/disk0s2","total_in_bytes":255200755712,"free_in_bytes":82445713408,"available_in_bytes":82183569408,"disk_reads":578277,"disk_writes":854240,"disk_io_op":1432517,"disk_read_size_in_bytes":9500736512,"disk_write_size_in_bytes":15133154304,"disk_io_size_in_bytes":24633890816}]},"transport":{"server_open":13,"rx_count":27,"rx_size_in_bytes":2753,"tx_count":27,"tx_size_in_bytes":3409},"http":{"current_open":6,"total_opened":139},"fielddata_breaker":{"maximum_size_in_bytes":845047398,"maximum_size":"805.8mb","estimated_size_in_bytes":0,"estimated_size":"0b","overhead":1.03}}}}');
	var settings2 = JSON.parse('{"persistent":{},"transient":{"cluster":{"routing":{"allocation":{"disable_allocation":"false"}}}}}');
	var cluster2 = new Cluster(state2, status2, stats2, settings2);

	cluster2.computeChanges(cluster);
	
	ok(cluster2.changes.getDocDelta() == 1, "Checking document delta");
	ok(cluster2.changes.getDataDelta() == 3000, "" + cluster2.changes.getDataDelta());
	ok(cluster2.changes.absDataDelta() == "2.93KB", "" + cluster2.changes.absDataDelta());

	ok(cluster2.changes.nodeJoins.length == 1, "checking joinng nodes");
	ok(cluster2.changes.nodeLeaves.length == 1, "checking disconnecting nodes");
	
	ok(cluster2.changes.nodeJoins[0].id == "JvYCtd57Tn-fxlK1GVHRw", "checking node identity");
	ok(cluster2.changes.nodeLeaves[0].id == "JvYCtd57Tne-fxlK1GVHRw", "checking node identity");
});
<commit_msg>added node host to tests<commit_after>// isDefined tests
test("cluster creating", function() {
	var state = JSON.parse('{"cluster_name":"elasticsearch","version":20,"master_node":"ijZWlj2cSfOecB8IXY2P4g","blocks":{"indices":{"qux":{"4":{"description":"index closed","retryable":false,"levels":["read","write"]}}}},"nodes":{"bisY7wgCSa67QMba_NOR4Q":{"name":"Ringleader","transport_address":"inet[/192.168.2.106:9301]","attributes":{}},"ijZWlj2cSfOecB8IXY2P4g":{"name":"Metal Master","transport_address":"inet[/192.168.2.106:9300]","attributes":{}}},"metadata":{"templates":{},"indices":{"foobaz":{"state":"open","settings":{"index":{"uuid":"2mYPJXfDSv63IL6KO8HutQ","analysis":{"analyzer":{"index_inc_search":{"filter":["lowercase"],"tokenizer":"whitespace"}}},"number_of_replicas":"2","number_of_shards":"1","version":{"created":"1030099"}}},"mappings":{"baz":{"properties":{"id":{"type":"long"},"content":{"path":"just_name","type":"string","fields":{"content.raw":{"type":"string"}}}}},"bar":{"properties":{"id":{"type":"long"},"content":{"type":"string","fields":{"content.raw":{"type":"string"}}}}}},"aliases":[]},"foobar":{"state":"open","settings":{"index":{"uuid":"TBNjcNOpSYmhl3Lt7MOZkQ","analysis":{"analyzer":{"index_inc_search":{"filter":["lowercase"],"tokenizer":"whitespace"}}},"number_of_replicas":"0","number_of_shards":"2","version":{"created":"1030099"}}},"mappings":{"baz":{"properties":{"id":{"type":"long"},"content":{"path":"just_name","type":"string","fields":{"content.raw":{"type":"string"}}}}},"bar":{"properties":{"id":{"type":"long"},"content":{"type":"string","fields":{"content.raw":{"type":"string"}}}}}},"aliases":[]},"qux":{"state":"close","settings":{"index":{"uuid":"hml0-oIYQnaoayWgjrC3Cw","analysis":{"analyzer":{"index_inc_search":{"filter":["lowercase"],"tokenizer":"whitespace"}}},"number_of_replicas":"2","number_of_shards":"1","version":{"created":"1030099"}}},"mappings":{"baz":{"properties":{"id":{"type":"long"},"content":{"path":"just_name","type":"string","fields":{"content.raw":{"type":"string"}}}}},"bar":{"properties":{"id":{"type":"long"},"content":{"type":"string","fields":{"content.raw":{"type":"string"}}}}}},"aliases":[]}}},"routing_table":{"indices":{"foobar":{"shards":{"0":[{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobar"}],"1":[{"state":"STARTED","primary":true,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":1,"index":"foobar"}]}},"foobaz":{"shards":{"0":[{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobaz"},{"state":"STARTED","primary":false,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":0,"index":"foobaz"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":0,"index":"foobaz"}]}}}},"routing_nodes":{"unassigned":[{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":0,"index":"foobaz"}],"nodes":{"bisY7wgCSa67QMba_NOR4Q":[{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobar"},{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobaz"}],"ijZWlj2cSfOecB8IXY2P4g":[{"state":"STARTED","primary":true,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":1,"index":"foobar"},{"state":"STARTED","primary":false,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":0,"index":"foobaz"}]}},"allocations":[]}');
	var status = JSON.parse('{"_shards":{"total":5,"successful":4,"failed":0},"indices":{"foobar":{"index":{"primary_size_in_bytes":6136,"size_in_bytes":6136},"translog":{"operations":8},"docs":{"num_docs":8,"max_doc":8,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":4,"total_time_in_millis":152},"flush":{"total":0,"total_time_in_millis":0},"shards":{"0":[{"routing":{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobar"},"state":"STARTED","index":{"size_in_bytes":3068},"translog":{"id":1401527904013,"operations":4},"docs":{"num_docs":4,"max_doc":4,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":78},"flush":{"total":0,"total_time_in_millis":0}}],"1":[{"routing":{"state":"STARTED","primary":true,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":1,"index":"foobar"},"state":"STARTED","index":{"size_in_bytes":3068},"translog":{"id":1401527904175,"operations":4},"docs":{"num_docs":4,"max_doc":4,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":74},"flush":{"total":0,"total_time_in_millis":0}}]}},"foobaz":{"index":{"primary_size_in_bytes":123,"size_in_bytes":210},"translog":{"operations":0},"docs":{"num_docs":0,"max_doc":0,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":3,"total_time_in_millis":0},"flush":{"total":0,"total_time_in_millis":0},"shards":{"0":[{"routing":{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobaz"},"state":"STARTED","index":{"size_in_bytes":123},"translog":{"id":1401527904397,"operations":0},"docs":{"num_docs":0,"max_doc":0,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":0},"flush":{"total":0,"total_time_in_millis":0}},{"routing":{"state":"STARTED","primary":false,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":0,"index":"foobaz"},"state":"STARTED","index":{"size_in_bytes":87},"translog":{"id":1401527904397,"operations":0},"docs":{"num_docs":0,"max_doc":0,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":1,"total_time_in_millis":0},"flush":{"total":0,"total_time_in_millis":0}}]}}}}');
	var stats = JSON.parse('{"cluster_name":"elasticsearch","nodes":{"bisY7wgCSa67QMba_NOR4Q":{"timestamp":1401527906054,"name":"Ringleader","transport_address":"inet[/192.168.2.106:9301]","host":"localhost","ip":["inet[/192.168.2.106:9301]","NONE"],"indices":{"docs":{"count":4,"deleted":0},"store":{"size_in_bytes":3191,"throttle_time_in_millis":0},"indexing":{"index_total":4,"index_time_in_millis":46,"index_current":0,"delete_total":0,"delete_time_in_millis":0,"delete_current":0},"get":{"total":0,"time_in_millis":0,"exists_total":0,"exists_time_in_millis":0,"missing_total":0,"missing_time_in_millis":0,"current":0},"search":{"open_contexts":0,"query_total":0,"query_time_in_millis":0,"query_current":0,"fetch_total":0,"fetch_time_in_millis":0,"fetch_current":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":4,"total_time_in_millis":78},"flush":{"total":0,"total_time_in_millis":0},"warmer":{"current":0,"total":6,"total_time_in_millis":4},"filter_cache":{"memory_size_in_bytes":0,"evictions":0},"id_cache":{"memory_size_in_bytes":0},"fielddata":{"memory_size_in_bytes":0,"evictions":0},"percolate":{"total":0,"time_in_millis":0,"current":0,"memory_size_in_bytes":-1,"memory_size":"-1b","queries":0},"completion":{"size_in_bytes":0},"segments":{"count":1,"memory_in_bytes":449},"translog":{"operations":4,"size_in_bytes":0},"suggest":{"total":0,"time_in_millis":0,"current":0}},"os":{"timestamp":1401527906060,"uptime_in_millis":623,"load_average":[1.478515625,1.7685546875,1.11083984375],"cpu":{"sys":1,"user":5,"idle":93,"usage":6,"stolen":0},"mem":{"free_in_bytes":2524221440,"used_in_bytes":6065713152,"free_percent":45,"used_percent":54,"actual_free_in_bytes":3930902528,"actual_used_in_bytes":4659032064},"swap":{"used_in_bytes":0,"free_in_bytes":1073741824}},"process":{"timestamp":1401527906060,"open_file_descriptors":258,"cpu":{"percent":8,"sys_in_millis":367,"user_in_millis":4740,"total_in_millis":5107},"mem":{"resident_in_bytes":210161664,"share_in_bytes":-1,"total_virtual_in_bytes":3938201600}},"jvm":{"timestamp":1401527906060,"uptime_in_millis":34407,"mem":{"heap_used_in_bytes":67887416,"heap_used_percent":6,"heap_committed_in_bytes":259522560,"heap_max_in_bytes":1037959168,"non_heap_used_in_bytes":34037248,"non_heap_committed_in_bytes":35520512,"pools":{"young":{"used_in_bytes":44759328,"max_in_bytes":286326784,"peak_used_in_bytes":71630848,"peak_max_in_bytes":286326784},"survivor":{"used_in_bytes":7839960,"max_in_bytes":35782656,"peak_used_in_bytes":8912888,"peak_max_in_bytes":35782656},"old":{"used_in_bytes":15288128,"max_in_bytes":715849728,"peak_used_in_bytes":15288128,"peak_max_in_bytes":715849728}}},"threads":{"count":74,"peak_count":74},"gc":{"collectors":{"young":{"collection_count":3,"collection_time_in_millis":42},"old":{"collection_count":0,"collection_time_in_millis":0}}},"buffer_pools":{"direct":{"count":76,"used_in_bytes":15729901,"total_capacity_in_bytes":15729901},"mapped":{"count":0,"used_in_bytes":0,"total_capacity_in_bytes":0}}},"thread_pool":{"generic":{"threads":2,"queue":0,"active":0,"rejected":0,"largest":2,"completed":28},"index":{"threads":4,"queue":0,"active":0,"rejected":0,"largest":4,"completed":4},"snapshot_data":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"bench":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"get":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"snapshot":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"merge":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":1},"suggest":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"bulk":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"optimize":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"warmer":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":4},"flush":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"search":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"percolate":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"management":{"threads":2,"queue":0,"active":1,"rejected":0,"largest":2,"completed":2},"refresh":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":2}},"network":{"tcp":{"active_opens":912,"passive_opens":98,"curr_estab":187,"in_segs":52310,"out_segs":28960,"retrans_segs":6,"estab_resets":48,"attempt_fails":25,"in_errs":2,"out_rsts":-1}},"fs":{"timestamp":1401527906061,"total":{"total_in_bytes":249804886016,"free_in_bytes":105004523520,"available_in_bytes":104742379520,"disk_reads":0,"disk_writes":0,"disk_io_op":0,"disk_read_size_in_bytes":0,"disk_write_size_in_bytes":0,"disk_io_size_in_bytes":0},"data":[{"path":"/Users/leonardo.menezes/Downloads/elasticsearch-1.3.0-SNAPSHOT/data/elasticsearch/nodes/1","mount":"/","dev":"/dev/disk1","total_in_bytes":249804886016,"free_in_bytes":105004523520,"available_in_bytes":104742379520,"disk_reads":0,"disk_writes":0,"disk_io_op":0,"disk_read_size_in_bytes":0,"disk_write_size_in_bytes":0,"disk_io_size_in_bytes":0}]},"transport":{"server_open":26,"rx_count":111,"rx_size_in_bytes":16986,"tx_count":110,"tx_size_in_bytes":6607},"http":{"current_open":0,"total_opened":0},"fielddata_breaker":{"maximum_size_in_bytes":622775500,"maximum_size":"593.9mb","estimated_size_in_bytes":0,"estimated_size":"0b","overhead":1.03,"tripped":0}},"ijZWlj2cSfOecB8IXY2P4g":{"timestamp":1401527906054,"name":"Metal Master","transport_address":"inet[/192.168.2.106:9300]","host":"localhost","ip":["inet[/192.168.2.106:9300]","NONE"],"indices":{"docs":{"count":4,"deleted":0},"store":{"size_in_bytes":3155,"throttle_time_in_millis":0},"indexing":{"index_total":4,"index_time_in_millis":41,"index_current":0,"delete_total":0,"delete_time_in_millis":0,"delete_current":0},"get":{"total":0,"time_in_millis":0,"exists_total":0,"exists_time_in_millis":0,"missing_total":0,"missing_time_in_millis":0,"current":0},"search":{"open_contexts":0,"query_total":0,"query_time_in_millis":0,"query_current":0,"fetch_total":0,"fetch_time_in_millis":0,"fetch_current":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":4,"total_time_in_millis":74},"flush":{"total":0,"total_time_in_millis":0},"warmer":{"current":0,"total":6,"total_time_in_millis":1},"filter_cache":{"memory_size_in_bytes":0,"evictions":0},"id_cache":{"memory_size_in_bytes":0},"fielddata":{"memory_size_in_bytes":0,"evictions":0},"percolate":{"total":0,"time_in_millis":0,"current":0,"memory_size_in_bytes":-1,"memory_size":"-1b","queries":0},"completion":{"size_in_bytes":0},"segments":{"count":1,"memory_in_bytes":449},"translog":{"operations":4,"size_in_bytes":0},"suggest":{"total":0,"time_in_millis":0,"current":0}},"os":{"timestamp":1401527906059,"uptime_in_millis":623,"load_average":[1.478515625,1.7685546875,1.11083984375],"cpu":{"sys":1,"user":5,"idle":93,"usage":6,"stolen":0},"mem":{"free_in_bytes":2524221440,"used_in_bytes":6065713152,"free_percent":45,"used_percent":54,"actual_free_in_bytes":3930902528,"actual_used_in_bytes":4659032064},"swap":{"used_in_bytes":0,"free_in_bytes":1073741824}},"process":{"timestamp":1401527906059,"open_file_descriptors":259,"cpu":{"percent":7,"sys_in_millis":422,"user_in_millis":5091,"total_in_millis":5513},"mem":{"resident_in_bytes":215416832,"share_in_bytes":-1,"total_virtual_in_bytes":3953086464}},"jvm":{"timestamp":1401527906059,"uptime_in_millis":44852,"mem":{"heap_used_in_bytes":90400736,"heap_used_percent":8,"heap_committed_in_bytes":259522560,"heap_max_in_bytes":1037959168,"non_heap_used_in_bytes":34782576,"non_heap_committed_in_bytes":36306944,"pools":{"young":{"used_in_bytes":66651328,"max_in_bytes":286326784,"peak_used_in_bytes":71630848,"peak_max_in_bytes":286326784},"survivor":{"used_in_bytes":8199352,"max_in_bytes":35782656,"peak_used_in_bytes":8912888,"peak_max_in_bytes":35782656},"old":{"used_in_bytes":15550056,"max_in_bytes":715849728,"peak_used_in_bytes":15550056,"peak_max_in_bytes":715849728}}},"threads":{"count":76,"peak_count":76},"gc":{"collectors":{"young":{"collection_count":3,"collection_time_in_millis":42},"old":{"collection_count":0,"collection_time_in_millis":0}}},"buffer_pools":{"direct":{"count":85,"used_in_bytes":20448493,"total_capacity_in_bytes":20448493},"mapped":{"count":0,"used_in_bytes":0,"total_capacity_in_bytes":0}}},"thread_pool":{"generic":{"threads":3,"queue":0,"active":0,"rejected":0,"largest":3,"completed":50},"index":{"threads":4,"queue":0,"active":0,"rejected":0,"largest":4,"completed":4},"snapshot_data":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"bench":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"get":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"snapshot":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"merge":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":1},"suggest":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"bulk":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"optimize":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"warmer":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":4},"flush":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"search":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"percolate":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"management":{"threads":2,"queue":0,"active":1,"rejected":0,"largest":2,"completed":5},"refresh":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":2}},"network":{"tcp":{"active_opens":912,"passive_opens":98,"curr_estab":187,"in_segs":52310,"out_segs":28960,"retrans_segs":6,"estab_resets":48,"attempt_fails":25,"in_errs":2,"out_rsts":-1}},"fs":{"timestamp":1401527906061,"total":{"total_in_bytes":249804886016,"free_in_bytes":105004523520,"available_in_bytes":104742379520,"disk_reads":0,"disk_writes":0,"disk_io_op":0,"disk_read_size_in_bytes":0,"disk_write_size_in_bytes":0,"disk_io_size_in_bytes":0},"data":[{"path":"/Users/leonardo.menezes/Downloads/elasticsearch-1.3.0-SNAPSHOT/data/elasticsearch/nodes/0","mount":"/","dev":"/dev/disk1","total_in_bytes":249804886016,"free_in_bytes":105004523520,"available_in_bytes":104742379520,"disk_reads":0,"disk_writes":0,"disk_io_op":0,"disk_read_size_in_bytes":0,"disk_write_size_in_bytes":0,"disk_io_size_in_bytes":0}]},"transport":{"server_open":26,"rx_count":110,"rx_size_in_bytes":6607,"tx_count":111,"tx_size_in_bytes":16986},"http":{"current_open":1,"total_opened":23},"fielddata_breaker":{"maximum_size_in_bytes":622775500,"maximum_size":"593.9mb","estimated_size_in_bytes":0,"estimated_size":"0b","overhead":1.03,"tripped":0}}}}');
	var settings = JSON.parse('{"_shards":{"total":5,"successful":4,"failed":0},"indices":{"foobar":{"index":{"primary_size_in_bytes":6136,"size_in_bytes":6136},"translog":{"operations":8},"docs":{"num_docs":8,"max_doc":8,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":4,"total_time_in_millis":152},"flush":{"total":0,"total_time_in_millis":0},"shards":{"0":[{"routing":{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobar"},"state":"STARTED","index":{"size_in_bytes":3068},"translog":{"id":1401527904013,"operations":4},"docs":{"num_docs":4,"max_doc":4,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":78},"flush":{"total":0,"total_time_in_millis":0}}],"1":[{"routing":{"state":"STARTED","primary":true,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":1,"index":"foobar"},"state":"STARTED","index":{"size_in_bytes":3068},"translog":{"id":1401527904175,"operations":4},"docs":{"num_docs":4,"max_doc":4,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":74},"flush":{"total":0,"total_time_in_millis":0}}]}},"foobaz":{"index":{"primary_size_in_bytes":123,"size_in_bytes":210},"translog":{"operations":0},"docs":{"num_docs":0,"max_doc":0,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":3,"total_time_in_millis":0},"flush":{"total":0,"total_time_in_millis":0},"shards":{"0":[{"routing":{"state":"STARTED","primary":true,"node":"bisY7wgCSa67QMba_NOR4Q","relocating_node":null,"shard":0,"index":"foobaz"},"state":"STARTED","index":{"size_in_bytes":123},"translog":{"id":1401527904397,"operations":0},"docs":{"num_docs":0,"max_doc":0,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":0},"flush":{"total":0,"total_time_in_millis":0}},{"routing":{"state":"STARTED","primary":false,"node":"ijZWlj2cSfOecB8IXY2P4g","relocating_node":null,"shard":0,"index":"foobaz"},"state":"STARTED","index":{"size_in_bytes":87},"translog":{"id":1401527904397,"operations":0},"docs":{"num_docs":0,"max_doc":0,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":1,"total_time_in_millis":0},"flush":{"total":0,"total_time_in_millis":0}}]}}}}');
	var cluster = new Cluster(state, status, stats, settings);
	
	var size_pattern = /\d+\.\d+\w{1,2}/;
	var number_pattern = /\d+/;
	
	// check clustercluster properties
	equal(cluster.num_docs, 8, "Number of documents");
	//equal(cluster.total_size == '16.49KB', "Checking total size");
	equal(cluster.unassigned_shards, 1, "Unassigned shards");
	equal(cluster.shards, 5, "Number of shards");
	equal(cluster.failed_shards, 0, "Failed shards");
	equal(cluster.total_indices, 3, "Number of indices");
	var master_node = cluster.master_node;
	
	// index info
	ok(cluster.indices.length, 3, "Indices list length");
	
	var indices = cluster.indices;
	indices.forEach(function(index) {
		ok(index.state == 'open' || index.state == 'close', "Checking index state: [" + index.state + "]");
		ok(number_pattern.test(index.size), "Checking primary size: [" + index.size + "]");
		ok(number_pattern.test(index.total_size), "Checking total size: [" + index.total_size + "]");
		if (index.state == 'open') {
			ok(size_pattern.test(index.size_in_bytes), "Checking primary size: [" + index.size_in_bytes + "]");
			ok(size_pattern.test(index.total_size_in_bytes), "Checking total size: [" + index.total_size_in_bytes + "]");
		}
		ok(number_pattern.test(index.num_docs), "Checking num docs: [" + index.num_docs + "]");
		ok(number_pattern.test(index.max_doc), "Checking max doc: [" + index.max_doc + "]");
		ok(number_pattern.test(index.deleted_docs), "Checking deleted docs: [" + index.deleted_docs + "]");
		ok(index.name.length > 0, "Checking index name: [" + index.name + "]");
		ok(number_pattern.test(index.num_of_shards), "Checking number of shards: [" + index.num_of_shards + "]");
		ok(number_pattern.test(index.num_of_replicas), "Checking number of replicas: [" + index.num_of_replicas + "]");
		var node_ids = cluster.getNodes('', true, true, true).map(function(node) { return node.id; });
		node_ids.forEach(function(node_id) {
			if (index.shards[node_id] !== undefined) {
				index.shards[node_id].forEach(function(shard) {
					ok(shard.primary == true || shard.primary == false, "Checking primary status: [" + shard.primary +"]");
					equal(shard.node, node_id, "Shards should have referece to correct node");
					ok(shard.state == 'STARTED', "Shards should be started: [" + shard.state + "]");
				});
			}
		});
		
		equal(index.getTypes().length , 2, "Checking types length");
		index.getTypes().forEach(function(type) {
			// id is not analyzable, so its not on the list
			equal(index.getFields(type).length, 2, "Checking fields length for " + type);
		});
		
		equal(index.getAnalyzers().length, 1, "Checking analyzers length");
	});

	// check nodes
	var nodes = cluster.getNodes('', true, true, true);
	equal(nodes.length, 2, "Unfiltered node list");
	var master_nodes = 0;
	nodes.forEach(function(node) {
		ok(size_pattern.test(node.disk_total), "Checking disk total [" + node.disk_total + "]");
		ok(size_pattern.test(node.disk_free), "Checking free disk [" + node.disk_total + "]");
		ok(node.disk_used_percent >= 0 && node.disk_used_percent <= 100, "Checking disk usage in percent [" + node.disk_used_percent + "]");
		ok(size_pattern.test(node.size), "Checking node sotre size [" + node.size + "]");
		ok(size_pattern.test(node.heap_used), "Checking node heap used [" + node.heap_used + "]");
		ok(size_pattern.test(node.heap_committed), "Checking node heap commited [" + node.heap_committed + "]");
		ok(size_pattern.test(node.heap_max), "Checking max heap size [" + node.heap_max + "]");
		ok(node.heap_used_percent >= 0 && node.heap_used_percent <= 100, "Checking heap used percent [" + node.heap_used_percent + "]");
		ok(node.cpu_user >= 0 && number_pattern.test(node.cpu_user), "Checking os user cpu [" + node.cpu_user + "]");
		ok(node.cpu_sys >= 0 && number_pattern.test(node.cpu_sys), "Checking os sys cpu [" + node.cpu_sys + "]");
		equal(node.id.length, 22, "Checking node id length");
		ok(number_pattern.test(node.docs), "Checking number of documents per node " + node.docs);
		if (node.current_master) {
			master_nodes += 1;
			equal(master_node, node.id, "Checking current master");
		}
		// should find at least current node
		var matchingNodes = cluster.getNodes(node.name, true, true, true);
		ok(matchingNodes.length >= 1, "Should find at least node with that name: [" + matchingNodes.length + "]");
		// should not find at least the current node
		var nonMatchingNodes = cluster.getNodes(node.name + "a", true, true, true);
		ok(nonMatchingNodes.length < matchingNodes.length, "Should find at least one less node with that name");
		ok(node.transport_address.length > 0, "Checking node transport address");	
		ok(node.host.length > 0, "Checking node host name");	
	});
	equal(master_nodes, 1, "There should be exactly one master node");
});

test("computing cluster changes", function() {
	var state = JSON.parse('{"cluster_name":"kopf_cluster","master_node":"JvYCtd57Tne-fxlK1GVHRw","blocks":{},"nodes":{"JvYCtd57Tne-fxlK1GVHRw":{"name":"<NAME>","transport_address":"inet[/192.168.2.104:9300]","attributes":{}}},"metadata":{"templates":{},"indices":{"kopf_test":{"state":"open","settings":{"index":{"uuid":"7yDVKjHeS7uKbQuQbs3VNw","analysis":{"analyzer":{"kopf_analyzer_1":{"type":"custom","tokenizer":"whitespace"},"kopf_analyzer_2":{"type":"custom","tokenizer":"whitespace"}}},"number_of_replicas":"1","number_of_shards":"5","version":{"created":"1000051"}}},"mappings":{"kopf":{"properties":{"id":{"type":"long"},"content_2":{"type":"string","fields":{"content_2_raw":{"type":"string"}}},"content_1":{"path":"just_name","type":"string","fields":{"content_1_raw":{"type":"string"}}}}}},"aliases":["kopf_alias_2","kopf_alias_1"]}}},"routing_table":{"indices":{"kopf_test":{"shards":{"2":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":2,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":2,"index":"kopf_test"}],"0":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":0,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":0,"index":"kopf_test"}],"3":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":3,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":3,"index":"kopf_test"}],"1":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":1,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":1,"index":"kopf_test"}],"4":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":4,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":4,"index":"kopf_test"}]}}}},"routing_nodes":{"unassigned":[{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":2,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":0,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":3,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":1,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":4,"index":"kopf_test"}],"nodes":{"JvYCtd57Tne-fxlK1GVHRw":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":2,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":0,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":3,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":1,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":4,"index":"kopf_test"}]}},"allocations":[]}');
	var status = JSON.parse('{"_shards":{"total":10,"successful":5,"failed":0},"indices":{"kopf_test":{"index":{"primary_size_in_bytes":16887,"size_in_bytes":16887},"translog":{"operations":8},"docs":{"num_docs":6,"max_doc":6,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":13,"total_time_in_millis":125},"flush":{"total":0,"total_time_in_millis":0},"shards":{"0":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":0,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853127,"operations":1},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":15},"flush":{"total":0,"total_time_in_millis":0}}],"1":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":1,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853155,"operations":1},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":16},"flush":{"total":0,"total_time_in_millis":0}}],"2":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":2,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":5563},"translog":{"id":1390857853170,"operations":2},"docs":{"num_docs":2,"max_doc":2,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":3,"total_time_in_millis":43},"flush":{"total":0,"total_time_in_millis":0}}],"3":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":3,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853142,"operations":3},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":4,"total_time_in_millis":35},"flush":{"total":0,"total_time_in_millis":0}}],"4":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tne-fxlK1GVHRw","relocating_node":null,"shard":4,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853204,"operations":1},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":16},"flush":{"total":0,"total_time_in_millis":0}}]}}}}');
	var stats = JSON.parse('{"cluster_name":"kopf_cluster","nodes":{"JvYCtd57Tne-fxlK1GVHRw":{"timestamp":1390858085598,"name":"<NAME>","transport_address":"inet[/192.168.2.104:9300]","host":"leo.local","ip":["inet[/192.168.2.104:9300]","NONE"],"indices":{"docs":{"count":6,"deleted":0},"store":{"size_in_bytes":16887,"throttle_time_in_millis":0},"indexing":{"index_total":11,"index_time_in_millis":194,"index_current":0,"delete_total":2,"delete_time_in_millis":2,"delete_current":0},"get":{"total":0,"time_in_millis":0,"exists_total":0,"exists_time_in_millis":0,"missing_total":0,"missing_time_in_millis":0,"current":0},"search":{"open_contexts":0,"query_total":20,"query_time_in_millis":31,"query_current":0,"fetch_total":0,"fetch_time_in_millis":0,"fetch_current":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":65,"total_time_in_millis":295},"flush":{"total":2,"total_time_in_millis":16},"warmer":{"current":0,"total":12,"total_time_in_millis":4},"filter_cache":{"memory_size_in_bytes":0,"evictions":0},"id_cache":{"memory_size_in_bytes":0},"fielddata":{"memory_size_in_bytes":0,"evictions":0},"percolate":{"total":0,"time_in_millis":0,"current":0,"memory_size_in_bytes":0,"memory_size":"0b","queries":0},"completion":{"size_in_bytes":0},"segments":{"count":6,"memory_in_bytes":0},"translog":{"operations":8,"size_in_bytes":113}},"os":{"timestamp":1390858084866,"uptime_in_millis":693508,"load_average":[1.42822265625,1.63525390625,1.88037109375],"cpu":{"sys":11,"user":18,"idle":69,"usage":29,"stolen":0},"mem":{"free_in_bytes":495689728,"used_in_bytes":8094244864,"free_percent":41,"used_percent":58,"actual_free_in_bytes":3530981376,"actual_used_in_bytes":5058953216},"swap":{"used_in_bytes":0,"free_in_bytes":1073741824}},"process":{"timestamp":1390858084866,"open_file_descriptors":148,"cpu":{"percent":0,"sys_in_millis":63331,"user_in_millis":113294,"total_in_millis":176625},"mem":{"resident_in_bytes":324427776,"share_in_bytes":-1,"total_virtual_in_bytes":3883094016}},"jvm":{"timestamp":1390858084867,"uptime_in_millis":182268477,"mem":{"heap_used_in_bytes":102054072,"heap_used_percent":9,"heap_committed_in_bytes":251002880,"heap_max_in_bytes":1056309248,"non_heap_used_in_bytes":38337328,"non_heap_committed_in_bytes":38666240,"pools":{"young":{"used_in_bytes":83487440,"max_in_bytes":139591680,"peak_used_in_bytes":139591680,"peak_max_in_bytes":139591680},"survivor":{"used_in_bytes":2591784,"max_in_bytes":17432576,"peak_used_in_bytes":17432576,"peak_max_in_bytes":17432576},"old":{"used_in_bytes":15974848,"max_in_bytes":899284992,"peak_used_in_bytes":15974848,"peak_max_in_bytes":899284992}}},"threads":{"count":49,"peak_count":50},"gc":{"collectors":{"young":{"collection_count":9,"collection_time_in_millis":299},"old":{"collection_count":0,"collection_time_in_millis":0}}},"buffer_pools":{"direct":{"count":37,"used_in_bytes":9392421,"total_capacity_in_bytes":9392421},"mapped":{"count":0,"used_in_bytes":0,"total_capacity_in_bytes":0}}},"thread_pool":{"generic":{"threads":4,"queue":0,"active":0,"rejected":0,"largest":5,"completed":17733},"index":{"threads":2,"queue":0,"active":0,"rejected":0,"largest":2,"completed":13},"get":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"snapshot":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":13},"merge":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":13},"suggest":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"bulk":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"optimize":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"warmer":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":86},"flush":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":2},"search":{"threads":6,"queue":0,"active":0,"rejected":0,"largest":6,"completed":20},"percolate":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"management":{"threads":5,"queue":0,"active":2,"rejected":0,"largest":5,"completed":19932},"refresh":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":13}},"network":{"tcp":{"active_opens":26842,"passive_opens":1470,"curr_estab":53,"in_segs":1812321,"out_segs":1561574,"retrans_segs":2190,"estab_resets":1395,"attempt_fails":4109,"in_errs":16,"out_rsts":-1}},"fs":{"timestamp":1390858084868,"total":{"total_in_bytes":255200755712,"free_in_bytes":82445713408,"available_in_bytes":82183569408,"disk_reads":578277,"disk_writes":854240,"disk_io_op":1432517,"disk_read_size_in_bytes":9500736512,"disk_write_size_in_bytes":15133154304,"disk_io_size_in_bytes":24633890816},"data":[{"path":"/Users/leo/Downloads/elasticsearch-1.0.0.RC1/data/kopf_cluster/nodes/0","mount":"/","dev":"/dev/disk0s2","total_in_bytes":255200755712,"free_in_bytes":82445713408,"available_in_bytes":82183569408,"disk_reads":578277,"disk_writes":854240,"disk_io_op":1432517,"disk_read_size_in_bytes":9500736512,"disk_write_size_in_bytes":15133154304,"disk_io_size_in_bytes":24633890816}]},"transport":{"server_open":13,"rx_count":27,"rx_size_in_bytes":2753,"tx_count":27,"tx_size_in_bytes":3409},"http":{"current_open":6,"total_opened":139},"fielddata_breaker":{"maximum_size_in_bytes":845047398,"maximum_size":"805.8mb","estimated_size_in_bytes":0,"estimated_size":"0b","overhead":1.03}}}}');
	var settings = JSON.parse('{"persistent":{},"transient":{"cluster":{"routing":{"allocation":{"disable_allocation":"false"}}}}}');
	var cluster = new Cluster(state, status, stats, settings);

	var state2 = JSON.parse('{"cluster_name":"kopf_cluster","master_node":"JvYCtd57Tn-fxlK1GVHRw","blocks":{},"nodes":{"JvYCtd57Tn-fxlK1GVHRw":{"name":"<NAME>","transport_address":"inet[/192.168.2.104:9300]","attributes":{}}},"metadata":{"templates":{},"indices":{"kopf_test":{"state":"open","settings":{"index":{"uuid":"7yDVKjHeS7uKbQuQbs3VNw","analysis":{"analyzer":{"kopf_analyzer_1":{"type":"custom","tokenizer":"whitespace"},"kopf_analyzer_2":{"type":"custom","tokenizer":"whitespace"}}},"number_of_replicas":"1","number_of_shards":"5","version":{"created":"1000051"}}},"mappings":{"kopf":{"properties":{"id":{"type":"long"},"content_2":{"type":"string","fields":{"content_2_raw":{"type":"string"}}},"content_1":{"path":"just_name","type":"string","fields":{"content_1_raw":{"type":"string"}}}}}},"aliases":["kopf_alias_2","kopf_alias_1"]}}},"routing_table":{"indices":{"kopf_test":{"shards":{"2":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":2,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":2,"index":"kopf_test"}],"0":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":0,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":0,"index":"kopf_test"}],"3":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":3,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":3,"index":"kopf_test"}],"1":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":1,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":1,"index":"kopf_test"}],"4":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":4,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":4,"index":"kopf_test"}]}}}},"routing_nodes":{"unassigned":[{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":2,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":0,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":3,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":1,"index":"kopf_test"},{"state":"UNASSIGNED","primary":false,"node":null,"relocating_node":null,"shard":4,"index":"kopf_test"}],"nodes":{"JvYCtd57Tn-fxlK1GVHRw":[{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":2,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":0,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":3,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":1,"index":"kopf_test"},{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":4,"index":"kopf_test"}]}},"allocations":[]}');
	var status2 = JSON.parse('{"_shards":{"total":10,"successful":5,"failed":0},"indices":{"kopf_test":{"index":{"primary_size_in_bytes":19887,"size_in_bytes":19887},"translog":{"operations":8},"docs":{"num_docs":7,"max_doc":7,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":13,"total_time_in_millis":125},"flush":{"total":0,"total_time_in_millis":0},"shards":{"0":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":0,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853127,"operations":1},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":15},"flush":{"total":0,"total_time_in_millis":0}}],"1":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":1,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853155,"operations":1},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":16},"flush":{"total":0,"total_time_in_millis":0}}],"2":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":2,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":5563},"translog":{"id":1390857853170,"operations":2},"docs":{"num_docs":2,"max_doc":2,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":3,"total_time_in_millis":43},"flush":{"total":0,"total_time_in_millis":0}}],"3":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":3,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853142,"operations":3},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":4,"total_time_in_millis":35},"flush":{"total":0,"total_time_in_millis":0}}],"4":[{"routing":{"state":"STARTED","primary":true,"node":"JvYCtd57Tn-fxlK1GVHRw","relocating_node":null,"shard":4,"index":"kopf_test"},"state":"STARTED","index":{"size_in_bytes":2831},"translog":{"id":1390857853204,"operations":1},"docs":{"num_docs":1,"max_doc":1,"deleted_docs":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":2,"total_time_in_millis":16},"flush":{"total":0,"total_time_in_millis":0}}]}}}}');
	var stats2 = JSON.parse('{"cluster_name":"kopf_cluster","nodes":{"JvYCtd57Tn-fxlK1GVHRw":{"timestamp":1390858085598,"name":"<NAME>","transport_address":"inet[/192.168.2.104:9300]","host":"leo.local","ip":["inet[/192.168.2.104:9300]","NONE"],"indices":{"docs":{"count":6,"deleted":0},"store":{"size_in_bytes":16887,"throttle_time_in_millis":0},"indexing":{"index_total":11,"index_time_in_millis":194,"index_current":0,"delete_total":2,"delete_time_in_millis":2,"delete_current":0},"get":{"total":0,"time_in_millis":0,"exists_total":0,"exists_time_in_millis":0,"missing_total":0,"missing_time_in_millis":0,"current":0},"search":{"open_contexts":0,"query_total":20,"query_time_in_millis":31,"query_current":0,"fetch_total":0,"fetch_time_in_millis":0,"fetch_current":0},"merges":{"current":0,"current_docs":0,"current_size_in_bytes":0,"total":0,"total_time_in_millis":0,"total_docs":0,"total_size_in_bytes":0},"refresh":{"total":65,"total_time_in_millis":295},"flush":{"total":2,"total_time_in_millis":16},"warmer":{"current":0,"total":12,"total_time_in_millis":4},"filter_cache":{"memory_size_in_bytes":0,"evictions":0},"id_cache":{"memory_size_in_bytes":0},"fielddata":{"memory_size_in_bytes":0,"evictions":0},"percolate":{"total":0,"time_in_millis":0,"current":0,"memory_size_in_bytes":0,"memory_size":"0b","queries":0},"completion":{"size_in_bytes":0},"segments":{"count":6,"memory_in_bytes":0},"translog":{"operations":8,"size_in_bytes":113}},"os":{"timestamp":1390858084866,"uptime_in_millis":693508,"load_average":[1.42822265625,1.63525390625,1.88037109375],"cpu":{"sys":11,"user":18,"idle":69,"usage":29,"stolen":0},"mem":{"free_in_bytes":495689728,"used_in_bytes":8094244864,"free_percent":41,"used_percent":58,"actual_free_in_bytes":3530981376,"actual_used_in_bytes":5058953216},"swap":{"used_in_bytes":0,"free_in_bytes":1073741824}},"process":{"timestamp":1390858084866,"open_file_descriptors":148,"cpu":{"percent":0,"sys_in_millis":63331,"user_in_millis":113294,"total_in_millis":176625},"mem":{"resident_in_bytes":324427776,"share_in_bytes":-1,"total_virtual_in_bytes":3883094016}},"jvm":{"timestamp":1390858084867,"uptime_in_millis":182268477,"mem":{"heap_used_in_bytes":102054072,"heap_used_percent":9,"heap_committed_in_bytes":251002880,"heap_max_in_bytes":1056309248,"non_heap_used_in_bytes":38337328,"non_heap_committed_in_bytes":38666240,"pools":{"young":{"used_in_bytes":83487440,"max_in_bytes":139591680,"peak_used_in_bytes":139591680,"peak_max_in_bytes":139591680},"survivor":{"used_in_bytes":2591784,"max_in_bytes":17432576,"peak_used_in_bytes":17432576,"peak_max_in_bytes":17432576},"old":{"used_in_bytes":15974848,"max_in_bytes":899284992,"peak_used_in_bytes":15974848,"peak_max_in_bytes":899284992}}},"threads":{"count":49,"peak_count":50},"gc":{"collectors":{"young":{"collection_count":9,"collection_time_in_millis":299},"old":{"collection_count":0,"collection_time_in_millis":0}}},"buffer_pools":{"direct":{"count":37,"used_in_bytes":9392421,"total_capacity_in_bytes":9392421},"mapped":{"count":0,"used_in_bytes":0,"total_capacity_in_bytes":0}}},"thread_pool":{"generic":{"threads":4,"queue":0,"active":0,"rejected":0,"largest":5,"completed":17733},"index":{"threads":2,"queue":0,"active":0,"rejected":0,"largest":2,"completed":13},"get":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"snapshot":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":13},"merge":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":13},"suggest":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"bulk":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"optimize":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"warmer":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":86},"flush":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":2},"search":{"threads":6,"queue":0,"active":0,"rejected":0,"largest":6,"completed":20},"percolate":{"threads":0,"queue":0,"active":0,"rejected":0,"largest":0,"completed":0},"management":{"threads":5,"queue":0,"active":2,"rejected":0,"largest":5,"completed":19932},"refresh":{"threads":1,"queue":0,"active":0,"rejected":0,"largest":1,"completed":13}},"network":{"tcp":{"active_opens":26842,"passive_opens":1470,"curr_estab":53,"in_segs":1812321,"out_segs":1561574,"retrans_segs":2190,"estab_resets":1395,"attempt_fails":4109,"in_errs":16,"out_rsts":-1}},"fs":{"timestamp":1390858084868,"total":{"total_in_bytes":255200755712,"free_in_bytes":82445713408,"available_in_bytes":82183569408,"disk_reads":578277,"disk_writes":854240,"disk_io_op":1432517,"disk_read_size_in_bytes":9500736512,"disk_write_size_in_bytes":15133154304,"disk_io_size_in_bytes":24633890816},"data":[{"path":"/Users/leo/Downloads/elasticsearch-1.0.0.RC1/data/kopf_cluster/nodes/0","mount":"/","dev":"/dev/disk0s2","total_in_bytes":255200755712,"free_in_bytes":82445713408,"available_in_bytes":82183569408,"disk_reads":578277,"disk_writes":854240,"disk_io_op":1432517,"disk_read_size_in_bytes":9500736512,"disk_write_size_in_bytes":15133154304,"disk_io_size_in_bytes":24633890816}]},"transport":{"server_open":13,"rx_count":27,"rx_size_in_bytes":2753,"tx_count":27,"tx_size_in_bytes":3409},"http":{"current_open":6,"total_opened":139},"fielddata_breaker":{"maximum_size_in_bytes":845047398,"maximum_size":"805.8mb","estimated_size_in_bytes":0,"estimated_size":"0b","overhead":1.03}}}}');
	var settings2 = JSON.parse('{"persistent":{},"transient":{"cluster":{"routing":{"allocation":{"disable_allocation":"false"}}}}}');
	var cluster2 = new Cluster(state2, status2, stats2, settings2);

	cluster2.computeChanges(cluster);
	
	ok(cluster2.changes.getDocDelta() == 1, "Checking document delta");
	ok(cluster2.changes.getDataDelta() == 3000, "" + cluster2.changes.getDataDelta());
	ok(cluster2.changes.absDataDelta() == "2.93KB", "" + cluster2.changes.absDataDelta());

	ok(cluster2.changes.nodeJoins.length == 1, "checking joinng nodes");
	ok(cluster2.changes.nodeLeaves.length == 1, "checking disconnecting nodes");
	
	ok(cluster2.changes.nodeJoins[0].id == "JvYCtd57Tn-fxlK1GVHRw", "checking node identity");
	ok(cluster2.changes.nodeLeaves[0].id == "JvYCtd57Tne-fxlK1GVHRw", "checking node identity");
});

{'fraction_non_alphanumeric': 0.2628501046433614, 'fraction_numerical': 0.08756997086007831, 'mean_word_length': 39.927868852459014, 'pattern_counts': {'":': 5168, '<': 16, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 24, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3676230', 'n_tokens_mistral': 42612, 'n_tokens_neox': 37173, 'n_words': 923}