You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by co...@apache.org on 2016/07/27 09:18:27 UTC
[11/14] incubator-ranger git commit: RANGER-1122 - Remove
ranger_solrj module
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java
deleted file mode 100644
index c524b1f..0000000
--- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java
+++ /dev/null
@@ -1,730 +0,0 @@
-/*
- * 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.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.CommonParams;
-import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SolrjNamedThreadFactory;
-import org.apache.solr.common.SolrException;
-
-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.*;
-
-/**
- * LBHttpSolrClient or "LoadBalanced HttpSolrClient" is a load balancing wrapper around
- * {@link HttpSolrClient}. This is useful when you
- * have multiple Solr servers 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 CloudSolrClient}, but this class may be used
- * for updates because the server will forward them to the appropriate leader.
- *
- * <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>
- * SolrClient lbHttpSolrClient = new LBHttpSolrClient("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();
- * SolrClient lbHttpSolrClient = new LBHttpSolrClient(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
- */
-public class LBHttpSolrClient extends SolrClient {
- 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 HttpSolrClient client;
-
- 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(HttpSolrClient client) {
- this.client = client;
- }
-
- @Override
- public String toString() {
- return client.getBaseURL();
- }
-
- public String getKey() {
- return client.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;
- }
- }
-
- public LBHttpSolrClient(String... solrServerUrls) throws MalformedURLException {
- this(null, solrServerUrls);
- }
-
- /** The provided httpClient should use a multi-threaded connection manager */
- public LBHttpSolrClient(HttpClient httpClient, String... solrServerUrl) {
- this(httpClient, new BinaryResponseParser(), solrServerUrl);
- }
-
- /** The provided httpClient should use a multi-threaded connection manager */
- public LBHttpSolrClient(HttpClient httpClient, ResponseParser parser, String... solrServerUrl) {
- clientIsInternal = (httpClient == null);
- this.parser = parser;
- if (httpClient == null) {
- ModifiableSolrParams params = new ModifiableSolrParams();
- if (solrServerUrl.length > 1) {
- // we prefer retrying another server
- params.set(HttpClientUtil.PROP_USE_RETRY, false);
- } else {
- params.set(HttpClientUtil.PROP_USE_RETRY, true);
- }
- this.httpClient = HttpClientUtil.createClient(params);
- } else {
- this.httpClient = httpClient;
- }
- for (String s : solrServerUrl) {
- ServerWrapper wrapper = new ServerWrapper(makeSolrClient(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 HttpSolrClient makeSolrClient(String server) {
- HttpSolrClient client = new HttpSolrClient(server, httpClient, parser);
- if (requestWriter != null) {
- client.setRequestWriter(requestWriter);
- }
- if (queryParams != null) {
- client.setQueryParams(queryParams);
- }
- return client;
- }
-
- /**
- * 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;
-
- long timeAllowedNano = getTimeAllowedInNanos(req.getRequest());
- long timeOutTime = System.nanoTime() + timeAllowedNano;
- for (String serverStr : req.getServers()) {
- if(isTimeExceeded(timeAllowedNano, timeOutTime)) {
- break;
- }
-
- 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;
- HttpSolrClient client = makeSolrClient(serverStr);
-
- ex = doRequest(client, req, rsp, isUpdate, false, null);
- if (ex == null) {
- return rsp; // SUCCESS
- }
- }
-
- // try the servers we previously skipped
- if (skipped != null) {
- for (ServerWrapper wrapper : skipped) {
- if(isTimeExceeded(timeAllowedNano, timeOutTime)) {
- break;
- }
-
- ex = doRequest(wrapper.client, 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(HttpSolrClient 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(HttpSolrClient client, Req req, Rsp rsp, boolean isUpdate,
- boolean isZombie, String zombieKey) throws SolrServerException, IOException {
- Exception ex = null;
- try {
- rsp.rsp = client.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(client, 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(client, e) : e;
- } else {
- throw e;
- }
- } catch (SocketTimeoutException e) {
- if (!isUpdate) {
- ex = (!isZombie) ? addZombie(client, e) : e;
- } else {
- throw e;
- }
- } catch (SolrServerException e) {
- Throwable rootCause = e.getRootCause();
- if (!isUpdate && rootCause instanceof IOException) {
- ex = (!isZombie) ? addZombie(client, e) : e;
- } else if (isUpdate && rootCause instanceof ConnectException) {
- ex = (!isZombie) ? addZombie(client, 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 {
- HttpSolrClient client = makeSolrClient(server);
- addToAlive(new ServerWrapper(client));
- }
-
- 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);
- }
-
- /**
- * 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 close() {
- shutdown();
- }
-
- @Override
- @Deprecated
- public void shutdown() {
- if (aliveCheckExecutor != null) {
- aliveCheckExecutor.shutdownNow();
- }
- if(clientIsInternal) {
- HttpClientUtil.close(httpClient);
- }
- }
-
- /**
- * 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;
-
- long timeAllowedNano = getTimeAllowedInNanos(request);
- long timeOutTime = System.nanoTime() + timeAllowedNano;
- for (int attempts=0; attempts<maxTries; attempts++) {
- if(isTimeExceeded(timeAllowedNano, timeOutTime)) {
- break;
- }
-
- int count = counter.incrementAndGet() & Integer.MAX_VALUE;
- ServerWrapper wrapper = serverList[count % serverList.length];
- wrapper.lastUsed = System.currentTimeMillis();
-
- try {
- return wrapper.client.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(isTimeExceeded(timeAllowedNano, timeOutTime)) {
- break;
- }
-
- if (wrapper.standard==false || justFailed!=null && justFailed.containsKey(wrapper.getKey())) continue;
- try {
- NamedList<Object> rsp = wrapper.client.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);
- }
- }
-
- /**
- * @return time allowed in nanos, returns -1 if no time_allowed is specified.
- */
- private long getTimeAllowedInNanos(final SolrRequest req) {
- SolrParams reqParams = req.getParams();
- return reqParams == null ? -1 :
- TimeUnit.NANOSECONDS.convert(reqParams.getInt(CommonParams.TIME_ALLOWED, -1), TimeUnit.MILLISECONDS);
- }
-
- private boolean isTimeExceeded(long timeAllowedNano, long timeOutTime) {
- return timeAllowedNano > 0 && System.nanoTime() > timeOutTime;
- }
-
- /**
- * 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.client.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<LBHttpSolrClient> lbRef) {
- return new Runnable() {
- @Override
- public void run() {
- LBHttpSolrClient 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
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
deleted file mode 100644
index ee28241..0000000
--- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.client.solrj.impl;
-
-import org.apache.http.client.HttpClient;
-import org.apache.solr.client.solrj.ResponseParser;
-
-import java.net.MalformedURLException;
-
-/**
- * @deprecated Use {@link org.apache.solr.client.solrj.impl.LBHttpSolrClient}
- */
-@Deprecated
-public class LBHttpSolrServer extends LBHttpSolrClient {
-
- public LBHttpSolrServer(String... solrServerUrls) throws MalformedURLException {
- super(solrServerUrls);
- }
-
- public LBHttpSolrServer(HttpClient httpClient, String... solrServerUrl) {
- super(httpClient, solrServerUrl);
- }
-
- public LBHttpSolrServer(HttpClient httpClient, ResponseParser parser, String... solrServerUrl) {
- super(httpClient, parser, solrServerUrl);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/NoOpResponseParser.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/NoOpResponseParser.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/NoOpResponseParser.java
deleted file mode 100644
index e9a346c..0000000
--- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/NoOpResponseParser.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.client.solrj.impl;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.solr.client.solrj.ResponseParser;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.NamedList;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringWriter;
-
-/**
- * Simply puts the entire response into an entry in a NamedList.
- * This parser isn't parse response into a QueryResponse.
- */
-public class NoOpResponseParser extends ResponseParser {
-
- private String writerType = "xml";
-
- public NoOpResponseParser() {
- }
-
- public NoOpResponseParser(String writerType) {
- this.writerType = writerType;
- }
-
- @Override
- public String getWriterType() {
- return writerType;
- }
-
- public void setWriterType(String writerType) {
- this.writerType = writerType;
- }
-
- @Override
- public NamedList<Object> processResponse(Reader reader) {
- try {
- StringWriter writer = new StringWriter();
- IOUtils.copy(reader, writer);
- String output = writer.toString();
- NamedList<Object> list = new NamedList<>();
- list.add("response", output);
- return list;
- } catch (IOException e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "parsing error", e);
- }
- }
-
- @Override
- public NamedList<Object> processResponse(InputStream body, String encoding) {
- try {
- StringWriter writer = new StringWriter();
- IOUtils.copy(body, writer, encoding);
- String output = writer.toString();
- NamedList<Object> list = new NamedList<>();
- list.add("response", output);
- return list;
- } catch (IOException e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "parsing error", e);
- }
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java
deleted file mode 100644
index 14be1f3..0000000
--- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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.client.solrj.impl;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-import org.apache.solr.client.solrj.StreamingResponseCallback;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.DataInputInputStream;
-import org.apache.solr.common.util.JavaBinCodec;
-import org.apache.solr.common.util.NamedList;
-
-/**
- * A BinaryResponseParser that sends callback events rather then build
- * a large response
- *
- *
- * @since solr 4.0
- */
-public class StreamingBinaryResponseParser extends BinaryResponseParser {
- final StreamingResponseCallback callback;
-
- public StreamingBinaryResponseParser( StreamingResponseCallback cb )
- {
- this.callback = cb;
- }
-
- @Override
- public NamedList<Object> processResponse(InputStream body, String encoding) {
- try {
- JavaBinCodec codec = new JavaBinCodec() {
-
- @Override
- public SolrDocument readSolrDocument(DataInputInputStream dis) throws IOException {
- SolrDocument doc = super.readSolrDocument(dis);
- callback.streamSolrDocument( doc );
- return null;
- }
-
- @Override
- public SolrDocumentList readSolrDocumentList(DataInputInputStream dis) throws IOException {
- SolrDocumentList solrDocs = new SolrDocumentList();
- List list = (List) readVal(dis);
- solrDocs.setNumFound((Long) list.get(0));
- solrDocs.setStart((Long) list.get(1));
- solrDocs.setMaxScore((Float) list.get(2));
-
- callback.streamDocListInfo(
- solrDocs.getNumFound(),
- solrDocs.getStart(),
- solrDocs.getMaxScore() );
-
- // Read the Array
- tagByte = dis.readByte();
- if( (tagByte >>> 5) != (ARR >>> 5) ) {
- throw new RuntimeException( "doclist must have an array" );
- }
- int sz = readSize(dis);
- for (int i = 0; i < sz; i++) {
- // must be a SolrDocument
- readVal( dis );
- }
- return solrDocs;
- }
- };
-
- return (NamedList<Object>) codec.unmarshal(body);
- }
- catch (IOException e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "parsing error", e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/XMLResponseParser.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/XMLResponseParser.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/XMLResponseParser.java
deleted file mode 100644
index f9177c8..0000000
--- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/XMLResponseParser.java
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * 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.client.solrj.impl;
-
-import org.apache.solr.client.solrj.ResponseParser;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.DateUtil;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
-import org.apache.solr.common.util.XMLErrorLogger;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-
-/**
- *
- *
- * @since solr 1.3
- */
-public class XMLResponseParser extends ResponseParser
-{
- public static final String XML_CONTENT_TYPE = "application/xml; charset=UTF-8";
- public static Logger log = LoggerFactory.getLogger(XMLResponseParser.class);
- private static final XMLErrorLogger xmllog = new XMLErrorLogger(log);
-
- // reuse the factory among all parser instances so things like string caches
- // won't be duplicated
- static final XMLInputFactory factory;
- static {
- factory = XMLInputFactory.newInstance();
- try {
- // The java 1.6 bundled stax parser (sjsxp) does not currently have a thread-safe
- // XMLInputFactory, as that implementation tries to cache and reuse the
- // XMLStreamReader. Setting the parser-specific "reuse-instance" property to false
- // prevents this.
- // All other known open-source stax parsers (and the bea ref impl)
- // have thread-safe factories.
- factory.setProperty("reuse-instance", Boolean.FALSE);
- }
- catch( IllegalArgumentException ex ) {
- // Other implementations will likely throw this exception since "reuse-instance"
- // isimplementation specific.
- log.debug( "Unable to set the 'reuse-instance' property for the input factory: "+factory );
- }
- factory.setXMLReporter(xmllog);
- }
-
- public XMLResponseParser() {}
-
- @Override
- public String getWriterType()
- {
- return "xml";
- }
-
- @Override
- public String getContentType() {
- return XML_CONTENT_TYPE;
- }
-
- @Override
- public NamedList<Object> processResponse(Reader in) {
- XMLStreamReader parser = null;
- try {
- parser = factory.createXMLStreamReader(in);
- } catch (XMLStreamException e) {
- throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "parsing error", e);
- }
-
- return processResponse(parser);
- }
-
- @Override
- public NamedList<Object> processResponse(InputStream in, String encoding)
- {
- XMLStreamReader parser = null;
- try {
- parser = factory.createXMLStreamReader(in, encoding);
- } catch (XMLStreamException e) {
- throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "parsing error", e);
- }
-
- return processResponse(parser);
- }
-
- /**
- * parse the text into a named list...
- */
- private NamedList<Object> processResponse(XMLStreamReader parser)
- {
- try {
- NamedList<Object> response = null;
- for (int event = parser.next();
- event != XMLStreamConstants.END_DOCUMENT;
- event = parser.next())
- {
- switch (event) {
- case XMLStreamConstants.START_ELEMENT:
-
- if( response != null ) {
- throw new Exception( "already read the response!" );
- }
-
- // only top-level element is "response
- String name = parser.getLocalName();
- if( name.equals( "response" ) || name.equals( "result" ) ) {
- response = readNamedList( parser );
- }
- else if( name.equals( "solr" ) ) {
- return new SimpleOrderedMap<>();
- }
- else {
- throw new Exception( "really needs to be response or result. " +
- "not:"+parser.getLocalName() );
- }
- break;
- }
- }
- return response;
- }
- catch( Exception ex ) {
- throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "parsing error", ex );
- }
- finally {
- try {
- parser.close();
- }
- catch( Exception ex ){}
- }
- }
-
-
- protected enum KnownType {
- STR (true) { @Override public String read( String txt ) { return txt; } },
- INT (true) { @Override public Integer read( String txt ) { return Integer.valueOf(txt); } },
- FLOAT (true) { @Override public Float read( String txt ) { return Float.valueOf(txt); } },
- DOUBLE (true) { @Override public Double read( String txt ) { return Double.valueOf(txt); } },
- LONG (true) { @Override public Long read( String txt ) { return Long.valueOf(txt); } },
- BOOL (true) { @Override public Boolean read( String txt ) { return Boolean.valueOf(txt); } },
- NULL (true) { @Override public Object read( String txt ) { return null; } },
- DATE (true) {
- @Override
- public Date read( String txt ) {
- try {
- return DateUtil.parseDate(txt);
- }
- catch( Exception ex ) {
- ex.printStackTrace();
- }
- return null;
- }
- },
-
- ARR (false) { @Override public Object read( String txt ) { return null; } },
- LST (false) { @Override public Object read( String txt ) { return null; } },
- RESULT (false) { @Override public Object read( String txt ) { return null; } },
- DOC (false) { @Override public Object read( String txt ) { return null; } };
-
- final boolean isLeaf;
-
- KnownType( boolean isLeaf )
- {
- this.isLeaf = isLeaf;
- }
-
- public abstract Object read( String txt );
-
- public static KnownType get( String v )
- {
- if( v != null ) {
- try {
- return KnownType.valueOf( v.toUpperCase(Locale.ROOT) );
- }
- catch( Exception ex ) {}
- }
- return null;
- }
- };
-
- protected NamedList<Object> readNamedList( XMLStreamReader parser ) throws XMLStreamException
- {
- if( XMLStreamConstants.START_ELEMENT != parser.getEventType() ) {
- throw new RuntimeException( "must be start element, not: "+parser.getEventType() );
- }
-
- StringBuilder builder = new StringBuilder();
- NamedList<Object> nl = new SimpleOrderedMap<>();
- KnownType type = null;
- String name = null;
-
- // just eat up the events...
- int depth = 0;
- while( true )
- {
- switch (parser.next()) {
- case XMLStreamConstants.START_ELEMENT:
- depth++;
- builder.setLength( 0 ); // reset the text
- type = KnownType.get( parser.getLocalName() );
- if( type == null ) {
- throw new RuntimeException( "this must be known type! not: "+parser.getLocalName() );
- }
-
- name = null;
- int cnt = parser.getAttributeCount();
- for( int i=0; i<cnt; i++ ) {
- if( "name".equals( parser.getAttributeLocalName( i ) ) ) {
- name = parser.getAttributeValue( i );
- break;
- }
- }
-
- /** The name in a NamedList can actually be null
- if( name == null ) {
- throw new XMLStreamException( "requires 'name' attribute: "+parser.getLocalName(), parser.getLocation() );
- }
- **/
-
- if( !type.isLeaf ) {
- switch( type ) {
- case LST: nl.add( name, readNamedList( parser ) ); depth--; continue;
- case ARR: nl.add( name, readArray( parser ) ); depth--; continue;
- case RESULT: nl.add( name, readDocuments( parser ) ); depth--; continue;
- case DOC: nl.add( name, readDocument( parser ) ); depth--; continue;
- }
- throw new XMLStreamException( "branch element not handled!", parser.getLocation() );
- }
- break;
-
- case XMLStreamConstants.END_ELEMENT:
- if( --depth < 0 ) {
- return nl;
- }
- //System.out.println( "NL:ELEM:"+type+"::"+name+"::"+builder );
- nl.add( name, type.read( builder.toString().trim() ) );
- break;
-
- case XMLStreamConstants.SPACE: // TODO? should this be trimmed? make sure it only gets one/two space?
- case XMLStreamConstants.CDATA:
- case XMLStreamConstants.CHARACTERS:
- builder.append( parser.getText() );
- break;
- }
- }
- }
-
- protected List<Object> readArray( XMLStreamReader parser ) throws XMLStreamException
- {
- if( XMLStreamConstants.START_ELEMENT != parser.getEventType() ) {
- throw new RuntimeException( "must be start element, not: "+parser.getEventType() );
- }
- if( !"arr".equals( parser.getLocalName().toLowerCase(Locale.ROOT) ) ) {
- throw new RuntimeException( "must be 'arr', not: "+parser.getLocalName() );
- }
-
- StringBuilder builder = new StringBuilder();
- KnownType type = null;
-
- List<Object> vals = new ArrayList<>();
-
- int depth = 0;
- while( true )
- {
- switch (parser.next()) {
- case XMLStreamConstants.START_ELEMENT:
- depth++;
- KnownType t = KnownType.get( parser.getLocalName() );
- if( t == null ) {
- throw new RuntimeException( "this must be known type! not: "+parser.getLocalName() );
- }
- if( type == null ) {
- type = t;
- }
- /*** actually, there is no rule that arrays need the same type
- else if( type != t && !(t == KnownType.NULL || type == KnownType.NULL)) {
- throw new RuntimeException( "arrays must have the same type! ("+type+"!="+t+") "+parser.getLocalName() );
- }
- ***/
- type = t;
-
- builder.setLength( 0 ); // reset the text
-
- if( !type.isLeaf ) {
- switch( type ) {
- case LST: vals.add( readNamedList( parser ) ); depth--; continue;
- case ARR: vals.add( readArray( parser ) ); depth--; continue;
- case RESULT: vals.add( readDocuments( parser ) ); depth--; continue;
- case DOC: vals.add( readDocument( parser ) ); depth--; continue;
- }
- throw new XMLStreamException( "branch element not handled!", parser.getLocation() );
- }
- break;
-
- case XMLStreamConstants.END_ELEMENT:
- if( --depth < 0 ) {
- return vals; // the last element is itself
- }
- //System.out.println( "ARR:"+type+"::"+builder );
- Object val = type.read( builder.toString().trim() );
- if( val == null && type != KnownType.NULL) {
- throw new XMLStreamException( "error reading value:"+type, parser.getLocation() );
- }
- vals.add( val );
- break;
-
- case XMLStreamConstants.SPACE: // TODO? should this be trimmed? make sure it only gets one/two space?
- case XMLStreamConstants.CDATA:
- case XMLStreamConstants.CHARACTERS:
- builder.append( parser.getText() );
- break;
- }
- }
- }
-
- protected SolrDocumentList readDocuments( XMLStreamReader parser ) throws XMLStreamException
- {
- SolrDocumentList docs = new SolrDocumentList();
-
- // Parse the attributes
- for( int i=0; i<parser.getAttributeCount(); i++ ) {
- String n = parser.getAttributeLocalName( i );
- String v = parser.getAttributeValue( i );
- if( "numFound".equals( n ) ) {
- docs.setNumFound( Long.parseLong( v ) );
- }
- else if( "start".equals( n ) ) {
- docs.setStart( Long.parseLong( v ) );
- }
- else if( "maxScore".equals( n ) ) {
- docs.setMaxScore( Float.parseFloat( v ) );
- }
- }
-
- // Read through each document
- int event;
- while( true ) {
- event = parser.next();
- if( XMLStreamConstants.START_ELEMENT == event ) {
- if( !"doc".equals( parser.getLocalName() ) ) {
- throw new RuntimeException( "should be doc! "+parser.getLocalName() + " :: " + parser.getLocation() );
- }
- docs.add( readDocument( parser ) );
- }
- else if ( XMLStreamConstants.END_ELEMENT == event ) {
- return docs; // only happens once
- }
- }
- }
-
- protected SolrDocument readDocument( XMLStreamReader parser ) throws XMLStreamException
- {
- if( XMLStreamConstants.START_ELEMENT != parser.getEventType() ) {
- throw new RuntimeException( "must be start element, not: "+parser.getEventType() );
- }
- if( !"doc".equals( parser.getLocalName().toLowerCase(Locale.ROOT) ) ) {
- throw new RuntimeException( "must be 'lst', not: "+parser.getLocalName() );
- }
-
- SolrDocument doc = new SolrDocument();
- StringBuilder builder = new StringBuilder();
- KnownType type = null;
- String name = null;
-
- // just eat up the events...
- int depth = 0;
- while( true )
- {
- switch (parser.next()) {
- case XMLStreamConstants.START_ELEMENT:
- depth++;
- builder.setLength( 0 ); // reset the text
- type = KnownType.get( parser.getLocalName() );
- if( type == null ) {
- throw new RuntimeException( "this must be known type! not: "+parser.getLocalName() );
- }
-
- name = null;
- int cnt = parser.getAttributeCount();
- for( int i=0; i<cnt; i++ ) {
- if( "name".equals( parser.getAttributeLocalName( i ) ) ) {
- name = parser.getAttributeValue( i );
- break;
- }
- }
-
- //Nested documents
- while( type == KnownType.DOC) {
- doc.addChildDocument(readDocument(parser));
- int event = parser.next();
- if (event == XMLStreamConstants.END_ELEMENT) { //Doc ends
- return doc;
- }
- }
-
- if( name == null ) {
- throw new XMLStreamException( "requires 'name' attribute: "+parser.getLocalName(), parser.getLocation() );
- }
-
- // Handle multi-valued fields
- if( type == KnownType.ARR ) {
- for( Object val : readArray( parser ) ) {
- doc.addField( name, val );
- }
- depth--; // the array reading clears out the 'endElement'
- } else if( type == KnownType.LST ) {
- doc.addField( name, readNamedList( parser ) );
- depth--;
- } else if( !type.isLeaf ) {
- System.out.println("nbot leaf!:" + type);
-
- throw new XMLStreamException( "must be value or array", parser.getLocation() );
- }
- break;
-
- case XMLStreamConstants.END_ELEMENT:
- if( --depth < 0 ) {
- return doc;
- }
- //System.out.println( "FIELD:"+type+"::"+name+"::"+builder );
- Object val = type.read( builder.toString().trim() );
- if( val == null ) {
- throw new XMLStreamException( "error reading value:"+type, parser.getLocation() );
- }
- doc.addField( name, val );
- break;
-
- case XMLStreamConstants.SPACE: // TODO? should this be trimmed? make sure it only gets one/two space?
- case XMLStreamConstants.CDATA:
- case XMLStreamConstants.CHARACTERS:
- builder.append( parser.getText() );
- break;
- }
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/package-info.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/package-info.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/package-info.java
deleted file mode 100644
index 491ef05..0000000
--- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/impl/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Concrete implementations of client API classes.
-
- */
-package org.apache.solr.client.solrj.impl;
-
-
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/package-info.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/package-info.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/package-info.java
deleted file mode 100644
index b88918e..0000000
--- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Primary APIs for communicating with a Solr Server from a Java client.
- */
-package org.apache.solr.client.solrj;
-
-
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/request/AbstractUpdateRequest.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/request/AbstractUpdateRequest.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/request/AbstractUpdateRequest.java
deleted file mode 100644
index 0588fc1..0000000
--- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/request/AbstractUpdateRequest.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * 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.client.solrj.request;
-
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.response.UpdateResponse;
-import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.params.UpdateParams;
-
-
-/**
- *
- *
- **/
-public abstract class AbstractUpdateRequest extends SolrRequest<UpdateResponse> implements IsUpdateRequest {
- protected ModifiableSolrParams params;
- protected int commitWithin = -1;
-
- public enum ACTION {
- COMMIT,
- OPTIMIZE
- }
-
- public AbstractUpdateRequest(METHOD m, String path) {
- super(m, path);
- }
-
- /** Sets appropriate parameters for the given ACTION */
- public AbstractUpdateRequest setAction(ACTION action, boolean waitFlush, boolean waitSearcher ) {
- return setAction(action, waitFlush, waitSearcher, 1);
- }
-
- public AbstractUpdateRequest setAction(ACTION action, boolean waitFlush, boolean waitSearcher, boolean softCommit ) {
- return setAction(action, waitFlush, waitSearcher, softCommit, 1);
- }
-
- public AbstractUpdateRequest setAction(ACTION action, boolean waitFlush, boolean waitSearcher, int maxSegments ) {
- return setAction(action, waitFlush, waitSearcher, false, maxSegments);
- }
-
- public AbstractUpdateRequest setAction(ACTION action, boolean waitFlush, boolean waitSearcher, boolean softCommit, int maxSegments ) {
- if (params == null)
- params = new ModifiableSolrParams();
-
- if( action == ACTION.OPTIMIZE ) {
- params.set( UpdateParams.OPTIMIZE, "true" );
- params.set(UpdateParams.MAX_OPTIMIZE_SEGMENTS, maxSegments);
- }
- else if( action == ACTION.COMMIT ) {
- params.set( UpdateParams.COMMIT, "true" );
- params.set( UpdateParams.SOFT_COMMIT, String.valueOf(softCommit));
- }
- params.set( UpdateParams.WAIT_SEARCHER, String.valueOf(waitSearcher));
- return this;
- }
-
- public AbstractUpdateRequest setAction(ACTION action, boolean waitFlush, boolean waitSearcher, int maxSegments , boolean softCommit, boolean expungeDeletes) {
- setAction(action, waitFlush, waitSearcher,softCommit,maxSegments) ;
- params.set(UpdateParams.EXPUNGE_DELETES, String.valueOf(expungeDeletes));
- return this;
- }
-
- public AbstractUpdateRequest setAction(ACTION action, boolean waitFlush, boolean waitSearcher, int maxSegments , boolean expungeDeletes) {
- return setAction(action, waitFlush, waitSearcher,maxSegments,false,expungeDeletes);
- }
-
- public AbstractUpdateRequest setAction(ACTION action, boolean waitFlush, boolean waitSearcher, int maxSegments, boolean softCommit, boolean expungeDeletes, boolean openSearcher) {
- setAction(action, waitFlush, waitSearcher, maxSegments, softCommit, expungeDeletes);
- params.set(UpdateParams.OPEN_SEARCHER, String.valueOf(openSearcher));
- return this;
- }
-
- /**
- * @since Solr 1.4
- */
- public AbstractUpdateRequest rollback() {
- if (params == null)
- params = new ModifiableSolrParams();
-
- params.set( UpdateParams.ROLLBACK, "true" );
- return this;
- }
-
- public void setParam(String param, String value) {
- if (params == null)
- params = new ModifiableSolrParams();
- params.set(param, value);
- }
-
- /** Sets the parameters for this update request, overwriting any previous */
- public void setParams(ModifiableSolrParams params) {
- this.params = params;
- }
-
- @Override
- public ModifiableSolrParams getParams() {
- return params;
- }
-
- @Override
- protected UpdateResponse createResponse(SolrClient client) {
- return new UpdateResponse();
- }
-
- public boolean isWaitSearcher() {
- return params != null && params.getBool(UpdateParams.WAIT_SEARCHER, false);
- }
-
- public ACTION getAction() {
- if (params==null) return null;
- if (params.getBool(UpdateParams.COMMIT, false)) return ACTION.COMMIT;
- if (params.getBool(UpdateParams.OPTIMIZE, false)) return ACTION.OPTIMIZE;
- return null;
- }
-
- public void setWaitSearcher(boolean waitSearcher) {
- setParam( UpdateParams.WAIT_SEARCHER, waitSearcher+"" );
- }
-
- public int getCommitWithin() {
- return commitWithin;
- }
-
- public void setCommitWithin(int commitWithin) {
- this.commitWithin = commitWithin;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
deleted file mode 100644
index 1ad0b26..0000000
--- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
+++ /dev/null
@@ -1,860 +0,0 @@
-/*
- * 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.client.solrj.request;
-
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.response.CollectionAdminResponse;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.cloud.DocCollection;
-import org.apache.solr.common.cloud.ZkStateReader;
-import org.apache.solr.common.params.CollectionParams.CollectionAction;
-import org.apache.solr.common.params.CoreAdminParams;
-import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.params.ShardParams;
-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.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * This class is experimental and subject to change.
- *
- * @since solr 4.5
- */
-public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse> {
-
- protected CollectionAction action = null;
-
- private static String PROPERTY_PREFIX = "property.";
-
- protected void setAction( CollectionAction action ) {
- this.action = action;
- }
-
- public CollectionAdminRequest()
- {
- super( METHOD.GET, "/admin/collections" );
- }
-
- public CollectionAdminRequest( String path )
- {
- super( METHOD.GET, path );
- }
-
- @Override
- public SolrParams getParams() {
- if( action == null ) {
- throw new RuntimeException( "no action specified!" );
- }
- ModifiableSolrParams params = new ModifiableSolrParams();
- params.set( CoreAdminParams.ACTION, action.toString() );
- return params;
- }
-
- @Override
- public Collection<ContentStream> getContentStreams() throws IOException {
- return null;
- }
-
- @Override
- protected CollectionAdminResponse createResponse(SolrClient client) {
- return new CollectionAdminResponse();
- }
-
- protected void addProperties(ModifiableSolrParams params, Properties props) {
- Iterator<Map.Entry<Object, Object>> iter = props.entrySet().iterator();
- while(iter.hasNext()) {
- Map.Entry<Object, Object> prop = iter.next();
- String key = (String) prop.getKey();
- String value = (String) prop.getValue();
- params.set(PROPERTY_PREFIX + key, value);
- }
- }
-
- //---------------------------------------------------------------------------------------
- //
- //---------------------------------------------------------------------------------------
-
- protected static class CollectionSpecificAdminRequest extends CollectionAdminRequest {
- protected String collection = null;
-
- public final void setCollectionName( String collectionName )
- {
- this.collection = collectionName;
- }
-
- @Override
- public SolrParams getParams() {
- ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
- params.set( CoreAdminParams.NAME, collection );
- return params;
- }
-
-
- }
-
- protected static class CollectionShardAdminRequest extends CollectionSpecificAdminRequest {
- protected String shardName = null;
-
- public void setShardName(String shard) { this.shardName = shard; }
- public String getShardName() { return this.shardName; }
-
- public ModifiableSolrParams getCommonParams() {
- ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
- params.set( "collection", collection );
- params.set( "shard", shardName);
- return params;
- }
-
- @Override
- public SolrParams getParams() {
- return getCommonParams();
- }
- }
-
- protected static class CollectionAdminRoleRequest extends CollectionAdminRequest {
- private String node;
- private String role;
-
- public void setNode(String node) {
- this.node = node;
- }
-
- public String getNode() {
- return this.node;
- }
-
- public void setRole(String role) {
- this.role = role;
- }
-
- public String getRole() {
- return this.role;
- }
-
- @Override
- public SolrParams getParams() {
- ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
- params.set("role", this.role);
- params.set("node", this.node);
- return params;
- }
-
- }
-
- /** Specific Collection API call implementations **/
-
- // CREATE request
- public static class Create extends CollectionSpecificAdminRequest {
- protected String configName = null;
- protected String createNodeSet = null;
- protected String routerName;
- protected String shards;
- protected String routerField;
- protected Integer numShards;
- protected Integer maxShardsPerNode;
- protected Integer replicationFactor;
-
- private Properties properties;
- protected Boolean autoAddReplicas;
- protected Integer stateFormat;
- protected String asyncId;
-
-
- public Create() {
- action = CollectionAction.CREATE;
- }
-
- public void setConfigName(String config) { this.configName = config; }
- public void setCreateNodeSet(String nodeSet) { this.createNodeSet = nodeSet; }
- public void setRouterName(String routerName) { this.routerName = routerName; }
- public void setShards(String shards) { this.shards = shards; }
- public void setRouterField(String routerField) { this.routerField = routerField; }
- public void setNumShards(Integer numShards) {this.numShards = numShards;}
- public void setMaxShardsPerNode(Integer numShards) { this.maxShardsPerNode = numShards; }
- public void setAutoAddReplicas(boolean autoAddReplicas) { this.autoAddReplicas = autoAddReplicas; }
- public void setReplicationFactor(Integer repl) { this.replicationFactor = repl; }
- public void setStateFormat(Integer stateFormat) { this.stateFormat = stateFormat; }
- public void setAsyncId(String asyncId) {
- this.asyncId = asyncId;
- }
-
- public String getConfigName() { return configName; }
- public String getCreateNodeSet() { return createNodeSet; }
- public String getRouterName() { return routerName; }
- public String getShards() { return shards; }
- public Integer getNumShards() { return numShards; }
- public Integer getMaxShardsPerNode() { return maxShardsPerNode; }
- public Integer getReplicationFactor() { return replicationFactor; }
- public Boolean getAutoAddReplicas() { return autoAddReplicas; }
- public Integer getStateFormat() { return stateFormat; }
- public String getAsyncId() {
- return asyncId;
- }
-
- public Properties getProperties() {
- return properties;
- }
-
- public void setProperties(Properties properties) {
- this.properties = properties;
- }
-
- @Override
- public SolrParams getParams() {
- ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
-
- params.set( "collection.configName", configName);
- params.set( "createNodeSet", createNodeSet);
- if (numShards != null) {
- params.set( ZkStateReader.NUM_SHARDS_PROP, numShards);
- }
- if (maxShardsPerNode != null) {
- params.set( "maxShardsPerNode", maxShardsPerNode);
- }
- params.set( "router.name", routerName);
- params.set("shards", shards);
- if (routerField != null) {
- params.set("router.field", routerField);
- }
- if (replicationFactor != null) {
- params.set( "replicationFactor", replicationFactor);
- }
- params.set("async", asyncId);
- if (autoAddReplicas != null) {
- params.set(ZkStateReader.AUTO_ADD_REPLICAS, autoAddReplicas);
- }
- if(properties != null) {
- addProperties(params, properties);
- }
- if (stateFormat != null) {
- params.set(DocCollection.STATE_FORMAT, stateFormat);
- }
- return params;
- }
-
- }
-
- // RELOAD request
- public static class Reload extends CollectionSpecificAdminRequest {
- public Reload() {
- action = CollectionAction.RELOAD;
- }
- }
-
- // DELETE request
- public static class Delete extends CollectionSpecificAdminRequest {
- public Delete() {
- action = CollectionAction.DELETE;
- }
- }
-
- // CREATESHARD request
- public static class CreateShard extends CollectionShardAdminRequest {
- protected String nodeSet;
- private Properties properties;
-
- public void setNodeSet(String nodeSet) {
- this.nodeSet = nodeSet;
- }
-
- public String getNodeSet() {
- return nodeSet;
- }
-
- public Properties getProperties() {
- return properties;
- }
-
- public void setProperties(Properties properties) {
- this.properties = properties;
- }
-
- public CreateShard() {
- action = CollectionAction.CREATESHARD;
- }
-
- @Override
- public SolrParams getParams() {
- ModifiableSolrParams params = getCommonParams();
- params.set( "createNodeSet", nodeSet);
- if(properties != null) {
- addProperties(params, properties);
- }
- return params;
- }
- }
-
- // SPLITSHARD request
- public static class SplitShard extends CollectionShardAdminRequest {
- protected String ranges;
- protected String splitKey;
- protected String asyncId;
-
- private Properties properties;
-
- public SplitShard() {
- action = CollectionAction.SPLITSHARD;
- }
-
- public void setRanges(String ranges) { this.ranges = ranges; }
- public String getRanges() { return ranges; }
-
- public void setSplitKey(String splitKey) {
- this.splitKey = splitKey;
- }
-
- public String getSplitKey() {
- return this.splitKey;
- }
-
- public Properties getProperties() {
- return properties;
- }
-
- public void setProperties(Properties properties) {
- this.properties = properties;
- }
-
- public void setAsyncId(String asyncId) {
- this.asyncId = asyncId;
- }
-
- public String getAsyncId() {
- return asyncId;
- }
-
- @Override
- public SolrParams getParams() {
- ModifiableSolrParams params = getCommonParams();
- params.set( "ranges", ranges);
-
- if(splitKey != null)
- params.set("split.key", this.splitKey);
-
- if(properties != null) {
- addProperties(params, properties);
- }
-
- params.set("async", asyncId);
- return params;
- }
- }
-
- // DELETESHARD request
- public static class DeleteShard extends CollectionShardAdminRequest {
- public DeleteShard() {
- action = CollectionAction.DELETESHARD;
- }
- }
-
- // REQUESTSTATUS request
- public static class RequestStatus extends CollectionAdminRequest {
- protected String requestId = null;
-
- public RequestStatus() {
- action = CollectionAction.REQUESTSTATUS;
- }
-
- public void setRequestId(String requestId) {this.requestId = requestId; }
- public String getRequestId() { return this.requestId; }
-
- @Override
- public SolrParams getParams() {
- ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
- params.set("requestid", requestId);
- return params;
- }
- }
-
- // CREATEALIAS request
- public static class CreateAlias extends CollectionAdminRequest {
- protected String aliasName;
- protected String aliasedCollections;
-
- public CreateAlias() {
- action = CollectionAction.CREATEALIAS;
- }
-
- public void setAliasName(String aliasName) {
- this.aliasName = aliasName;
- }
-
- public String getAliasName() {
- return aliasName;
- }
-
- public void setAliasedCollections(String alias) { this.aliasedCollections = alias; }
- public String getAliasedCollections() { return this.aliasedCollections; }
-
- @Deprecated
- public void setCollectionName(String aliasName) {
- this.aliasName = aliasName;
- }
-
- @Override
- public SolrParams getParams() {
- ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
- params.set("name", aliasName);
- params.set( "collections", aliasedCollections );
- return params;
- }
- }
-
- // DELETEALIAS request
- public static class DeleteAlias extends CollectionAdminRequest {
- protected String aliasName;
-
- public DeleteAlias() {
- action = CollectionAction.DELETEALIAS;
- }
-
- public void setAliasName(String aliasName) {
- this.aliasName = aliasName;
- }
-
- @Override
- public SolrParams getParams() {
- ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
- params.set("name", aliasName);
- return params;
- }
- }
-
- // ADDREPLICA request
- public static class AddReplica extends CollectionShardAdminRequest {
- private String node;
- private String routeKey;
- private String instanceDir;
- private String dataDir;
- private Properties properties;
- private String asyncId;
-
- public AddReplica() {
- action = CollectionAction.ADDREPLICA;
- }
-
- public Properties getProperties() {
- return properties;
- }
-
- public void setProperties(Properties properties) {
- this.properties = properties;
- }
-
- public String getNode() {
- return node;
- }
-
- public void setNode(String node) {
- this.node = node;
- }
-
- public String getRouteKey() {
- return routeKey;
- }
-
- public void setRouteKey(String routeKey) {
- this.routeKey = routeKey;
- }
-
- public String getInstanceDir() {
- return instanceDir;
- }
-
- public void setInstanceDir(String instanceDir) {
- this.instanceDir = instanceDir;
- }
-
- public String getDataDir() {
- return dataDir;
- }
-
- public void setDataDir(String dataDir) {
- this.dataDir = dataDir;
- }
-
- @Override
- public SolrParams getParams() {
- ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
- if (shardName == null || shardName.isEmpty()) {
- params.remove("shard");
- if (routeKey == null) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Either shard or routeKey must be provided");
- }
- params.add(ShardParams._ROUTE_, routeKey);
- }
- params.set("async", asyncId);
- if (node != null) {
- params.add("node", node);
- }
- if (instanceDir != null) {
- params.add("instanceDir", instanceDir);
- }
- if (dataDir != null) {
- params.add("dataDir", dataDir);
- }
- if (properties != null) {
- addProperties(params, properties);
- }
- return params;
- }
-
- public void setAsyncId(String asyncId) {
- this.asyncId = asyncId;
- }
-
- public String getAsyncId() {
- return asyncId;
- }
- }
-
- // DELETEREPLICA request
- public static class DeleteReplica extends CollectionShardAdminRequest {
- private String replica;
- private Boolean onlyIfDown;
-
- public DeleteReplica() {
- action = CollectionAction.DELETEREPLICA;
- }
-
- public void setReplica(String replica) {
- this.replica = replica;
- }
-
- public String getReplica() {
- return this.replica;
- }
-
- public void setOnlyIfDown(boolean onlyIfDown) {
- this.onlyIfDown = onlyIfDown;
- }
-
- public Boolean getOnlyIfDown() {
- return this.onlyIfDown;
- }
-
- @Override
- public SolrParams getParams() {
- ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
- params.set(ZkStateReader.REPLICA_PROP, this.replica);
-
- if(onlyIfDown != null) {
- params.set("onlyIfDown", this.onlyIfDown);
- }
- return params;
- }
- }
-
- // CLUSTERPROP request
- public static class ClusterProp extends CollectionAdminRequest {
- private String propertyName;
- private String propertyValue;
-
- public ClusterProp() {
- this.action = CollectionAction.CLUSTERPROP;
- }
-
- public void setPropertyName(String propertyName) {
- this.propertyName = propertyName;
- }
-
- public String getPropertyName() {
- return this.propertyName;
- }
-
- public void setPropertyValue(String propertyValue) {
- this.propertyValue = propertyValue;
- }
-
- public String getPropertyValue() {
- return this.propertyValue;
- }
-
- public SolrParams getParams() {
- ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
- params.add("name", propertyName);
- params.add("val", propertyValue);
-
- return params;
- }
-
- }
-
- // MIGRATE request
- public static class Migrate extends CollectionSpecificAdminRequest {
- private String targetCollection;
- private String splitKey;
- private Integer forwardTimeout;
- private Properties properties;
- private String asyncId;
-
- public Migrate() {
- action = CollectionAction.MIGRATE;
- }
-
- public void setTargetCollection(String targetCollection) {
- this.targetCollection = targetCollection;
- }
-
- public String getTargetCollection() {
- return this.targetCollection;
- }
-
- public void setSplitKey(String splitKey) {
- this.splitKey = splitKey;
- }
-
- public String getSplitKey() {
- return this.splitKey;
- }
-
- public void setForwardTimeout(int forwardTimeout) {
- this.forwardTimeout = forwardTimeout;
- }
-
- public Integer getForwardTimeout() {
- return this.forwardTimeout;
- }
-
- public void setProperties(Properties properties) {
- this.properties = properties;
- }
-
- public Properties getProperties() {
- return this.properties;
- }
-
- @Override
- public SolrParams getParams() {
- ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
- params.set( "collection", collection );
- params.set("target.collection", targetCollection);
- params.set("split.key", splitKey);
- if(forwardTimeout != null) {
- params.set("forward.timeout", forwardTimeout);
- }
- params.set("async", asyncId);
-
- if(properties != null) {
- addProperties(params, properties);
- }
-
- return params;
- }
-
- public void setAsyncId(String asyncId) {
- this.asyncId = asyncId;
- }
-
- public String getAsyncId() {
- return asyncId;
- }
- }
-
- // ADDROLE request
- public static class AddRole extends CollectionAdminRoleRequest {
- public AddRole() {
- action = CollectionAction.ADDROLE;
- }
- }
-
- // REMOVEROLE request
- public static class RemoveRole extends CollectionAdminRoleRequest {
- public RemoveRole() {
- action = CollectionAction.REMOVEROLE;
- }
- }
-
- // OVERSEERSTATUS request
- public static class OverseerStatus extends CollectionAdminRequest {
- public OverseerStatus () {
- action = CollectionAction.OVERSEERSTATUS;
- }
- }
-
- // CLUSTERSTATUS request
- public static class ClusterStatus extends CollectionShardAdminRequest {
-
- public ClusterStatus () {
- action = CollectionAction.CLUSTERSTATUS;
- }
-
- }
-
- // LIST request
- public static class List extends CollectionAdminRequest {
- public List () {
- action = CollectionAction.LIST;
- }
- }
-
- // ADDREPLICAPROP request
- public static class AddReplicaProp extends CollectionShardAdminRequest {
- private String replica;
- private String propertyName;
- private String propertyValue;
- private Boolean shardUnique;
-
- public AddReplicaProp() {
- action = CollectionAction.ADDREPLICAPROP;
- }
-
- public String getReplica() {
- return replica;
- }
-
- public void setReplica(String replica) {
- this.replica = replica;
- }
-
- public String getPropertyName() {
- return propertyName;
- }
-
- public void setPropertyName(String propertyName) {
- this.propertyName = propertyName;
- }
-
- public String getPropertyValue() {
- return propertyValue;
- }
-
- public void setPropertyValue(String propertyValue) {
- this.propertyValue = propertyValue;
- }
-
- public Boolean getShardUnique() {
- return shardUnique;
- }
-
- public void setShardUnique(Boolean shardUnique) {
- this.shardUnique = shardUnique;
- }
-
- @Override
- public SolrParams getParams() {
- ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
- params.set("replica", replica);
- params.set("property", propertyName);
- params.set("property.value", propertyValue);
-
- if(shardUnique != null)
- params.set("shardUnique", shardUnique);
-
- return params;
- }
-
- }
-
- // DELETEREPLICAPROP request
- public static class DeleteReplicaProp extends CollectionShardAdminRequest {
- private String replica;
- private String propertyName;
-
- public DeleteReplicaProp() {
- this.action = CollectionAction.DELETEREPLICAPROP;
- }
-
- public String getReplica() {
- return replica;
- }
-
- public void setReplica(String replica) {
- this.replica = replica;
- }
-
- public String getPropertyName() {
- return propertyName;
- }
-
- public void setPropertyName(String propertyName) {
- this.propertyName = propertyName;
- }
-
- @Override
- public SolrParams getParams() {
- ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
- params.set("replica", replica);
- params.set("property", propertyName);
- return params;
- }
- }
-
- // BALANCESHARDUNIQUE request
- public static class BalanceShardUnique extends CollectionAdminRequest {
- private String collection;
- private String propertyName;
- private Boolean onlyActiveNodes;
- private Boolean shardUnique;
-
- public BalanceShardUnique() {
- this.action = CollectionAction.BALANCESHARDUNIQUE;
- }
-
- public String getPropertyName() {
- return propertyName;
- }
-
- public void setPropertyName(String propertyName) {
- this.propertyName = propertyName;
- }
-
- public Boolean getOnlyActiveNodes() {
- return onlyActiveNodes;
- }
-
- public void setOnlyActiveNodes(Boolean onlyActiveNodes) {
- this.onlyActiveNodes = onlyActiveNodes;
- }
-
- public Boolean getShardUnique() {
- return shardUnique;
- }
-
- public void setShardUnique(Boolean shardUnique) {
- this.shardUnique = shardUnique;
- }
-
- public void setCollection(String collection) {
- this.collection = collection;
- }
-
- public String getCollection() {
- return collection;
- }
-
- @Override
- public SolrParams getParams() {
- ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
- params.set("collection", collection);
- params.set("property", propertyName);
- if(onlyActiveNodes != null)
- params.set("onlyactivenodes", onlyActiveNodes);
- if(shardUnique != null)
- params.set("shardUnique", shardUnique);
- return params;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/request/ContentStreamUpdateRequest.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/request/ContentStreamUpdateRequest.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/request/ContentStreamUpdateRequest.java
deleted file mode 100644
index 44e37c9..0000000
--- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/request/ContentStreamUpdateRequest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.client.solrj.request;
-
-import org.apache.solr.common.util.ContentStream;
-import org.apache.solr.common.util.ContentStreamBase;
-
-import java.io.IOException;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-
-/**
- * Basic functionality to upload a File or {@link org.apache.solr.common.util.ContentStream} to a Solr Cell or some
- * other handler that takes ContentStreams (CSV)
- * <p>
- * See http://wiki.apache.org/solr/ExtractingRequestHandler<br>
- * See http://wiki.apache.org/solr/UpdateCSV
- *
- *
- **/
-public class ContentStreamUpdateRequest extends AbstractUpdateRequest {
- List<ContentStream> contentStreams;
-
- /**
- *
- * @param url The URL to send the {@link org.apache.solr.common.util.ContentStream} to in Solr.
- */
- public ContentStreamUpdateRequest(String url) {
- super(METHOD.POST, url);
- contentStreams = new ArrayList<>();
- }
-
- @Override
- public Collection<ContentStream> getContentStreams() throws IOException {
- return contentStreams;
- }
-
- /**
- * Add a File to the {@link org.apache.solr.common.util.ContentStream}s.
- * @param file The File to add.
- * @throws IOException if there was an error with the file.
- *
- * @see #getContentStreams()
- * @see org.apache.solr.common.util.ContentStreamBase.FileStream
- */
- public void addFile(File file, String contentType) throws IOException {
- ContentStreamBase cs = new ContentStreamBase.FileStream(file);
- cs.setContentType(contentType);
- addContentStream(cs);
- }
-
- /**
- * Add a {@link org.apache.solr.common.util.ContentStream} to {@link #getContentStreams()}
- * @param contentStream The {@link org.apache.solr.common.util.ContentStream}
- */
- public void addContentStream(ContentStream contentStream){
- contentStreams.add(contentStream);
- }
-
-}