lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject [21/26] lucene-solr:starburst: The Star Burst Upgrade - a work in progress - the branch gets replaced often.
Date Sun, 29 Jul 2018 15:08:43 GMT
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/response/BinaryQueryResponseWriter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/response/BinaryQueryResponseWriter.java b/solr/core/src/java/org/apache/solr/response/BinaryQueryResponseWriter.java
index 8ae901b..571841f 100644
--- a/solr/core/src/java/org/apache/solr/response/BinaryQueryResponseWriter.java
+++ b/solr/core/src/java/org/apache/solr/response/BinaryQueryResponseWriter.java
@@ -15,8 +15,8 @@
  * limitations under the License.
  */
 package org.apache.solr.response;
-import java.io.OutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 
 import org.apache.solr.request.SolrQueryRequest;
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java b/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
index 04b2606..48e02a1 100644
--- a/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
@@ -48,7 +48,7 @@ import org.apache.solr.analysis.TokenizerChain;
 import org.apache.solr.client.solrj.SolrClient;
 import org.apache.solr.client.solrj.SolrRequest;
 import org.apache.solr.client.solrj.SolrResponse;
-import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.client.solrj.impl.Http2SolrClient;
 import org.apache.solr.cloud.ZkController;
 import org.apache.solr.cloud.ZkSolrResourceLoader;
 import org.apache.solr.common.SolrException;
