mirror of https://github.com/apache/lucene.git
SOLR-4566: Fix DocCollection to return all shards not just active shards.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1455911 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fd1e30a471
commit
ccb85cd5cd
|
@ -81,6 +81,8 @@ Bug Fixes
|
|||
* SOLR-4567: copyField source glob matching explicit field(s) stopped working
|
||||
in Solr 4.2. (Alexandre Rafalovitch, Steve Rowe)
|
||||
|
||||
* SOLR-4566: Fix DocCollection to return all shards not just active shards.
|
||||
(Mark Miller)
|
||||
|
||||
Other Changes
|
||||
----------------------
|
||||
|
|
|
@ -171,7 +171,7 @@ public class SliceStateUpdateTest extends SolrTestCaseJ4 {
|
|||
Map<String, Slice> slices = null;
|
||||
for (int i = 75; i > 0; i--) {
|
||||
clusterState2 = zkController2.getClusterState();
|
||||
slices = clusterState2.getAllSlicesMap("collection1");
|
||||
slices = clusterState2.getSlicesMap("collection1");
|
||||
if (slices != null && slices.containsKey("shard1")
|
||||
&& slices.get("shard1").getState().equals("inactive")) {
|
||||
break;
|
||||
|
|
|
@ -114,17 +114,11 @@ public class ClusterState implements JSONWriter.Writable {
|
|||
if (coll == null) return null;
|
||||
return coll.getSlicesMap();
|
||||
}
|
||||
|
||||
public Map<String, Slice> getAllSlicesMap(String collection) {
|
||||
DocCollection coll = collectionStates.get(collection);
|
||||
if (coll == null) return null;
|
||||
return coll.getAllSlicesMap();
|
||||
}
|
||||
|
||||
public Collection<Slice> getSlices(String collection) {
|
||||
DocCollection coll = collectionStates.get(collection);
|
||||
if (coll == null) return null;
|
||||
return coll.getSlices();
|
||||
return coll.getSlicesMap().values();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,16 +17,14 @@ package org.apache.solr.common.cloud;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
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.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.noggit.JSONUtil;
|
||||
import org.apache.noggit.JSONWriter;
|
||||
|
||||
/**
|
||||
* Models a Collection in zookeeper (but that Java name is obviously taken, hence "DocCollection")
|
||||
*/
|
||||
|
@ -36,7 +34,6 @@ public class DocCollection extends ZkNodeProps {
|
|||
|
||||
private final String name;
|
||||
private final Map<String, Slice> slices;
|
||||
private final Map<String, Slice> allSlices;
|
||||
private final DocRouter router;
|
||||
|
||||
/**
|
||||
|
@ -48,16 +45,7 @@ public class DocCollection extends ZkNodeProps {
|
|||
super( props==null ? Collections.<String,Object>emptyMap() : props);
|
||||
this.name = name;
|
||||
|
||||
this.allSlices = slices;
|
||||
this.slices = new HashMap<String, Slice>();
|
||||
|
||||
Iterator<Map.Entry<String, Slice>> iter = slices.entrySet().iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry<String, Slice> slice = iter.next();
|
||||
if (slice.getValue().getState().equals(Slice.ACTIVE))
|
||||
this.slices.put(slice.getKey(), slice.getValue());
|
||||
}
|
||||
this.slices = slices;
|
||||
this.router = router;
|
||||
|
||||
assert name != null && slices != null;
|
||||
|
@ -72,22 +60,14 @@ public class DocCollection extends ZkNodeProps {
|
|||
}
|
||||
|
||||
public Slice getSlice(String sliceName) {
|
||||
return allSlices.get(sliceName);
|
||||
return slices.get(sliceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of active slices for this collection.
|
||||
*/
|
||||
public Collection<Slice> getSlices() {
|
||||
return slices.values();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the list of all slices for this collection.
|
||||
*/
|
||||
public Collection<Slice> getAllSlices() {
|
||||
return allSlices.values();
|
||||
public Collection<Slice> getSlices() {
|
||||
return slices.values();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,13 +77,6 @@ public class DocCollection extends ZkNodeProps {
|
|||
return slices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the map of all slices (sliceName->Slice) for this collection.
|
||||
*/
|
||||
public Map<String, Slice> getAllSlicesMap() {
|
||||
return allSlices;
|
||||
}
|
||||
|
||||
public DocRouter getRouter() {
|
||||
return router;
|
||||
}
|
||||
|
@ -115,9 +88,9 @@ public class DocCollection extends ZkNodeProps {
|
|||
|
||||
@Override
|
||||
public void write(JSONWriter jsonWriter) {
|
||||
LinkedHashMap<String, Object> all = new LinkedHashMap<String, Object>(allSlices.size() + 1);
|
||||
LinkedHashMap<String, Object> all = new LinkedHashMap<String, Object>(slices.size() + 1);
|
||||
all.putAll(propMap);
|
||||
all.put(SHARDS, allSlices);
|
||||
all.put(SHARDS, slices);
|
||||
jsonWriter.write(all);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue