mirror of https://github.com/apache/lucene.git
SOLR-2592: add additional level in clusterstate.json for collection properties
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1421499 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
902381a8ec
commit
43f36a5750
|
@ -225,10 +225,21 @@ public class ClusterState implements JSONWriter.Writable {
|
|||
}
|
||||
|
||||
private static DocCollection collectionFromObjects(String name, Map<String,Object> objs) {
|
||||
Map<String,Object> props = (Map<String,Object>)objs.get(DocCollection.PROPERTIES);
|
||||
if (props == null) props = Collections.emptyMap();
|
||||
Map<String,Object> props;
|
||||
Map<String,Slice> slices;
|
||||
|
||||
Map<String,Object> sliceObjs = (Map<String,Object>)objs.get(DocCollection.SHARDS);
|
||||
if (sliceObjs == null) {
|
||||
// legacy format from 4.0... there was no separate "shards" level to contain the collection shards.
|
||||
slices = makeSlices(objs);
|
||||
props = Collections.emptyMap();
|
||||
} else {
|
||||
slices = makeSlices(sliceObjs);
|
||||
props = new HashMap<String, Object>(objs);
|
||||
objs.remove(DocCollection.SHARDS);
|
||||
}
|
||||
|
||||
DocRouter router = DocRouter.getDocRouter(props.get(DocCollection.DOC_ROUTER));
|
||||
Map<String,Slice> slices = makeSlices(objs);
|
||||
return new DocCollection(name, slices, props, router);
|
||||
}
|
||||
|
||||
|
@ -237,15 +248,12 @@ public class ClusterState implements JSONWriter.Writable {
|
|||
Map<String,Slice> result = new LinkedHashMap<String, Slice>(genericSlices.size());
|
||||
for (Map.Entry<String,Object> entry : genericSlices.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
if (DocCollection.PROPERTIES.equals(name)) continue; // skip special properties entry
|
||||
Object val = entry.getValue();
|
||||
Slice s;
|
||||
if (val instanceof Slice) {
|
||||
s = (Slice)val;
|
||||
} else {
|
||||
s = new Slice(name, null, (Map<String,Object>)val);
|
||||
result.put(name, (Slice)val);
|
||||
} else if (val instanceof Map) {
|
||||
result.put(name, new Slice(name, null, (Map<String,Object>)val));
|
||||
}
|
||||
result.put(name, s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.apache.noggit.JSONUtil;
|
|||
import org.apache.noggit.JSONWriter;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
@ -29,18 +30,24 @@ import java.util.Map;
|
|||
* Models a Collection in zookeeper (but that Java name is obviously taken, hence "DocCollection")
|
||||
*/
|
||||
public class DocCollection extends ZkNodeProps {
|
||||
public static final String PROPERTIES = "properties";
|
||||
public static final String DOC_ROUTER = "router";
|
||||
public static final String SHARDS = "shards";
|
||||
|
||||
private final String name;
|
||||
private final Map<String, Slice> slices;
|
||||
private final DocRouter router;
|
||||
|
||||
/**
|
||||
* @param name The name of the collection
|
||||
* @param slices The logical shards of the collection. This is used directly and a copy is not made.
|
||||
* @param props The properties of the slice. This is used directly and a copy is not made.
|
||||
*/
|
||||
public DocCollection(String name, Map<String, Slice> slices, Map<String, Object> props, DocRouter router) {
|
||||
super(props == null ? new HashMap<String,Object>(1) : props);
|
||||
super( props==null ? Collections.<String,Object>emptyMap() : props);
|
||||
this.name = name;
|
||||
this.slices = slices;
|
||||
this.router = router;
|
||||
|
||||
assert name != null && slices != null;
|
||||
}
|
||||
|
||||
|
@ -81,10 +88,9 @@ public class DocCollection extends ZkNodeProps {
|
|||
|
||||
@Override
|
||||
public void write(JSONWriter jsonWriter) {
|
||||
// write out the properties under "properties"
|
||||
LinkedHashMap<String,Object> all = new LinkedHashMap<String,Object>(slices.size()+1);
|
||||
all.put(PROPERTIES, propMap);
|
||||
all.putAll(slices);
|
||||
all.putAll(propMap);
|
||||
all.put(SHARDS, slices);
|
||||
jsonWriter.write(all);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -369,13 +369,13 @@ var prepare_graph = function( graph_element, callback )
|
|||
for( var c in state )
|
||||
{
|
||||
var shards = [];
|
||||
for( var s in state[c] )
|
||||
for( var s in state[c].shards )
|
||||
{
|
||||
var nodes = [];
|
||||
for( var n in state[c][s].replicas )
|
||||
for( var n in state[c].shards[s].replicas )
|
||||
{
|
||||
leaf_count++;
|
||||
var replica = state[c][s].replicas[n]
|
||||
var replica = state[c].shards[s].replicas[n]
|
||||
|
||||
var uri = replica.base_url;
|
||||
var parts = uri.match( /^(\w+:)\/\/(([\w\d\.-]+)(:(\d+))?)(.+)$/ );
|
||||
|
|
Loading…
Reference in New Issue