SOLR-4566: revert

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1455943 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2013-03-13 14:00:32 +00:00
parent ccb85cd5cd
commit c04f1ba800
4 changed files with 46 additions and 15 deletions

View File

@ -81,8 +81,6 @@ Bug Fixes
* SOLR-4567: copyField source glob matching explicit field(s) stopped working * SOLR-4567: copyField source glob matching explicit field(s) stopped working
in Solr 4.2. (Alexandre Rafalovitch, Steve Rowe) in Solr 4.2. (Alexandre Rafalovitch, Steve Rowe)
* SOLR-4566: Fix DocCollection to return all shards not just active shards.
(Mark Miller)
Other Changes Other Changes
---------------------- ----------------------

View File

@ -171,7 +171,7 @@ public class SliceStateUpdateTest extends SolrTestCaseJ4 {
Map<String, Slice> slices = null; Map<String, Slice> slices = null;
for (int i = 75; i > 0; i--) { for (int i = 75; i > 0; i--) {
clusterState2 = zkController2.getClusterState(); clusterState2 = zkController2.getClusterState();
slices = clusterState2.getSlicesMap("collection1"); slices = clusterState2.getAllSlicesMap("collection1");
if (slices != null && slices.containsKey("shard1") if (slices != null && slices.containsKey("shard1")
&& slices.get("shard1").getState().equals("inactive")) { && slices.get("shard1").getState().equals("inactive")) {
break; break;

View File

@ -115,10 +115,16 @@ public class ClusterState implements JSONWriter.Writable {
return coll.getSlicesMap(); 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) { public Collection<Slice> getSlices(String collection) {
DocCollection coll = collectionStates.get(collection); DocCollection coll = collectionStates.get(collection);
if (coll == null) return null; if (coll == null) return null;
return coll.getSlicesMap().values(); return coll.getSlices();
} }
/** /**

View File

@ -17,14 +17,16 @@ package org.apache.solr.common.cloud;
* limitations under the License. * limitations under the License.
*/ */
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.noggit.JSONUtil; import org.apache.noggit.JSONUtil;
import org.apache.noggit.JSONWriter; 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;
/** /**
* Models a Collection in zookeeper (but that Java name is obviously taken, hence "DocCollection") * Models a Collection in zookeeper (but that Java name is obviously taken, hence "DocCollection")
*/ */
@ -34,6 +36,7 @@ public class DocCollection extends ZkNodeProps {
private final String name; private final String name;
private final Map<String, Slice> slices; private final Map<String, Slice> slices;
private final Map<String, Slice> allSlices;
private final DocRouter router; private final DocRouter router;
/** /**
@ -45,7 +48,16 @@ public class DocCollection extends ZkNodeProps {
super( props==null ? Collections.<String,Object>emptyMap() : props); super( props==null ? Collections.<String,Object>emptyMap() : props);
this.name = name; this.name = name;
this.slices = slices; 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.router = router; this.router = router;
assert name != null && slices != null; assert name != null && slices != null;
@ -60,14 +72,22 @@ public class DocCollection extends ZkNodeProps {
} }
public Slice getSlice(String sliceName) { public Slice getSlice(String sliceName) {
return slices.get(sliceName); return allSlices.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. * Return the list of all slices for this collection.
*/ */
public Collection<Slice> getSlices() { public Collection<Slice> getAllSlices() {
return slices.values(); return allSlices.values();
} }
/** /**
@ -77,6 +97,13 @@ public class DocCollection extends ZkNodeProps {
return slices; return slices;
} }
/**
* Get the map of all slices (sliceName->Slice) for this collection.
*/
public Map<String, Slice> getAllSlicesMap() {
return allSlices;
}
public DocRouter getRouter() { public DocRouter getRouter() {
return router; return router;
} }
@ -88,9 +115,9 @@ public class DocCollection extends ZkNodeProps {
@Override @Override
public void write(JSONWriter jsonWriter) { public void write(JSONWriter jsonWriter) {
LinkedHashMap<String, Object> all = new LinkedHashMap<String, Object>(slices.size() + 1); LinkedHashMap<String, Object> all = new LinkedHashMap<String, Object>(allSlices.size() + 1);
all.putAll(propMap); all.putAll(propMap);
all.put(SHARDS, slices); all.put(SHARDS, allSlices);
jsonWriter.write(all); jsonWriter.write(all);
} }
} }