forked from apache/ranger
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DINF-1390 Introduced stub interface to isolate solr usage
- Loading branch information
1 parent
1a6b97e
commit 8af9ead
Showing
63 changed files
with
1,045 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
agents-audit/src/main/java/org/apache/ranger/index/solr/SolrClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.apache.ranger.index.solr; | ||
|
||
import org.apache.ranger.index.solr.client.solrj.response.UpdateResponse; | ||
import org.apache.ranger.index.solr.common.SolrInputDocument; | ||
import org.apache.solr.client.solrj.SolrServerException; | ||
|
||
import java.io.IOException; | ||
import java.util.Collection; | ||
import java.util.stream.Collectors; | ||
|
||
public class SolrClient { | ||
public final org.apache.solr.client.solrj.SolrClient inner; | ||
|
||
public SolrClient(org.apache.solr.client.solrj.SolrClient inner) { | ||
this.inner = inner; | ||
} | ||
|
||
public UpdateResponse add(Collection<SolrInputDocument> docs) throws IOException, SolrServerException { | ||
return new UpdateResponse(inner.add(docs.stream().map(x->x.inner).collect(Collectors.toList()))); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
agents-audit/src/main/java/org/apache/ranger/index/solr/client/solrj/SolrClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.apache.ranger.index.solr.client.solrj; | ||
|
||
import org.apache.ranger.index.solr.client.solrj.response.UpdateResponse; | ||
import org.apache.ranger.index.solr.common.SolrInputDocument; | ||
import org.apache.solr.client.solrj.SolrServerException; | ||
|
||
import java.io.IOException; | ||
import java.util.Collection; | ||
import java.util.stream.Collectors; | ||
|
||
public class SolrClient extends org.apache.ranger.index.solr.SolrClient { | ||
public final org.apache.solr.client.solrj.SolrClient inner; | ||
|
||
public SolrClient(org.apache.solr.client.solrj.SolrClient inner) { | ||
super(inner); | ||
this.inner = inner; | ||
} | ||
|
||
public UpdateResponse add(Collection<SolrInputDocument> docs) throws IOException, SolrServerException { | ||
return new UpdateResponse(inner.add(docs.stream().map(x->x.inner).collect(Collectors.toList()))); | ||
} | ||
|
||
public void close() throws IOException { | ||
inner.close(); | ||
} | ||
|
||
public UpdateResponse add(SolrInputDocument document) throws IOException, SolrServerException { | ||
return new UpdateResponse(inner.add(document.inner)); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
agents-audit/src/main/java/org/apache/ranger/index/solr/client/solrj/SolrQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.apache.ranger.index.solr.client.solrj; | ||
|
||
public class SolrQuery { | ||
public final org.apache.solr.client.solrj.SolrQuery inner; | ||
|
||
public SolrQuery(org.apache.solr.client.solrj.SolrQuery inner) { | ||
this.inner = inner; | ||
} | ||
|
||
public SolrQuery() { | ||
this(new org.apache.solr.client.solrj.SolrQuery()); | ||
} | ||
|
||
public void setQuery(String s) { | ||
inner.setQuery(s); | ||
} | ||
|
||
public void addFilterQuery(String fq) { | ||
inner.addFilterQuery(fq); | ||
} | ||
|
||
public void setStart(int startIndex) { | ||
inner.setStart(startIndex); | ||
} | ||
|
||
public void setRows(int maxRows) { | ||
inner.setRows(maxRows); | ||
} | ||
|
||
public void addSort(String querySortBy, ORDER order) { | ||
inner.addSort(querySortBy, order.inner); | ||
} | ||
|
||
public void setRequestHandler(String queryStr) { | ||
inner.setRequestHandler(queryStr); | ||
} | ||
|
||
public enum ORDER { | ||
asc(org.apache.solr.client.solrj.SolrQuery.ORDER.asc), | ||
desc(org.apache.solr.client.solrj.SolrQuery.ORDER.desc); | ||
|
||
public final org.apache.solr.client.solrj.SolrQuery.ORDER inner; | ||
|
||
ORDER(org.apache.solr.client.solrj.SolrQuery.ORDER inner) { | ||
this.inner = inner; | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
agents-audit/src/main/java/org/apache/ranger/index/solr/client/solrj/SolrRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.apache.ranger.index.solr.client.solrj; | ||
|
||
public class SolrRequest { | ||
public enum METHOD { | ||
POST(org.apache.solr.client.solrj.SolrRequest.METHOD.POST); | ||
|
||
public final org.apache.solr.client.solrj.SolrRequest.METHOD inner; | ||
|
||
METHOD(org.apache.solr.client.solrj.SolrRequest.METHOD post) { | ||
inner = post; | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
agents-audit/src/main/java/org/apache/ranger/index/solr/client/solrj/SolrResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.apache.ranger.index.solr.client.solrj; | ||
|
||
import org.apache.ranger.index.solr.common.util.NamedList; | ||
import org.apache.solr.client.solrj.response.CollectionAdminResponse; | ||
|
||
public class SolrResponse { | ||
private final org.apache.solr.client.solrj.SolrResponse inner; | ||
|
||
public SolrResponse(org.apache.solr.client.solrj.SolrResponse process) { | ||
this.inner = process; | ||
} | ||
|
||
public NamedList<Object> getResponse() { | ||
return new NamedList<>(inner.getResponse()); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...ts-audit/src/main/java/org/apache/ranger/index/solr/client/solrj/SolrServerException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.apache.ranger.index.solr.client.solrj; | ||
|
||
public class SolrServerException extends Exception { | ||
public final org.apache.solr.client.solrj.SolrServerException inner; | ||
|
||
public SolrServerException(org.apache.solr.client.solrj.SolrServerException inner) { | ||
this.inner = inner; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...dit/src/main/java/org/apache/ranger/index/solr/client/solrj/impl/BinaryRequestWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.apache.ranger.index.solr.client.solrj.impl; | ||
|
||
public class BinaryRequestWriter { | ||
public final org.apache.solr.client.solrj.impl.BinaryRequestWriter inner = new org.apache.solr.client.solrj.impl.BinaryRequestWriter(); | ||
} |
5 changes: 5 additions & 0 deletions
5
agents-audit/src/main/java/org/apache/ranger/index/solr/client/solrj/impl/Builder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.apache.ranger.index.solr.client.solrj.impl; | ||
|
||
public class Builder { | ||
public final org.apache.solr.client.solrj.impl.Builder inner = new org.apache.solr.client.solrj.impl.Builder(); | ||
} |
51 changes: 51 additions & 0 deletions
51
...s-audit/src/main/java/org/apache/ranger/index/solr/client/solrj/impl/CloudSolrClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.apache.ranger.index.solr.client.solrj.impl; | ||
|
||
import org.apache.ranger.index.solr.client.solrj.SolrClient; | ||
import org.apache.solr.client.solrj.impl.ClusterStateProvider; | ||
import org.apache.solr.client.solrj.impl.LBHttpSolrClient; | ||
import org.apache.ranger.index.solr.common.cloud.ZkStateReader; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public class CloudSolrClient extends SolrClient { | ||
|
||
public final org.apache.solr.client.solrj.impl.CloudSolrClient inner; | ||
|
||
public CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient inner) { | ||
super(inner); | ||
this.inner = inner; | ||
} | ||
|
||
public void setDefaultCollection(String collectionName) { | ||
inner.setDefaultCollection(collectionName); | ||
} | ||
|
||
public LBHttpSolrClient getLbClient() { | ||
return inner.getLbClient(); | ||
} | ||
|
||
public ZkStateReader getZkStateReader() { | ||
return new ZkStateReader(inner.getZkStateReader()); | ||
} | ||
|
||
public ClusterStateProvider getClusterStateProvider() { | ||
return this.inner.getClusterStateProvider(); | ||
} | ||
|
||
public static class Builder { | ||
public final org.apache.solr.client.solrj.impl.CloudSolrClient.Builder inner; | ||
|
||
public Builder(List<String> zkhosts, Optional<String> empty) { | ||
inner = new org.apache.solr.client.solrj.impl.CloudSolrClient.Builder(zkhosts, empty); | ||
} | ||
|
||
public CloudSolrClient build() { | ||
return new CloudSolrClient(inner.build()); | ||
} | ||
} | ||
|
||
public void connect() { | ||
inner.connect(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...ts-audit/src/main/java/org/apache/ranger/index/solr/client/solrj/impl/HttpClientUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.apache.ranger.index.solr.client.solrj.impl; | ||
|
||
public class HttpClientUtil { | ||
public static void setHttpClientBuilder(SolrHttpClientBuilder kb) { | ||
org.apache.solr.client.solrj.impl.HttpClientUtil.setHttpClientBuilder(kb.inner); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ts-audit/src/main/java/org/apache/ranger/index/solr/client/solrj/impl/HttpSolrClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.apache.ranger.index.solr.client.solrj.impl; | ||
|
||
import org.apache.ranger.index.solr.client.solrj.SolrClient; | ||
|
||
public class HttpSolrClient extends SolrClient { | ||
public final org.apache.solr.client.solrj.impl.HttpSolrClient inner; | ||
|
||
public HttpSolrClient(org.apache.solr.client.solrj.impl.HttpSolrClient inner) { | ||
super(new org.apache.solr.client.solrj.SolrClient()); | ||
this.inner = inner; | ||
} | ||
|
||
public void setRequestWriter(BinaryRequestWriter binaryRequestWriter) { | ||
inner.setRequestWriter(binaryRequestWriter.inner); | ||
} | ||
|
||
public static class Builder { | ||
public final org.apache.solr.client.solrj.impl.HttpSolrClient.Builder inner = new org.apache.solr.client.solrj.impl.HttpSolrClient.Builder(); | ||
|
||
public void withBaseSolrUrl(String solrURL) { | ||
inner.withBaseSolrUrl(solrURL); | ||
} | ||
|
||
public void allowCompression(boolean b) { | ||
inner.allowCompression(b); | ||
} | ||
|
||
public void withConnectionTimeout(int i) { | ||
inner.withConnectionTimeout(i); | ||
} | ||
|
||
public HttpSolrClient build() { | ||
return new HttpSolrClient(inner.build()); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...t/src/main/java/org/apache/ranger/index/solr/client/solrj/impl/Krb5HttpClientBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.apache.ranger.index.solr.client.solrj.impl; | ||
|
||
public class Krb5HttpClientBuilder { | ||
public final org.apache.solr.client.solrj.impl.Krb5HttpClientBuilder inner = new org.apache.solr.client.solrj.impl.Krb5HttpClientBuilder(); | ||
public SolrHttpClientBuilder getBuilder() { | ||
return new SolrHttpClientBuilder(inner.getBuilder()); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...-audit/src/main/java/org/apache/ranger/index/solr/client/solrj/impl/LBHttpSolrClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.apache.ranger.index.solr.client.solrj.impl; | ||
|
||
import org.apache.ranger.index.solr.SolrClient; | ||
|
||
import java.net.MalformedURLException; | ||
|
||
public class LBHttpSolrClient extends SolrClient { | ||
private final org.apache.solr.client.solrj.impl.LBHttpSolrClient inner; | ||
|
||
public LBHttpSolrClient(org.apache.solr.client.solrj.impl.LBHttpSolrClient inner) { | ||
super(new org.apache.solr.client.solrj.SolrClient()); | ||
this.inner = inner; | ||
} | ||
|
||
public void addSolrServer(String s) throws MalformedURLException { | ||
inner.addSolrServer(s); | ||
} | ||
|
||
public static class Builder { | ||
public final org.apache.solr.client.solrj.impl.LBHttpSolrClient.Builder inner = new org.apache.solr.client.solrj.impl.LBHttpSolrClient.Builder(); | ||
public void withBaseSolrUrl(String s) { | ||
inner.withBaseSolrUrl(s); | ||
} | ||
|
||
public void withConnectionTimeout(int i) { | ||
inner.withConnectionTimeout(i); | ||
} | ||
|
||
public LBHttpSolrClient build() { | ||
return new LBHttpSolrClient(inner.build()); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...t/src/main/java/org/apache/ranger/index/solr/client/solrj/impl/SolrHttpClientBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.apache.ranger.index.solr.client.solrj.impl; | ||
|
||
public class SolrHttpClientBuilder { | ||
public final org.apache.solr.client.solrj.impl.SolrHttpClientBuilder inner; | ||
|
||
public SolrHttpClientBuilder(org.apache.solr.client.solrj.impl.SolrHttpClientBuilder builder) { | ||
this.inner = builder; | ||
} | ||
} |
Oops, something went wrong.