You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ro...@apache.org on 2014/12/31 15:05:50 UTC
svn commit: r1648697 [10/13] - in /lucene/dev/trunk/solr: ./
contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/
contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/
contrib/map-reduce/src/java/org/apache/solr/hadoo...
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java Wed Dec 31 14:05:48 2014
@@ -14,673 +14,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.solr.client.solrj.impl;
import org.apache.http.client.HttpClient;
-import org.apache.solr.client.solrj.*;
-import org.apache.solr.client.solrj.request.IsUpdateRequest;
-import org.apache.solr.client.solrj.request.RequestWriter;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SolrjNamedThreadFactory;
-import org.apache.solr.common.SolrException;
+import org.apache.solr.client.solrj.ResponseParser;
-import java.io.IOException;
-import java.lang.ref.WeakReference;
-import java.net.ConnectException;
import java.net.MalformedURLException;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
-import java.net.URL;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.*;
/**
- * LBHttpSolrServer or "LoadBalanced HttpSolrServer" is a load balancing wrapper around
- * {@link org.apache.solr.client.solrj.impl.HttpSolrServer}. This is useful when you
- * have multiple SolrServers and the requests need to be Load Balanced among them.
- *
- * Do <b>NOT</b> use this class for indexing in master/slave scenarios since documents must be sent to the
- * correct master; no inter-node routing is done.
- *
- * In SolrCloud (leader/replica) scenarios, it is usually better to use
- * {@link org.apache.solr.client.solrj.impl.CloudSolrServer}, but this class may be used
- * for updates because the server will forward them to the appropriate leader.
- *
- * Also see the <a href="http://wiki.apache.org/solr/LBHttpSolrServer">wiki</a> page.
- *
- * <p/>
- * It offers automatic failover when a server goes down and it detects when the server comes back up.
- * <p/>
- * Load balancing is done using a simple round-robin on the list of servers.
- * <p/>
- * If a request to a server fails by an IOException due to a connection timeout or read timeout then the host is taken
- * off the list of live servers and moved to a 'dead server list' and the request is resent to the next live server.
- * This process is continued till it tries all the live servers. If at least one server is alive, the request succeeds,
- * and if not it fails.
- * <blockquote><pre>
- * SolrServer lbHttpSolrServer = new LBHttpSolrServer("http://host1:8080/solr/","http://host2:8080/solr","http://host2:8080/solr");
- * //or if you wish to pass the HttpClient do as follows
- * httpClient httpClient = new HttpClient();
- * SolrServer lbHttpSolrServer = new LBHttpSolrServer(httpClient,"http://host1:8080/solr/","http://host2:8080/solr","http://host2:8080/solr");
- * </pre></blockquote>
- * This detects if a dead server comes alive automatically. The check is done in fixed intervals in a dedicated thread.
- * This interval can be set using {@link #setAliveCheckInterval} , the default is set to one minute.
- * <p/>
- * <b>When to use this?</b><br/> This can be used as a software load balancer when you do not wish to setup an external
- * load balancer. Alternatives to this code are to use
- * a dedicated hardware load balancer or using Apache httpd with mod_proxy_balancer as a load balancer. See <a
- * href="http://en.wikipedia.org/wiki/Load_balancing_(computing)">Load balancing on Wikipedia</a>
- *
- * @since solr 1.4
+ * @deprecated Use {@link org.apache.solr.client.solrj.impl.LBHttpSolrClient}
*/
-public class LBHttpSolrServer extends SolrServer {
- private static Set<Integer> RETRY_CODES = new HashSet<>(4);
-
- static {
- RETRY_CODES.add(404);
- RETRY_CODES.add(403);
- RETRY_CODES.add(503);
- RETRY_CODES.add(500);
- }
-
- // keys to the maps are currently of the form "http://localhost:8983/solr"
- // which should be equivalent to HttpSolrServer.getBaseURL()
- private final Map<String, ServerWrapper> aliveServers = new LinkedHashMap<>();
- // access to aliveServers should be synchronized on itself
-
- protected final Map<String, ServerWrapper> zombieServers = new ConcurrentHashMap<>();
-
- // changes to aliveServers are reflected in this array, no need to synchronize
- private volatile ServerWrapper[] aliveServerList = new ServerWrapper[0];
-
-
- private ScheduledExecutorService aliveCheckExecutor;
-
- private final HttpClient httpClient;
- private final boolean clientIsInternal;
- private final AtomicInteger counter = new AtomicInteger(-1);
-
- private static final SolrQuery solrQuery = new SolrQuery("*:*");
- private volatile ResponseParser parser;
- private volatile RequestWriter requestWriter;
-
- private Set<String> queryParams = new HashSet<>();
-
- static {
- solrQuery.setRows(0);
- /**
- * Default sort (if we don't supply a sort) is by score and since
- * we request 0 rows any sorting and scoring is not necessary.
- * SolrQuery.DOCID schema-independently specifies a non-scoring sort.
- * <code>_docid_ asc</code> sort is efficient,
- * <code>_docid_ desc</code> sort is not, so choose ascending DOCID sort.
- */
- solrQuery.setSort(SolrQuery.DOCID, SolrQuery.ORDER.asc);
- // not a top-level request, we are interested only in the server being sent to i.e. it need not distribute our request to further servers
- solrQuery.setDistrib(false);
- }
-
- protected static class ServerWrapper {
- final HttpSolrServer solrServer;
-
- long lastUsed; // last time used for a real request
- long lastChecked; // last time checked for liveness
-
- // "standard" servers are used by default. They normally live in the alive list
- // and move to the zombie list when unavailable. When they become available again,
- // they move back to the alive list.
- boolean standard = true;
-
- int failedPings = 0;
-
- public ServerWrapper(HttpSolrServer solrServer) {
- this.solrServer = solrServer;
- }
-
- @Override
- public String toString() {
- return solrServer.getBaseURL();
- }
-
- public String getKey() {
- return solrServer.getBaseURL();
- }
-
- @Override
- public int hashCode() {
- return this.getKey().hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (!(obj instanceof ServerWrapper)) return false;
- return this.getKey().equals(((ServerWrapper)obj).getKey());
- }
- }
-
- public static class Req {
- protected SolrRequest request;
- protected List<String> servers;
- protected int numDeadServersToTry;
-
- public Req(SolrRequest request, List<String> servers) {
- this.request = request;
- this.servers = servers;
- this.numDeadServersToTry = servers.size();
- }
-
- public SolrRequest getRequest() {
- return request;
- }
- public List<String> getServers() {
- return servers;
- }
-
- /** @return the number of dead servers to try if there are no live servers left */
- public int getNumDeadServersToTry() {
- return numDeadServersToTry;
- }
-
- /** @param numDeadServersToTry The number of dead servers to try if there are no live servers left.
- * Defaults to the number of servers in this request. */
- public void setNumDeadServersToTry(int numDeadServersToTry) {
- this.numDeadServersToTry = numDeadServersToTry;
- }
- }
-
- public static class Rsp {
- protected String server;
- protected NamedList<Object> rsp;
-
- /** The response from the server */
- public NamedList<Object> getResponse() {
- return rsp;
- }
-
- /** The server that returned the response */
- public String getServer() {
- return server;
- }
- }
+@Deprecated
+public class LBHttpSolrServer extends LBHttpSolrClient {
public LBHttpSolrServer(String... solrServerUrls) throws MalformedURLException {
- this(null, solrServerUrls);
+ super(solrServerUrls);
}
-
- /** The provided httpClient should use a multi-threaded connection manager */
+
public LBHttpSolrServer(HttpClient httpClient, String... solrServerUrl) {
- this(httpClient, new BinaryResponseParser(), solrServerUrl);
+ super(httpClient, solrServerUrl);
}
- /** The provided httpClient should use a multi-threaded connection manager */
public LBHttpSolrServer(HttpClient httpClient, ResponseParser parser, String... solrServerUrl) {
- clientIsInternal = (httpClient == null);
- this.parser = parser;
- if (httpClient == null) {
- ModifiableSolrParams params = new ModifiableSolrParams();
- params.set(HttpClientUtil.PROP_USE_RETRY, false);
- this.httpClient = HttpClientUtil.createClient(params);
- } else {
- this.httpClient = httpClient;
- }
- for (String s : solrServerUrl) {
- ServerWrapper wrapper = new ServerWrapper(makeServer(s));
- aliveServers.put(wrapper.getKey(), wrapper);
- }
- updateAliveList();
- }
-
- public Set<String> getQueryParams() {
- return queryParams;
- }
-
- /**
- * Expert Method.
- * @param queryParams set of param keys to only send via the query string
- */
- public void setQueryParams(Set<String> queryParams) {
- this.queryParams = queryParams;
- }
- public void addQueryParams(String queryOnlyParam) {
- this.queryParams.add(queryOnlyParam) ;
- }
-
- public static String normalize(String server) {
- if (server.endsWith("/"))
- server = server.substring(0, server.length() - 1);
- return server;
- }
-
- protected HttpSolrServer makeServer(String server) {
- HttpSolrServer s = new HttpSolrServer(server, httpClient, parser);
- if (requestWriter != null) {
- s.setRequestWriter(requestWriter);
- }
- if (queryParams != null) {
- s.setQueryParams(queryParams);
- }
- return s;
- }
-
- /**
- * Tries to query a live server from the list provided in Req. Servers in the dead pool are skipped.
- * If a request fails due to an IOException, the server is moved to the dead pool for a certain period of
- * time, or until a test request on that server succeeds.
- *
- * Servers are queried in the exact order given (except servers currently in the dead pool are skipped).
- * If no live servers from the provided list remain to be tried, a number of previously skipped dead servers will be tried.
- * Req.getNumDeadServersToTry() controls how many dead servers will be tried.
- *
- * If no live servers are found a SolrServerException is thrown.
- *
- * @param req contains both the request as well as the list of servers to query
- *
- * @return the result of the request
- *
- * @throws IOException If there is a low-level I/O error.
- */
- public Rsp request(Req req) throws SolrServerException, IOException {
- Rsp rsp = new Rsp();
- Exception ex = null;
- boolean isUpdate = req.request instanceof IsUpdateRequest;
- List<ServerWrapper> skipped = null;
-
- for (String serverStr : req.getServers()) {
- serverStr = normalize(serverStr);
- // if the server is currently a zombie, just skip to the next one
- ServerWrapper wrapper = zombieServers.get(serverStr);
- if (wrapper != null) {
- // System.out.println("ZOMBIE SERVER QUERIED: " + serverStr);
- final int numDeadServersToTry = req.getNumDeadServersToTry();
- if (numDeadServersToTry > 0) {
- if (skipped == null) {
- skipped = new ArrayList<>(numDeadServersToTry);
- skipped.add(wrapper);
- }
- else if (skipped.size() < numDeadServersToTry) {
- skipped.add(wrapper);
- }
- }
- continue;
- }
- rsp.server = serverStr;
- HttpSolrServer server = makeServer(serverStr);
-
- ex = doRequest(server, req, rsp, isUpdate, false, null);
- if (ex == null) {
- return rsp; // SUCCESS
- }
- }
-
- // try the servers we previously skipped
- if (skipped != null) {
- for (ServerWrapper wrapper : skipped) {
- ex = doRequest(wrapper.solrServer, req, rsp, isUpdate, true, wrapper.getKey());
- if (ex == null) {
- return rsp; // SUCCESS
- }
- }
- }
-
-
- if (ex == null) {
- throw new SolrServerException("No live SolrServers available to handle this request");
- } else {
- throw new SolrServerException("No live SolrServers available to handle this request:" + zombieServers.keySet(), ex);
- }
-
- }
-
- protected Exception addZombie(HttpSolrServer server, Exception e) {
-
- ServerWrapper wrapper;
-
- wrapper = new ServerWrapper(server);
- wrapper.lastUsed = System.currentTimeMillis();
- wrapper.standard = false;
- zombieServers.put(wrapper.getKey(), wrapper);
- startAliveCheckExecutor();
- return e;
- }
-
- protected Exception doRequest(HttpSolrServer server, Req req, Rsp rsp, boolean isUpdate,
- boolean isZombie, String zombieKey) throws SolrServerException, IOException {
- Exception ex = null;
- try {
- rsp.rsp = server.request(req.getRequest());
- if (isZombie) {
- zombieServers.remove(zombieKey);
- }
- } catch (SolrException e) {
- // we retry on 404 or 403 or 503 or 500
- // unless it's an update - then we only retry on connect exception
- if (!isUpdate && RETRY_CODES.contains(e.code())) {
- ex = (!isZombie) ? addZombie(server, e) : e;
- } else {
- // Server is alive but the request was likely malformed or invalid
- if (isZombie) {
- zombieServers.remove(zombieKey);
- }
- throw e;
- }
- } catch (SocketException e) {
- if (!isUpdate || e instanceof ConnectException) {
- ex = (!isZombie) ? addZombie(server, e) : e;
- } else {
- throw e;
- }
- } catch (SocketTimeoutException e) {
- if (!isUpdate) {
- ex = (!isZombie) ? addZombie(server, e) : e;
- } else {
- throw e;
- }
- } catch (SolrServerException e) {
- Throwable rootCause = e.getRootCause();
- if (!isUpdate && rootCause instanceof IOException) {
- ex = (!isZombie) ? addZombie(server, e) : e;
- } else if (isUpdate && rootCause instanceof ConnectException) {
- ex = (!isZombie) ? addZombie(server, e) : e;
- } else {
- throw e;
- }
- } catch (Exception e) {
- throw new SolrServerException(e);
- }
-
- return ex;
- }
-
- private void updateAliveList() {
- synchronized (aliveServers) {
- aliveServerList = aliveServers.values().toArray(new ServerWrapper[aliveServers.size()]);
- }
- }
-
- private ServerWrapper removeFromAlive(String key) {
- synchronized (aliveServers) {
- ServerWrapper wrapper = aliveServers.remove(key);
- if (wrapper != null)
- updateAliveList();
- return wrapper;
- }
- }
-
- private void addToAlive(ServerWrapper wrapper) {
- synchronized (aliveServers) {
- ServerWrapper prev = aliveServers.put(wrapper.getKey(), wrapper);
- // TODO: warn if there was a previous entry?
- updateAliveList();
- }
- }
-
- public void addSolrServer(String server) throws MalformedURLException {
- HttpSolrServer solrServer = makeServer(server);
- addToAlive(new ServerWrapper(solrServer));
- }
-
- public String removeSolrServer(String server) {
- try {
- server = new URL(server).toExternalForm();
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
- if (server.endsWith("/")) {
- server = server.substring(0, server.length() - 1);
- }
-
- // there is a small race condition here - if the server is in the process of being moved between
- // lists, we could fail to remove it.
- removeFromAlive(server);
- zombieServers.remove(server);
- return null;
- }
-
- public void setConnectionTimeout(int timeout) {
- HttpClientUtil.setConnectionTimeout(httpClient, timeout);
+ super(httpClient, parser, solrServerUrl);
}
- /**
- * set soTimeout (read timeout) on the underlying HttpConnectionManager. This is desirable for queries, but probably
- * not for indexing.
- */
- public void setSoTimeout(int timeout) {
- HttpClientUtil.setSoTimeout(httpClient, timeout);
- }
-
- @Override
- public void shutdown() {
- if (aliveCheckExecutor != null) {
- aliveCheckExecutor.shutdownNow();
- }
- if(clientIsInternal) {
- httpClient.getConnectionManager().shutdown();
- }
- }
-
- /**
- * Tries to query a live server. A SolrServerException is thrown if all servers are dead.
- * If the request failed due to IOException then the live server is moved to dead pool and the request is
- * retried on another live server. After live servers are exhausted, any servers previously marked as dead
- * will be tried before failing the request.
- *
- * @param request the SolrRequest.
- *
- * @return response
- *
- * @throws IOException If there is a low-level I/O error.
- */
- @Override
- public NamedList<Object> request(final SolrRequest request)
- throws SolrServerException, IOException {
- Exception ex = null;
- ServerWrapper[] serverList = aliveServerList;
-
- int maxTries = serverList.length;
- Map<String,ServerWrapper> justFailed = null;
-
- for (int attempts=0; attempts<maxTries; attempts++) {
- int count = counter.incrementAndGet() & Integer.MAX_VALUE;
- ServerWrapper wrapper = serverList[count % serverList.length];
- wrapper.lastUsed = System.currentTimeMillis();
-
- try {
- return wrapper.solrServer.request(request);
- } catch (SolrException e) {
- // Server is alive but the request was malformed or invalid
- throw e;
- } catch (SolrServerException e) {
- if (e.getRootCause() instanceof IOException) {
- ex = e;
- moveAliveToDead(wrapper);
- if (justFailed == null) justFailed = new HashMap<>();
- justFailed.put(wrapper.getKey(), wrapper);
- } else {
- throw e;
- }
- } catch (Exception e) {
- throw new SolrServerException(e);
- }
- }
-
-
- // try other standard servers that we didn't try just now
- for (ServerWrapper wrapper : zombieServers.values()) {
- if (wrapper.standard==false || justFailed!=null && justFailed.containsKey(wrapper.getKey())) continue;
- try {
- NamedList<Object> rsp = wrapper.solrServer.request(request);
- // remove from zombie list *before* adding to alive to avoid a race that could lose a server
- zombieServers.remove(wrapper.getKey());
- addToAlive(wrapper);
- return rsp;
- } catch (SolrException e) {
- // Server is alive but the request was malformed or invalid
- throw e;
- } catch (SolrServerException e) {
- if (e.getRootCause() instanceof IOException) {
- ex = e;
- // still dead
- } else {
- throw e;
- }
- } catch (Exception e) {
- throw new SolrServerException(e);
- }
- }
-
-
- if (ex == null) {
- throw new SolrServerException("No live SolrServers available to handle this request");
- } else {
- throw new SolrServerException("No live SolrServers available to handle this request", ex);
- }
- }
-
- /**
- * Takes up one dead server and check for aliveness. The check is done in a roundrobin. Each server is checked for
- * aliveness once in 'x' millis where x is decided by the setAliveCheckinterval() or it is defaulted to 1 minute
- *
- * @param zombieServer a server in the dead pool
- */
- private void checkAZombieServer(ServerWrapper zombieServer) {
- long currTime = System.currentTimeMillis();
- try {
- zombieServer.lastChecked = currTime;
- QueryResponse resp = zombieServer.solrServer.query(solrQuery);
- if (resp.getStatus() == 0) {
- // server has come back up.
- // make sure to remove from zombies before adding to alive to avoid a race condition
- // where another thread could mark it down, move it back to zombie, and then we delete
- // from zombie and lose it forever.
- ServerWrapper wrapper = zombieServers.remove(zombieServer.getKey());
- if (wrapper != null) {
- wrapper.failedPings = 0;
- if (wrapper.standard) {
- addToAlive(wrapper);
- }
- } else {
- // something else already moved the server from zombie to alive
- }
- }
- } catch (Exception e) {
- //Expected. The server is still down.
- zombieServer.failedPings++;
-
- // If the server doesn't belong in the standard set belonging to this load balancer
- // then simply drop it after a certain number of failed pings.
- if (!zombieServer.standard && zombieServer.failedPings >= NONSTANDARD_PING_LIMIT) {
- zombieServers.remove(zombieServer.getKey());
- }
- }
- }
-
- private void moveAliveToDead(ServerWrapper wrapper) {
- wrapper = removeFromAlive(wrapper.getKey());
- if (wrapper == null)
- return; // another thread already detected the failure and removed it
- zombieServers.put(wrapper.getKey(), wrapper);
- startAliveCheckExecutor();
- }
-
- private int interval = CHECK_INTERVAL;
-
- /**
- * LBHttpSolrServer keeps pinging the dead servers at fixed interval to find if it is alive. Use this to set that
- * interval
- *
- * @param interval time in milliseconds
- */
- public void setAliveCheckInterval(int interval) {
- if (interval <= 0) {
- throw new IllegalArgumentException("Alive check interval must be " +
- "positive, specified value = " + interval);
- }
- this.interval = interval;
- }
-
- private void startAliveCheckExecutor() {
- // double-checked locking, but it's OK because we don't *do* anything with aliveCheckExecutor
- // if it's not null.
- if (aliveCheckExecutor == null) {
- synchronized (this) {
- if (aliveCheckExecutor == null) {
- aliveCheckExecutor = Executors.newSingleThreadScheduledExecutor(
- new SolrjNamedThreadFactory("aliveCheckExecutor"));
- aliveCheckExecutor.scheduleAtFixedRate(
- getAliveCheckRunner(new WeakReference<>(this)),
- this.interval, this.interval, TimeUnit.MILLISECONDS);
- }
- }
- }
- }
-
- private static Runnable getAliveCheckRunner(final WeakReference<LBHttpSolrServer> lbRef) {
- return new Runnable() {
- @Override
- public void run() {
- LBHttpSolrServer lb = lbRef.get();
- if (lb != null && lb.zombieServers != null) {
- for (ServerWrapper zombieServer : lb.zombieServers.values()) {
- lb.checkAZombieServer(zombieServer);
- }
- }
- }
- };
- }
-
- /**
- * Return the HttpClient this instance uses.
- */
- public HttpClient getHttpClient() {
- return httpClient;
- }
-
- public ResponseParser getParser() {
- return parser;
- }
-
- /**
- * Changes the {@link ResponseParser} that will be used for the internal
- * SolrServer objects.
- *
- * @param parser Default Response Parser chosen to parse the response if the parser
- * were not specified as part of the request.
- * @see org.apache.solr.client.solrj.SolrRequest#getResponseParser()
- */
- public void setParser(ResponseParser parser) {
- this.parser = parser;
- }
-
- /**
- * Changes the {@link RequestWriter} that will be used for the internal
- * SolrServer objects.
- *
- * @param requestWriter Default RequestWriter, used to encode requests sent to the server.
- */
- public void setRequestWriter(RequestWriter requestWriter) {
- this.requestWriter = requestWriter;
- }
-
- public RequestWriter getRequestWriter() {
- return requestWriter;
- }
-
- @Override
- protected void finalize() throws Throwable {
- try {
- if(this.aliveCheckExecutor!=null)
- this.aliveCheckExecutor.shutdownNow();
- } finally {
- super.finalize();
- }
- }
-
- // defaults
- private static final int CHECK_INTERVAL = 60 * 1000; //1 minute between checks
- private static final int NONSTANDARD_PING_LIMIT = 5; // number of times we'll ping dead servers not in the server list
-
}
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/AbstractUpdateRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/AbstractUpdateRequest.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/AbstractUpdateRequest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/AbstractUpdateRequest.java Wed Dec 31 14:05:48 2014
@@ -17,7 +17,7 @@ package org.apache.solr.client.solrj.req
*/
import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.params.ModifiableSolrParams;
@@ -117,11 +117,11 @@ public abstract class AbstractUpdateRequ
}
@Override
- public UpdateResponse process( SolrServer server ) throws SolrServerException, IOException
+ public UpdateResponse process(SolrClient client) throws SolrServerException, IOException
{
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
UpdateResponse res = new UpdateResponse();
- res.setResponse( server.request( this ) );
+ res.setResponse(client.request(this));
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
res.setElapsedTime(endTime - startTime);
return res;
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java Wed Dec 31 14:05:48 2014
@@ -18,7 +18,7 @@
package org.apache.solr.client.solrj.request;
import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.common.SolrException;
@@ -78,7 +78,7 @@ public class CollectionAdminRequest exte
}
@Override
- public CollectionAdminResponse process(SolrServer server) throws SolrServerException, IOException
+ public CollectionAdminResponse process(SolrClient server) throws SolrServerException, IOException
{
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
CollectionAdminResponse res = new CollectionAdminResponse();
@@ -814,8 +814,7 @@ public class CollectionAdminRequest exte
private String propertyName;
private Boolean onlyActiveNodes;
private Boolean shardUnique;
-
-
+
public String getPropertyName() {
return propertyName;
}
@@ -859,5 +858,6 @@ public class CollectionAdminRequest exte
params.set("shardUnique", shardUnique);
return params;
}
+
}
}
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java Wed Dec 31 14:05:48 2014
@@ -18,7 +18,7 @@
package org.apache.solr.client.solrj.request;
import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.CoreAdminResponse;
import org.apache.solr.common.cloud.ZkStateReader;
@@ -503,11 +503,11 @@ public class CoreAdminRequest extends So
}
@Override
- public CoreAdminResponse process(SolrServer server) throws SolrServerException, IOException
+ public CoreAdminResponse process(SolrClient client) throws SolrServerException, IOException
{
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
CoreAdminResponse res = new CoreAdminResponse();
- res.setResponse( server.request( this ) );
+ res.setResponse(client.request(this));
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
res.setElapsedTime(endTime - startTime);
return res;
@@ -517,57 +517,57 @@ public class CoreAdminRequest extends So
//
//---------------------------------------------------------------------------------------
- public static CoreAdminResponse reloadCore( String name, SolrServer server ) throws SolrServerException, IOException
+ public static CoreAdminResponse reloadCore(String name, SolrClient client) throws SolrServerException, IOException
{
CoreAdminRequest req = new CoreAdminRequest();
- req.setCoreName( name );
- req.setAction( CoreAdminAction.RELOAD );
- return req.process( server );
+ req.setCoreName(name);
+ req.setAction(CoreAdminAction.RELOAD);
+ return req.process(client);
}
- public static CoreAdminResponse unloadCore( String name, SolrServer server ) throws SolrServerException, IOException
+ public static CoreAdminResponse unloadCore(String name, SolrClient client) throws SolrServerException, IOException
{
- return unloadCore(name, false, server);
+ return unloadCore(name, false, client);
}
- public static CoreAdminResponse unloadCore(String name, boolean deleteIndex, SolrServer server) throws SolrServerException, IOException {
- return unloadCore(name, deleteIndex, false, server);
+ public static CoreAdminResponse unloadCore(String name, boolean deleteIndex, SolrClient client) throws SolrServerException, IOException {
+ return unloadCore(name, deleteIndex, false, client);
}
- public static CoreAdminResponse unloadCore(String name, boolean deleteIndex, boolean deleteInstanceDir, SolrServer server) throws SolrServerException, IOException {
+ public static CoreAdminResponse unloadCore(String name, boolean deleteIndex, boolean deleteInstanceDir, SolrClient client) throws SolrServerException, IOException {
Unload req = new Unload(deleteIndex);
req.setCoreName(name);
req.setDeleteInstanceDir(deleteInstanceDir);
- return req.process(server);
+ return req.process(client);
}
- public static CoreAdminResponse renameCore(String coreName, String newName, SolrServer server ) throws SolrServerException, IOException
+ public static CoreAdminResponse renameCore(String coreName, String newName, SolrClient client ) throws SolrServerException, IOException
{
CoreAdminRequest req = new CoreAdminRequest();
req.setCoreName(coreName);
req.setOtherCoreName(newName);
req.setAction( CoreAdminAction.RENAME );
- return req.process( server );
+ return req.process( client );
}
- public static CoreAdminResponse getStatus( String name, SolrServer server ) throws SolrServerException, IOException
+ public static CoreAdminResponse getStatus( String name, SolrClient client ) throws SolrServerException, IOException
{
CoreAdminRequest req = new CoreAdminRequest();
req.setCoreName( name );
req.setAction( CoreAdminAction.STATUS );
- return req.process( server );
+ return req.process( client );
}
- public static CoreAdminResponse createCore( String name, String instanceDir, SolrServer server ) throws SolrServerException, IOException
+ public static CoreAdminResponse createCore( String name, String instanceDir, SolrClient client ) throws SolrServerException, IOException
{
- return CoreAdminRequest.createCore(name, instanceDir, server, null, null);
+ return CoreAdminRequest.createCore(name, instanceDir, client, null, null);
}
- public static CoreAdminResponse createCore( String name, String instanceDir, SolrServer server, String configFile, String schemaFile ) throws SolrServerException, IOException {
- return createCore(name, instanceDir, server, configFile, schemaFile, null, null);
+ public static CoreAdminResponse createCore( String name, String instanceDir, SolrClient client, String configFile, String schemaFile ) throws SolrServerException, IOException {
+ return createCore(name, instanceDir, client, configFile, schemaFile, null, null);
}
- public static CoreAdminResponse createCore( String name, String instanceDir, SolrServer server, String configFile, String schemaFile, String dataDir, String tlogDir ) throws SolrServerException, IOException
+ public static CoreAdminResponse createCore( String name, String instanceDir, SolrClient client, String configFile, String schemaFile, String dataDir, String tlogDir ) throws SolrServerException, IOException
{
CoreAdminRequest.Create req = new CoreAdminRequest.Create();
req.setCoreName( name );
@@ -584,24 +584,24 @@ public class CoreAdminRequest extends So
if(schemaFile != null){
req.setSchemaName(schemaFile);
}
- return req.process( server );
+ return req.process( client );
}
@Deprecated
- public static CoreAdminResponse persist(String fileName, SolrServer server) throws SolrServerException, IOException
+ public static CoreAdminResponse persist(String fileName, SolrClient client) throws SolrServerException, IOException
{
CoreAdminRequest.Persist req = new CoreAdminRequest.Persist();
req.setFileName(fileName);
- return req.process(server);
+ return req.process(client);
}
public static CoreAdminResponse mergeIndexes(String name,
- String[] indexDirs, String[] srcCores, SolrServer server) throws SolrServerException,
+ String[] indexDirs, String[] srcCores, SolrClient client) throws SolrServerException,
IOException {
CoreAdminRequest.MergeIndexes req = new CoreAdminRequest.MergeIndexes();
req.setCoreName(name);
req.setIndexDirs(Arrays.asList(indexDirs));
req.setSrcCores(Arrays.asList(srcCores));
- return req.process(server);
+ return req.process(client);
}
}
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/DirectXmlRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/DirectXmlRequest.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/DirectXmlRequest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/DirectXmlRequest.java Wed Dec 31 14:05:48 2014
@@ -17,18 +17,18 @@
package org.apache.solr.client.solrj.request;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.solr.client.solrj.SolrServer;
-import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.client.solrj.util.ClientUtils;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.ContentStream;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
/**
* Send arbitrary XML to a request handler
*
@@ -62,11 +62,11 @@ public class DirectXmlRequest extends So
}
@Override
- public UpdateResponse process( SolrServer server ) throws SolrServerException, IOException
+ public UpdateResponse process(SolrClient client) throws SolrServerException, IOException
{
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
UpdateResponse res = new UpdateResponse();
- res.setResponse( server.request( this ) );
+ res.setResponse(client.request(this));
res.setElapsedTime( TimeUnit.MILLISECONDS.convert(System.nanoTime()-startTime, TimeUnit.NANOSECONDS) );
return res;
}
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/DocumentAnalysisRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/DocumentAnalysisRequest.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/DocumentAnalysisRequest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/DocumentAnalysisRequest.java Wed Dec 31 14:05:48 2014
@@ -18,7 +18,7 @@
package org.apache.solr.client.solrj.request;
import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.DocumentAnalysisResponse;
import org.apache.solr.client.solrj.util.ClientUtils;
@@ -87,10 +87,10 @@ public class DocumentAnalysisRequest ext
* {@inheritDoc}
*/
@Override
- public DocumentAnalysisResponse process(SolrServer server) throws SolrServerException, IOException {
+ public DocumentAnalysisResponse process(SolrClient client) throws SolrServerException, IOException {
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
DocumentAnalysisResponse res = new DocumentAnalysisResponse();
- res.setResponse(server.request(this));
+ res.setResponse(client.request(this));
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
res.setElapsedTime(endTime - startTime);
return res;
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/FieldAnalysisRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/FieldAnalysisRequest.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/FieldAnalysisRequest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/FieldAnalysisRequest.java Wed Dec 31 14:05:48 2014
@@ -18,7 +18,7 @@
package org.apache.solr.client.solrj.request;
import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.FieldAnalysisResponse;
import org.apache.solr.common.params.AnalysisParams;
@@ -96,7 +96,7 @@ public class FieldAnalysisRequest extend
* {@inheritDoc}
*/
@Override
- public FieldAnalysisResponse process(SolrServer server) throws SolrServerException, IOException {
+ public FieldAnalysisResponse process(SolrClient server) throws SolrServerException, IOException {
if (fieldTypes == null && fieldNames == null) {
throw new IllegalStateException("At least one field type or field name need to be specified");
}
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/LukeRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/LukeRequest.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/LukeRequest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/LukeRequest.java Wed Dec 31 14:05:48 2014
@@ -17,21 +17,21 @@
package org.apache.solr.client.solrj.request;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.solr.client.solrj.SolrServer;
-import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.LukeResponse;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.ContentStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
/**
*
*
@@ -115,11 +115,11 @@ public class LukeRequest extends SolrReq
}
@Override
- public LukeResponse process( SolrServer server ) throws SolrServerException, IOException
+ public LukeResponse process( SolrClient client ) throws SolrServerException, IOException
{
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
LukeResponse res = new LukeResponse();
- res.setResponse( server.request( this ) );
+ res.setResponse(client.request(this));
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
res.setElapsedTime(endTime - startTime);
return res;
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/QueryRequest.java Wed Dec 31 14:05:48 2014
@@ -18,7 +18,7 @@
package org.apache.solr.client.solrj.request;
import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrException;
@@ -84,11 +84,11 @@ public class QueryRequest extends SolrRe
}
@Override
- public QueryResponse process( SolrServer server ) throws SolrServerException
+ public QueryResponse process( SolrClient client ) throws SolrServerException
{
try {
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
- QueryResponse res = new QueryResponse( server.request( this ), server );
+ QueryResponse res = new QueryResponse( client.request( this ), client );
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
res.setElapsedTime(endTime - startTime);
return res;
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrPing.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrPing.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrPing.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrPing.java Wed Dec 31 14:05:48 2014
@@ -17,20 +17,20 @@
package org.apache.solr.client.solrj.request;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.concurrent.TimeUnit;
-
+import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.SolrPingResponse;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.ContentStream;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
/**
- * Verify that there is a working Solr core at the URL of a {@link SolrServer}.
+ * Verify that there is a working Solr core at the URL of a {@link org.apache.solr.client.solrj.SolrClient}.
* To use this class, the solrconfig.xml for the relevant core must include the
* request handler for <code>/admin/ping</code>.
*
@@ -63,11 +63,11 @@ public class SolrPing extends SolrReques
}
@Override
- public SolrPingResponse process(SolrServer server)
+ public SolrPingResponse process(SolrClient client)
throws SolrServerException, IOException {
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
SolrPingResponse res = new SolrPingResponse();
- res.setResponse(server.request(this));
+ res.setResponse(client.request(this));
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
res.setElapsedTime(endTime - startTime);
return res;
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java Wed Dec 31 14:05:48 2014
@@ -30,7 +30,7 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.LinkedHashMap;
-import org.apache.solr.client.solrj.impl.LBHttpSolrServer;
+import org.apache.solr.client.solrj.impl.LBHttpSolrClient;
import org.apache.solr.client.solrj.util.ClientUtils;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.DocCollection;
@@ -171,7 +171,7 @@ public class UpdateRequest extends Abstr
* @param idField the id field
* @return a Map of urls to requests
*/
- public Map<String,LBHttpSolrServer.Req> getRoutes(DocRouter router,
+ public Map<String,LBHttpSolrClient.Req> getRoutes(DocRouter router,
DocCollection col, Map<String,List<String>> urlMap,
ModifiableSolrParams params, String idField) {
@@ -180,7 +180,7 @@ public class UpdateRequest extends Abstr
return null;
}
- Map<String,LBHttpSolrServer.Req> routes = new HashMap<>();
+ Map<String,LBHttpSolrClient.Req> routes = new HashMap<>();
if (documents != null) {
Set<Entry<SolrInputDocument,Map<String,Object>>> entries = documents.entrySet();
for (Entry<SolrInputDocument,Map<String,Object>> entry : entries) {
@@ -196,7 +196,7 @@ public class UpdateRequest extends Abstr
}
List<String> urls = urlMap.get(slice.getName());
String leaderUrl = urls.get(0);
- LBHttpSolrServer.Req request = (LBHttpSolrServer.Req) routes
+ LBHttpSolrClient.Req request = (LBHttpSolrClient.Req) routes
.get(leaderUrl);
if (request == null) {
UpdateRequest updateRequest = new UpdateRequest();
@@ -204,7 +204,7 @@ public class UpdateRequest extends Abstr
updateRequest.setCommitWithin(getCommitWithin());
updateRequest.setParams(params);
updateRequest.setPath(getPath());
- request = new LBHttpSolrServer.Req(updateRequest, urls);
+ request = new LBHttpSolrClient.Req(updateRequest, urls);
routes.put(leaderUrl, request);
}
UpdateRequest urequest = (UpdateRequest) request.getRequest();
@@ -234,7 +234,7 @@ public class UpdateRequest extends Abstr
}
List<String> urls = urlMap.get(slice.getName());
String leaderUrl = urls.get(0);
- LBHttpSolrServer.Req request = routes.get(leaderUrl);
+ LBHttpSolrClient.Req request = routes.get(leaderUrl);
if (request != null) {
UpdateRequest urequest = (UpdateRequest) request.getRequest();
urequest.deleteById(deleteId, version);
@@ -242,7 +242,7 @@ public class UpdateRequest extends Abstr
UpdateRequest urequest = new UpdateRequest();
urequest.setParams(params);
urequest.deleteById(deleteId, version);
- request = new LBHttpSolrServer.Req(urequest, urls);
+ request = new LBHttpSolrClient.Req(urequest, urls);
routes.put(leaderUrl, request);
}
}
Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/response/QueryResponse.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/response/QueryResponse.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/response/QueryResponse.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/response/QueryResponse.java Wed Dec 31 14:05:48 2014
@@ -25,7 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.beans.DocumentObjectBinder;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.params.CursorMarkParams;
@@ -85,18 +85,18 @@ public class QueryResponse extends SolrR
private Map<String,String> _explainMap = null;
// utility variable used for automatic binding -- it should not be serialized
- private transient final SolrServer solrServer;
+ private transient final SolrClient solrClient;
public QueryResponse(){
- solrServer = null;
+ solrClient = null;
}
/**
* Utility constructor to set the solrServer and namedList
*/
- public QueryResponse( NamedList<Object> res , SolrServer solrServer){
+ public QueryResponse( NamedList<Object> res , SolrClient solrClient){
this.setResponse( res );
- this.solrServer = solrServer;
+ this.solrClient = solrClient;
}
@Override
@@ -564,9 +564,9 @@ public class QueryResponse extends SolrR
}
public <T> List<T> getBeans(Class<T> type){
- return solrServer == null ?
+ return solrClient == null ?
new DocumentObjectBinder().getBeans(type,_results):
- solrServer.getBinder().getBeans(type, _results);
+ solrClient.getBinder().getBeans(type, _results);
}
public Map<String, FieldStatsInfo> getFieldStatsInfo() {
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/LargeVolumeTestBase.java Wed Dec 31 14:05:48 2014
@@ -17,9 +17,6 @@
package org.apache.solr.client.solrj;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.solr.SolrJettyTestBase;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
@@ -29,6 +26,9 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.List;
+
/**
*
* @since solr 1.3
@@ -43,8 +43,8 @@ public abstract class LargeVolumeTestBas
@Test
public void testMultiThreaded() throws Exception {
- SolrServer gserver = this.getSolrServer();
- gserver.deleteByQuery( "*:*" ); // delete everything!
+ SolrClient client = this.getSolrClient();
+ client.deleteByQuery("*:*"); // delete everything!
DocThread[] threads = new DocThread[threadCount];
for (int i=0; i<threadCount; i++) {
@@ -59,28 +59,28 @@ public abstract class LargeVolumeTestBas
// some of the commits could have failed because maxWarmingSearchers exceeded,
// so do a final commit to make sure everything is visible.
- gserver.commit();
+ client.commit();
query(threadCount * numdocs);
log.info("done");
}
private void query(int count) throws SolrServerException {
- SolrServer gserver = this.getSolrServer();
+ SolrClient client = this.getSolrClient();
SolrQuery query = new SolrQuery("*:*");
- QueryResponse response = gserver.query(query);
+ QueryResponse response = client.query(query);
assertEquals(0, response.getStatus());
assertEquals(count, response.getResults().getNumFound());
}
public class DocThread extends Thread {
- final SolrServer tserver;
+ final SolrClient client;
final String name;
public DocThread( String name )
{
- tserver = createNewSolrServer();
+ client = createNewSolrClient();
this.name = name;
}
@@ -91,13 +91,13 @@ public abstract class LargeVolumeTestBas
List<SolrInputDocument> docs = new ArrayList<>();
for (int i = 0; i < numdocs; i++) {
if (i > 0 && i % 200 == 0) {
- resp = tserver.add(docs);
+ resp = client.add(docs);
assertEquals(0, resp.getStatus());
docs = new ArrayList<>();
}
if (i > 0 && i % 5000 == 0) {
log.info(getName() + " - Committing " + i);
- resp = tserver.commit();
+ resp = client.commit();
assertEquals(0, resp.getStatus());
}
SolrInputDocument doc = new SolrInputDocument();
@@ -105,20 +105,20 @@ public abstract class LargeVolumeTestBas
doc.addField("cat", "foocat");
docs.add(doc);
}
- resp = tserver.add(docs);
+ resp = client.add(docs);
assertEquals(0, resp.getStatus());
try {
- resp = tserver.commit();
+ resp = client.commit();
assertEquals(0, resp.getStatus());
- resp = tserver.optimize();
+ resp = client.optimize();
assertEquals(0, resp.getStatus());
} catch (Exception e) {
// a commit/optimize can fail with a too many warming searchers exception
log.info("Caught benign exception during commit: " + e.getMessage());
}
- if (!(tserver instanceof EmbeddedSolrServer)) {
- tserver.shutdown();
+ if (!(client instanceof EmbeddedSolrServer)) {
+ client.shutdown();
}
} catch (Exception e) {
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java Wed Dec 31 14:05:48 2014
@@ -17,10 +17,6 @@
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;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
@@ -33,6 +29,10 @@ import org.apache.solr.core.CoreContaine
import org.apache.solr.core.SolrCore;
import org.junit.BeforeClass;
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
/**
* Abstract base class for testing merge indexes command
*
@@ -91,22 +91,22 @@ public abstract class MergeIndexesExampl
}
@Override
- protected final SolrServer getSolrServer() {
+ protected final SolrClient getSolrClient() {
throw new UnsupportedOperationException();
}
@Override
- protected final SolrServer createNewSolrServer() {
+ protected final SolrClient createNewSolrClient() {
throw new UnsupportedOperationException();
}
- protected abstract SolrServer getSolrCore0();
+ protected abstract SolrClient getSolrCore0();
- protected abstract SolrServer getSolrCore1();
+ protected abstract SolrClient getSolrCore1();
- protected abstract SolrServer getSolrAdmin();
+ protected abstract SolrClient getSolrAdmin();
- protected abstract SolrServer getSolrCore(String name);
+ protected abstract SolrClient getSolrCore(String name);
protected abstract String getIndexDirCore1();
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java Wed Dec 31 14:05:48 2014
@@ -18,12 +18,9 @@
package org.apache.solr.client.solrj;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
-import org.apache.solr.client.solrj.SolrExampleTests;
-import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.impl.BinaryRequestWriter;
import org.apache.solr.client.solrj.impl.BinaryResponseParser;
-import org.apache.solr.client.solrj.impl.HttpSolrServer;
-import org.apache.solr.util.ExternalPaths;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.junit.BeforeClass;
@@ -39,22 +36,22 @@ public class SolrExampleBinaryTest exten
}
@Override
- public SolrServer createNewSolrServer()
+ public SolrClient createNewSolrClient()
{
try {
// setup the server...
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());
+ HttpSolrClient client = new HttpSolrClient( url );
+ client.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
+ client.setDefaultMaxConnectionsPerHost(100);
+ client.setMaxTotalConnections(100);
+ client.setUseMultiPartPost(random().nextBoolean());
// where the magic happens
- s.setParser(new BinaryResponseParser());
- s.setRequestWriter(new BinaryRequestWriter());
+ client.setParser(new BinaryResponseParser());
+ client.setRequestWriter(new BinaryRequestWriter());
- return s;
+ return client;
}
catch( Exception ex ) {
throw new RuntimeException( ex );
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestBase.java?rev=1648697&r1=1648696&r2=1648697&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestBase.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestBase.java Wed Dec 31 14:05:48 2014
@@ -57,10 +57,10 @@ abstract public class SolrExampleTestBas
/**
* Subclasses need to initialize the server impl
*/
- protected abstract SolrServer getSolrServer();
+ protected abstract SolrClient getSolrClient();
/**
* Create a new solr server
*/
- protected abstract SolrServer createNewSolrServer();
+ protected abstract SolrClient createNewSolrClient();
}