You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ja...@apache.org on 2013/05/30 09:53:46 UTC

svn commit: r1487777 [49/50] - in /lucene/dev/branches/security: ./ dev-tools/ dev-tools/eclipse/dot.settings/ dev-tools/idea/.idea/ dev-tools/idea/.idea/libraries/ dev-tools/idea/lucene/replicator/ dev-tools/maven/ dev-tools/maven/lucene/ dev-tools/ma...

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/client/solrj/response/QueryResponse.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/client/solrj/response/QueryResponse.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/client/solrj/response/QueryResponse.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/client/solrj/response/QueryResponse.java Thu May 30 07:53:18 2013
@@ -314,8 +314,9 @@ public class QueryResponse extends SolrR
 
           Number before = (Number) values.get("before");
           Number after = (Number) values.get("after");
+          Number between = (Number) values.get("between");
 
-          rangeFacet = new RangeFacet.Numeric(facet.getKey(), start, end, gap, before, after);
+          rangeFacet = new RangeFacet.Numeric(facet.getKey(), start, end, gap, before, after, between);
         } else {
           String gap = (String) rawGap;
           Date start = (Date) values.get("start");
@@ -323,8 +324,9 @@ public class QueryResponse extends SolrR
 
           Number before = (Number) values.get("before");
           Number after = (Number) values.get("after");
+          Number between = (Number) values.get("between");
 
-          rangeFacet = new RangeFacet.Date(facet.getKey(), start, end, gap, before, after);
+          rangeFacet = new RangeFacet.Date(facet.getKey(), start, end, gap, before, after, between);
         }
 
         NamedList<Integer> counts = (NamedList<Integer>) values.get("counts");

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/client/solrj/response/RangeFacet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/client/solrj/response/RangeFacet.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/client/solrj/response/RangeFacet.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/client/solrj/response/RangeFacet.java Thu May 30 07:53:18 2013
@@ -34,14 +34,16 @@ public abstract class RangeFacet<B, G> {
 
   private final Number before;
   private final Number after;
+  private final Number between;
 
-  protected RangeFacet(String name, B start, B end, G gap, Number before, Number after) {
+  protected RangeFacet(String name, B start, B end, G gap, Number before, Number after, Number between) {
     this.name = name;
     this.start = start;
     this.end = end;
     this.gap = gap;
     this.before = before;
     this.after = after;
+    this.between = between;
   }
 
   public void addCount(String value, int count) {
@@ -76,18 +78,32 @@ public abstract class RangeFacet<B, G> {
     return after;
   }
 
+  public Number getBetween() {
+    return between;
+  }
+
   public static class Numeric extends RangeFacet<Number, Number> {
 
+    @Deprecated
     public Numeric(String name, Number start, Number end, Number gap, Number before, Number after) {
-      super(name, start, end, gap, before, after);
+      this(name, start, end, gap, before, after, null);
+    }
+
+    public Numeric(String name, Number start, Number end, Number gap, Number before, Number after, Number between) {
+      super(name, start, end, gap, before, after, between);
     }
 
   }
 
   public static class Date extends RangeFacet<java.util.Date, String> {
 
+    @Deprecated
     public Date(String name, java.util.Date start, java.util.Date end, String gap, Number before, Number after) {
-      super(name, start, end, gap, before, after);
+      this(name, start, end, gap, before, after, null);
+    }
+
+    public Date(String name, java.util.Date start, java.util.Date end, String gap, Number before, Number after, Number between) {
+      super(name, start, end, gap, before, after, between);
     }
 
   }

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/SolrException.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/SolrException.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/SolrException.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/SolrException.java Thu May 30 07:53:18 2013
@@ -31,6 +31,9 @@ import org.slf4j.Logger;
 public class SolrException extends RuntimeException {
 
   /**
+   * This list of valid HTTP Status error codes that Solr may return in 
+   * the case of a "Server Side" error.
+   *
    * @since solr 1.2
    */
   public enum ErrorCode {
@@ -69,8 +72,28 @@ public class SolrException extends Runti
     super(th);
     this.code = code.code;
   }
+
+  /**
+   * Constructor that can set arbitrary http status code. Not for 
+   * use in Solr, but may be used by clients in subclasses to capture 
+   * errors returned by the servlet container or other HTTP proxies.
+   */
+  protected SolrException(int code, String msg, Throwable th) {
+    super(msg, th);
+    this.code = code;
+  }
   
   int code=0;
+
+  /**
+   * The HTTP Status code associated with this Exception.  For SolrExceptions 
+   * thrown by Solr "Server Side", this should valid {@link ErrorCode}, 
+   * however client side exceptions may contain an arbitrary error code based 
+   * on the behavior of the Servlet Container hosting Solr, or any HTTP 
+   * Proxies that may exist between the client and the server.
+   *
+   * @return The HTTP Status code associated with this Exception
+   */
   public int code() { return code; }
 
 

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java Thu May 30 07:53:18 2013
@@ -17,21 +17,18 @@ package org.apache.solr.common.cloud;
  * limitations under the License.
  */
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import org.apache.noggit.JSONWriter;
+import org.noggit.JSONWriter;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
-import org.apache.solr.common.cloud.DocRouter.Range;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.data.Stat;
 import org.slf4j.Logger;
@@ -118,10 +115,10 @@ public class ClusterState implements JSO
     return coll.getSlicesMap();
   }
   
-  public Map<String, Slice> getAllSlicesMap(String collection) {
+  public Map<String, Slice> getActiveSlicesMap(String collection) {
     DocCollection coll = collectionStates.get(collection);
     if (coll == null) return null;
-    return coll.getAllSlicesMap();
+    return coll.getActiveSlicesMap();
   }
 
   public Collection<Slice> getSlices(String collection) {
@@ -130,6 +127,12 @@ public class ClusterState implements JSO
     return coll.getSlices();
   }
 
+  public Collection<Slice> getActiveSlices(String collection) {
+    DocCollection coll = collectionStates.get(collection);
+    if (coll == null) return null;
+    return coll.getActiveSlices();
+  }
+
   /**
    * Get the named DocCollection object, or throw an exception if it doesn't exist.
    */
@@ -229,6 +232,15 @@ public class ClusterState implements JSO
     // System.out.println("######## ClusterState.load result:" + collections);
     return new ClusterState(version, liveNodes, collections);
   }
+  
+  public static Aliases load(byte[] bytes) {
+    if (bytes == null || bytes.length == 0) {
+      return new Aliases();
+    }
+    Map<String,Map<String,String>> aliasMap = (Map<String,Map<String,String>>) ZkStateReader.fromJSON(bytes);
+
+    return new Aliases(aliasMap);
+  }
 
   private static DocCollection collectionFromObjects(String name, Map<String,Object> objs) {
     Map<String,Object> props;

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.java Thu May 30 07:53:18 2013
@@ -36,7 +36,7 @@ public class CompositeIdRouter extends H
   private int separator = '!';
 
   // separator used to optionally specify number of bits to allocate toward first part.
-  private int bitsSepartor = '/';
+  private int bitsSeparator = '/';
   private int bits = 16;
   private int mask1 = 0xffff0000;
   private int mask2 = 0x0000ffff;
@@ -59,7 +59,7 @@ public class CompositeIdRouter extends H
   }
 
   @Override
-  protected int sliceHash(String id, SolrInputDocument doc, SolrParams params) {
+  public int sliceHash(String id, SolrInputDocument doc, SolrParams params) {
     int idx = id.indexOf(separator);
     if (idx < 0) {
       return Hash.murmurhash3_x86_32(id, 0, id.length(), 0);
@@ -69,7 +69,7 @@ public class CompositeIdRouter extends H
     int m2 = mask2;
 
     String part1 = id.substring(0,idx);
-    int commaIdx = part1.indexOf(bitsSepartor);
+    int commaIdx = part1.indexOf(bitsSeparator);
     if (commaIdx > 0) {
       int firstBits = getBits(part1, commaIdx);
       if (firstBits >= 0) {
@@ -91,7 +91,7 @@ public class CompositeIdRouter extends H
     if (shardKey == null) {
       // search across whole collection
       // TODO: this may need modification in the future when shard splitting could cause an overlap
-      return collection.getSlices();
+      return collection.getActiveSlices();
     }
     String id = shardKey;
 
@@ -105,7 +105,7 @@ public class CompositeIdRouter extends H
     int m2 = mask2;
 
     String part1 = id.substring(0,idx);
-    int bitsSepIdx = part1.indexOf(bitsSepartor);
+    int bitsSepIdx = part1.indexOf(bitsSeparator);
     if (bitsSepIdx > 0) {
       int firstBits = getBits(part1, bitsSepIdx);
       if (firstBits >= 0) {
@@ -132,7 +132,7 @@ public class CompositeIdRouter extends H
     Range completeRange = new Range(lowerBound, upperBound);
 
     List<Slice> targetSlices = new ArrayList<Slice>(1);
-    for (Slice slice : collection.getSlices()) {
+    for (Slice slice : collection.getActiveSlices()) {
       Range range = slice.getRange();
       if (range != null && range.overlaps(completeRange)) {
         targetSlices.add(slice);

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java Thu May 30 07:53:18 2013
@@ -17,8 +17,8 @@ package org.apache.solr.common.cloud;
  * limitations under the License.
  */
 
-import org.apache.noggit.JSONUtil;
-import org.apache.noggit.JSONWriter;
+import org.noggit.JSONUtil;
+import org.noggit.JSONWriter;
 
 import java.util.Collection;
 import java.util.Collections;
@@ -36,7 +36,7 @@ public class DocCollection extends ZkNod
 
   private final String name;
   private final Map<String, Slice> slices;
-  private final Map<String, Slice> allSlices;
+  private final Map<String, Slice> activeSlices;
   private final DocRouter router;
 
   /**
@@ -48,15 +48,15 @@ public class DocCollection extends ZkNod
     super( props==null ? Collections.<String,Object>emptyMap() : props);
     this.name = name;
 
-    this.allSlices = slices;
-    this.slices = new HashMap<String, Slice>();
+    this.slices = slices;
+    this.activeSlices = 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.activeSlices.put(slice.getKey(), slice.getValue());
     }
     this.router = router;
 
@@ -72,11 +72,11 @@ public class DocCollection extends ZkNod
   }
 
   public Slice getSlice(String sliceName) {
-    return allSlices.get(sliceName);
+    return slices.get(sliceName);
   }
 
   /**
-   * Gets the list of active slices for this collection.
+   * Gets the list of all slices for this collection.
    */
   public Collection<Slice> getSlices() {
     return slices.values();
@@ -84,24 +84,24 @@ public class DocCollection extends ZkNod
 
 
   /**
-   * Return the list of all slices for this collection.
+   * Return the list of active slices for this collection.
    */
-  public Collection<Slice> getAllSlices() {
-    return allSlices.values();
+  public Collection<Slice> getActiveSlices() {
+    return activeSlices.values();
   }
 
   /**
-   * Get the map of active slices (sliceName->Slice) for this collection.
+   * Get the map of all slices (sliceName->Slice) for this collection.
    */
   public Map<String, Slice> getSlicesMap() {
     return slices;
   }
 
   /**
-   * Get the map of all slices (sliceName->Slice) for this collection.
+   * Get the map of active slices (sliceName->Slice) for this collection.
    */
-  public Map<String, Slice> getAllSlicesMap() {
-    return allSlices;
+  public Map<String, Slice> getActiveSlicesMap() {
+    return activeSlices;
   }
 
   public DocRouter getRouter() {
@@ -115,9 +115,9 @@ public class DocCollection extends ZkNod
 
   @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);
   }
 }

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/DocRouter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/DocRouter.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/DocRouter.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/DocRouter.java Thu May 30 07:53:18 2013
@@ -17,7 +17,7 @@ package org.apache.solr.common.cloud;
  * limitations under the License.
  */
 
-import org.apache.noggit.JSONWriter;
+import org.noggit.JSONWriter;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.params.SolrParams;
@@ -164,6 +164,8 @@ public abstract class DocRouter {
    **/
   public abstract Collection<Slice> getSearchSlicesSingle(String shardKey, SolrParams params, DocCollection collection);
 
+  public abstract boolean isTargetSlice(String id, SolrInputDocument sdoc, SolrParams params, String shardId, DocCollection collection);
+
 
   /** This method is consulted to determine what slices should be queried for a request when
    *  an explicit shards parameter was not used.

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/HashBasedRouter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/HashBasedRouter.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/HashBasedRouter.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/HashBasedRouter.java Thu May 30 07:53:18 2013
@@ -34,7 +34,15 @@ public abstract class HashBasedRouter ex
     return hashToSlice(hash, collection);
   }
 
-  protected int sliceHash(String id, SolrInputDocument sdoc, SolrParams params) {
+  @Override
+  public boolean isTargetSlice(String id, SolrInputDocument sdoc, SolrParams params, String shardId, DocCollection collection) {
+    if (id == null) id = getId(sdoc, params);
+    int hash = sliceHash(id, sdoc, params);
+    Range range = collection.getSlice(shardId).getRange();
+    return range != null && range.includes(hash);
+  }
+
+  public int sliceHash(String id, SolrInputDocument sdoc, SolrParams params) {
     return Hash.murmurhash3_x86_32(id, 0, id.length(), 0);
   }
 
@@ -45,11 +53,11 @@ public abstract class HashBasedRouter ex
   }
 
   protected Slice hashToSlice(int hash, DocCollection collection) {
-    for (Slice slice : collection.getSlices()) {
+    for (Slice slice : collection.getActiveSlices()) {
       Range range = slice.getRange();
       if (range != null && range.includes(hash)) return slice;
     }
-    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No slice servicing hash code " + Integer.toHexString(hash) + " in " + collection);
+    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No active slice servicing hash code " + Integer.toHexString(hash) + " in " + collection);
   }
 
 
@@ -58,7 +66,7 @@ public abstract class HashBasedRouter ex
     if (shardKey == null) {
       // search across whole collection
       // TODO: this may need modification in the future when shard splitting could cause an overlap
-      return collection.getSlices();
+      return collection.getActiveSlices();
     }
 
     // use the shardKey as an id for plain hashing

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ImplicitDocRouter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ImplicitDocRouter.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ImplicitDocRouter.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ImplicitDocRouter.java Thu May 30 07:53:18 2013
@@ -55,9 +55,15 @@ public class ImplicitDocRouter extends D
   }
 
   @Override
+  public boolean isTargetSlice(String id, SolrInputDocument sdoc, SolrParams params, String shardId, DocCollection collection) {
+    // todo : how to handle this?
+    return false;
+  }
+
+  @Override
   public Collection<Slice> getSearchSlicesSingle(String shardKey, SolrParams params, DocCollection collection) {
     if (shardKey == null) {
-      return collection.getSlices();
+      return collection.getActiveSlices();
     }
 
     // assume the shardKey is just a slice name

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java Thu May 30 07:53:18 2013
@@ -17,7 +17,7 @@ package org.apache.solr.common.cloud;
  * limitations under the License.
  */
 
-import org.apache.noggit.JSONUtil;
+import org.noggit.JSONUtil;
 
 import java.util.Map;
 

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/Slice.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/Slice.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/Slice.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/Slice.java Thu May 30 07:53:18 2013
@@ -17,8 +17,8 @@ package org.apache.solr.common.cloud;
  * limitations under the License.
  */
 
-import org.apache.noggit.JSONUtil;
-import org.apache.noggit.JSONWriter;
+import org.noggit.JSONUtil;
+import org.noggit.JSONWriter;
 
 import java.util.Collection;
 import java.util.HashMap;
@@ -34,6 +34,8 @@ public class Slice extends ZkNodeProps {
   public static String STATE = "state";
   public static String LEADER = "leader";       // FUTURE: do we want to record the leader as a slice property in the JSON (as opposed to isLeader as a replica property?)
   public static String ACTIVE = "active";
+  public static String INACTIVE = "inactive";
+  public static String CONSTRUCTION = "construction";
 
   private final String name;
   private final DocRouter.Range range;
@@ -52,10 +54,10 @@ public class Slice extends ZkNodeProps {
     this.name = name;
 
     Object rangeObj = propMap.get(RANGE);
-    if (propMap.containsKey(STATE))
-      state = (String) propMap.get(STATE);
+    if (propMap.containsKey(STATE) && propMap.get(STATE) != null)
+      this.state = (String) propMap.get(STATE);
     else {
-      state = ACTIVE;                         //Default to ACTIVE
+      this.state = ACTIVE;                         //Default to ACTIVE
       propMap.put(STATE, this.state);
     }
     DocRouter.Range tmpRange = null;

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java Thu May 30 07:53:18 2013
@@ -24,7 +24,6 @@ import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.List;
-import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicLong;
 
 import javax.xml.transform.OutputKeys;
@@ -40,10 +39,10 @@ import org.apache.solr.common.cloud.ZkCl
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.KeeperException.NoNodeException;
+import org.apache.zookeeper.KeeperException.NodeExistsException;
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.ZooDefs;
 import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.KeeperException.NodeExistsException;
 import org.apache.zookeeper.data.ACL;
 import org.apache.zookeeper.data.Stat;
 import org.slf4j.Logger;
@@ -312,13 +311,13 @@ public class SolrZkClient {
   
   public void makePath(String path, File file, boolean failOnExists, boolean retryOnConnLoss)
       throws IOException, KeeperException, InterruptedException {
-    makePath(path, FileUtils.readFileToString(file).getBytes("UTF-8"),
+    makePath(path, FileUtils.readFileToByteArray(file),
         CreateMode.PERSISTENT, null, failOnExists, retryOnConnLoss);
   }
   
   public void makePath(String path, File file, boolean retryOnConnLoss) throws IOException,
       KeeperException, InterruptedException {
-    makePath(path, FileUtils.readFileToString(file).getBytes("UTF-8"), retryOnConnLoss);
+    makePath(path, FileUtils.readFileToByteArray(file), retryOnConnLoss);
   }
   
   public void makePath(String path, CreateMode createMode, boolean retryOnConnLoss) throws KeeperException,
@@ -448,9 +447,9 @@ public class SolrZkClient {
   /**
    * Write data to ZooKeeper.
    */
-  public void setData(String path, byte[] data, boolean retryOnConnLoss) throws KeeperException,
+  public Stat setData(String path, byte[] data, boolean retryOnConnLoss) throws KeeperException,
       InterruptedException {
-    setData(path, data, -1, retryOnConnLoss);
+    return setData(path, data, -1, retryOnConnLoss);
   }
 
   /**
@@ -459,14 +458,14 @@ public class SolrZkClient {
    * @param path path to upload file to e.g. /solr/conf/solrconfig.xml
    * @param file path to file to be uploaded
    */
-  public void setData(String path, File file, boolean retryOnConnLoss) throws IOException,
+  public Stat setData(String path, File file, boolean retryOnConnLoss) throws IOException,
       KeeperException, InterruptedException {
     if (log.isInfoEnabled()) {
       log.info("Write to ZooKeepeer " + file.getAbsolutePath() + " to " + path);
     }
 
     String data = FileUtils.readFileToString(file);
-    setData(path, data.getBytes("UTF-8"), retryOnConnLoss);
+    return setData(path, data.getBytes("UTF-8"), retryOnConnLoss);
   }
 
   /**

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java Thu May 30 07:53:18 2013
@@ -17,8 +17,8 @@ package org.apache.solr.common.cloud;
  * limitations under the License.
  */
 
-import org.apache.noggit.JSONUtil;
-import org.apache.noggit.JSONWriter;
+import org.noggit.JSONUtil;
+import org.noggit.JSONWriter;
 
 import java.util.Collections;
 import java.util.HashMap;

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java Thu May 30 07:53:18 2013
@@ -31,10 +31,10 @@ import java.util.concurrent.ThreadFactor
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import org.apache.noggit.CharArr;
-import org.apache.noggit.JSONParser;
-import org.apache.noggit.JSONWriter;
-import org.apache.noggit.ObjectBuilder;
+import org.noggit.CharArr;
+import org.noggit.JSONParser;
+import org.noggit.JSONWriter;
+import org.noggit.ObjectBuilder;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.util.ByteUtils;
@@ -57,11 +57,14 @@ public class ZkStateReader {
   public static final String CORE_NAME_PROP = "core";
   public static final String COLLECTION_PROP = "collection";
   public static final String SHARD_ID_PROP = "shard";
+  public static final String SHARD_RANGE_PROP = "shard_range";
+  public static final String SHARD_STATE_PROP = "shard_state";
   public static final String NUM_SHARDS_PROP = "numShards";
   public static final String LEADER_PROP = "leader";
   
   public static final String COLLECTIONS_ZKNODE = "/collections";
   public static final String LIVE_NODES_ZKNODE = "/live_nodes";
+  public static final String ALIASES = "/aliases.json";
   public static final String CLUSTER_STATE = "/clusterstate.json";
   
   public static final String RECOVERING = "recovering";
@@ -129,7 +132,11 @@ public class ZkStateReader {
   private boolean closeClient = false;
 
   private ZkCmdExecutor cmdExecutor;
-  
+
+  private Aliases aliases = new Aliases();
+
+  private volatile boolean closed = false;
+
   public ZkStateReader(SolrZkClient zkClient) {
     this.zkClient = zkClient;
     initZkCmdExecutor(zkClient.getZkClientTimeout());
@@ -177,12 +184,17 @@ public class ZkStateReader {
     updateClusterState(true, true);
   }
   
+  public Aliases getAliases() {
+    return aliases;
+  }
+  
   public synchronized void createClusterStateWatchersAndUpdate() throws KeeperException,
       InterruptedException {
     // We need to fetch the current cluster state and the set of live nodes
     
     synchronized (getUpdateLock()) {
       cmdExecutor.ensureExists(CLUSTER_STATE, zkClient);
+      cmdExecutor.ensureExists(ALIASES, zkClient);
       
       log.info("Updating cluster state from ZooKeeper... ");
       
@@ -286,7 +298,51 @@ public class ZkStateReader {
       liveNodeSet.addAll(liveNodes);
       ClusterState clusterState = ClusterState.load(zkClient, liveNodeSet);
       this.clusterState = clusterState;
+      
+      zkClient.exists(ALIASES,
+          new Watcher() {
+            
+            @Override
+            public void process(WatchedEvent event) {
+              // session events are not change events,
+              // and do not remove the watcher
+              if (EventType.None.equals(event.getType())) {
+                return;
+              }
+              try {
+                synchronized (ZkStateReader.this.getUpdateLock()) {
+                  log.info("Updating aliases... ");
+
+                  // remake watch
+                  final Watcher thisWatch = this;
+                  Stat stat = new Stat();
+                  byte[] data = zkClient.getData(ALIASES, thisWatch, stat ,
+                      true);
+
+                  Aliases aliases = ClusterState.load(data);
+
+                  ZkStateReader.this.aliases = aliases;
+                }
+              } catch (KeeperException e) {
+                if (e.code() == KeeperException.Code.SESSIONEXPIRED
+                    || e.code() == KeeperException.Code.CONNECTIONLOSS) {
+                  log.warn("ZooKeeper watch triggered, but Solr cannot talk to ZK");
+                  return;
+                }
+                log.error("", e);
+                throw new ZooKeeperException(
+                    SolrException.ErrorCode.SERVER_ERROR, "", e);
+              } catch (InterruptedException e) {
+                // Restore the interrupted status
+                Thread.currentThread().interrupt();
+                log.warn("", e);
+                return;
+              }
+            }
+            
+          }, true);
     }
+    updateAliases();
   }
   
   
@@ -386,6 +442,7 @@ public class ZkStateReader {
   }
 
   public void close() {
+    this.closed  = true;
     if (closeClient) {
       zkClient.close();
     }
@@ -418,7 +475,7 @@ public class ZkStateReader {
    */
   public Replica getLeaderRetry(String collection, String shard, int timeout) throws InterruptedException {
     long timeoutAt = System.currentTimeMillis() + timeout;
-    while (System.currentTimeMillis() < timeoutAt) {
+    while (System.currentTimeMillis() < timeoutAt && !closed) {
       if (clusterState != null) {    
         Replica replica = clusterState.getLeader(collection, shard);
         if (replica != null && getClusterState().liveNodesContain(replica.getNodeName())) {
@@ -493,5 +550,13 @@ public class ZkStateReader {
   public SolrZkClient getZkClient() {
     return zkClient;
   }
+
+  public void updateAliases() throws KeeperException, InterruptedException {
+    byte[] data = zkClient.getData(ALIASES, null, null, true);
+
+    Aliases aliases = ClusterState.load(data);
+
+    ZkStateReader.this.aliases = aliases;
+  }
   
 }

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/CollectionParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/CollectionParams.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/CollectionParams.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/CollectionParams.java Thu May 30 07:53:18 2013
@@ -28,7 +28,7 @@ public interface CollectionParams 
 
 
   public enum CollectionAction {
-    CREATE, DELETE, RELOAD, SYNCSHARD;
+    CREATE, DELETE, RELOAD, SYNCSHARD, CREATEALIAS, DELETEALIAS, SPLITSHARD;
     
     public static CollectionAction get( String p )
     {

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java Thu May 30 07:53:18 2013
@@ -59,6 +59,23 @@ public interface CommonParams {
   
   /** number of documents to return starting at "start" */
   public static final String ROWS ="rows";
+
+  // SOLR-4228 start
+  /** handler value for SolrPing */
+  public static final String PING_HANDLER = "/admin/ping";
+  
+  /** "action" parameter for SolrPing */
+  public static final String ACTION = "action";
+  
+  /** "disable" value for SolrPing action */
+  public static final String DISABLE = "disable";
+  
+  /** "enable" value for SolrPing action */
+  public static final String ENABLE = "enable";
+  
+  /** "ping" value for SolrPing action */
+  public static final String PING = "ping";
+  // SOLR-4228 end
   
   //Issue 1726 start
   /** score of the last document of the previous page */

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java Thu May 30 07:53:18 2013
@@ -74,6 +74,16 @@ public interface CoreAdminParams 
   /** The shard id in solr cloud */
   public final static String SHARD = "shard";
   
+  /** The shard range in solr cloud */
+  public final static String SHARD_RANGE = "shard.range";
+
+  /** The shard range in solr cloud */
+  public final static String SHARD_STATE = "shard.state";
+
+  /** The target core to which a split index should be written to
+   * Multiple targetCores can be specified by multiple targetCore parameters */
+  public final static String TARGET_CORE = "targetCore";
+  
   public static final String ROLES = "roles";
   
   public static final String CORE_NODE_NAME = "coreNodeName";
@@ -88,6 +98,9 @@ public interface CoreAdminParams 
 
   public static final String DELETE_INSTANCE_DIR = "deleteInstanceDir";
 
+  public static final String LOAD_ON_STARTUP = "loadOnStartup";
+  
+  public static final String TRANSIENT = "transient";
 
   public enum CoreAdminAction {
     STATUS,  
@@ -102,7 +115,12 @@ public interface CoreAdminParams 
     SPLIT,
     PREPRECOVERY,
     REQUESTRECOVERY, 
-    REQUESTSYNCSHARD;
+    REQUESTSYNCSHARD,
+    CREATEALIAS,
+    DELETEALIAS,
+    REQUESTAPPLYUPDATES,
+    LOAD_ON_STARTUP,
+    TRANSIENT;
     
     public static CoreAdminAction get( String p )
     {

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/HighlightParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/HighlightParams.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/HighlightParams.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/HighlightParams.java Thu May 30 07:53:18 2013
@@ -41,9 +41,13 @@ public interface HighlightParams {
   public static final String BS_TYPE = HIGHLIGHT+".bs.type";
   public static final String BS_LANGUAGE = HIGHLIGHT+".bs.language";
   public static final String BS_COUNTRY = HIGHLIGHT+".bs.country";
+  public static final String BS_VARIANT = HIGHLIGHT+".bs.variant";
   public static final String FIELD_MATCH = HIGHLIGHT+".requireFieldMatch";
+  public static final String DEFAULT_SUMMARY = HIGHLIGHT + ".defaultSummary";
   public static final String ALTERNATE_FIELD = HIGHLIGHT+".alternateField";
   public static final String ALTERNATE_FIELD_LENGTH = HIGHLIGHT+".maxAlternateFieldLength";
+  public static final String MAX_MULTIVALUED_TO_EXAMINE = HIGHLIGHT + ".maxMultiValuedToExamine";
+  public static final String MAX_MULTIVALUED_TO_MATCH = HIGHLIGHT + ".maxMultiValuedToMatch";
   
   public static final String USE_PHRASE_HIGHLIGHTER = HIGHLIGHT+".usePhraseHighlighter";
   public static final String HIGHLIGHT_MULTI_TERM = HIGHLIGHT+".highlightMultiTerm";
@@ -53,6 +57,7 @@ public interface HighlightParams {
   public static final String USE_FVH  = HIGHLIGHT + ".useFastVectorHighlighter";
   public static final String TAG_PRE  = HIGHLIGHT + ".tag.pre";
   public static final String TAG_POST = HIGHLIGHT + ".tag.post";
+  public static final String TAG_ELLIPSIS = HIGHLIGHT + ".tag.ellipsis";
   public static final String PHRASE_LIMIT = HIGHLIGHT + ".phraseLimit";
   public static final String MULTI_VALUED_SEPARATOR = HIGHLIGHT + ".multiValuedSeparatorChar";
   
@@ -66,4 +71,10 @@ public interface HighlightParams {
   public static final String SLOP  = HIGHLIGHT+"."+REGEX+".slop";
   public static final String PATTERN  = HIGHLIGHT+"."+REGEX+".pattern";
   public static final String MAX_RE_CHARS   = HIGHLIGHT+"."+REGEX+".maxAnalyzedChars";
+  
+  // Scoring parameters
+  public static final String SCORE = "score";
+  public static final String SCORE_K1 = HIGHLIGHT +"."+SCORE+".k1";
+  public static final String SCORE_B = HIGHLIGHT +"."+SCORE+".b";
+  public static final String SCORE_PIVOT = HIGHLIGHT +"."+SCORE+".pivot";
 }

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/SpellingParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/SpellingParams.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/SpellingParams.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/params/SpellingParams.java Thu May 30 07:53:18 2013
@@ -129,13 +129,32 @@ public interface SpellingParams {
    * </p>
    */
   public static final String SPELLCHECK_MAX_COLLATION_EVALUATIONS = SPELLCHECK_PREFIX + "maxCollationEvaluations";
-  
+  /**
+   * <p>
+   * For use with {@link SpellingParams#SPELLCHECK_MAX_COLLATION_TRIES} and 
+   * {@link SpellingParams#SPELLCHECK_COLLATE_EXTENDED_RESULTS}.
+   * A performance optimization in cases where the exact number of hits a collation would return is not needed.  
+   * Specify "0" to return the exact # of hits, otherwise give the maximum documents Lucene should collect 
+   * with which to base an estimate.  The higher the value the more likely the estimates will be accurate 
+   * (at expense of performance). 
+   * </p>
+   * 
+   * <p>
+   * The default is 0 (report exact hit-counts) when {@link SpellingParams#SPELLCHECK_COLLATE_EXTENDED_RESULTS} is TRUE.
+   * When {@link SpellingParams#SPELLCHECK_COLLATE_EXTENDED_RESULTS} is FALSE, this optimization is always performed.
+   * </p>
+   */
+  public static final String SPELLCHECK_COLLATE_MAX_COLLECT_DOCS = SPELLCHECK_PREFIX + "collateMaxCollectDocs";
   /**
    * <p>
    * Whether to use the Extended Results Format for collations. 
    * Includes "before>after" pairs to easily allow clients to generate messages like "no results for PORK.  did you mean POLK?"
    * Also indicates the # of hits each collation will return on re-query.  Default=false, which retains 1.4-compatible output.
    * </p>
+   * <p>
+   * Note: that if {@link SpellingParams#SPELLCHECK_COLLATE_MAX_COLLECT_DOCS} is set to a value greater than 0, 
+   * then the hit counts returned by this will be estimated.
+   * </p>
    */
   public static final String SPELLCHECK_COLLATE_EXTENDED_RESULTS = SPELLCHECK_PREFIX + "collateExtendedResults";
   

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/ByteUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/ByteUtils.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/ByteUtils.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/ByteUtils.java Thu May 30 07:53:18 2013
@@ -17,7 +17,7 @@
 
 package org.apache.solr.common.util;
 
-import org.apache.noggit.CharArr;
+import org.noggit.CharArr;
 
 public class ByteUtils {
 

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/ContentStreamBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/ContentStreamBase.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/ContentStreamBase.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/ContentStreamBase.java Thu May 30 07:53:18 2013
@@ -233,4 +233,27 @@ public abstract class ContentStreamBase 
   public void setSourceInfo(String sourceInfo) {
     this.sourceInfo = sourceInfo;
   }
+  
+  /**
+   * Construct a <code>ContentStream</code> from a <code>File</code>
+   */
+  public static class ByteArrayStream extends ContentStreamBase
+  {
+    private final byte[] bytes;
+    
+    public ByteArrayStream( byte[] bytes, String source ) {
+      this.bytes = bytes; 
+      
+      this.contentType = null;
+      name = source;
+      size = new Long(bytes.length);
+      sourceInfo = source;
+    }
+
+
+    @Override
+    public InputStream getStream() throws IOException {
+      return new ByteArrayInputStream( bytes );
+    }
+  }  
 }

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java Thu May 30 07:53:18 2013
@@ -16,7 +16,7 @@
  */
 package org.apache.solr.common.util;
 
-import org.apache.noggit.CharArr;
+import org.noggit.CharArr;
 import org.apache.solr.common.SolrDocument;
 import org.apache.solr.common.SolrDocumentList;
 import org.apache.solr.common.SolrInputDocument;

Modified: lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/NamedList.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/NamedList.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/NamedList.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/java/org/apache/solr/common/util/NamedList.java Thu May 30 07:53:18 2013
@@ -17,10 +17,11 @@
 
 package org.apache.solr.common.util;
 
-import java.util.*;
 import java.io.Serializable;
-
-
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 /**
  * A simple container class for modeling an ordered list of name/value pairs.
@@ -47,9 +48,10 @@ import java.io.Serializable;
  * or simply use a regular {@link Map}
  * </p>
  *
- *
  */
 public class NamedList<T> implements Cloneable, Serializable, Iterable<Map.Entry<String,T>> {
+
+  private static final long serialVersionUID = 1957981902839867821L;
   protected final List<Object> nvPairs;
 
   /** Creates an empty instance */
@@ -57,7 +59,6 @@ public class NamedList<T> implements Clo
     nvPairs = new ArrayList<Object>();
   }
 
-
   /**
    * Creates a NamedList instance containing the "name,value" pairs contained in the
    * Entry[].
@@ -80,8 +81,8 @@ public class NamedList<T> implements Clo
    * pairwise names/values.
    *
    * <p>
-   * When using this constructor, runtime typesafety is only guaranteed if the all
-   * even numbered elements of the input list are of type "T".
+   * When using this constructor, runtime type safety is only guaranteed if
+   * all even numbered elements of the input list are of type "T".
    * </p>
    *
    * @param nameValuePairs underlying List which should be used to implement a NamedList
@@ -153,6 +154,7 @@ public class NamedList<T> implements Clo
 
   /**
    * Modifies the value of the pair at the specified index.
+   *
    * @return the value that used to be at index
    */
   public T setVal(int idx, T val) {
@@ -165,6 +167,7 @@ public class NamedList<T> implements Clo
 
   /**
    * Removes the name/value pair at the specified index.
+   *
    * @return the value at the index removed
    */
   public T remove(int idx) {
@@ -203,10 +206,11 @@ public class NamedList<T> implements Clo
    * NOTE: this runs in linear time (it scans starting at the
    * beginning of the list until it finds the first pair with
    * the specified name).
+   *
    * @return null if not found or if the value stored was null.
    * @see #indexOf
    * @see #get(String,int)
-   * 
+   *
    */
   public T get(String name) {
     return get(name,0);
@@ -219,6 +223,7 @@ public class NamedList<T> implements Clo
    * NOTE: this runs in linear time (it scans starting at the
    * specified position until it finds the first pair with
    * the specified name).
+   *
    * @return null if not found or if the value stored was null.
    * @see #indexOf
    */
@@ -237,6 +242,7 @@ public class NamedList<T> implements Clo
 
   /**
    * Gets the values for the the specified name
+   *
    * @param name Name
    * @return List of values
    */
@@ -252,6 +258,71 @@ public class NamedList<T> implements Clo
     return result;
   }
 
+  /**
+   * Recursively parses the NamedList structure to arrive at a specific element.
+   * As you descend the NamedList tree, the last element can be any type,
+   * including NamedList, but the previous elements MUST be NamedList objects
+   * themselves. A null value is returned if the indicated hierarchy doesn't
+   * exist, but NamedList allows null values so that could be the actual value
+   * at the end of the path.
+   * 
+   * This method is particularly useful for parsing the response from Solr's
+   * /admin/mbeans handler, but it also works for any complex structure.
+   * 
+   * Explicitly casting the return value is recommended. An even safer option is
+   * to accept the return value as an object and then check its type.
+   * 
+   * Usage examples:
+   * 
+   * String coreName = (String) response.findRecursive
+   * ("solr-mbeans", "CORE", "core", "stats", "coreName");
+   * long numDoc = (long) response.findRecursive
+   * ("solr-mbeans", "CORE", "searcher", "stats", "numDocs");
+   * 
+   * @param args
+   *          One or more strings specifying the tree to navigate.
+   * @return the last entry in the given path hierarchy, null if not found.
+   */
+  public Object findRecursive(String... args) {
+    NamedList<?> currentList = null;
+    Object value = null;
+    for (int i = 0; i < args.length; i++) {
+      String key = args[i];
+      /*
+       * The first time through the loop, the current list is null, so we assign
+       * it to this list. Then we retrieve the first key from this list and
+       * assign it to value.
+       * 
+       * On the next loop, we check whether the retrieved value is a NamedList.
+       * If it is, then we drop down to that NamedList, grab the value of the
+       * next key, and start the loop over. If it is not a NamedList, then we
+       * assign the value to null and break out of the loop.
+       * 
+       * Assigning the value to null and then breaking out of the loop seems
+       * like the wrong thing to do, but there's a very simple reason that it
+       * works: If we have reached the last key, then the loop ends naturally
+       * after we retrieve the value, and that code is never executed.
+       */
+      if (currentList == null) {
+        currentList = this;
+      } else {
+        if (value instanceof NamedList) {
+          currentList = (NamedList<?>) value;
+        } else {
+          value = null;
+          break;
+        }
+      }
+      /*
+       * We do not need to do a null check on currentList for the following
+       * assignment. The instanceof check above will fail if the current list is
+       * null, and if that happens, the loop will end before this point.
+       */
+      value = currentList.get(key, 0);
+    }
+    return value;
+  }
+
   @Override
   public String toString() {
     StringBuilder sb = new StringBuilder();
@@ -269,12 +340,12 @@ public class NamedList<T> implements Clo
   }
 
   /**
-   *
+   * 
    * Helper class implementing Map.Entry&lt;String, T&gt; to store the key-value
-   * relationship in NamedList (the keys of which are String-s) 
+   * relationship in NamedList (the keys of which are String-s)
    */
-  public static final class NamedListEntry<T> implements Map.Entry<String, T> {
-
+  public static final class NamedListEntry<T> implements Map.Entry<String,T> {
+    
     public NamedListEntry() {
 
     }
@@ -291,7 +362,7 @@ public class NamedList<T> implements Clo
 
     @Override
     public T getValue() {
-      return  value;
+      return value;
     }
 
     @Override
@@ -310,8 +381,8 @@ public class NamedList<T> implements Clo
    * Iterates over the Map and sequentially adds it's key/value pairs
    */
   public boolean addAll(Map<String,T> args) {
-    for( Map.Entry<String, T> entry : args.entrySet() ) {
-      add( entry.getKey(), entry.getValue() );
+    for (Map.Entry<String, T> entry : args.entrySet() ) {
+      add(entry.getKey(), entry.getValue());
     }
     return args.size()>0;
   }
@@ -332,7 +403,6 @@ public class NamedList<T> implements Clo
     return new NamedList<T>(newList);
   }
 
-
   //----------------------------------------------------------------------------
   // Iterable interface
   //----------------------------------------------------------------------------
@@ -364,14 +434,12 @@ public class NamedList<T> implements Clo
           }
 
           @Override
-          @SuppressWarnings("unchecked")
           public T getValue() {
             return list.getVal( index );
           }
 
           @Override
-          public String toString()
-          {
+          public String toString() {
             return getKey()+"="+getValue();
           }
 
@@ -391,7 +459,7 @@ public class NamedList<T> implements Clo
     return iter;
   }
 
-  /** 
+  /**
    * NOTE: this runs in linear time (it scans starting at the
    * beginning of the list until it finds the first pair with
    * the specified name).
@@ -402,7 +470,6 @@ public class NamedList<T> implements Clo
     return null;
   }
 
-
   public void clear() {
     nvPairs.clear();
   }
@@ -415,7 +482,7 @@ public class NamedList<T> implements Clo
   @Override
   public boolean equals(Object obj) {
     if (!(obj instanceof NamedList)) return false;
-    NamedList nl = (NamedList) obj;
+    NamedList<?> nl = (NamedList<?>) obj;
     return this.nvPairs.equals(nl.nvPairs);
   }
 }

Modified: lucene/dev/branches/security/solr/solrj/src/test-files/solrj/sampleDateFacetResponse.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test-files/solrj/sampleDateFacetResponse.xml?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test-files/solrj/sampleDateFacetResponse.xml (original)
+++ lucene/dev/branches/security/solr/solrj/src/test-files/solrj/sampleDateFacetResponse.xml Thu May 30 07:53:18 2013
@@ -74,7 +74,8 @@
         <date name="end">2008-02-13T15:26:37Z</date>
         <int name="before">90</int>
         <int name="after">1</int>
+        <int name="between">11</int>
       </lst>
     </lst>
   </lst>
-</response>
\ No newline at end of file
+</response>

Modified: lucene/dev/branches/security/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig.xml?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig.xml (original)
+++ lucene/dev/branches/security/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig.xml Thu May 30 07:53:18 2013
@@ -49,7 +49,17 @@
   <requestHandler name="standard" class="solr.StandardRequestHandler" default="true" />
   <requestHandler name="/update" class="solr.UpdateRequestHandler"  />
   <requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
-      
+
+  <requestHandler name="/admin/ping" class="solr.PingRequestHandler">
+    <lst name="invariants">
+      <str name="q">*:*</str>
+    </lst>
+    <lst name="defaults">
+       <str name="echoParams">all</str>
+    </lst>
+    <str name="healthcheckFile">server-enabled.txt</str>
+  </requestHandler>
+
   <!-- config for the admin interface --> 
   <admin>
     <defaultQuery>solr</defaultQuery>

Modified: lucene/dev/branches/security/solr/solrj/src/test-files/solrj/solr/shared/solr.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test-files/solrj/solr/shared/solr.xml?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test-files/solrj/solr/shared/solr.xml (original)
+++ lucene/dev/branches/security/solr/solrj/src/test-files/solrj/solr/shared/solr.xml Thu May 30 07:53:18 2013
@@ -30,7 +30,7 @@
   adminPath: RequestHandler path to manage cores.  
     If 'null' (or absent), cores will not be manageable via REST
   -->
-  <cores adminPath="/admin/cores" defaultCoreName="core0" host="127.0.0.1" hostPort="${hostPort:8983}" hostContext="${hostContext:}" zkClientTimeout="8000">
+  <cores adminPath="/admin/cores" defaultCoreName="core0" host="127.0.0.1" hostPort="${hostPort:8983}" hostContext="${hostContext:solr}" zkClientTimeout="8000">
     <core name="collection1" instanceDir="." />
     <core name="core0" instanceDir="${theInstanceDir:./}" dataDir="${dataDir1}" collection="${collection:acollection}">
       <property name="version" value="3.5"/>

Modified: lucene/dev/branches/security/solr/solrj/src/test-files/solrj/solr/solr.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test-files/solrj/solr/solr.xml?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test-files/solrj/solr/solr.xml (original)
+++ lucene/dev/branches/security/solr/solrj/src/test-files/solrj/solr/solr.xml Thu May 30 07:53:18 2013
@@ -28,7 +28,7 @@
   adminPath: RequestHandler path to manage cores.  
     If 'null' (or absent), cores will not be manageable via request handler
   -->
-  <cores adminPath="/admin/cores" defaultCoreName="collection1" host="127.0.0.1" hostPort="${hostPort:8983}" hostContext="${hostContext:}" zkClientTimeout="8000" numShards="${numShards:3}">
+  <cores adminPath="/admin/cores" defaultCoreName="collection1" host="127.0.0.1" hostPort="${hostPort:8983}" hostContext="${hostContext:solr}" zkClientTimeout="8000" numShards="${numShards:3}">
     <core name="collection1" instanceDir="collection1" shard="${shard:}" collection="${collection:collection1}" config="${solrconfig:solrconfig.xml}" schema="${schema:schema.xml}"/>
   </cores>
 </solr>

Modified: lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java Thu May 30 07:53:18 2013
@@ -19,6 +19,7 @@ package org.apache.solr.client.solrj;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Arrays;
 
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
@@ -26,6 +27,8 @@ import org.apache.solr.client.solrj.requ
 import org.apache.solr.client.solrj.request.QueryRequest;
 import org.apache.solr.client.solrj.request.UpdateRequest;
 import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.params.CoreAdminParams;
+import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.util.ExternalPaths;
@@ -190,4 +193,14 @@ public abstract class MergeIndexesExampl
     assertEquals(1,
         getSolrCore0().query(new SolrQuery("id:BBB")).getResults().size());
   }
+
+  public void testMergeMultipleRequest() throws Exception {
+    CoreAdminRequest.MergeIndexes req = new CoreAdminRequest.MergeIndexes();
+    req.setCoreName("core0");
+    req.setIndexDirs(Arrays.asList("/path/1", "/path/2"));
+    req.setSrcCores(Arrays.asList("core1", "core2"));
+    SolrParams params = req.getParams();
+    assertEquals(2, params.getParams(CoreAdminParams.SRC_CORE).length);
+    assertEquals(2, params.getParams(CoreAdminParams.INDEX_DIR).length);
+  }
 }

Modified: lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java Thu May 30 07:53:18 2013
@@ -19,9 +19,9 @@ package org.apache.solr.client.solrj;
 
 import java.io.File;
 
-import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.request.AbstractUpdateRequest.ACTION;
 import org.apache.solr.client.solrj.request.CoreAdminRequest;
+import org.apache.solr.client.solrj.request.CoreAdminRequest.Unload;
 import org.apache.solr.client.solrj.request.QueryRequest;
 import org.apache.solr.client.solrj.request.UpdateRequest;
 import org.apache.solr.client.solrj.response.CoreAdminResponse;
@@ -44,6 +44,7 @@ public abstract class MultiCoreExampleTe
   protected static CoreContainer cores;
 
   private File dataDir2;
+  private File dataDir1;
 
   @Override public String getSolrHome() { return ExternalPaths.EXAMPLE_MULTICORE_HOME; }
 
@@ -64,11 +65,15 @@ public abstract class MultiCoreExampleTe
     SolrCore.log.info("CORES=" + cores + " : " + cores.getCoreNames());
     cores.setPersistent(false);
     
+    dataDir1 = new File(TEMP_DIR, getClass().getName() + "-core0-"
+        + System.currentTimeMillis());
+    dataDir1.mkdirs();
+    
     dataDir2 = new File(TEMP_DIR, getClass().getName() + "-core1-"
         + System.currentTimeMillis());
     dataDir2.mkdirs();
     
-    System.setProperty( "solr.core0.data.dir", SolrTestCaseJ4.dataDir.getCanonicalPath() ); 
+    System.setProperty( "solr.core0.data.dir", this.dataDir1.getCanonicalPath() ); 
     System.setProperty( "solr.core1.data.dir", this.dataDir2.getCanonicalPath() ); 
   }
   
@@ -219,13 +224,24 @@ public abstract class MultiCoreExampleTe
     String indexDir = (String) ((NamedList<Object>) coreInfo.get("directory")).get("index");
     
     
+    response = getSolrCore("core0").query(new SolrQuery().setRequestHandler("/admin/system")).getResponse();
+    coreInfo = (NamedList<Object>) response.get("core");
+    String dataDir = (String) ((NamedList<Object>) coreInfo.get("directory")).get("data");
+    
 
     System.out.println( (String) ((NamedList<Object>) coreInfo.get("directory")).get("dirimpl"));
 
-    
     // test delete index on core
     CoreAdminRequest.unloadCore("corefoo", true, coreadmin);
     File dir = new File(indexDir);
     assertFalse("Index directory exists after core unload with deleteIndex=true", dir.exists());
+    
+    Unload req = new Unload(false);
+    req.setDeleteDataDir(true);
+    req.setCoreName("core0");
+    req.process(coreadmin);
+    
+    dir = new File(dataDir);
+    assertFalse("Data directory exists after core unload with deleteDataDir=true : " + dir, dir.exists());
   }
 }

Modified: lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java Thu May 30 07:53:18 2013
@@ -41,11 +41,12 @@ public class SolrExampleBinaryTest exten
   {
     try {
       // setup the server...
-      String url = jetty.getBaseUrl().toString();
+      String url = jetty.getBaseUrl().toString() + "/collection1";
       HttpSolrServer s = new HttpSolrServer( url );
       s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
       s.setDefaultMaxConnectionsPerHost(100);
       s.setMaxTotalConnections(100);
+      s.setUseMultiPartPost(random().nextBoolean());
 
       // where the magic happens
       s.setParser(new BinaryResponseParser());

Modified: lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java Thu May 30 07:53:18 2013
@@ -1438,6 +1438,29 @@ abstract public class SolrExampleTests e
     assertNotNull("Entire doc was replaced because null update was not written", response.getResults().get(0).getFieldValue("single_s"));
     assertNull("Null update failed. Value still exists in document", response.getResults().get(0).getFieldValue("multi_ss"));
   }
+
+  public void testSetNullUpdateOrder() throws Exception {
+    SolrServer solrServer = getSolrServer();
+    SolrInputDocument doc = new SolrInputDocument();
+    doc.addField("id", "testSetNullUpdateOrder");
+    doc.addField("single_s", "test-value");
+    doc.addField("multi_ss", Arrays.asList("first", "second"));
+    solrServer.add(doc);
+    solrServer.commit(true, true);
+
+    Map<String, Object> map = Maps.newHashMap();
+    map.put("set", null);
+    doc = new SolrInputDocument();
+    doc.addField("multi_ss", map);
+    doc.addField("id", "testSetNullUpdateOrder");
+    doc.addField("single_s", "test-value2");
+    solrServer.add(doc);
+    solrServer.commit();
+
+    QueryResponse response = solrServer.query(new SolrQuery("id:testSetNullUpdateOrder"));
+    assertEquals("Field included after set null=true not updated via atomic update", "test-value2",
+        response.getResults().get(0).getFieldValue("single_s"));
+  }
   
   @Test
   public void testQueryWithParams() throws SolrServerException {

Modified: lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java Thu May 30 07:53:18 2013
@@ -36,8 +36,9 @@ public class SolrExampleXMLTest extends 
   @Override
   public SolrServer createNewSolrServer() {
     try {
-      String url = jetty.getBaseUrl().toString();
+      String url = jetty.getBaseUrl().toString() + "/collection1";
       HttpSolrServer s = new HttpSolrServer(url);
+      s.setUseMultiPartPost(random().nextBoolean());
       s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
       s.setDefaultMaxConnectionsPerHost(100);
       s.setMaxTotalConnections(100);

Modified: lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java Thu May 30 07:53:18 2013
@@ -72,6 +72,7 @@ public class TestLBHttpSolrServer extend
   public static void beforeClass() {
     savedFactory = System.getProperty("solr.DirectoryFactory");
     System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory");
+    System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong()));
   }
 
   @AfterClass
@@ -81,6 +82,7 @@ public class TestLBHttpSolrServer extend
     } else {
       System.setProperty("solr.directoryFactory", savedFactory);
     }
+    System.clearProperty("tests.shardhandler.randomSeed");
   }
   
   @Override

Modified: lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java Thu May 30 07:53:18 2013
@@ -60,7 +60,7 @@ public abstract class AbstractEmbeddedSo
     System.setProperty("dataDir1", dataDir.getAbsolutePath());
     System.setProperty("dataDir2", dataDir2.getAbsolutePath());
     System.setProperty("tempDir", tempDir.getAbsolutePath());
-
+    System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong()));
     cores = new CoreContainer(SOLR_HOME.getAbsolutePath(), getSolrXml());
   }
   
@@ -74,7 +74,8 @@ public abstract class AbstractEmbeddedSo
 
     System.clearProperty("dataDir1");
     System.clearProperty("dataDir2");
-    
+    System.clearProperty("tests.shardhandler.randomSeed");
+
     deleteAdditionalFiles();
 
     File dataDir = new File(tempDir,"data");

Modified: lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java Thu May 30 07:53:18 2013
@@ -55,7 +55,8 @@ public class JettyWebappTest extends Luc
   {
     super.setUp();
     System.setProperty("solr.solr.home", ExternalPaths.EXAMPLE_HOME);
-    
+    System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong()));
+
     File dataDir = new File(LuceneTestCase.TEMP_DIR,
         getClass().getName() + "-" + System.currentTimeMillis());
     dataDir.mkdirs();
@@ -84,6 +85,7 @@ public class JettyWebappTest extends Luc
     try {
       server.stop();
     } catch( Exception ex ) {}
+    System.clearProperty("tests.shardhandler.randomSeed");
     super.tearDown();
   }
   

Modified: lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java Thu May 30 07:53:18 2013
@@ -55,7 +55,7 @@ public class SolrExampleStreamingTest ex
   {
     try {
       // setup the server...
-      String url = jetty.getBaseUrl().toString();
+      String url = jetty.getBaseUrl().toString() + "/collection1";
       // smaller queue size hits locks more often
       ConcurrentUpdateSolrServer s = new ConcurrentUpdateSolrServer( url, 2, 5 ) {
         
@@ -80,7 +80,7 @@ public class SolrExampleStreamingTest ex
     // SOLR-3903
     final List<Throwable> failures = new ArrayList<Throwable>();
     ConcurrentUpdateSolrServer s = new ConcurrentUpdateSolrServer
-      (jetty.getBaseUrl().toString(), 2, 2) {
+      (jetty.getBaseUrl().toString() + "/collection1", 2, 2) {
         @Override
         public void handleError(Throwable ex) {
           failures.add(ex);

Modified: lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java Thu May 30 07:53:18 2013
@@ -194,8 +194,8 @@ public class TestSolrProperties extends 
                  exists("/solr/cores[@hostPort='${hostPort:8983}']", document));
       assertTrue("\"/solr/cores[@zkClientTimeout='8000']\" doesn't match in:\n" + solrPersistXml,
                  exists("/solr/cores[@zkClientTimeout='8000']", document));
-      assertTrue("\"/solr/cores[@hostContext='solr']\" doesn't match in:\n" + solrPersistXml,
-                 exists("/solr/cores[@hostContext='solr']", document));
+      assertTrue("\"/solr/cores[@hostContext='${hostContext:solr}']\" doesn't match in:\n" + solrPersistXml,
+                 exists("/solr/cores[@hostContext='${hostContext:solr}']", document));
       
     } finally {
       fis.close();

Modified: lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java Thu May 30 07:53:18 2013
@@ -43,6 +43,8 @@ import org.apache.solr.client.solrj.requ
 import org.apache.solr.client.solrj.request.UpdateRequest;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.util.ExternalPaths;
@@ -55,7 +57,7 @@ public class BasicHttpSolrServerTest ext
     @Override
     protected void doGet(HttpServletRequest req, HttpServletResponse resp)
         throws ServletException, IOException {
-      resp.sendRedirect("/solr/select?" + req.getQueryString());
+      resp.sendRedirect("/solr/collection1/select?" + req.getQueryString());
     }
   }
   
@@ -74,12 +76,19 @@ public class BasicHttpSolrServerTest ext
       lastMethod = null;
       headers = null;
       parameters = null;
+      errorCode = null;
     }
     
+    public static Integer errorCode = null;
     public static String lastMethod = null;
     public static HashMap<String,String> headers = null;
     public static Map<String,String[]> parameters = null;
     
+    public static void setErrorCode(Integer code) {
+      errorCode = code;
+    }
+    
+
     @Override
     protected void doGet(HttpServletRequest req, HttpServletResponse resp)
         throws ServletException, IOException {
@@ -110,6 +119,13 @@ public class BasicHttpSolrServerTest ext
     private void recordRequest(HttpServletRequest req, HttpServletResponse resp) {
       setHeaders(req);
       setParameters(req);
+      if (null != errorCode) {
+        try { 
+          resp.sendError(errorCode); 
+        } catch (IOException e) {
+          throw new RuntimeException("sendError IO fail in DebugServlet", e);
+        }
+      }
     }
   }
   
@@ -160,6 +176,34 @@ public class BasicHttpSolrServerTest ext
     server.shutdown();
   }
   
+  /**
+   * test that SolrExceptions thrown by HttpSolrServer can
+   * correctly encapsulate http status codes even when not on the list of
+   * ErrorCodes solr may return.
+   */
+  public void testSolrExceptionCodeNotFromSolr() throws IOException, SolrServerException {
+    final int status = 527;
+    assertEquals(status + " didn't generate an UNKNOWN error code, someone modified the list of valid ErrorCode's w/o changing this test to work a different way",
+                 ErrorCode.UNKNOWN, ErrorCode.getErrorCode(status));
+
+    HttpSolrServer server = new HttpSolrServer(jetty.getBaseUrl().toString() +
+                                               "/debug/foo");
+    try {
+      DebugServlet.setErrorCode(status);
+      try {
+        SolrQuery q = new SolrQuery("foo");
+        server.query(q, METHOD.GET);
+        fail("Didn't get excepted exception from oversided request");
+      } catch (SolrException e) {
+        System.out.println(e);
+        assertEquals("Unexpected exception status code", status, e.code());
+      }
+    } finally {
+      server.shutdown();
+      DebugServlet.clear();
+    }
+  }
+
   @Test
   public void testQuery(){
     DebugServlet.clear();
@@ -395,7 +439,7 @@ public class BasicHttpSolrServerTest ext
     assertNull(DebugServlet.headers.get("Accept-Encoding"));
     
     // verify server compresses output
-    HttpGet get = new HttpGet(jetty.getBaseUrl().toString() + 
+    HttpGet get = new HttpGet(jetty.getBaseUrl().toString() + "/collection1" +
                               "/select?q=foo&wt=xml");
     get.setHeader("Accept-Encoding", "gzip");
     HttpClient client = HttpClientUtil.createClient(null);
@@ -414,7 +458,7 @@ public class BasicHttpSolrServerTest ext
     }
     
     // verify compressed response can be handled
-    server = new HttpSolrServer(jetty.getBaseUrl().toString());
+    server = new HttpSolrServer(jetty.getBaseUrl().toString() + "/collection1");
     server.setAllowCompression(true);
     q = new SolrQuery("foo");
     QueryResponse response = server.query(q);
@@ -441,7 +485,7 @@ public class BasicHttpSolrServerTest ext
   @Test
   public void testGetRawStream() throws SolrServerException, IOException{
     HttpClient client = HttpClientUtil.createClient(null);
-    HttpSolrServer server = new HttpSolrServer(jetty.getBaseUrl().toString(), 
+    HttpSolrServer server = new HttpSolrServer(jetty.getBaseUrl().toString() + "/collection1", 
                                                client, null);
     QueryRequest req = new QueryRequest();
     NamedList response = server.request(req);

Modified: lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java Thu May 30 07:53:18 2013
@@ -85,7 +85,7 @@ public class CloudSolrServerTest extends
   public CloudSolrServerTest() {
     super();
     sliceCount = 2;
-    shardCount = 6;
+    shardCount = 4;
   }
   
   @Override
@@ -149,10 +149,4 @@ public class CloudSolrServerTest extends
     indexDoc(doc);
   }
 
-  SolrInputDocument getDoc(Object... fields) throws Exception {
-    SolrInputDocument doc = new SolrInputDocument();
-    addFields(doc, fields);
-    return doc;
-  }
-
 }

Modified: lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java Thu May 30 07:53:18 2013
@@ -23,6 +23,9 @@ import org.apache.solr.SolrIgnoredThread
 import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.client.solrj.embedded.AbstractEmbeddedSolrServerTestCase;
 import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrCore;
 import org.apache.commons.io.FileUtils;
 import org.junit.After;
@@ -80,13 +83,29 @@ public class TestCoreAdmin extends Abstr
     req.setInstanceDir(newCoreInstanceDir.getAbsolutePath() + File.separator + "newcore");
     req.setDataDir(dataDir.getAbsolutePath());
     req.setUlogDir(new File(dataDir, "ulog").getAbsolutePath());
+
+    // These should be the inverse of defaults.
+    req.setIsLoadOnStartup(false);
+    req.setIsTransient(true);
     req.process(server);
-    
+
+    // Show that the newly-created core has values for load on startup and transient different than defaults due to the
+    // above.
+
+    SolrCore coreProveIt = cores.getCore("collection1");
     SolrCore core = cores.getCore("newcore");
+
+    assertTrue(core.getCoreDescriptor().isTransient());
+    assertFalse(coreProveIt.getCoreDescriptor().isTransient());
+
+    assertFalse(core.getCoreDescriptor().isLoadOnStartup());
+    assertTrue(coreProveIt.getCoreDescriptor().isLoadOnStartup());
+
     File logDir;
     try {
       logDir = core.getUpdateHandler().getUpdateLog().getLogDir();
     } finally {
+      coreProveIt.close();
       core.close();
     }
     assertEquals(new File(dataDir, "ulog" + File.separator + "tlog").getAbsolutePath(), logDir.getAbsolutePath());
@@ -94,6 +113,26 @@ public class TestCoreAdmin extends Abstr
     
   }
   
+  @Test
+  public void testErrorCases() throws Exception {
+    
+    ModifiableSolrParams params = new ModifiableSolrParams();
+    params.set("action", "BADACTION");
+    String collectionName = "badactioncollection";
+    params.set("name", collectionName);
+    QueryRequest request = new QueryRequest(params);
+    request.setPath("/admin/cores");
+    boolean gotExp = false;
+    NamedList<Object> resp = null;
+    try {
+      resp = getSolrAdmin().request(request);
+    } catch (SolrException e) {
+      gotExp = true;
+    }
+    
+    assertTrue(gotExp);
+  }
+  
   @BeforeClass
   public static void before() {
     // wtf?

Modified: lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/client/solrj/response/QueryResponseTest.java Thu May 30 07:53:18 2013
@@ -114,6 +114,7 @@ public class QueryResponseTest extends L
     assertEquals(0, manufacturedateDt.getCounts().get(2).getCount());
     assertEquals(90, manufacturedateDt.getBefore());
     assertEquals(1, manufacturedateDt.getAfter());
+    assertEquals(11, manufacturedateDt.getBetween());
   }
 
   @Test

Modified: lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/common/util/NamedListTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/common/util/NamedListTest.java?rev=1487777&r1=1487776&r2=1487777&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/common/util/NamedListTest.java (original)
+++ lucene/dev/branches/security/solr/solrj/src/test/org/apache/solr/common/util/NamedListTest.java Thu May 30 07:53:18 2013
@@ -29,4 +29,95 @@ public class NamedListTest extends Lucen
     assertEquals("value1", value);
     assertEquals(1, nl.size());
   }
+  
+  public void testRecursive() {
+    // key1
+    // key2
+    // - key2a
+    // - key2b
+    // --- key2b1
+    // --- key2b2
+    // - key2c
+    // - k2int1
+    // key3
+    // - key3a
+    // --- key3a1
+    // --- key3a2
+    // --- key3a3
+    // - key3b
+    // - key3c
+    
+    // this is a varied NL structure.
+    NamedList<String> nl2b = new NamedList<String>();
+    nl2b.add("key2b1", "value2b1");
+    nl2b.add("key2b2", "value2b2");
+    NamedList<String> nl3a = new NamedList<String>();
+    nl3a.add("key3a1", "value3a1");
+    nl3a.add("key3a2", "value3a2");
+    nl3a.add("key3a3", "value3a3");
+    NamedList<Object> nl2 = new NamedList<Object>();
+    nl2.add("key2a", "value2a");
+    nl2.add("key2b", nl2b);
+    nl2.add("k2int1", (int) 5);
+    NamedList<Object> nl3 = new NamedList<Object>();
+    nl3.add("key3a", nl3a);
+    nl3.add("key3b", "value3b");
+    nl3.add("key3c", "value3c");
+    nl3.add("key3c", "value3c2");
+    NamedList<Object> nl = new NamedList<Object>();
+    nl.add("key1", "value1");
+    nl.add("key2", nl2);
+    nl.add("key3", nl3);
+    
+    // Simple three-level checks.
+    String test1 = (String) nl.findRecursive("key2", "key2b", "key2b2");
+    assertEquals("value2b2", test1);
+    String test2 = (String) nl.findRecursive("key3", "key3a", "key3a3");
+    assertEquals("value3a3", test2);
+    // Two-level check.
+    String test3 = (String) nl.findRecursive("key3", "key3c");
+    assertEquals("value3c", test3);
+    // Checking that invalid values return null.
+    String test4 = (String) nl.findRecursive("key3", "key3c", "invalid");
+    assertEquals(null, test4);
+    String test5 = (String) nl.findRecursive("key3", "invalid", "invalid");
+    assertEquals(null, test5);
+    String test6 = (String) nl.findRecursive("invalid", "key3c");
+    assertEquals(null, test6);
+    // Verify that retrieved NamedList objects have the right type.
+    Object test7 = nl.findRecursive("key2", "key2b");
+    assertTrue(test7 instanceof NamedList);
+    // Integer check.
+    int test8 = (Integer) nl.findRecursive("key2", "k2int1");
+    assertEquals(5, test8);
+    // Check that a single argument works the same as get(String).
+    String test9 = (String) nl.findRecursive("key1");
+    assertEquals("value1", test9);
+    // enl == explicit nested list
+    //
+    // key1
+    // - key1a
+    // - key1b
+    // key2 (null list)
+    NamedList<NamedList<String>> enl = new NamedList<NamedList<String>>();
+    NamedList<String> enlkey1 = new NamedList<String>();
+    NamedList<String> enlkey2 = null;
+    enlkey1.add("key1a", "value1a");
+    enlkey1.add("key1b", "value1b");
+    enl.add("key1", enlkey1);
+    enl.add("key2", enlkey2);
+    
+    // Tests that are very similar to the test above, just repeated
+    // on the explicitly nested object type.
+    String enltest1 = (String) enl.findRecursive("key1", "key1a");
+    assertEquals("value1a", enltest1);
+    String enltest2 = (String) enl.findRecursive("key1", "key1b");
+    assertEquals("value1b", enltest2);
+    // Verify that when a null value is stored, the standard get method
+    // says it is null, then check the recursive method.
+    Object enltest3 = enl.get("key2");
+    assertNull(enltest3);
+    Object enltest4 = enl.findRecursive("key2");
+    assertNull(enltest4);
+  }
 }