SOLR-14565: Fix or suppress warnings in solrj/impl and solrj/io/graph

This commit is contained in:
Erick Erickson 2020-06-12 20:06:16 -04:00
parent 8cbfb192ab
commit 6801d4c139
29 changed files with 133 additions and 81 deletions

View File

@ -336,6 +336,8 @@ Other Changes
* SOLR-14563: Fix or suppress warnings in solr/contrib (Erick Erickson) * SOLR-14563: Fix or suppress warnings in solr/contrib (Erick Erickson)
* SOLR-14565: Fix or suppress warnings in solrj/impl and solrj/io/graph (Erick Erickson)
================== 8.5.2 ================== ================== 8.5.2 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release. Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -463,6 +463,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
assertZKStateProvider().zkStateReader.registerDocCollectionWatcher(collection, watcher); assertZKStateProvider().zkStateReader.registerDocCollectionWatcher(collection, watcher);
} }
@SuppressWarnings({"unchecked"})
private NamedList<Object> directUpdate(AbstractUpdateRequest request, String collection) throws SolrServerException { private NamedList<Object> directUpdate(AbstractUpdateRequest request, String collection) throws SolrServerException {
UpdateRequest updateRequest = (UpdateRequest) request; UpdateRequest updateRequest = (UpdateRequest) request;
SolrParams params = request.getParams(); SolrParams params = request.getParams();
@ -522,6 +523,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
} }
final NamedList<Throwable> exceptions = new NamedList<>(); final NamedList<Throwable> exceptions = new NamedList<>();
@SuppressWarnings({"rawtypes"})
final NamedList<NamedList> shardResponses = new NamedList<>(routes.size()+1); // +1 for deleteQuery final NamedList<NamedList> shardResponses = new NamedList<>(routes.size()+1); // +1 for deleteQuery
long start = System.nanoTime(); long start = System.nanoTime();
@ -612,6 +614,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
long end = System.nanoTime(); long end = System.nanoTime();
@SuppressWarnings({"rawtypes"})
RouteResponse rr = condenseResponse(shardResponses, (int) TimeUnit.MILLISECONDS.convert(end - start, TimeUnit.NANOSECONDS)); RouteResponse rr = condenseResponse(shardResponses, (int) TimeUnit.MILLISECONDS.convert(end - start, TimeUnit.NANOSECONDS));
rr.setRouteResponses(shardResponses); rr.setRouteResponses(shardResponses);
rr.setRoutes(routes); rr.setRoutes(routes);
@ -670,6 +673,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
return urlMap; return urlMap;
} }
@SuppressWarnings({"unchecked", "rawtypes"})
protected <T extends RouteResponse> T condenseResponse(NamedList response, int timeMillis, Supplier<T> supplier) { protected <T extends RouteResponse> T condenseResponse(NamedList response, int timeMillis, Supplier<T> supplier) {
T condensed = supplier.get(); T condensed = supplier.get();
int status = 0; int status = 0;
@ -766,10 +770,12 @@ public abstract class BaseCloudSolrClient extends SolrClient {
return condensed; return condensed;
} }
@SuppressWarnings({"rawtypes"})
public RouteResponse condenseResponse(NamedList response, int timeMillis) { public RouteResponse condenseResponse(NamedList response, int timeMillis) {
return condenseResponse(response, timeMillis, RouteResponse::new); return condenseResponse(response, timeMillis, RouteResponse::new);
} }
@SuppressWarnings({"rawtypes"})
public static class RouteResponse<T extends LBSolrClient.Req> extends NamedList { public static class RouteResponse<T extends LBSolrClient.Req> extends NamedList {
private NamedList routeResponses; private NamedList routeResponses;
private Map<String, T> routes; private Map<String, T> routes;
@ -829,7 +835,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
} }
@Override @Override
public NamedList<Object> request(SolrRequest request, String collection) throws SolrServerException, IOException { public NamedList<Object> request(@SuppressWarnings({"rawtypes"})SolrRequest request, String collection) throws SolrServerException, IOException {
// the collection parameter of the request overrides that of the parameter to this method // the collection parameter of the request overrides that of the parameter to this method
String requestCollection = request.getCollection(); String requestCollection = request.getCollection();
if (requestCollection != null) { if (requestCollection != null) {
@ -847,7 +853,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
* there's a chance that the request will fail due to cached stale state, * there's a chance that the request will fail due to cached stale state,
* which means the state must be refreshed from ZK and retried. * which means the state must be refreshed from ZK and retried.
*/ */
protected NamedList<Object> requestWithRetryOnStaleState(SolrRequest request, int retryCount, List<String> inputCollections) protected NamedList<Object> requestWithRetryOnStaleState(@SuppressWarnings({"rawtypes"})SolrRequest request, int retryCount, List<String> inputCollections)
throws SolrServerException, IOException { throws SolrServerException, IOException {
connect(); // important to call this before you start working with the ZkStateReader connect(); // important to call this before you start working with the ZkStateReader
@ -911,8 +917,10 @@ public abstract class BaseCloudSolrClient extends SolrClient {
if(o != null && o instanceof Map) { if(o != null && o instanceof Map) {
//remove this because no one else needs this and tests would fail if they are comparing responses //remove this because no one else needs this and tests would fail if they are comparing responses
resp.remove(resp.size()-1); resp.remove(resp.size()-1);
@SuppressWarnings({"rawtypes"})
Map invalidStates = (Map) o; Map invalidStates = (Map) o;
for (Object invalidEntries : invalidStates.entrySet()) { for (Object invalidEntries : invalidStates.entrySet()) {
@SuppressWarnings({"rawtypes"})
Map.Entry e = (Map.Entry) invalidEntries; Map.Entry e = (Map.Entry) invalidEntries;
getDocCollection((String) e.getKey(), (Integer) e.getValue()); getDocCollection((String) e.getKey(), (Integer) e.getValue());
} }
@ -1030,7 +1038,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
return resp; return resp;
} }
protected NamedList<Object> sendRequest(SolrRequest request, List<String> inputCollections) protected NamedList<Object> sendRequest(@SuppressWarnings({"rawtypes"})SolrRequest request, List<String> inputCollections)
throws SolrServerException, IOException { throws SolrServerException, IOException {
connect(); connect();
@ -1205,6 +1213,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
//it is readily available just return it //it is readily available just return it
return ref.get(); return ref.get();
} }
@SuppressWarnings({"rawtypes"})
List locks = this.locks; List locks = this.locks;
final Object lock = locks.get(Math.abs(Hash.murmurhash3_x86_32(collection, 0, collection.length(), 0) % locks.size())); final Object lock = locks.get(Math.abs(Hash.murmurhash3_x86_32(collection, 0, collection.length(), 0) % locks.size()));
DocCollection fetchedCol = null; DocCollection fetchedCol = null;
@ -1262,7 +1271,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
* the replication factor that was achieved in each shard involved in the request. * the replication factor that was achieved in each shard involved in the request.
* For single doc updates, there will be only one shard in the return value. * For single doc updates, there will be only one shard in the return value.
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings({"unchecked", "rawtypes"})
public Map<String,Integer> getShardReplicationFactor(String collection, NamedList resp) { public Map<String,Integer> getShardReplicationFactor(String collection, NamedList resp) {
connect(); connect();

View File

@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
import static org.apache.solr.client.solrj.impl.BaseHttpSolrClient.*; import static org.apache.solr.client.solrj.impl.BaseHttpSolrClient.*;
@SuppressWarnings({"unchecked"})
public abstract class BaseHttpClusterStateProvider implements ClusterStateProvider { public abstract class BaseHttpClusterStateProvider implements ClusterStateProvider {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@ -108,7 +109,7 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
+ " solrUrl(s) or zkHost(s)."); + " solrUrl(s) or zkHost(s).");
} }
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes"})
private ClusterState fetchClusterState(SolrClient client, String collection, Map<String, Object> clusterProperties) throws SolrServerException, IOException, NotACollectionException { private ClusterState fetchClusterState(SolrClient client, String collection, Map<String, Object> clusterProperties) throws SolrServerException, IOException, NotACollectionException {
ModifiableSolrParams params = new ModifiableSolrParams(); ModifiableSolrParams params = new ModifiableSolrParams();
if (collection != null) { if (collection != null) {
@ -179,6 +180,7 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
} }
} }
@SuppressWarnings({"rawtypes"})
private static Set<String> fetchLiveNodes(SolrClient client) throws Exception { private static Set<String> fetchLiveNodes(SolrClient client) throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams(); ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", "CLUSTERSTATUS"); params.set("action", "CLUSTERSTATUS");

View File

@ -49,15 +49,16 @@ public abstract class BaseHttpSolrClient extends SolrClient {
* it sends a proper payload back to the client * it sends a proper payload back to the client
*/ */
public static class RemoteExecutionException extends RemoteSolrException { public static class RemoteExecutionException extends RemoteSolrException {
@SuppressWarnings({"rawtypes"})
private NamedList meta; private NamedList meta;
public RemoteExecutionException(String remoteHost, int code, String msg, NamedList meta) { public RemoteExecutionException(String remoteHost, int code, String msg, @SuppressWarnings({"rawtypes"})NamedList meta) {
super(remoteHost, code, msg, null); super(remoteHost, code, msg, null);
this.meta = meta; this.meta = meta;
} }
public static RemoteExecutionException create(String host, NamedList errResponse) { public static RemoteExecutionException create(String host, @SuppressWarnings({"rawtypes"})NamedList errResponse) {
Object errObj = errResponse.get("error"); Object errObj = errResponse.get("error");
if (errObj != null) { if (errObj != null) {
Number code = (Number) getObjectByPath(errObj, true, Collections.singletonList("code")); Number code = (Number) getObjectByPath(errObj, true, Collections.singletonList("code"));
@ -71,6 +72,7 @@ public abstract class BaseHttpSolrClient extends SolrClient {
} }
@SuppressWarnings({"rawtypes"})
public NamedList getMetaData() { public NamedList getMetaData() {
return meta; return meta;

View File

@ -39,7 +39,7 @@ import static org.apache.solr.common.params.CommonParams.JAVABIN_MIME;
public class BinaryRequestWriter extends RequestWriter { public class BinaryRequestWriter extends RequestWriter {
@Override @Override
public ContentWriter getContentWriter(SolrRequest req) { public ContentWriter getContentWriter(@SuppressWarnings({"rawtypes"})SolrRequest req) {
if (req instanceof UpdateRequest) { if (req instanceof UpdateRequest) {
UpdateRequest updateRequest = (UpdateRequest) req; UpdateRequest updateRequest = (UpdateRequest) req;
if (isEmpty(updateRequest)) return null; if (isEmpty(updateRequest)) return null;
@ -60,7 +60,7 @@ public class BinaryRequestWriter extends RequestWriter {
} }
@Override @Override
public Collection<ContentStream> getContentStreams(SolrRequest req) throws IOException { public Collection<ContentStream> getContentStreams(@SuppressWarnings({"rawtypes"})SolrRequest req) throws IOException {
if (req instanceof UpdateRequest) { if (req instanceof UpdateRequest) {
UpdateRequest updateRequest = (UpdateRequest) req; UpdateRequest updateRequest = (UpdateRequest) req;
if (isEmpty(updateRequest) ) return null; if (isEmpty(updateRequest) ) return null;
@ -77,7 +77,7 @@ public class BinaryRequestWriter extends RequestWriter {
} }
@Override @Override
public void write(SolrRequest request, OutputStream os) throws IOException { public void write(@SuppressWarnings({"rawtypes"})SolrRequest request, OutputStream os) throws IOException {
if (request instanceof UpdateRequest) { if (request instanceof UpdateRequest) {
UpdateRequest updateRequest = (UpdateRequest) request; UpdateRequest updateRequest = (UpdateRequest) request;
new JavaBinUpdateRequestCodec().marshal(updateRequest, os); new JavaBinUpdateRequestCodec().marshal(updateRequest, os);

View File

@ -45,6 +45,7 @@ public class BinaryResponseParser extends ResponseParser {
} }
@Override @Override
@SuppressWarnings({"unchecked"})
public NamedList<Object> processResponse(InputStream body, String encoding) { public NamedList<Object> processResponse(InputStream body, String encoding) {
try { try {
return (NamedList<Object>) createCodec().unmarshal(body); return (NamedList<Object>) createCodec().unmarshal(body);

View File

@ -135,7 +135,7 @@ public class CloudSolrClient extends BaseCloudSolrClient {
* @deprecated since Solr 8.0 * @deprecated since Solr 8.0
*/ */
@Deprecated @Deprecated
public RouteResponse condenseResponse(NamedList response, int timeMillis) { public RouteResponse condenseResponse(@SuppressWarnings({"rawtypes"})NamedList response, int timeMillis) {
return condenseResponse(response, timeMillis, RouteResponse::new); return condenseResponse(response, timeMillis, RouteResponse::new);
} }

View File

@ -89,6 +89,7 @@ public interface ClusterStateProvider extends SolrCloseable {
* Obtain a cluster property, or the default value if it doesn't exist. * Obtain a cluster property, or the default value if it doesn't exist.
*/ */
default <T> T getClusterProperty(String key, T defaultValue) { default <T> T getClusterProperty(String key, T defaultValue) {
@SuppressWarnings({"unchecked"})
T value = (T) getClusterProperties().get(key); T value = (T) getClusterProperties().get(key);
if (value == null) if (value == null)
return defaultValue; return defaultValue;
@ -98,6 +99,7 @@ public interface ClusterStateProvider extends SolrCloseable {
/** /**
* Obtain a cluster property, or null if it doesn't exist. * Obtain a cluster property, or null if it doesn't exist.
*/ */
@SuppressWarnings({"unchecked"})
default <T> T getClusterProperty(String propertyName) { default <T> T getClusterProperty(String propertyName) {
return (T) getClusterProperties().get(propertyName); return (T) getClusterProperties().get(propertyName);
} }

View File

@ -209,6 +209,7 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
// Pull from the queue multiple times and streams over a single connection. // Pull from the queue multiple times and streams over a single connection.
// Exits on exception, interruption, or an empty queue to pull from. // Exits on exception, interruption, or an empty queue to pull from.
// //
@SuppressWarnings({"unchecked"})
void sendUpdateStream() throws Exception { void sendUpdateStream() throws Exception {
try { try {
@ -345,7 +346,7 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
} }
@Override @Override
public NamedList<Object> request(final SolrRequest request, String collection) public NamedList<Object> request(@SuppressWarnings({"rawtypes"})final SolrRequest request, String collection)
throws SolrServerException, IOException { throws SolrServerException, IOException {
if (!(request instanceof UpdateRequest)) { if (!(request instanceof UpdateRequest)) {
request.setBasePath(basePath); request.setBasePath(basePath);

View File

@ -171,6 +171,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
/** /**
* Opens a connection and sends everything... * Opens a connection and sends everything...
*/ */
@SuppressWarnings({"unchecked"})
class Runner implements Runnable { class Runner implements Runnable {
volatile Thread thread = null; volatile Thread thread = null;
volatile boolean inPoll = false; volatile boolean inPoll = false;
@ -481,7 +482,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
} }
@Override @Override
public NamedList<Object> request(final SolrRequest request, String collection) public NamedList<Object> request(@SuppressWarnings({"rawtypes"})final SolrRequest request, String collection)
throws SolrServerException, IOException { throws SolrServerException, IOException {
if (!(request instanceof UpdateRequest)) { if (!(request instanceof UpdateRequest)) {
return client.request(request, collection); return client.request(request, collection);

View File

@ -88,7 +88,7 @@ public class DelegationTokenHttpSolrClient extends HttpSolrClient {
} }
@Override @Override
protected HttpRequestBase createMethod(final SolrRequest request, String collection) throws IOException, SolrServerException { protected HttpRequestBase createMethod(@SuppressWarnings({"rawtypes"})final SolrRequest request, String collection) throws IOException, SolrServerException {
SolrParams params = request.getParams(); SolrParams params = request.getParams();
if (params != null && params.getParams(DELEGATION_TOKEN_PARAM) != null) { if (params != null && params.getParams(DELEGATION_TOKEN_PARAM) != null) {
throw new IllegalArgumentException(DELEGATION_TOKEN_PARAM + " parameter not supported"); throw new IllegalArgumentException(DELEGATION_TOKEN_PARAM + " parameter not supported");

View File

@ -22,6 +22,7 @@ import java.util.List;
import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrClient;
@SuppressWarnings({"unchecked"})
public class Http2ClusterStateProvider extends BaseHttpClusterStateProvider { public class Http2ClusterStateProvider extends BaseHttpClusterStateProvider {
final Http2SolrClient httpClient; final Http2SolrClient httpClient;
final boolean closeClient; final boolean closeClient;

View File

@ -244,7 +244,7 @@ public class Http2SolrClient extends SolrClient {
assert ObjectReleaseTracker.release(this); assert ObjectReleaseTracker.release(this);
} }
public boolean isV2ApiRequest(final SolrRequest request) { public boolean isV2ApiRequest(@SuppressWarnings({"rawtypes"})final SolrRequest request) {
return request instanceof V2Request || request.getPath().contains("/____v2"); return request instanceof V2Request || request.getPath().contains("/____v2");
} }
@ -268,7 +268,7 @@ public class Http2SolrClient extends SolrClient {
this.isXml = isXml; this.isXml = isXml;
} }
boolean belongToThisStream(SolrRequest solrRequest, String collection) { boolean belongToThisStream(@SuppressWarnings({"rawtypes"})SolrRequest solrRequest, String collection) {
ModifiableSolrParams solrParams = new ModifiableSolrParams(solrRequest.getParams()); ModifiableSolrParams solrParams = new ModifiableSolrParams(solrRequest.getParams());
if (!origParams.toNamedList().equals(solrParams.toNamedList()) || !StringUtils.equals(origCollection, collection)) { if (!origParams.toNamedList().equals(solrParams.toNamedList()) || !StringUtils.equals(origCollection, collection)) {
return false; return false;
@ -336,7 +336,7 @@ public class Http2SolrClient extends SolrClient {
return outStream; return outStream;
} }
public void send(OutStream outStream, SolrRequest req, String collection) throws IOException { public void send(OutStream outStream, @SuppressWarnings({"rawtypes"})SolrRequest req, String collection) throws IOException {
assert outStream.belongToThisStream(req, collection); assert outStream.belongToThisStream(req, collection);
this.requestWriter.write(req, outStream.outProvider.getOutputStream()); this.requestWriter.write(req, outStream.outProvider.getOutputStream());
if (outStream.isXml) { if (outStream.isXml) {
@ -361,7 +361,7 @@ public class Http2SolrClient extends SolrClient {
outStream.flush(); outStream.flush();
} }
public NamedList<Object> request(SolrRequest solrRequest, public NamedList<Object> request(@SuppressWarnings({"rawtypes"})SolrRequest solrRequest,
String collection, String collection,
OnComplete onComplete) throws IOException, SolrServerException { OnComplete onComplete) throws IOException, SolrServerException {
Request req = makeRequest(solrRequest, collection); Request req = makeRequest(solrRequest, collection);
@ -436,7 +436,7 @@ public class Http2SolrClient extends SolrClient {
return StringUtils.isEmpty(contentType)? null : ContentType.parse(contentType); return StringUtils.isEmpty(contentType)? null : ContentType.parse(contentType);
} }
private void setBasicAuthHeader(SolrRequest solrRequest, Request req) { private void setBasicAuthHeader(@SuppressWarnings({"rawtypes"})SolrRequest solrRequest, Request req) {
if (solrRequest.getBasicAuthUser() != null && solrRequest.getBasicAuthPassword() != null) { if (solrRequest.getBasicAuthUser() != null && solrRequest.getBasicAuthPassword() != null) {
String userPass = solrRequest.getBasicAuthUser() + ":" + solrRequest.getBasicAuthPassword(); String userPass = solrRequest.getBasicAuthUser() + ":" + solrRequest.getBasicAuthPassword();
String encoded = Base64.byteArrayToBase64(userPass.getBytes(FALLBACK_CHARSET)); String encoded = Base64.byteArrayToBase64(userPass.getBytes(FALLBACK_CHARSET));
@ -444,14 +444,14 @@ public class Http2SolrClient extends SolrClient {
} }
} }
private Request makeRequest(SolrRequest solrRequest, String collection) private Request makeRequest(@SuppressWarnings({"rawtypes"})SolrRequest solrRequest, String collection)
throws SolrServerException, IOException { throws SolrServerException, IOException {
Request req = createRequest(solrRequest, collection); Request req = createRequest(solrRequest, collection);
decorateRequest(req, solrRequest); decorateRequest(req, solrRequest);
return req; return req;
} }
private void decorateRequest(Request req, SolrRequest solrRequest) { private void decorateRequest(Request req, @SuppressWarnings({"rawtypes"})SolrRequest solrRequest) {
req.header(HttpHeader.ACCEPT_ENCODING, null); req.header(HttpHeader.ACCEPT_ENCODING, null);
if (solrRequest.getUserPrincipal() != null) { if (solrRequest.getUserPrincipal() != null) {
req.attribute(REQ_PRINCIPAL_KEY, solrRequest.getUserPrincipal()); req.attribute(REQ_PRINCIPAL_KEY, solrRequest.getUserPrincipal());
@ -465,6 +465,7 @@ public class Http2SolrClient extends SolrClient {
req.onComplete(listener); req.onComplete(listener);
} }
@SuppressWarnings({"unchecked"})
Map<String, String> headers = solrRequest.getHeaders(); Map<String, String> headers = solrRequest.getHeaders();
if (headers != null) { if (headers != null) {
for (Map.Entry<String, String> entry : headers.entrySet()) { for (Map.Entry<String, String> entry : headers.entrySet()) {
@ -479,7 +480,8 @@ public class Http2SolrClient extends SolrClient {
return new URL(oldURL.getProtocol(), oldURL.getHost(), oldURL.getPort(), newPath).toString(); return new URL(oldURL.getProtocol(), oldURL.getHost(), oldURL.getPort(), newPath).toString();
} }
private Request createRequest(SolrRequest solrRequest, String collection) throws IOException, SolrServerException { @SuppressWarnings({"unchecked"})
private Request createRequest(@SuppressWarnings({"rawtypes"})SolrRequest solrRequest, String collection) throws IOException, SolrServerException {
if (solrRequest.getBasePath() == null && serverBaseUrl == null) if (solrRequest.getBasePath() == null && serverBaseUrl == null)
throw new IllegalArgumentException("Destination node is not provided!"); throw new IllegalArgumentException("Destination node is not provided!");
@ -630,7 +632,7 @@ public class Http2SolrClient extends SolrClient {
return processor == null || processor instanceof InputStreamResponseParser; return processor == null || processor instanceof InputStreamResponseParser;
} }
@SuppressWarnings({"unchecked"}) @SuppressWarnings({"unchecked", "rawtypes"})
private NamedList<Object> processErrorsAndResponse(Response response, private NamedList<Object> processErrorsAndResponse(Response response,
final ResponseParser processor, final ResponseParser processor,
InputStream is, InputStream is,
@ -749,7 +751,7 @@ public class Http2SolrClient extends SolrClient {
} }
@Override @Override
public NamedList<Object> request(SolrRequest request, String collection) throws SolrServerException, IOException { public NamedList<Object> request(@SuppressWarnings({"rawtypes"})SolrRequest request, String collection) throws SolrServerException, IOException {
return request(request, collection, null); return request(request, collection, null);
} }

View File

@ -22,6 +22,7 @@ import java.util.List;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrClient;
@SuppressWarnings({"unchecked"})
public class HttpClusterStateProvider extends BaseHttpClusterStateProvider { public class HttpClusterStateProvider extends BaseHttpClusterStateProvider {
private final HttpClient httpClient; private final HttpClient httpClient;

View File

@ -239,7 +239,7 @@ public class HttpSolrClient extends BaseHttpSolrClient {
* org.apache.solr.client.solrj.ResponseParser) * org.apache.solr.client.solrj.ResponseParser)
*/ */
@Override @Override
public NamedList<Object> request(final SolrRequest request, String collection) public NamedList<Object> request(@SuppressWarnings({"rawtypes"})final SolrRequest request, String collection)
throws SolrServerException, IOException { throws SolrServerException, IOException {
ResponseParser responseParser = request.getResponseParser(); ResponseParser responseParser = request.getResponseParser();
if (responseParser == null) { if (responseParser == null) {
@ -248,15 +248,16 @@ public class HttpSolrClient extends BaseHttpSolrClient {
return request(request, responseParser, collection); return request(request, responseParser, collection);
} }
public NamedList<Object> request(final SolrRequest request, final ResponseParser processor) throws SolrServerException, IOException { public NamedList<Object> request(@SuppressWarnings({"rawtypes"})final SolrRequest request, final ResponseParser processor) throws SolrServerException, IOException {
return request(request, processor, null); return request(request, processor, null);
} }
public NamedList<Object> request(final SolrRequest request, final ResponseParser processor, String collection) public NamedList<Object> request(@SuppressWarnings({"rawtypes"})final SolrRequest request, final ResponseParser processor, String collection)
throws SolrServerException, IOException { throws SolrServerException, IOException {
HttpRequestBase method = createMethod(request, collection); HttpRequestBase method = createMethod(request, collection);
setBasicAuthHeader(request, method); setBasicAuthHeader(request, method);
if (request.getHeaders() != null) { if (request.getHeaders() != null) {
@SuppressWarnings({"unchecked"})
Map<String, String> headers = request.getHeaders(); Map<String, String> headers = request.getHeaders();
for (Map.Entry<String, String> entry : headers.entrySet()) { for (Map.Entry<String, String> entry : headers.entrySet()) {
method.setHeader(entry.getKey(), entry.getValue()); method.setHeader(entry.getKey(), entry.getValue());
@ -265,11 +266,11 @@ public class HttpSolrClient extends BaseHttpSolrClient {
return executeMethod(method, request.getUserPrincipal(), processor, isV2ApiRequest(request)); return executeMethod(method, request.getUserPrincipal(), processor, isV2ApiRequest(request));
} }
private boolean isV2ApiRequest(final SolrRequest request) { private boolean isV2ApiRequest(@SuppressWarnings({"rawtypes"})final SolrRequest request) {
return request instanceof V2Request || request.getPath().contains("/____v2"); return request instanceof V2Request || request.getPath().contains("/____v2");
} }
private void setBasicAuthHeader(SolrRequest request, HttpRequestBase method) throws UnsupportedEncodingException { private void setBasicAuthHeader(@SuppressWarnings({"rawtypes"})SolrRequest request, HttpRequestBase method) throws UnsupportedEncodingException {
if (request.getBasicAuthUser() != null && request.getBasicAuthPassword() != null) { if (request.getBasicAuthUser() != null && request.getBasicAuthPassword() != null) {
String userPass = request.getBasicAuthUser() + ":" + request.getBasicAuthPassword(); String userPass = request.getBasicAuthUser() + ":" + request.getBasicAuthPassword();
String encoded = Base64.byteArrayToBase64(userPass.getBytes(FALLBACK_CHARSET)); String encoded = Base64.byteArrayToBase64(userPass.getBytes(FALLBACK_CHARSET));
@ -288,7 +289,7 @@ public class HttpSolrClient extends BaseHttpSolrClient {
/** /**
* @lucene.experimental * @lucene.experimental
*/ */
public HttpUriRequestResponse httpUriRequest(final SolrRequest request) public HttpUriRequestResponse httpUriRequest(@SuppressWarnings({"rawtypes"})final SolrRequest request)
throws SolrServerException, IOException { throws SolrServerException, IOException {
ResponseParser responseParser = request.getResponseParser(); ResponseParser responseParser = request.getResponseParser();
if (responseParser == null) { if (responseParser == null) {
@ -300,7 +301,7 @@ public class HttpSolrClient extends BaseHttpSolrClient {
/** /**
* @lucene.experimental * @lucene.experimental
*/ */
public HttpUriRequestResponse httpUriRequest(final SolrRequest request, final ResponseParser processor) throws SolrServerException, IOException { public HttpUriRequestResponse httpUriRequest(@SuppressWarnings({"rawtypes"})final SolrRequest request, final ResponseParser processor) throws SolrServerException, IOException {
HttpUriRequestResponse mrr = new HttpUriRequestResponse(); HttpUriRequestResponse mrr = new HttpUriRequestResponse();
final HttpRequestBase method = createMethod(request, null); final HttpRequestBase method = createMethod(request, null);
ExecutorService pool = ExecutorUtil.newMDCAwareFixedThreadPool(1, new SolrNamedThreadFactory("httpUriRequest")); ExecutorService pool = ExecutorUtil.newMDCAwareFixedThreadPool(1, new SolrNamedThreadFactory("httpUriRequest"));
@ -340,7 +341,8 @@ public class HttpSolrClient extends BaseHttpSolrClient {
return new URL(oldURL.getProtocol(), oldURL.getHost(), oldURL.getPort(), newPath).toString(); return new URL(oldURL.getProtocol(), oldURL.getHost(), oldURL.getPort(), newPath).toString();
} }
protected HttpRequestBase createMethod(SolrRequest request, String collection) throws IOException, SolrServerException { @SuppressWarnings({"unchecked"})
protected HttpRequestBase createMethod(@SuppressWarnings({"rawtypes"})SolrRequest request, String collection) throws IOException, SolrServerException {
if (request instanceof V2RequestSupport) { if (request instanceof V2RequestSupport) {
request = ((V2RequestSupport) request).getV2Request(); request = ((V2RequestSupport) request).getV2Request();
} }
@ -474,7 +476,11 @@ public class HttpSolrClient extends BaseHttpSolrClient {
} }
private HttpEntityEnclosingRequestBase fillContentStream(SolrRequest request, Collection<ContentStream> streams, ModifiableSolrParams wparams, boolean isMultipart, LinkedList<NameValuePair> postOrPutParams, String fullQueryUrl) throws IOException { private HttpEntityEnclosingRequestBase fillContentStream(
@SuppressWarnings({"rawtypes"})SolrRequest request,
Collection<ContentStream> streams, ModifiableSolrParams wparams,
boolean isMultipart, LinkedList<NameValuePair> postOrPutParams,
String fullQueryUrl) throws IOException {
HttpEntityEnclosingRequestBase postOrPut = SolrRequest.METHOD.POST == request.getMethod() ? HttpEntityEnclosingRequestBase postOrPut = SolrRequest.METHOD.POST == request.getMethod() ?
new HttpPost(fullQueryUrl) : new HttpPut(fullQueryUrl); new HttpPost(fullQueryUrl) : new HttpPut(fullQueryUrl);
@ -533,7 +539,7 @@ public class HttpSolrClient extends BaseHttpSolrClient {
private static final List<String> errPath = Arrays.asList("metadata", "error-class");//Utils.getObjectByPath(err, false,"metadata/error-class") private static final List<String> errPath = Arrays.asList("metadata", "error-class");//Utils.getObjectByPath(err, false,"metadata/error-class")
@SuppressWarnings({"unchecked"}) @SuppressWarnings({"unchecked", "rawtypes"})
protected NamedList<Object> executeMethod(HttpRequestBase method, Principal userPrincipal, final ResponseParser processor, final boolean isV2Api) throws SolrServerException { protected NamedList<Object> executeMethod(HttpRequestBase method, Principal userPrincipal, final ResponseParser processor, final boolean isV2Api) throws SolrServerException {
method.addHeader("User-Agent", AGENT); method.addHeader("User-Agent", AGENT);

View File

@ -208,6 +208,7 @@ public class Krb5HttpClientBuilder implements HttpClientBuilderFactory {
private javax.security.auth.login.Configuration baseConfig; private javax.security.auth.login.Configuration baseConfig;
// the com.sun.security.jgss appNames // the com.sun.security.jgss appNames
@SuppressWarnings({"unchecked", "rawtypes"})
private Set<String> initiateAppNames = new HashSet( private Set<String> initiateAppNames = new HashSet(
Arrays.asList("com.sun.security.jgss.krb5.initiate", "com.sun.security.jgss.initiate")); Arrays.asList("com.sun.security.jgss.krb5.initiate", "com.sun.security.jgss.initiate"));

View File

@ -80,11 +80,11 @@ public class LBHttpSolrClient extends LBSolrClient {
*/ */
@Deprecated @Deprecated
public static class Req extends LBSolrClient.Req { public static class Req extends LBSolrClient.Req {
public Req(SolrRequest request, List<String> servers) { public Req(@SuppressWarnings({"rawtypes"})SolrRequest request, List<String> servers) {
super(request, servers); super(request, servers);
} }
public Req(SolrRequest request, List<String> servers, Integer numServersToTry) { public Req(@SuppressWarnings({"rawtypes"})SolrRequest request, List<String> servers, Integer numServersToTry) {
super(request, servers, numServersToTry); super(request, servers, numServersToTry);
} }
} }

View File

@ -138,22 +138,24 @@ public abstract class LBSolrClient extends SolrClient {
public static class Req { public static class Req {
@SuppressWarnings({"rawtypes"})
protected SolrRequest request; protected SolrRequest request;
protected List<String> servers; protected List<String> servers;
protected int numDeadServersToTry; protected int numDeadServersToTry;
private final Integer numServersToTry; private final Integer numServersToTry;
public Req(SolrRequest request, List<String> servers) { public Req(@SuppressWarnings({"rawtypes"})SolrRequest request, List<String> servers) {
this(request, servers, null); this(request, servers, null);
} }
public Req(SolrRequest request, List<String> servers, Integer numServersToTry) { public Req(@SuppressWarnings({"rawtypes"})SolrRequest request, List<String> servers, Integer numServersToTry) {
this.request = request; this.request = request;
this.servers = servers; this.servers = servers;
this.numDeadServersToTry = servers.size(); this.numDeadServersToTry = servers.size();
this.numServersToTry = numServersToTry; this.numServersToTry = numServersToTry;
} }
@SuppressWarnings({"rawtypes"})
public SolrRequest getRequest() { public SolrRequest getRequest() {
return request; return request;
} }
@ -349,7 +351,7 @@ public abstract class LBSolrClient extends SolrClient {
/** /**
* @return time allowed in nanos, returns -1 if no time_allowed is specified. * @return time allowed in nanos, returns -1 if no time_allowed is specified.
*/ */
private long getTimeAllowedInNanos(final SolrRequest req) { private long getTimeAllowedInNanos(@SuppressWarnings({"rawtypes"})final SolrRequest req) {
SolrParams reqParams = req.getParams(); SolrParams reqParams = req.getParams();
return reqParams == null ? -1 : return reqParams == null ? -1 :
TimeUnit.NANOSECONDS.convert(reqParams.getInt(CommonParams.TIME_ALLOWED, -1), TimeUnit.MILLISECONDS); TimeUnit.NANOSECONDS.convert(reqParams.getInt(CommonParams.TIME_ALLOWED, -1), TimeUnit.MILLISECONDS);
@ -576,12 +578,12 @@ public abstract class LBSolrClient extends SolrClient {
* @throws IOException If there is a low-level I/O error. * @throws IOException If there is a low-level I/O error.
*/ */
@Override @Override
public NamedList<Object> request(final SolrRequest request, String collection) public NamedList<Object> request(@SuppressWarnings({"rawtypes"})final SolrRequest request, String collection)
throws SolrServerException, IOException { throws SolrServerException, IOException {
return request(request, collection, null); return request(request, collection, null);
} }
public NamedList<Object> request(final SolrRequest request, String collection, public NamedList<Object> request(@SuppressWarnings({"rawtypes"})final SolrRequest request, String collection,
final Integer numServersToTry) throws SolrServerException, IOException { final Integer numServersToTry) throws SolrServerException, IOException {
Exception ex = null; Exception ex = null;
ServerWrapper[] serverList = aliveServerList; ServerWrapper[] serverList = aliveServerList;
@ -678,7 +680,8 @@ public abstract class LBSolrClient extends SolrClient {
* @param request the request will be sent to the picked server * @param request the request will be sent to the picked server
* @return the picked server * @return the picked server
*/ */
protected ServerWrapper pickServer(ServerWrapper[] aliveServerList, SolrRequest request) { protected ServerWrapper pickServer(ServerWrapper[] aliveServerList,
@SuppressWarnings({"rawtypes"})SolrRequest request) {
int count = counter.incrementAndGet() & Integer.MAX_VALUE; int count = counter.incrementAndGet() & Integer.MAX_VALUE;
return aliveServerList[count % aliveServerList.length]; return aliveServerList[count % aliveServerList.length];
} }

View File

@ -124,7 +124,7 @@ public class SolrClientCloudManager implements SolrCloudManager {
} }
@Override @Override
public SolrResponse request(SolrRequest req) throws IOException { public SolrResponse request(@SuppressWarnings({"rawtypes"})SolrRequest req) throws IOException {
try { try {
return req.process(solrClient); return req.process(solrClient);
} catch (SolrServerException e) { } catch (SolrServerException e) {

View File

@ -78,6 +78,7 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter
private final CloudSolrClient solrClient; private final CloudSolrClient solrClient;
protected final Map<String, Map<String, Map<String, List<ReplicaInfo>>>> nodeVsCollectionVsShardVsReplicaInfo = new HashMap<>(); protected final Map<String, Map<String, Map<String, List<ReplicaInfo>>>> nodeVsCollectionVsShardVsReplicaInfo = new HashMap<>();
private Map<String, Object> snitchSession = new HashMap<>(); private Map<String, Object> snitchSession = new HashMap<>();
@SuppressWarnings({"rawtypes"})
private Map<String, Map> nodeVsTags = new HashMap<>(); private Map<String, Map> nodeVsTags = new HashMap<>();
private Map<String, String> withCollectionsMap = new HashMap<>(); private Map<String, String> withCollectionsMap = new HashMap<>();
@ -147,6 +148,7 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter
@Override @Override
public Map<String, Map<String, List<ReplicaInfo>>> getReplicaInfo(String node, Collection<String> keys) { public Map<String, Map<String, List<ReplicaInfo>>> getReplicaInfo(String node, Collection<String> keys) {
@SuppressWarnings({"unchecked"})
Map<String, Map<String, List<ReplicaInfo>>> result = nodeVsCollectionVsShardVsReplicaInfo.computeIfAbsent(node, Utils.NEW_HASHMAP_FUN); Map<String, Map<String, List<ReplicaInfo>>> result = nodeVsCollectionVsShardVsReplicaInfo.computeIfAbsent(node, Utils.NEW_HASHMAP_FUN);
if (!keys.isEmpty()) { if (!keys.isEmpty()) {
Map<String, Pair<String, ReplicaInfo>> metricsKeyVsTagReplica = new HashMap<>(); Map<String, Pair<String, ReplicaInfo>> metricsKeyVsTagReplica = new HashMap<>();
@ -197,6 +199,7 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter
metricsKeyVsTag.forEach((key, tag) -> { metricsKeyVsTag.forEach((key, tag) -> {
Object v = Utils.getObjectByPath(rsp.nl, true, Arrays.asList("metrics", key)); Object v = Utils.getObjectByPath(rsp.nl, true, Arrays.asList("metrics", key));
if (tag instanceof Function) { if (tag instanceof Function) {
@SuppressWarnings({"unchecked"})
Pair<String, Object> p = (Pair<String, Object>) ((Function) tag).apply(v); Pair<String, Object> p = (Pair<String, Object>) ((Function) tag).apply(v);
ctx.getTags().put(p.first(), p.second()); ctx.getTags().put(p.first(), p.second());
} else { } else {
@ -334,6 +337,7 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter
@Override @Override
@SuppressWarnings({"rawtypes"})
public Map getZkJson(String path) throws KeeperException, InterruptedException { public Map getZkJson(String path) throws KeeperException, InterruptedException {
return Utils.getJson(zkClientClusterStateProvider.getZkStateReader().getZkClient(), path, true); return Utils.getJson(zkClientClusterStateProvider.getZkStateReader().getZkClient(), path, true);
} }

View File

@ -101,6 +101,7 @@ public class StreamingBinaryResponseParser extends BinaryResponseParser {
EntryImpl entry = (EntryImpl) e; EntryImpl entry = (EntryImpl) e;
if( !entry.type().isContainer) return; if( !entry.type().isContainer) return;
if (e.isKeyValEntry() && entry.getTag() == Tag._SOLRDOCLST) { if (e.isKeyValEntry() && entry.getTag() == Tag._SOLRDOCLST) {
@SuppressWarnings({"rawtypes"})
List l = (List) e.metadata(); List l = (List) e.metadata();
e.listenContainer(fastCallback.initDocList( e.listenContainer(fastCallback.initDocList(
(Long) l.get(0), (Long) l.get(0),
@ -120,6 +121,7 @@ public class StreamingBinaryResponseParser extends BinaryResponseParser {
private EntryListener docListener; private EntryListener docListener;
@SuppressWarnings({"unchecked"})
private NamedList<Object> streamDocs(InputStream body) { private NamedList<Object> streamDocs(InputStream body) {
try (JavaBinCodec codec = new JavaBinCodec() { try (JavaBinCodec codec = new JavaBinCodec() {
@ -143,6 +145,7 @@ public class StreamingBinaryResponseParser extends BinaryResponseParser {
@Override @Override
public SolrDocumentList readSolrDocumentList(DataInputInputStream dis) throws IOException { public SolrDocumentList readSolrDocumentList(DataInputInputStream dis) throws IOException {
SolrDocumentList solrDocs = new SolrDocumentList(); SolrDocumentList solrDocs = new SolrDocumentList();
@SuppressWarnings({"rawtypes"})
List list = (List) readVal(dis); List list = (List) readVal(dis);
solrDocs.setNumFound((Long) list.get(0)); solrDocs.setNumFound((Long) list.get(0));
solrDocs.setStart((Long) list.get(1)); solrDocs.setStart((Long) list.get(1));

View File

@ -36,6 +36,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@SuppressWarnings({"unchecked"})
public class ZkClientClusterStateProvider implements ClusterStateProvider { public class ZkClientClusterStateProvider implements ClusterStateProvider {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

View File

@ -181,6 +181,7 @@ public class ZkDistribStateManager implements DistribStateManager {
} }
@Override @Override
@SuppressWarnings({"unchecked"})
public AutoScalingConfig getAutoScalingConfig(Watcher watcher) throws InterruptedException, IOException { public AutoScalingConfig getAutoScalingConfig(Watcher watcher) throws InterruptedException, IOException {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
Stat stat = new Stat(); Stat stat = new Stat();

View File

@ -82,7 +82,7 @@ public class GatherNodesStream extends TupleStream implements Expressible {
String traverseFrom, String traverseFrom,
String traverseTo, String traverseTo,
String gather, String gather,
Map queryParams, @SuppressWarnings({"rawtypes"})Map queryParams,
List<Metric> metrics, List<Metric> metrics,
boolean trackTraversal, boolean trackTraversal,
Set<Traversal.Scatter> scatter, Set<Traversal.Scatter> scatter,
@ -115,7 +115,7 @@ public class GatherNodesStream extends TupleStream implements Expressible {
} }
Set<Traversal.Scatter> scatter = new HashSet(); Set<Traversal.Scatter> scatter = new HashSet<>();
StreamExpressionNamedParameter scatterExpression = factory.getNamedOperand(expression, "scatter"); StreamExpressionNamedParameter scatterExpression = factory.getNamedOperand(expression, "scatter");
@ -169,7 +169,7 @@ public class GatherNodesStream extends TupleStream implements Expressible {
} }
String[] rootNodes = fields[0].split(","); String[] rootNodes = fields[0].split(",");
List<String> l = new ArrayList(); List<String> l = new ArrayList<>();
for(String n : rootNodes) { for(String n : rootNodes) {
l.add(n.trim()); l.add(n.trim());
} }
@ -181,7 +181,7 @@ public class GatherNodesStream extends TupleStream implements Expressible {
} }
List<StreamExpression> metricExpressions = factory.getExpressionOperandsRepresentingTypes(expression, Expressible.class, Metric.class); List<StreamExpression> metricExpressions = factory.getExpressionOperandsRepresentingTypes(expression, Expressible.class, Metric.class);
List<Metric> metrics = new ArrayList(); List<Metric> metrics = new ArrayList<>();
for(int idx = 0; idx < metricExpressions.size(); ++idx){ for(int idx = 0; idx < metricExpressions.size(); ++idx){
metrics.add(factory.constructMetric(metricExpressions.get(idx))); metrics.add(factory.constructMetric(metricExpressions.get(idx)));
} }
@ -245,13 +245,14 @@ public class GatherNodesStream extends TupleStream implements Expressible {
docFreq); docFreq);
} }
@SuppressWarnings({"unchecked"})
private void init(String zkHost, private void init(String zkHost,
String collection, String collection,
TupleStream tupleStream, TupleStream tupleStream,
String traverseFrom, String traverseFrom,
String traverseTo, String traverseTo,
String gather, String gather,
Map queryParams, @SuppressWarnings({"rawtypes"})Map queryParams,
List<Metric> metrics, List<Metric> metrics,
boolean trackTraversal, boolean trackTraversal,
Set<Traversal.Scatter> scatter, Set<Traversal.Scatter> scatter,
@ -295,7 +296,7 @@ public class GatherNodesStream extends TupleStream implements Expressible {
Set<Map.Entry<String,String>> entries = queryParams.entrySet(); Set<Map.Entry<String,String>> entries = queryParams.entrySet();
// parameters // parameters
for(Map.Entry param : entries){ for(@SuppressWarnings({"rawtypes"})Map.Entry param : entries){
String value = param.getValue().toString(); String value = param.getValue().toString();
// SOLR-8409: This is a special case where the params contain a " character // SOLR-8409: This is a special case where the params contain a " character
@ -400,7 +401,7 @@ public class GatherNodesStream extends TupleStream implements Expressible {
} }
public List<TupleStream> children() { public List<TupleStream> children() {
List<TupleStream> l = new ArrayList(); List<TupleStream> l = new ArrayList<>();
l.add(tupleStream); l.add(tupleStream);
return l; return l;
} }
@ -409,10 +410,11 @@ public class GatherNodesStream extends TupleStream implements Expressible {
tupleStream.open(); tupleStream.open();
} }
@SuppressWarnings({"unchecked"})
private class JoinRunner implements Callable<List<Tuple>> { private class JoinRunner implements Callable<List<Tuple>> {
private List<String> nodes; private List<String> nodes;
private List<Tuple> edges = new ArrayList(); private List<Tuple> edges = new ArrayList<>();
public JoinRunner(List<String> nodes) { public JoinRunner(List<String> nodes) {
this.nodes = nodes; this.nodes = nodes;
@ -421,7 +423,7 @@ public class GatherNodesStream extends TupleStream implements Expressible {
public List<Tuple> call() { public List<Tuple> call() {
Set<String> flSet = new HashSet(); Set<String> flSet = new HashSet<>();
flSet.add(gather); flSet.add(gather);
flSet.add(traverseTo); flSet.add(traverseTo);
@ -508,24 +510,26 @@ public class GatherNodesStream extends TupleStream implements Expressible {
tupleStream.close(); tupleStream.close();
} }
@SuppressWarnings({"unchecked"})
public Tuple read() throws IOException { public Tuple read() throws IOException {
if (out == null) { if (out == null) {
List<String> joinBatch = new ArrayList(); List<String> joinBatch = new ArrayList<>();
List<Future<List<Tuple>>> futures = new ArrayList(); List<Future<List<Tuple>>> futures = new ArrayList<>();
Map<String, Node> level = new HashMap(); Map<String, Node> level = new HashMap<>();
ExecutorService threadPool = null; ExecutorService threadPool = null;
try { try {
threadPool = ExecutorUtil.newMDCAwareFixedThreadPool(4, new SolrNamedThreadFactory("GatherNodesStream")); threadPool = ExecutorUtil.newMDCAwareFixedThreadPool(4, new SolrNamedThreadFactory("GatherNodesStream"));
Map<String, Node> roots = new HashMap(); Map<String, Node> roots = new HashMap<>();
while (true) { while (true) {
Tuple tuple = tupleStream.read(); Tuple tuple = tupleStream.read();
if (tuple.EOF) { if (tuple.EOF) {
if (joinBatch.size() > 0) { if (joinBatch.size() > 0) {
JoinRunner joinRunner = new JoinRunner(joinBatch); JoinRunner joinRunner = new JoinRunner(joinBatch);
@SuppressWarnings({"rawtypes"})
Future future = threadPool.submit(joinRunner); Future future = threadPool.submit(joinRunner);
futures.add(future); futures.add(future);
} }
@ -541,7 +545,7 @@ public class GatherNodesStream extends TupleStream implements Expressible {
if(!roots.containsKey(key)) { if(!roots.containsKey(key)) {
Node node = new Node(value, trackTraversal); Node node = new Node(value, trackTraversal);
if (metrics != null) { if (metrics != null) {
List<Metric> _metrics = new ArrayList(); List<Metric> _metrics = new ArrayList<>();
for (Metric metric : metrics) { for (Metric metric : metrics) {
_metrics.add(metric.newInstance()); _metrics.add(metric.newInstance());
} }
@ -557,9 +561,10 @@ public class GatherNodesStream extends TupleStream implements Expressible {
joinBatch.add(value); joinBatch.add(value);
if (joinBatch.size() == 400) { if (joinBatch.size() == 400) {
JoinRunner joinRunner = new JoinRunner(joinBatch); JoinRunner joinRunner = new JoinRunner(joinBatch);
@SuppressWarnings({"rawtypes"})
Future future = threadPool.submit(joinRunner); Future future = threadPool.submit(joinRunner);
futures.add(future); futures.add(future);
joinBatch = new ArrayList(); joinBatch = new ArrayList<>();
} }
} }
@ -588,7 +593,7 @@ public class GatherNodesStream extends TupleStream implements Expressible {
} else { } else {
node = new Node(_gather, trackTraversal); node = new Node(_gather, trackTraversal);
if (metrics != null) { if (metrics != null) {
List<Metric> _metrics = new ArrayList(); List<Metric> _metrics = new ArrayList<>();
for (Metric metric : metrics) { for (Metric metric : metrics) {
_metrics.add(metric.newInstance()); _metrics.add(metric.newInstance());
} }
@ -638,7 +643,7 @@ public class GatherNodesStream extends TupleStream implements Expressible {
public void open() {this.it = ids.iterator();} public void open() {this.it = ids.iterator();}
public void close() {} public void close() {}
public StreamComparator getStreamSort() {return null;} public StreamComparator getStreamSort() {return null;}
public List<TupleStream> children() {return new ArrayList();} public List<TupleStream> children() {return new ArrayList<>();}
public void setStreamContext(StreamContext context) {} public void setStreamContext(StreamContext context) {}
public Tuple read() { public Tuple read() {

View File

@ -30,7 +30,7 @@ public class Node {
public Node(String id, boolean track) { public Node(String id, boolean track) {
this.id=id; this.id=id;
if(track) { if(track) {
ancestors = new HashSet(); ancestors = new HashSet<>();
} }
} }
@ -62,7 +62,7 @@ public class Node {
List<String> cols = traversal.getCollections(); List<String> cols = traversal.getCollections();
if(ancestors != null) { if(ancestors != null) {
List<String> l = new ArrayList(); List<String> l = new ArrayList<>();
for(String ancestor : ancestors) { for(String ancestor : ancestors) {
String[] ancestorParts = ancestor.split("\\^"); String[] ancestorParts = ancestor.split("\\^");

View File

@ -68,7 +68,7 @@ public class ShortestPathStream extends TupleStream implements Expressible {
private int maxDepth; private int maxDepth;
private String zkHost; private String zkHost;
private String collection; private String collection;
private LinkedList<Tuple> shortestPaths = new LinkedList(); private LinkedList<Tuple> shortestPaths = new LinkedList<>();
private boolean found; private boolean found;
private StreamContext streamContext; private StreamContext streamContext;
private int threads; private int threads;
@ -282,20 +282,21 @@ public class ShortestPathStream extends TupleStream implements Expressible {
} }
public List<TupleStream> children() { public List<TupleStream> children() {
List<TupleStream> l = new ArrayList(); List<TupleStream> l = new ArrayList<>();
return l; return l;
} }
@SuppressWarnings({"unchecked", "rawtypes"})
public void open() throws IOException { public void open() throws IOException {
List<Map<String,List<String>>> allVisited = new ArrayList(); List<Map<String,List<String>>> allVisited = new ArrayList<>();
Map visited = new HashMap(); Map visited = new HashMap();
visited.put(this.fromNode, null); visited.put(this.fromNode, null);
allVisited.add(visited); allVisited.add(visited);
int depth = 0; int depth = 0;
Map<String, List<String>> nextVisited = null; Map<String, List<String>> nextVisited = null;
List<Edge> targets = new ArrayList(); List<Edge> targets = new ArrayList<>();
ExecutorService threadPool = null; ExecutorService threadPool = null;
try { try {
@ -309,8 +310,8 @@ public class ShortestPathStream extends TupleStream implements Expressible {
Iterator<String> it = nodes.iterator(); Iterator<String> it = nodes.iterator();
nextVisited = new HashMap(); nextVisited = new HashMap();
int batchCount = 0; int batchCount = 0;
List<String> queryNodes = new ArrayList(); List<String> queryNodes = new ArrayList<>();
List<Future> futures = new ArrayList(); List<Future> futures = new ArrayList<>();
JOIN: JOIN:
//Queue up all the batches //Queue up all the batches
while (it.hasNext()) { while (it.hasNext()) {
@ -343,7 +344,7 @@ public class ShortestPathStream extends TupleStream implements Expressible {
List<String> parents = nextVisited.get(edge.to); List<String> parents = nextVisited.get(edge.to);
parents.add(edge.from); parents.add(edge.from);
} else { } else {
List<String> parents = new ArrayList(); List<String> parents = new ArrayList<>();
parents.add(edge.from); parents.add(edge.from);
nextVisited.put(edge.to, parents); nextVisited.put(edge.to, parents);
} }
@ -353,7 +354,7 @@ public class ShortestPathStream extends TupleStream implements Expressible {
List<String> parents = nextVisited.get(edge.to); List<String> parents = nextVisited.get(edge.to);
parents.add(edge.from); parents.add(edge.from);
} else { } else {
List<String> parents = new ArrayList(); List<String> parents = new ArrayList<>();
parents.add(edge.from); parents.add(edge.from);
nextVisited.put(edge.to, parents); nextVisited.put(edge.to, parents);
} }
@ -376,7 +377,7 @@ public class ShortestPathStream extends TupleStream implements Expressible {
Set<String> finalPaths = new HashSet(); Set<String> finalPaths = new HashSet();
if(targets.size() > 0) { if(targets.size() > 0) {
for(Edge edge : targets) { for(Edge edge : targets) {
List<LinkedList> paths = new ArrayList(); List<LinkedList> paths = new ArrayList<>();
LinkedList<String> path = new LinkedList(); LinkedList<String> path = new LinkedList();
path.addFirst(edge.to); path.addFirst(edge.to);
paths.add(path); paths.add(path);
@ -415,7 +416,7 @@ public class ShortestPathStream extends TupleStream implements Expressible {
private class JoinRunner implements Callable<List<Edge>> { private class JoinRunner implements Callable<List<Edge>> {
private List<String> nodes; private List<String> nodes;
private List<Edge> edges = new ArrayList(); private List<Edge> edges = new ArrayList<>();
public JoinRunner(List<String> nodes) { public JoinRunner(List<String> nodes) {
this.nodes = nodes; this.nodes = nodes;

View File

@ -22,11 +22,11 @@ import java.util.*;
public class Traversal { public class Traversal {
private List<Map<String, Node>> graph = new ArrayList(); private List<Map<String, Node>> graph = new ArrayList<>();
private List<String> fields = new ArrayList(); private List<String> fields = new ArrayList<>();
private List<String> collections = new ArrayList(); private List<String> collections = new ArrayList<>();
private Set<Scatter> scatter = new HashSet(); private Set<Scatter> scatter = new HashSet<>();
private Set<String> collectionSet = new HashSet(); private Set<String> collectionSet = new HashSet<>();
private boolean trackTraversal; private boolean trackTraversal;
private int depth; private int depth;
@ -90,6 +90,7 @@ public class Traversal {
LEAVES; LEAVES;
} }
@SuppressWarnings({"unchecked"})
public Iterator<Tuple> iterator() { public Iterator<Tuple> iterator() {
return new TraversalIterator(this, scatter); return new TraversalIterator(this, scatter);
} }

View File

@ -26,6 +26,7 @@ import java.util.Set;
import org.apache.solr.client.solrj.io.Tuple; import org.apache.solr.client.solrj.io.Tuple;
import org.apache.solr.client.solrj.io.graph.Traversal.Scatter; import org.apache.solr.client.solrj.io.graph.Traversal.Scatter;
@SuppressWarnings({"rawtypes"})
class TraversalIterator implements Iterator { class TraversalIterator implements Iterator {
private List<Map<String,Node>> graph; private List<Map<String,Node>> graph;
@ -49,10 +50,10 @@ class TraversalIterator implements Iterator {
collections = traversal.getCollections(); collections = traversal.getCollections();
fields = traversal.getFields(); fields = traversal.getFields();
List<String> outCollections = new ArrayList(); List<String> outCollections = new ArrayList<>();
List<String> outFields = new ArrayList(); List<String> outFields = new ArrayList<>();
List<Integer> levelNums = new ArrayList(); List<Integer> levelNums = new ArrayList<>();
List<Iterator<Node>> levelIterators = new ArrayList(); List<Iterator<Node>> levelIterators = new ArrayList<>();
if(scatter.contains(Scatter.BRANCHES)) { if(scatter.contains(Scatter.BRANCHES)) {
if(graph.size() > 1) { if(graph.size() > 1) {

View File

@ -24,6 +24,7 @@ public class HealthCheckResponse extends SolrResponseBase {
public HealthCheckResponse() { public HealthCheckResponse() {
} }
@SuppressWarnings({"unchecked"})
public NamedList<String> getErrorMessages() { public NamedList<String> getErrorMessages() {
return (NamedList<String>) getResponse().get( "errors" ); return (NamedList<String>) getResponse().get( "errors" );
} }