@@ -331,12 +331,13 @@ public final class ManagedIndexSchema extends IndexSchema {
     @Override
     public Integer call() throws Exception {
       int remoteVersion = -1;
-      try (HttpSolrClient solr = new HttpSolrClient.Builder(coreUrl).build()) {
+      try (Http2SolrClient client = new Http2SolrClient.Builder(coreUrl).build()) {
         // eventually, this loop will get killed by the ExecutorService's timeout
         while (remoteVersion == -1 || remoteVersion < expectedZkVersion) {
           try {
-            HttpSolrClient.HttpUriRequestResponse mrr = solr.httpUriRequest(this);
-            NamedList<Object> zkversionResp = mrr.future.get();
+            //Http2SolrClient.HttpUriRequestResponse mrr = solr.httpUriRequest(this);
+            //client.httpGet(coreUrl + "/schema/zkversion?" + "refreshIfBelowVersion=" + expectedZkVersion );
+            NamedList<Object> zkversionResp = client.request(this);
             if (zkversionResp != null)
               remoteVersion = (Integer)zkversionResp.get("zkversion");
 
@@ -362,7 +363,7 @@ public final class ManagedIndexSchema extends IndexSchema {
 
 
     @Override
-    protected SolrResponse createResponse(SolrClient client) {
+    public SolrResponse createResponse(SolrClient client) {
       return null;
     }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/search/SolrFilter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/SolrFilter.java b/solr/core/src/java/org/apache/solr/search/SolrFilter.java
index f1bf505..00da536 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrFilter.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrFilter.java
@@ -16,14 +16,14 @@
  */
 package org.apache.solr.search;
 
+import java.io.IOException;
+import java.util.Map;
+
 import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.DocIdSet;
+import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.util.Bits;
 
-import java.util.Map;
-import java.io.IOException;
-
 
 /** A SolrFilter extends the Lucene Filter and adds extra semantics such as passing on
  * weight context info for function queries.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
index 44e12a7..809c05c 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -34,8 +34,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 
-import com.codahale.metrics.MetricRegistry;
-import com.google.common.collect.Iterables;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.ExitableDirectoryReader;
@@ -50,8 +48,37 @@ import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermStates;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
-import org.apache.lucene.search.*;
+import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanClause.Occur;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.CollectionStatistics;
+import org.apache.lucene.search.Collector;
+import org.apache.lucene.search.ConstantScoreQuery;
+import org.apache.lucene.search.DocIdSet;
+import org.apache.lucene.search.DocIdSetIterator;
+import org.apache.lucene.search.Explanation;
+import org.apache.lucene.search.FieldDoc;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.LeafCollector;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.MultiCollector;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.ScoreMode;
+import org.apache.lucene.search.Scorer;
+import org.apache.lucene.search.SimpleCollector;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TermStatistics;
+import org.apache.lucene.search.TimeLimitingCollector;
+import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.search.TopDocsCollector;
+import org.apache.lucene.search.TopFieldCollector;
+import org.apache.lucene.search.TopFieldDocs;
+import org.apache.lucene.search.TopScoreDocCollector;
+import org.apache.lucene.search.TotalHitCountCollector;
+import org.apache.lucene.search.Weight;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
@@ -82,6 +109,9 @@ import org.apache.solr.update.SolrIndexConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.codahale.metrics.MetricRegistry;
+import com.google.common.collect.Iterables;
+
 /**
  * SolrIndexSearcher adds schema awareness and caching functionality over {@link IndexSearcher}.
  *

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/search/SolrReturnFields.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/SolrReturnFields.java b/solr/core/src/java/org/apache/solr/search/SolrReturnFields.java
index 2b1b303..b5bf079 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrReturnFields.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrReturnFields.java
@@ -16,6 +16,14 @@
  */
 package org.apache.solr.search;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.commons.io.FilenameUtils;
 import org.apache.lucene.queries.function.FunctionQuery;
 import org.apache.lucene.queries.function.ValueSource;
@@ -34,14 +42,6 @@ import org.apache.solr.response.transform.ScoreAugmenter;
 import org.apache.solr.response.transform.TransformerFactory;
 import org.apache.solr.response.transform.ValueSourceAugmenter;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * The default implementation of return fields parsing for Solr.
  */

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/security/PKIAuthenticationPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/security/PKIAuthenticationPlugin.java b/solr/core/src/java/org/apache/solr/security/PKIAuthenticationPlugin.java
index 43dac48..a78d46e 100644
--- a/solr/core/src/java/org/apache/solr/security/PKIAuthenticationPlugin.java
+++ b/solr/core/src/java/org/apache/solr/security/PKIAuthenticationPlugin.java
@@ -16,11 +16,8 @@
  */
 package org.apache.solr.security;
 
-import javax.servlet.FilterChain;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.IOException;
 import java.lang.invoke.MethodHandles;
 import java.nio.ByteBuffer;
@@ -30,13 +27,17 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import javax.servlet.FilterChain;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.HttpResponse;
 import org.apache.http.auth.BasicUserPrincipal;
-import org.apache.http.client.methods.HttpGet;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.util.EntityUtils;
 import org.apache.solr.client.solrj.impl.HttpClientUtil;
@@ -52,8 +53,6 @@ import org.apache.solr.util.CryptoKeys;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
-
 
 public class PKIAuthenticationPlugin extends AuthenticationPlugin implements HttpClientBuilderPlugin {
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@@ -197,9 +196,10 @@ public class PKIAuthenticationPlugin extends AuthenticationPlugin implements Htt
     try {
       String uri = url + PublicKeyHandler.PATH + "?wt=json&omitHeader=true";
       log.debug("Fetching fresh public key from : {}",uri);
-      HttpResponse rsp = cores.getUpdateShardHandler().getDefaultHttpClient()
-          .execute(new HttpGet(uri), HttpClientUtil.createNewHttpClientRequestContext());
-      entity  = rsp.getEntity();
+      // nocommit
+//      HttpResponse rsp = cores.getUpdateShardHandler().getDefaultHttpClient()
+//          .execute(new HttpGet(uri), HttpClientUtil.createNewHttpClientRequestContext());
+//      entity  = rsp.getEntity();
       byte[] bytes = EntityUtils.toByteArray(entity);
       Map m = (Map) Utils.fromJSON(bytes);
       String key = (String) m.get("key");

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/servlet/AdjustableSemaphore.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/servlet/AdjustableSemaphore.java b/solr/core/src/java/org/apache/solr/servlet/AdjustableSemaphore.java
new file mode 100644
index 0000000..4362622
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/servlet/AdjustableSemaphore.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF liceHealthCheckHandlerTestnses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.servlet;
+
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+final public class AdjustableSemaphore {
+
+  private final ExposeSemaphore semaphore;
+
+  private int maxPermits = 0;
+
+  public AdjustableSemaphore(boolean fair) {
+    semaphore = new ExposeSemaphore(fair);
+  }
+
+  synchronized void setMaxPermits(int newMax) {
+    int diff = newMax - this.maxPermits;
+
+    if (diff == 0) {
+      return;
+    } else if (diff > 0) {
+      this.semaphore.release(diff);
+    } else {
+      diff *= -1;
+      this.semaphore.reducePermits(diff);
+    }
+
+    this.maxPermits = newMax;
+  }
+
+  void release() {
+    this.semaphore.release();
+  }
+
+  void acquire() throws InterruptedException {
+    this.semaphore.acquire();
+  }
+
+  int availablePermits() {
+    return this.semaphore.availablePermits();
+  }
+
+  private static final class ExposeSemaphore extends Semaphore {
+
+    private static final long serialVersionUID = 1L;
+
+    ExposeSemaphore(boolean fair) {
+      super(0, fair);
+    }
+
+    @Override
+    protected void reducePermits(int reduction) {
+      super.reducePermits(reduction);
+    }
+  }
+
+  public boolean tryAcquire(long waitMs, TimeUnit milliseconds) throws InterruptedException {
+    return this.semaphore.tryAcquire(waitMs, milliseconds);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/servlet/DirectSolrConnection.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/servlet/DirectSolrConnection.java b/solr/core/src/java/org/apache/solr/servlet/DirectSolrConnection.java
index 7fecd29..15ba42d 100644
--- a/solr/core/src/java/org/apache/solr/servlet/DirectSolrConnection.java
+++ b/solr/core/src/java/org/apache/solr/servlet/DirectSolrConnection.java
@@ -55,7 +55,7 @@ public class DirectSolrConnection
   public DirectSolrConnection( SolrCore c )
   {
     core = c;
-    parser = new SolrRequestParsers( c.getSolrConfig() );
+    parser = new SolrRequestParsers( c.getSolrConfig(), null );
   }
   
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
index b297a44..a6c3750 100644
--- a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
+++ b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
@@ -16,47 +16,56 @@
  */
 package org.apache.solr.servlet;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import static org.apache.solr.common.cloud.ZkStateReader.BASE_URL_PROP;
+import static org.apache.solr.common.cloud.ZkStateReader.COLLECTION_PROP;
+import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;
+import static org.apache.solr.common.cloud.ZkStateReader.NODE_NAME_PROP;
+import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
+import static org.apache.solr.common.params.CollectionAdminParams.SYSTEM_COLL;
+import static org.apache.solr.common.params.CollectionParams.CollectionAction.CREATE;
+import static org.apache.solr.common.params.CollectionParams.CollectionAction.DELETE;
+import static org.apache.solr.common.params.CollectionParams.CollectionAction.RELOAD;
+import static org.apache.solr.common.params.CommonParams.NAME;
+import static org.apache.solr.common.params.CoreAdminParams.ACTION;
+import static org.apache.solr.servlet.SolrDispatchFilter.Action.ADMIN;
+import static org.apache.solr.servlet.SolrDispatchFilter.Action.FORWARD;
+import static org.apache.solr.servlet.SolrDispatchFilter.Action.PASSTHROUGH;
+import static org.apache.solr.servlet.SolrDispatchFilter.Action.PROCESS;
+import static org.apache.solr.servlet.SolrDispatchFilter.Action.REMOTEQUERY;
+import static org.apache.solr.servlet.SolrDispatchFilter.Action.RETRY;
+import static org.apache.solr.servlet.SolrDispatchFilter.Action.RETURN;
+
 import java.io.EOFException;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.lang.invoke.MethodHandles;
+import java.net.URL;
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Random;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
-import org.apache.http.Header;
-import org.apache.http.HeaderIterator;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.entity.InputStreamEntity;
 import org.apache.solr.api.ApiBag;
 import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.apache.solr.client.solrj.impl.HttpClientUtil;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.cloud.Aliases;
@@ -69,6 +78,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.MapSolrParams;
 import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.QoSParams;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.CommandOperation;
 import org.apache.solr.common.util.ContentStream;
@@ -105,28 +115,16 @@ import org.apache.solr.update.processor.DistributingUpdateProcessorFactory;
 import org.apache.solr.util.RTimerTree;
 import org.apache.solr.util.TimeOut;
 import org.apache.zookeeper.KeeperException;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.api.Response;
+import org.eclipse.jetty.client.util.InputStreamContentProvider;
+import org.eclipse.jetty.client.util.InputStreamResponseListener;
+import org.eclipse.jetty.http.HttpField;
+import org.eclipse.jetty.http.HttpHeader;
+import org.eclipse.jetty.http.HttpVersion;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.solr.common.cloud.ZkStateReader.BASE_URL_PROP;
-import static org.apache.solr.common.cloud.ZkStateReader.COLLECTION_PROP;
-import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;
-import static org.apache.solr.common.cloud.ZkStateReader.NODE_NAME_PROP;
-import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
-import static org.apache.solr.common.params.CollectionAdminParams.SYSTEM_COLL;
-import static org.apache.solr.common.params.CollectionParams.CollectionAction.CREATE;
-import static org.apache.solr.common.params.CollectionParams.CollectionAction.DELETE;
-import static org.apache.solr.common.params.CollectionParams.CollectionAction.RELOAD;
-import static org.apache.solr.common.params.CommonParams.NAME;
-import static org.apache.solr.common.params.CoreAdminParams.ACTION;
-import static org.apache.solr.servlet.SolrDispatchFilter.Action.ADMIN;
-import static org.apache.solr.servlet.SolrDispatchFilter.Action.FORWARD;
-import static org.apache.solr.servlet.SolrDispatchFilter.Action.PASSTHROUGH;
-import static org.apache.solr.servlet.SolrDispatchFilter.Action.PROCESS;
-import static org.apache.solr.servlet.SolrDispatchFilter.Action.REMOTEQUERY;
-import static org.apache.solr.servlet.SolrDispatchFilter.Action.RETRY;
-import static org.apache.solr.servlet.SolrDispatchFilter.Action.RETURN;
-
 /**
  * This class represents a call made to Solr
  **/
@@ -170,6 +168,8 @@ public class HttpSolrCall {
 
   protected RequestType requestType;
 
+  private boolean preserveHost;
+
   public HttpSolrCall(SolrDispatchFilter solrDispatchFilter, CoreContainer cores,
                HttpServletRequest request, HttpServletResponse response, boolean retry) {
     this.solrDispatchFilter = solrDispatchFilter;
@@ -233,7 +233,7 @@ public class HttpSolrCall {
     // Check for container handlers
     handler = cores.getRequestHandler(path);
     if (handler != null) {
-      solrReq = SolrRequestParsers.DEFAULT.parse(null, path, req);
+      solrReq = SolrRequestParsers.createInstance(cores.getFileCleaningTracker()).parse(null, path, req);
       solrReq.getContext().put(CoreContainer.class.getName(), cores);
       requestType = RequestType.ADMIN;
       action = ADMIN;
@@ -369,15 +369,14 @@ public class HttpSolrCall {
    * {@link #getCollectionsList()}
    */
   protected List<String> resolveCollectionListOrAlias(String collectionStr) {
-    if (collectionStr == null) {
-      return Collections.emptyList();
-    }
     LinkedHashSet<String> resultList = new LinkedHashSet<>();
-    Aliases aliases = getAliases();
-    List<String> inputCollections = StrUtils.splitSmart(collectionStr, ",", true);
-    for (String inputCollection : inputCollections) {
-      List<String> resolvedCollections = aliases.resolveAliases(inputCollection);
-      resultList.addAll(resolvedCollections);
+    if (collectionStr != null) {
+      Aliases aliases = getAliases();
+      List<String> inputCollections = StrUtils.splitSmart(collectionStr, ",", true);
+      for (String inputCollection : inputCollections) {
+        List<String> resolvedCollections = aliases.resolveAliases(inputCollection);
+        resultList.addAll(resolvedCollections);
+      }
     }
     return new ArrayList<>(resultList);
   }
@@ -496,7 +495,7 @@ public class HttpSolrCall {
           handleAdminRequest();
           return RETURN;
         case REMOTEQUERY:
-          remoteQuery(coreUrl + path, resp);
+          Action a = remoteQuery(coreUrl + path);
           return RETURN;
         case PROCESS:
           final Method reqMethod = Method.getMethod(req.getMethod());
@@ -527,7 +526,6 @@ public class HttpSolrCall {
         default: return action;
       }
     } catch (Throwable ex) {
-      sendError(ex);
       // walk the the entire cause chain to search for an Error
       Throwable t = ex;
       while (t != null) {
@@ -535,10 +533,11 @@ public class HttpSolrCall {
           if (t != ex) {
             log.error("An Error was wrapped in another exception - please report complete stacktrace on SOLR-6161", ex);
           }
-          throw (Error) t;
+          //throw (Error) t;
         }
         t = t.getCause();
       }
+      sendError(ex);
       return RETURN;
     } finally {
       MDCLoggingContext.clear();
@@ -574,84 +573,174 @@ public class HttpSolrCall {
     }
   }
 
-  private void remoteQuery(String coreUrl, HttpServletResponse resp) throws IOException {
-    HttpRequestBase method = null;
-    HttpEntity httpEntity = null;
-    try {
-      String urlstr = coreUrl + queryParams.toQueryString();
-
-      boolean isPostOrPutRequest = "POST".equals(req.getMethod()) || "PUT".equals(req.getMethod());
-      if ("GET".equals(req.getMethod())) {
-        method = new HttpGet(urlstr);
-      } else if ("HEAD".equals(req.getMethod())) {
-        method = new HttpHead(urlstr);
-      } else if (isPostOrPutRequest) {
-        HttpEntityEnclosingRequestBase entityRequest =
-            "POST".equals(req.getMethod()) ? new HttpPost(urlstr) : new HttpPut(urlstr);
-        InputStream in = req.getInputStream();
-        HttpEntity entity = new InputStreamEntity(in, req.getContentLength());
-        entityRequest.setEntity(entity);
-        method = entityRequest;
-      } else if ("DELETE".equals(req.getMethod())) {
-        method = new HttpDelete(urlstr);
+  private Action remoteQuery(String coreUrl) throws IOException, ServletException {
+    if (req != null) {
+
+      System.out.println("proxy to:" + coreUrl + "?" + req.getQueryString());
+      // nocommit - dont proxy around too much
+      String fhost = req.getHeader(HttpHeader.X_FORWARDED_FOR.toString());
+      final URL proxyFromUrl;
+      if (fhost != null) {
+        // already proxied, allow this?
+        proxyFromUrl = new URL("http://" + fhost);
+        // OR? action = PASSTHROUGH;
+        // nocommit: look into how much we can proxy around
+        System.out.println("Already proxied");
+        sendError(404, "No SolrCore found to service request.");
+        return RETURN;
       } else {
-        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
-            "Unexpected method type: " + req.getMethod());
+        proxyFromUrl = null;
       }
 
-      for (Enumeration<String> e = req.getHeaderNames(); e.hasMoreElements(); ) {
-        String headerName = e.nextElement();
-        if (!"host".equalsIgnoreCase(headerName)
-            && !"authorization".equalsIgnoreCase(headerName)
-            && !"accept".equalsIgnoreCase(headerName)) {
-          method.addHeader(headerName, req.getHeader(headerName));
-        }
-      }
-      // These headers not supported for HttpEntityEnclosingRequests
-      if (method instanceof HttpEntityEnclosingRequest) {
-        method.removeHeaders(TRANSFER_ENCODING_HEADER);
-        method.removeHeaders(CONTENT_LENGTH_HEADER);
-      }
+      System.out.println("protocol:" + req.getProtocol());
+      final Request proxyRequest = solrDispatchFilter.httpClient.newRequest(coreUrl + "?" + (req.getQueryString() != null ? req.getQueryString() : ""))
+          .method(req.getMethod())
+          .version(HttpVersion.fromString(req.getProtocol()));
 
-      final HttpResponse response
-          = solrDispatchFilter.httpClient.execute(method, HttpClientUtil.createNewHttpClientRequestContext());
-      int httpStatus = response.getStatusLine().getStatusCode();
-      httpEntity = response.getEntity();
+      copyRequestHeaders(req, proxyRequest);
 
-      resp.setStatus(httpStatus);
-      for (HeaderIterator responseHeaders = response.headerIterator(); responseHeaders.hasNext(); ) {
-        Header header = responseHeaders.nextHeader();
+      addProxyHeaders(req, proxyRequest);
 
-        // We pull out these two headers below because they can cause chunked
-        // encoding issues with Tomcat
-        if (header != null && !header.getName().equalsIgnoreCase(TRANSFER_ENCODING_HEADER)
-            && !header.getName().equalsIgnoreCase(CONNECTION_HEADER)) {
-          resp.addHeader(header.getName(), header.getValue());
-        }
+      InputStreamContentProvider defferedContent = new InputStreamContentProvider(req.getInputStream());
+      
+      if (hasContent(req)) {
+        proxyRequest.content(defferedContent);
       }
 
-      if (httpEntity != null) {
-        if (httpEntity.getContentEncoding() != null)
-          resp.setCharacterEncoding(httpEntity.getContentEncoding().getValue());
-        if (httpEntity.getContentType() != null) resp.setContentType(httpEntity.getContentType().getValue());
-
-        InputStream is = httpEntity.getContent();
-        OutputStream os = resp.getOutputStream();
+      InputStreamResponseListener listener = new InputStreamResponseListener() {
+        @Override
+        public void onFailure(Response resp, Throwable t) {
+          System.out.println("proxy to failed");
+          super.onFailure(resp, t);
+          
+        }
 
-        IOUtils.copyLarge(is, os);
+        @Override
+        public void onHeaders(Response resp) {
+          System.out.println("resp code:" + resp.getStatus());
+          for (HttpField field : resp.getHeaders()) {
+            String headerName = field.getName();
+            String lowerHeaderName = headerName.toLowerCase(Locale.ENGLISH);
+             System.out.println("response header: " + headerName + " : " + field.getValue() + " status:" +
+             resp.getStatus());
+            if (HOP_HEADERS.contains(lowerHeaderName))
+              continue;
+
+            response.addHeader(headerName, field.getValue());
+          }
+          response.setStatus(resp.getStatus());
+          super.onHeaders(resp);
+        }
+      };
+    
+   
+      proxyRequest.send(listener);
+      
+      
+      IOUtils.copyLarge(listener.getInputStream(), response.getOutputStream());
+      response.getOutputStream().flush(); // nocommit try not flushing
+      
+    }
+    
+    return RETURN;
+  }
+  
+  protected void addProxyHeaders(HttpServletRequest clientRequest, Request proxyRequest) {
+    proxyRequest.header(HttpHeader.VIA, "HTTP/2.0 Solr Proxy"); //nocommit protocol hard code
+    proxyRequest.header(HttpHeader.X_FORWARDED_FOR, clientRequest.getRemoteAddr());
+    // we have some tricky to see in tests header size limitations
+   // proxyRequest.header(HttpHeader.X_FORWARDED_PROTO, clientRequest.getScheme());
+   // proxyRequest.header(HttpHeader.X_FORWARDED_HOST, clientRequest.getHeader(HttpHeader.HOST.asString()));
+   // proxyRequest.header(HttpHeader.X_FORWARDED_SERVER, clientRequest.getLocalName());
+    proxyRequest.header(QoSParams.REQUEST_SOURCE, QoSParams.INTERNAL);
+  }
+  
+  protected void copyRequestHeaders(HttpServletRequest clientRequest, Request proxyRequest) {
+    // First clear possibly existing headers, as we are going to copy those from the client request.
+    proxyRequest.getHeaders().clear();
+
+    Set<String> headersToRemove = findConnectionHeaders(clientRequest);
+
+    for (Enumeration<String> headerNames = clientRequest.getHeaderNames(); headerNames.hasMoreElements();) {
+      String headerName = headerNames.nextElement();
+      String lowerHeaderName = headerName.toLowerCase(Locale.ENGLISH);
+
+      if (HttpHeader.HOST.is(headerName) && !preserveHost)
+        continue;
+
+      // Remove hop-by-hop headers.
+      if (HOP_HEADERS.contains(lowerHeaderName))
+        continue;
+      if (headersToRemove != null && headersToRemove.contains(lowerHeaderName))
+        continue;
+
+      for (Enumeration<String> headerValues = clientRequest.getHeaders(headerName); headerValues.hasMoreElements();) {
+        String headerValue = headerValues.nextElement();
+        if (headerValue != null) {
+          proxyRequest.header(headerName, headerValue);
+          //System.out.println("request header: " + headerName + " : " + headerValue);
+        }
       }
-
-    } catch (IOException e) {
-      sendError(new SolrException(
-          SolrException.ErrorCode.SERVER_ERROR,
-          "Error trying to proxy request for url: " + coreUrl, e));
-    } finally {
-      Utils.consumeFully(httpEntity);
     }
 
+    // Force the Host header if configured
+    // if (_hostHeader != null)
+    // proxyRequest.header(HttpHeader.HOST, _hostHeader);
+  }
+  
+  protected Set<String> findConnectionHeaders(HttpServletRequest clientRequest)
+  {
+      // Any header listed by the Connection header must be removed:
+      // http://tools.ietf.org/html/rfc7230#section-6.1.
+      Set<String> hopHeaders = null;
+      Enumeration<String> connectionHeaders = clientRequest.getHeaders(HttpHeader.CONNECTION.asString());
+      while (connectionHeaders.hasMoreElements())
+      {
+          String value = connectionHeaders.nextElement();
+          String[] values = value.split(",");
+          for (String name : values)
+          {
+              name = name.trim().toLowerCase(Locale.ENGLISH);
+              if (hopHeaders == null)
+                  hopHeaders = new HashSet<>();
+              hopHeaders.add(name);
+          }
+      }
+      return hopHeaders;
+  }
+  
+  protected boolean hasContent(HttpServletRequest clientRequest) {
+    boolean hasContent = clientRequest.getContentLength() > 0 ||
+        clientRequest.getContentType() != null ||
+        clientRequest.getHeader(HttpHeader.TRANSFER_ENCODING.asString()) != null;
+    return hasContent;
+  }
+  
+  protected static final Set<String> HOP_HEADERS;
+  static
+  {
+      Set<String> hopHeaders = new HashSet<>();
+      hopHeaders.add("accept-encoding");
+      hopHeaders.add("connection");
+      hopHeaders.add("keep-alive");
+      hopHeaders.add("proxy-authorization");
+      hopHeaders.add("proxy-authenticate");
+      hopHeaders.add("proxy-connection");
+      hopHeaders.add("transfer-encoding");
+      hopHeaders.add("te");
+      hopHeaders.add("trailer");
+      hopHeaders.add("upgrade");
+//      hopHeaders.add(HttpHeader.X_FORWARDED_FOR.asString());
+//      hopHeaders.add(HttpHeader.X_FORWARDED_PROTO.asString());
+//      hopHeaders.add(HttpHeader.VIA.asString());
+//      hopHeaders.add(HttpHeader.X_FORWARDED_HOST.asString());
+//      hopHeaders.add(HttpHeader.SERVER.asString());
+//      
+      HOP_HEADERS = Collections.unmodifiableSet(hopHeaders);
   }
 
   protected void sendError(Throwable ex) throws IOException {
+    ex.printStackTrace();
     Exception exp = null;
     SolrCore localCore = null;
     try {
@@ -659,7 +748,8 @@ public class HttpSolrCall {
       if (ex instanceof Exception) {
         solrResp.setException((Exception) ex);
       } else {
-        solrResp.setException(new RuntimeException(ex));
+        RuntimeException we = new RuntimeException(ex.getMessage(), ex);
+        solrResp.setException(we);
       }
       localCore = core;
       if (solrReq == null) {
@@ -677,6 +767,7 @@ public class HttpSolrCall {
       QueryResponseWriter writer = getResponseWriter();
       writeResponse(solrResp, writer, Method.GET);
     } catch (Exception e) { // This error really does not matter
+      e.printStackTrace();
       exp = e;
     } finally {
       try {
@@ -694,6 +785,7 @@ public class HttpSolrCall {
   }
 
   protected void sendError(int code, String message) throws IOException {
+    // assert false : "evil send error";
     try {
       response.sendError(code, message);
     } catch (EOFException e) {
@@ -886,7 +978,7 @@ public class HttpSolrCall {
     if (slices == null) {
       slices = new ArrayList<>();
       // look by core name
-      byCoreName = true;
+     // byCoreName = true;
       getSlicesForCollections(clusterState, slices, true);
       if (slices.isEmpty()) {
         getSlicesForCollections(clusterState, slices, false);
@@ -899,7 +991,7 @@ public class HttpSolrCall {
 
     collectionsList.add(collectionName);
     String coreUrl = getCoreUrl(collectionName, origCorename, clusterState,
-        slices, byCoreName, true);
+        slices, true, true);
 
     if (coreUrl == null) {
       coreUrl = getCoreUrl(collectionName, origCorename, clusterState,
@@ -926,23 +1018,30 @@ public class HttpSolrCall {
       for (Replica replica : randomizedReplicas) {
         if (!activeReplicas || (liveNodes.contains(replica.getNodeName())
             && replica.getState() == Replica.State.ACTIVE)) {
-
-          if (byCoreName && !collectionName.equals(replica.getStr(CORE_NAME_PROP))) {
+          if (byCoreName && !origCorename.equals(replica.getStr(CORE_NAME_PROP))) {
             // if it's by core name, make sure they match
             continue;
           }
+
+        
           if (replica.getStr(BASE_URL_PROP).equals(cores.getZkController().getBaseUrl())) {
             // don't count a local core
             continue;
           }
 
           if (origCorename != null) {
+            System.out.println("use replica with corename:" + replica.getStr(CORE_NAME_PROP));
             coreUrl = replica.getStr(BASE_URL_PROP) + "/" + origCorename;
+            System.out.println("we are " + cores.getZkController().getBaseUrl());
+            System.out.println("found remote core:" + coreUrl);
+            System.out.println("instead of " + replica.getCoreUrl());
           } else {
             coreUrl = replica.getCoreUrl();
             if (coreUrl.endsWith("/")) {
               coreUrl = coreUrl.substring(0, coreUrl.length() - 1);
             }
+            System.out.println("we are " + cores.getZkController().getBaseUrl());
+            System.out.println("found remote core:" + coreUrl + " replica " + replica);
           }
 
           return coreUrl;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java b/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java
index f5c301e..1052e0c 100644
--- a/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java
+++ b/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java
@@ -16,6 +16,15 @@
  */
 package org.apache.solr.servlet;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.charset.StandardCharsets;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.output.CloseShieldOutputStream;
 import org.apache.commons.lang.StringEscapeUtils;
@@ -24,15 +33,6 @@ import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.SolrCore;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.nio.charset.StandardCharsets;
-
 /**
  * A simple servlet to load the Solr Admin UI
  * 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/servlet/QoSFilter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/servlet/QoSFilter.java b/solr/core/src/java/org/apache/solr/servlet/QoSFilter.java
new file mode 100644
index 0000000..425f20b
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/servlet/QoSFilter.java
@@ -0,0 +1,402 @@
+//
+//  ========================================================================
+//  Copyright (c) 1995-2018 Mort Bay Consulting Pty. Ltd.
+//  ------------------------------------------------------------------------
+//  All rights reserved. This program and the accompanying materials
+//  are made available under the terms of the Eclipse Public License v1.0
+//  and Apache License v2.0 which accompanies this distribution.
+//
+//      The Eclipse Public License is available at
+//      http://www.eclipse.org/legal/epl-v10.html
+//
+//      The Apache License v2.0 is available at
+//      http://www.opensource.org/licenses/apache2.0.php
+//
+//  You may elect to redistribute this code under either of these licenses.
+//  ========================================================================
+//
+
+package org.apache.solr.servlet;
+
+import java.io.IOException;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.AsyncEvent;
+import javax.servlet.AsyncListener;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.eclipse.jetty.server.handler.ContextHandler;
+import org.eclipse.jetty.util.annotation.ManagedAttribute;
+import org.eclipse.jetty.util.annotation.ManagedObject;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
+
+/**
+ * Quality of Service Filter.
+ * <p>
+ * This filter limits the number of active requests to the number set by the "maxRequests" init parameter (default 10).
+ * If more requests are received, they are suspended and placed on priority queues.  Priorities are determined by
+ * the {@link #getPriority(ServletRequest)} method and are a value between 0 and the value given by the "maxPriority"
+ * init parameter (default 10), with higher values having higher priority.
+ * <p>
+ * This filter is ideal to prevent wasting threads waiting for slow/limited
+ * resources such as a JDBC connection pool.  It avoids the situation where all of a
+ * containers thread pool may be consumed blocking on such a slow resource.
+ * By limiting the number of active threads, a smaller thread pool may be used as
+ * the threads are not wasted waiting.  Thus more memory may be available for use by
+ * the active threads.
+ * <p>
+ * Furthermore, this filter uses a priority when resuming waiting requests. So that if
+ * a container is under load, and there are many requests waiting for resources,
+ * the {@link #getPriority(ServletRequest)} method is used, so that more important
+ * requests are serviced first.     For example, this filter could be deployed with a
+ * maxRequest limit slightly smaller than the containers thread pool and a high priority
+ * allocated to admin users.  Thus regardless of load, admin users would always be
+ * able to access the web application.
+ * <p>
+ * The maxRequest limit is policed by a {@link Semaphore} and the filter will wait a short while attempting to acquire
+ * the semaphore. This wait is controlled by the "waitMs" init parameter and allows the expense of a suspend to be
+ * avoided if the semaphore is shortly available.  If the semaphore cannot be obtained, the request will be suspended
+ * for the default suspend period of the container or the valued set as the "suspendMs" init parameter.
+ * <p>
+ * If the "managedAttr" init parameter is set to true, then this servlet is set as a {@link ServletContext} attribute with the
+ * filter name as the attribute name.  This allows context external mechanism (eg JMX via {@link ContextHandler#MANAGED_ATTRIBUTES}) to
+ * manage the configuration of the filter.
+ */
+@ManagedObject("Quality of Service Filter")
+public class QoSFilter implements Filter
+{
+    private static final Logger LOG = Log.getLogger(QoSFilter.class);
+
+    static final int __DEFAULT_MAX_PRIORITY = 10;
+    static final int __DEFAULT_PASSES = 10;
+    static final int __DEFAULT_WAIT_MS = 50;
+    static final long __DEFAULT_TIMEOUT_MS = -1;
+
+    static final String MANAGED_ATTR_INIT_PARAM = "managedAttr";
+    static final String MAX_REQUESTS_INIT_PARAM = "maxRequests";
+    static final String MAX_PRIORITY_INIT_PARAM = "maxPriority";
+    static final String MAX_WAIT_INIT_PARAM = "waitMs";
+    static final String SUSPEND_INIT_PARAM = "suspendMs";
+
+    private final String _suspended = "QoSFilter@" + Integer.toHexString(hashCode()) + ".SUSPENDED";
+    private final String _resumed = "QoSFilter@" + Integer.toHexString(hashCode()) + ".RESUMED";
+    private long _waitMs;
+    private long _suspendMs;
+    private volatile int _maxRequests;
+    private final AdjustableSemaphore _passes = new AdjustableSemaphore(true);
+    private Queue<AsyncContext>[] _queues;
+    private AsyncListener[] _listeners;
+
+    @Override
+    public void init(FilterConfig filterConfig)
+    {
+        int max_priority = __DEFAULT_MAX_PRIORITY;
+        if (filterConfig.getInitParameter(MAX_PRIORITY_INIT_PARAM) != null)
+            max_priority = Integer.parseInt(filterConfig.getInitParameter(MAX_PRIORITY_INIT_PARAM));
+        _queues = new Queue[max_priority + 1];
+        _listeners = new AsyncListener[_queues.length];
+        for (int p = 0; p < _queues.length; ++p)
+        {
+            _queues[p] = new ConcurrentLinkedQueue<>();
+            _listeners[p] = new QoSAsyncListener(p);
+        }
+
+        int maxRequests = __DEFAULT_PASSES;
+        if (filterConfig.getInitParameter(MAX_REQUESTS_INIT_PARAM) != null)
+            maxRequests = Integer.parseInt(filterConfig.getInitParameter(MAX_REQUESTS_INIT_PARAM));
+        _maxRequests = maxRequests;
+
+        long wait = __DEFAULT_WAIT_MS;
+        if (filterConfig.getInitParameter(MAX_WAIT_INIT_PARAM) != null)
+            wait = Integer.parseInt(filterConfig.getInitParameter(MAX_WAIT_INIT_PARAM));
+        _waitMs = wait;
+
+        long suspend = __DEFAULT_TIMEOUT_MS;
+        if (filterConfig.getInitParameter(SUSPEND_INIT_PARAM) != null)
+            suspend = Integer.parseInt(filterConfig.getInitParameter(SUSPEND_INIT_PARAM));
+        _suspendMs = suspend;
+
+        ServletContext context = filterConfig.getServletContext();
+        if (context != null && Boolean.parseBoolean(filterConfig.getInitParameter(MANAGED_ATTR_INIT_PARAM)))
+            context.setAttribute(filterConfig.getFilterName(), this);
+    }
+
+    @Override
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+    {
+      //System.out.println("QoSFilter with max requests:" + _maxRequests + " permits avialable:" + _passes.availablePermits());
+        boolean accepted = false;
+        try
+        {
+            Boolean suspended = (Boolean)request.getAttribute(_suspended);
+            if (suspended == null)
+            {
+              //System.out.println("Try aquire " + Thread.currentThread().getId());
+                accepted = _passes.tryAcquire(getWaitMs(), TimeUnit.MILLISECONDS);
+                if (accepted)
+                {
+                  //System.out.println("Accept " + Thread.currentThread().getId());
+                    request.setAttribute(_suspended, Boolean.FALSE);
+                    if (LOG.isDebugEnabled())
+                        LOG.debug("Accepted {}", request);
+                }
+                else
+                {
+                  //System.out.println("Suspend " + Thread.currentThread().getId());
+                    request.setAttribute(_suspended, Boolean.TRUE);
+                    int priority = getPriority(request);
+                    AsyncContext asyncContext = request.startAsync(request, response);
+                    long suspendMs = getSuspendMs();
+                    if (suspendMs > 0)
+                        asyncContext.setTimeout(suspendMs);
+                    asyncContext.addListener(_listeners[priority]);
+                    _queues[priority].add(asyncContext);
+                    if (LOG.isDebugEnabled())
+                        LOG.debug("Suspended {}", request);
+                    return;
+                }
+            }
+            else
+            {
+                if (suspended)
+                {
+                  //System.out.println("Resume " + Thread.currentThread().getId());
+                    request.setAttribute(_suspended, Boolean.FALSE);
+                    Boolean resumed = (Boolean)request.getAttribute(_resumed);
+                    if (Boolean.TRUE.equals(resumed))
+                    {
+                        _passes.acquire();
+                        accepted = true;
+                        if (LOG.isDebugEnabled())
+                            LOG.debug("Resumed {}", request);
+                    }
+                    else
+                    {
+                        // Timeout! try 1 more time.
+                      //System.out.println("Time out! Try once more " + Thread.currentThread().getId());
+                        accepted = _passes.tryAcquire(getWaitMs(), TimeUnit.MILLISECONDS);
+                        if (LOG.isDebugEnabled())
+                            LOG.debug("Timeout {}", request);
+                    }
+                }
+                else
+                {
+                    // Pass through resume of previously accepted request.
+                 // System.out.println("Passthrough " + Thread.currentThread().getId());
+                    _passes.acquire();
+                    accepted = true;
+                    if (LOG.isDebugEnabled())
+                        LOG.debug("Passthrough {}", request);
+                }
+            }
+
+            if (accepted)
+            {
+             // System.out.println("Accepted, on to Solr " + Thread.currentThread().getId());
+                chain.doFilter(request, response);
+            }
+            else
+            {
+            //  System.out.println("Rejected " + Thread.currentThread().getId());
+                if (LOG.isDebugEnabled())
+                    LOG.debug("Rejected {}", request);
+                ((HttpServletResponse)response).sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "Solr is overloaded.");
+                
+                //((HttpServletResponse) response).setStatus(503); 
+                return;
+            }
+        }
+        catch (InterruptedException e)
+        {
+          ((HttpServletResponse)response).sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "Solr is overloaded.");
+          //((HttpServletResponse) response).setStatus(503); 
+          return;
+        }
+        finally
+        {
+            if (accepted)
+            {
+                for (int p = _queues.length - 1; p >= 0; --p)
+                {
+                    AsyncContext asyncContext = _queues[p].poll();
+                    if (asyncContext != null)
+                    {
+                        ServletRequest candidate = asyncContext.getRequest();
+                        Boolean suspended = (Boolean)candidate.getAttribute(_suspended);
+                        if (Boolean.TRUE.equals(suspended))
+                        {
+                           // System.out.println("RESUME");
+                            candidate.setAttribute(_resumed, Boolean.TRUE);
+                         //   System.out.println("candidate:" + candidate);
+                            asyncContext.dispatch();
+                            break;
+                        }
+                    }
+                }
+                _passes.release();
+            }
+        }
+    }
+
+    /**
+     * Computes the request priority.
+     * <p>
+     * The default implementation assigns the following priorities:
+     * <ul>
+     * <li> 2 - for an authenticated request
+     * <li> 1 - for a request with valid / non new session
+     * <li> 0 - for all other requests.
+     * </ul>
+     * This method may be overridden to provide application specific priorities.
+     *
+     * @param request the incoming request
+     * @return the computed request priority
+     */
+    protected int getPriority(ServletRequest request)
+    {
+        HttpServletRequest baseRequest = (HttpServletRequest)request;
+        if (baseRequest.getUserPrincipal() != null)
+        {
+            return 2;
+        }
+        else
+        {
+            HttpSession session = baseRequest.getSession(false);
+            if (session != null && !session.isNew())
+                return 1;
+            else
+                return 0;
+        }
+    }
+
+    @Override
+    public void destroy()
+    {
+    }
+
+    /**
+     * Get the (short) amount of time (in milliseconds) that the filter would wait
+     * for the semaphore to become available before suspending a request.
+     *
+     * @return wait time (in milliseconds)
+     */
+    @ManagedAttribute("(short) amount of time filter will wait before suspending request (in ms)")
+    public long getWaitMs()
+    {
+        return _waitMs;
+    }
+
+    /**
+     * Set the (short) amount of time (in milliseconds) that the filter would wait
+     * for the semaphore to become available before suspending a request.
+     *
+     * @param value wait time (in milliseconds)
+     */
+    public void setWaitMs(long value)
+    {
+        _waitMs = value;
+    }
+
+    /**
+     * Get the amount of time (in milliseconds) that the filter would suspend
+     * a request for while waiting for the semaphore to become available.
+     *
+     * @return suspend time (in milliseconds)
+     */
+    @ManagedAttribute("amount of time filter will suspend a request for while waiting for the semaphore to become available (in ms)")
+    public long getSuspendMs()
+    {
+        return _suspendMs;
+    }
+
+    /**
+     * Set the amount of time (in milliseconds) that the filter would suspend
+     * a request for while waiting for the semaphore to become available.
+     *
+     * @param value suspend time (in milliseconds)
+     */
+    public void setSuspendMs(long value)
+    {
+        _suspendMs = value;
+    }
+
+    /**
+     * Get the maximum number of requests allowed to be processed
+     * at the same time.
+     *
+     * @return maximum number of requests
+     */
+    @ManagedAttribute("maximum number of requests to allow processing of at the same time")
+    public int getMaxRequests()
+    {
+        return _maxRequests;
+    }
+
+    /**
+     * Set the maximum number of requests allowed to be processed
+     * at the same time.
+     *
+     * @param value the number of requests
+     */
+    public void setMaxRequests(int value)
+    {
+   
+        //_passes = new Semaphore((value - getMaxRequests() + _passes.availablePermits()), true);
+      
+         _passes.setMaxPermits(value);
+
+        _maxRequests = value;
+    }
+
+    private class QoSAsyncListener implements AsyncListener
+    {
+        private final int priority;
+
+        public QoSAsyncListener(int priority)
+        {
+            this.priority = priority;
+        }
+
+        @Override
+        public void onStartAsync(AsyncEvent event) throws IOException
+        {
+        }
+
+        @Override
+        public void onComplete(AsyncEvent event) throws IOException
+        {
+        //  System.out.println("complete");
+        }
+
+        @Override
+        public void onTimeout(AsyncEvent event) throws IOException
+        {
+            // Remove before it's redispatched, so it won't be
+            // redispatched again at the end of the filtering.
+         // System.out.println("on timeout");
+            AsyncContext asyncContext = event.getAsyncContext();
+            _queues[priority].remove(asyncContext);
+            asyncContext.dispatch();
+        }
+
+        @Override
+        public void onError(AsyncEvent event) throws IOException
+        {
+        //  System.out.println("ERROR in asyn");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
index 78e58d0..c291446 100644
--- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
@@ -16,20 +16,6 @@
  */
 package org.apache.solr.servlet;
 
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ReadListener;
-import javax.servlet.ServletException;
-import javax.servlet.ServletInputStream;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.UnavailableException;
-import javax.servlet.WriteListener;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletResponseWrapper;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -37,6 +23,7 @@ import java.io.OutputStream;
 import java.lang.invoke.MethodHandles;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.security.Security;
 import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -49,13 +36,22 @@ import java.util.concurrent.atomic.AtomicReference;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import com.codahale.metrics.jvm.ClassLoadingGaugeSet;
-import com.codahale.metrics.jvm.GarbageCollectorMetricSet;
-import com.codahale.metrics.jvm.MemoryUsageGaugeSet;
-import com.codahale.metrics.jvm.ThreadStatesGaugeSet;
-import org.apache.commons.io.FileCleaningTracker;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ReadListener;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.UnavailableException;
+import javax.servlet.WriteListener;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
 import org.apache.commons.lang.StringUtils;
-import org.apache.http.client.HttpClient;
 import org.apache.lucene.util.Version;
 import org.apache.solr.api.V2HttpCall;
 import org.apache.solr.common.SolrException;
@@ -76,12 +72,18 @@ import org.apache.solr.request.SolrRequestInfo;
 import org.apache.solr.security.AuthenticationPlugin;
 import org.apache.solr.security.PKIAuthenticationPlugin;
 import org.apache.solr.security.PublicKeyHandler;
-import org.apache.solr.util.SolrFileCleaningTracker;
 import org.apache.solr.util.StartupLoggingUtils;
 import org.apache.solr.util.configuration.SSLConfigurationsFactory;
+import org.conscrypt.OpenSSLProvider;
+import org.eclipse.jetty.client.HttpClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.codahale.metrics.jvm.ClassLoadingGaugeSet;
+import com.codahale.metrics.jvm.GarbageCollectorMetricSet;
+import com.codahale.metrics.jvm.MemoryUsageGaugeSet;
+import com.codahale.metrics.jvm.ThreadStatesGaugeSet;
+
 /**
  * This filter looks at the incoming URL maps them to handlers defined in solrconfig.xml
  *
@@ -90,6 +92,27 @@ import org.slf4j.LoggerFactory;
 public class SolrDispatchFilter extends BaseSolrFilter {
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
+  
+  static {
+    // this has to happen in the right class loader
+    try {
+      if (Security.getProvider("Conscrypt") == null) {
+        Security.addProvider(new OpenSSLProvider("Conscrypt"));
+      }
+    } catch(UnsatisfiedLinkError e) {
+      log.error("Could not load SSL Provider due to " + UnsatisfiedLinkError.class.getSimpleName(), e);
+      Throwable[] suppressed = e.getSuppressed();
+      for (Throwable t : suppressed) {
+        log.error("Supressed Throwable:", t);
+      }
+      throw e;
+    } catch (Throwable t) {
+      log.error("Could not load SSL Provider", t);
+      throw t;
+    }
+  }
+
+  
   protected volatile CoreContainer cores;
   protected final CountDownLatch init = new CountDownLatch(1);
 
@@ -138,8 +161,6 @@ public class SolrDispatchFilter extends BaseSolrFilter {
     CoreContainer coresInit = null;
     try{
 
-    SolrRequestParsers.fileCleaningTracker = new SolrFileCleaningTracker();
-
     StartupLoggingUtils.checkLogDir();
     log.info("Using logger factory {}", StartupLoggingUtils.getLoggerImplStr());
     logWelcomeBanner();
@@ -171,7 +192,6 @@ public class SolrDispatchFilter extends BaseSolrFilter {
 
       coresInit = createCoreContainer(solrHome == null ? SolrResourceLoader.locateSolrHome() : Paths.get(solrHome),
                                        extraProperties);
-      this.httpClient = coresInit.getUpdateShardHandler().getDefaultHttpClient();
       setupJvmMetrics(coresInit);
       log.debug("user.dir=" + System.getProperty("user.dir"));
     }
@@ -187,6 +207,19 @@ public class SolrDispatchFilter extends BaseSolrFilter {
     }finally{
       log.trace("SolrDispatchFilter.init() done");
       this.cores = coresInit; // crucially final assignment 
+      this.httpClient = coresInit.getUpdateShardHandler().getDefaultHttpClient();
+      try {
+        // nocommit
+        //httpClient.getContentDecoderFactories().clear();
+        // Content must not be decoded, otherwise the client gets confused.
+  
+
+        // Pass traffic to the client, only intercept what's necessary.
+        //ProtocolHandlers protocolHandlers = httpClient.getProtocolHandlers();
+       // protocolHandlers.clear();
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
       init.countDown();
     }
   }
@@ -295,26 +328,19 @@ public class SolrDispatchFilter extends BaseSolrFilter {
   @Override
   public void destroy() {
     try {
-      FileCleaningTracker fileCleaningTracker = SolrRequestParsers.fileCleaningTracker;
-      if (fileCleaningTracker != null) {
-        fileCleaningTracker.exitWhenFinished();
+      if (metricManager != null) {
+        metricManager.unregisterGauges(registryName, metricTag);
       }
-    } catch (Exception e) {
-      log.warn("Exception closing FileCleaningTracker", e);
-    } finally {
-      SolrRequestParsers.fileCleaningTracker = null;
-    }
-
-    if (metricManager != null) {
-      metricManager.unregisterGauges(registryName, metricTag);
-    }
 
-    if (cores != null) {
-      try {
-        cores.shutdown();
-      } finally {
-        cores = null;
+      if (cores != null) {
+        try {
+          cores.shutdown();
+        } finally {
+          cores = null;
+        }
       }
+    } catch (Exception e) {
+      log.error("Exception while shutting down.", e);
     }
   }
   

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/servlet/SolrQoSFilter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrQoSFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrQoSFilter.java
new file mode 100644
index 0000000..0db8597
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrQoSFilter.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.servlet;
+
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.solr.common.params.QoSParams;
+
+
+public class SolrQoSFilter extends QoSFilter {
+  static final String MAX_REQUESTS_INIT_PARAM = "maxRequests";
+  static final String SUSPEND_INIT_PARAM = "suspendMs";
+  static final int PROC_COUNT = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors();
+  protected int _origMaxRequests;
+  
+  private AtomicInteger requestCnt = new AtomicInteger();
+  
+  @Override
+  public void init(FilterConfig filterConfig) {
+    super.init(filterConfig);
+    _origMaxRequests = 100;
+    super.setMaxRequests(_origMaxRequests);
+    super.setSuspendMs(60000);
+    super.setWaitMs(50);
+  }
+  
+  @Override
+  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+      throws IOException, ServletException {
+    HttpServletRequest req = (HttpServletRequest) request;
+    //requestCnt.incrementAndGet();
+    String source = req.getHeader(QoSParams.REQUEST_SOURCE);
+    if (source == null || !source.equals(QoSParams.INTERNAL)) {
+
+      if (requestCnt.getAndIncrement() % 5 == 0) {
+        // nocommit - deal with not supported? dont call every request?
+        double load = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage();
+        double sLoad = load / (double) PROC_COUNT;
+        if (sLoad > 0.95D) {
+          int cMax = getMaxRequests();
+          if (cMax > 3) {
+            setMaxRequests(Math.max(3, (int) ((double) cMax * 0.60D)));
+          }
+        } else if (sLoad < 0.9D && _origMaxRequests != getMaxRequests()) {
+          setMaxRequests(_origMaxRequests);
+        }
+        //System.out.println("external request, load:" + load);
+      }
+
+      super.doFilter(req, response, chain);
+
+    } else {
+      //System.out.println("internal request");
+      chain.doFilter(req, response);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java b/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
index 8a664c4..bffe9b7 100644
--- a/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
@@ -16,7 +16,8 @@
  */
 package org.apache.solr.servlet;
 
-import javax.servlet.http.HttpServletRequest;
+import static org.apache.solr.common.params.CommonParams.PATH;
+
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
@@ -38,10 +39,11 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
+import javax.servlet.http.HttpServletRequest;
+
 import org.apache.commons.fileupload.FileItem;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
-import org.apache.commons.io.FileCleaningTracker;
 import org.apache.commons.io.input.CloseShieldInputStream;
 import org.apache.lucene.util.IOUtils;
 import org.apache.solr.api.V2HttpCall;
@@ -62,8 +64,6 @@ import org.apache.solr.request.SolrQueryRequestBase;
 import org.apache.solr.util.RTimerTree;
 import org.apache.solr.util.SolrFileCleaningTracker;
 
-import static org.apache.solr.common.params.CommonParams.PATH;
-
 
 public class SolrRequestParsers 
 {
@@ -88,17 +88,22 @@ public class SolrRequestParsers
   private StandardRequestParser standard;
   private boolean handleSelect = true;
   private boolean addHttpRequestToContext;
+  
+  private SolrFileCleaningTracker fileCleaningTracker;
 
   /** Default instance for e.g. admin requests. Limits to 2 MB uploads and does not allow remote streams. */
-  public static final SolrRequestParsers DEFAULT = new SolrRequestParsers();
+  //public static final SolrRequestParsers DEFAULT = new SolrRequestParsers();
   
-  public static volatile SolrFileCleaningTracker fileCleaningTracker;
+  public static SolrRequestParsers createInstance(SolrFileCleaningTracker fileCleaningTracker) {
+    return new SolrRequestParsers(fileCleaningTracker);
+  }
   
   /**
    * Pass in an xml configuration.  A null configuration will enable
    * everything with maximum values.
    */
-  public SolrRequestParsers( SolrConfig globalConfig ) {
+  // nocommit we have to passs cleaner in case of config made in corecontainer
+  public SolrRequestParsers(SolrConfig globalConfig, SolrFileCleaningTracker fileCleaningTracker) {
     final int multipartUploadLimitKB, formUploadLimitKB;
     if( globalConfig == null ) {
       multipartUploadLimitKB = formUploadLimitKB = Integer.MAX_VALUE; 
@@ -122,7 +127,7 @@ public class SolrRequestParsers
     init(multipartUploadLimitKB, formUploadLimitKB);
   }
   
-  private SolrRequestParsers() {
+  private SolrRequestParsers(SolrFileCleaningTracker fileCleaningTracker) {
     enableRemoteStreams = false;
     enableStreamBody = false;
     handleSelect = false;
@@ -131,7 +136,7 @@ public class SolrRequestParsers
   }
 
   private void init( int multipartUploadLimitKB, int formUploadLimitKB) {       
-    MultipartRequestParser multi = new MultipartRequestParser( multipartUploadLimitKB );
+    MultipartRequestParser multi = new MultipartRequestParser(fileCleaningTracker, multipartUploadLimitKB );
     RawRequestParser raw = new RawRequestParser();
     FormDataRequestParser formdata = new FormDataRequestParser( formUploadLimitKB );
     standard = new StandardRequestParser( multi, raw, formdata );
@@ -571,16 +576,15 @@ public class SolrRequestParsers
    */
   static class MultipartRequestParser implements SolrRequestParser {
     private final int uploadLimitKB;
-    private DiskFileItemFactory factory = new DiskFileItemFactory();
+    private DiskFileItemFactory factory = new DiskFileItemFactory(1000000, null);
     
-    public MultipartRequestParser(int limit) {
+    public MultipartRequestParser(SolrFileCleaningTracker fileCleaningTracker, int limit) {
       uploadLimitKB = limit;
 
       // Set factory constraints
-      FileCleaningTracker fct = fileCleaningTracker;
-      if (fct != null) {
-        factory.setFileCleaningTracker(fileCleaningTracker);
-      }
+   
+      factory.setFileCleaningTracker(fileCleaningTracker);
+      
       // TODO - configure factory.setSizeThreshold(yourMaxMemorySize);
       // TODO - configure factory.setRepository(yourTempDirectory);
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/servlet/cache/HttpCacheHeaderUtil.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/servlet/cache/HttpCacheHeaderUtil.java b/solr/core/src/java/org/apache/solr/servlet/cache/HttpCacheHeaderUtil.java
index 41824a9..5057ea6 100644
--- a/solr/core/src/java/org/apache/solr/servlet/cache/HttpCacheHeaderUtil.java
+++ b/solr/core/src/java/org/apache/solr/servlet/cache/HttpCacheHeaderUtil.java
@@ -24,19 +24,18 @@ import java.util.List;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.codec.binary.Base64;
 import org.apache.lucene.util.WeakIdentityMap;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.util.SuppressForbidden;
 import org.apache.solr.core.IndexDeletionPolicyWrapper;
-import org.apache.solr.core.SolrCore;
 import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.SolrConfig.HttpCachingConfig.LastModFrom;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrException.ErrorCode;
-import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.core.SolrCore;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
-
-import org.apache.commons.codec.binary.Base64;
+import org.apache.solr.search.SolrIndexSearcher;
 
 public final class HttpCacheHeaderUtil {
   

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java b/solr/core/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java
index fd9ca21..a6b7527 100644
--- a/solr/core/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java
+++ b/solr/core/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java
@@ -21,26 +21,25 @@ import java.io.InputStreamReader;
 import java.lang.invoke.MethodHandles;
 import java.util.List;
 
+import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.document.TextField;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.LogByteSizeMergePolicy;
 import org.apache.lucene.index.LogMergePolicy;
-import org.apache.solr.schema.IndexSchema;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.TextField;
 import org.apache.lucene.search.spell.HighFrequencyDictionary;
 import org.apache.lucene.search.spell.PlainTextDictionary;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.schema.FieldType;
+import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.search.SolrIndexSearcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * <p>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java b/solr/core/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java
index aa6e049..80676cd 100644
--- a/solr/core/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java
+++ b/solr/core/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java
@@ -15,19 +15,18 @@
  * limitations under the License.
  */
 package org.apache.solr.spelling;
+import java.io.File;
+import java.io.IOException;
+
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.search.spell.HighFrequencyDictionary;
-
+import org.apache.lucene.store.FSDirectory;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.search.SolrIndexSearcher;
 
-import java.io.File;
-import java.io.IOException;
-
 /**
  * <p>
  * A spell checker implementation that loads words from Solr as well as arbitrary Lucene indices.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/spelling/SpellCheckCollator.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/spelling/SpellCheckCollator.java b/solr/core/src/java/org/apache/solr/spelling/SpellCheckCollator.java
index ad3accf..b97cdfa 100644
--- a/solr/core/src/java/org/apache/solr/spelling/SpellCheckCollator.java
+++ b/solr/core/src/java/org/apache/solr/spelling/SpellCheckCollator.java
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 package org.apache.solr.spelling;
+import static org.apache.solr.common.params.CommonParams.ID;
+
 import java.lang.invoke.MethodHandles;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -40,8 +42,6 @@ import org.apache.solr.search.SolrIndexSearcher;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.solr.common.params.CommonParams.ID;
-
 public class SpellCheckCollator {
   private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
   private int maxCollations = 1;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/spelling/SpellingResult.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/spelling/SpellingResult.java b/solr/core/src/java/org/apache/solr/spelling/SpellingResult.java
index fb13bbc..7477bc0 100644
--- a/solr/core/src/java/org/apache/solr/spelling/SpellingResult.java
+++ b/solr/core/src/java/org/apache/solr/spelling/SpellingResult.java
@@ -18,8 +18,8 @@ package org.apache.solr.spelling;
 
 import java.util.Collection;
 import java.util.LinkedHashMap;
-import java.util.Map;
 import java.util.List;
+import java.util.Map;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/spelling/suggest/SolrSuggester.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/spelling/suggest/SolrSuggester.java b/solr/core/src/java/org/apache/solr/spelling/suggest/SolrSuggester.java
index 267d9ad..7ca1c62 100644
--- a/solr/core/src/java/org/apache/solr/spelling/suggest/SolrSuggester.java
+++ b/solr/core/src/java/org/apache/solr/spelling/suggest/SolrSuggester.java
@@ -16,6 +16,9 @@
  */
 package org.apache.solr.spelling.suggest;
 
+import static org.apache.solr.common.params.CommonParams.NAME;
+import static org.apache.solr.spelling.suggest.fst.AnalyzingInfixLookupFactory.CONTEXTS_FIELD_NAME;
+
 import java.io.Closeable;
 import java.io.File;
 import java.io.FileInputStream;
@@ -48,9 +51,6 @@ import org.apache.solr.update.SolrCoreState;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.solr.common.params.CommonParams.NAME;
-import static org.apache.solr.spelling.suggest.fst.AnalyzingInfixLookupFactory.CONTEXTS_FIELD_NAME;
-
 /** 
  * Responsible for loading the lookup and dictionary Implementations specified by 
  * the SolrConfig. 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/spelling/suggest/fst/BlendedInfixLookupFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/spelling/suggest/fst/BlendedInfixLookupFactory.java b/solr/core/src/java/org/apache/solr/spelling/suggest/fst/BlendedInfixLookupFactory.java
index 32a0ff0..5f9cf45 100644
--- a/solr/core/src/java/org/apache/solr/spelling/suggest/fst/BlendedInfixLookupFactory.java
+++ b/solr/core/src/java/org/apache/solr/spelling/suggest/fst/BlendedInfixLookupFactory.java
@@ -26,8 +26,8 @@ import java.util.Set;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.search.suggest.Lookup;
 import org.apache.lucene.search.suggest.analyzing.AnalyzingInfixSuggester;
-import org.apache.lucene.search.suggest.analyzing.BlendedInfixSuggester.BlenderType;
 import org.apache.lucene.search.suggest.analyzing.BlendedInfixSuggester;
+import org.apache.lucene.search.suggest.analyzing.BlendedInfixSuggester.BlenderType;
 import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.util.BytesRef;
 import org.apache.solr.common.util.NamedList;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java b/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java
index 72d48ae..1391777 100644
--- a/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java
+++ b/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java
@@ -95,6 +95,7 @@ public class HdfsDirectory extends BaseDirectory {
   @Override
   public void close() throws IOException {
     LOG.info("Closing hdfs directory {}", hdfsDirPath);
+
     fileSystem.close();
     isOpen = false;
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/store/hdfs/HdfsLocalityReporter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/store/hdfs/HdfsLocalityReporter.java b/solr/core/src/java/org/apache/solr/store/hdfs/HdfsLocalityReporter.java
index d10216b..de054cb 100644
--- a/solr/core/src/java/org/apache/solr/store/hdfs/HdfsLocalityReporter.java
+++ b/solr/core/src/java/org/apache/solr/store/hdfs/HdfsLocalityReporter.java
@@ -26,7 +26,6 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
-import com.codahale.metrics.MetricRegistry;
 import org.apache.hadoop.fs.BlockLocation;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
@@ -37,6 +36,8 @@ import org.apache.solr.metrics.SolrMetricProducer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.codahale.metrics.MetricRegistry;
+
 public class HdfsLocalityReporter implements SolrInfoBean, SolrMetricProducer {
   public static final String LOCALITY_BYTES_TOTAL = "locality.bytes.total";
   public static final String LOCALITY_BYTES_LOCAL = "locality.bytes.local";

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/uninverting/FieldCache.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/uninverting/FieldCache.java b/solr/core/src/java/org/apache/solr/uninverting/FieldCache.java
index 87f5f4c..e3cbbda 100644
--- a/solr/core/src/java/org/apache/solr/uninverting/FieldCache.java
+++ b/solr/core/src/java/org/apache/solr/uninverting/FieldCache.java
@@ -27,12 +27,12 @@ import org.apache.lucene.index.SortedDocValues;
 import org.apache.lucene.index.SortedSetDocValues;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
-import org.apache.solr.legacy.LegacyNumericUtils;
 import org.apache.lucene.util.Accountable;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.NumericUtils;
 import org.apache.lucene.util.RamUsageEstimator;
+import org.apache.solr.legacy.LegacyNumericUtils;
 
 /**
  * Expert: Maintains caches of term values.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/update/CommitTracker.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/CommitTracker.java b/solr/core/src/java/org/apache/solr/update/CommitTracker.java
index 8f06d11..0daa3ff 100644
--- a/solr/core/src/java/org/apache/solr/update/CommitTracker.java
+++ b/solr/core/src/java/org/apache/solr/update/CommitTracker.java
@@ -17,7 +17,6 @@
 package org.apache.solr.update;
 
 import java.lang.invoke.MethodHandles;
-
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
@@ -58,7 +57,7 @@ public final class CommitTracker implements Runnable {
   private long tLogFileSizeUpperBound;
   
   private final ScheduledExecutorService scheduler = 
-      Executors.newScheduledThreadPool(1, new DefaultSolrThreadFactory("commitScheduler"));
+      Executors.newScheduledThreadPool(0, new DefaultSolrThreadFactory("commitScheduler"));
   private ScheduledFuture pending;
   
   // state

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
index cc79e3c..19e1981 100644
--- a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
+++ b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
@@ -34,8 +34,8 @@ import org.apache.lucene.index.MergePolicy;
 import org.apache.lucene.search.Sort;
 import org.apache.solr.cloud.ActionThrottle;
 import org.apache.solr.cloud.RecoveryStrategy;
-import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.CoreDescriptor;
 import org.apache.solr.core.DirectoryFactory;
@@ -48,14 +48,14 @@ import org.slf4j.LoggerFactory;
 
 public final class DefaultSolrCoreState extends SolrCoreState implements RecoveryStrategy.RecoveryListener {
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-  
+
   private final boolean SKIP_AUTO_RECOVERY = Boolean.getBoolean("solrcloud.skip.autorecovery");
 
   private final ReentrantLock recoveryLock = new ReentrantLock();
   
-  private final ActionThrottle recoveryThrottle = new ActionThrottle("recovery", 10000);
+  private final ActionThrottle recoveryThrottle = new ActionThrottle("recovery", 1000);
   
-  private final ActionThrottle leaderThrottle = new ActionThrottle("leader", 5000);
+  private final ActionThrottle leaderThrottle = new ActionThrottle("leader", 1000);
   
   private final AtomicInteger recoveryWaiting = new AtomicInteger();
 
@@ -286,7 +286,7 @@ public final class DefaultSolrCoreState extends SolrCoreState implements Recover
 
   @Override
   public void doRecovery(CoreContainer cc, CoreDescriptor cd) {
-    
+    // nocommit - limit recovery executor based on load
     Runnable recoveryTask = new Runnable() {
       @Override
       public void run() {
@@ -335,6 +335,9 @@ public final class DefaultSolrCoreState extends SolrCoreState implements Recover
               
               recoveryStrat = recoveryStrategyBuilder.create(cc, cd, DefaultSolrCoreState.this);
               recoveryStrat.setRecoveringAfterStartup(recoveringAfterStartup);
+              
+              cc.getUpdateShardHandler().sizeRecoveryExecutorForLoad();
+              
               Future<?> future = cc.getUpdateShardHandler().getRecoveryExecutor().submit(recoveryStrat);
               try {
                 future.get();

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74a9b54c/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
index c913509..79d8701 100644
--- a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
+++ b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
@@ -25,7 +25,6 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.atomic.LongAdder;
 
-import com.codahale.metrics.Meter;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.CodecReader;
@@ -67,6 +66,8 @@ import org.apache.solr.util.TestInjection;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.codahale.metrics.Meter;
+
 /**
  * <code>DirectUpdateHandler2</code> implements an UpdateHandler where documents are added
  * directly to the main Lucene index as opposed to adding to a separate smaller index.


Mime
View raw message