ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lpus...@apache.org
Subject [05/50] [abbrv] ambari git commit: AMBARI-21596 Log Search should stop using deprecated API for solr (mgergely)
Date Tue, 08 Aug 2017 16:02:21 GMT
AMBARI-21596 Log Search should stop using deprecated API for solr (mgergely)

Change-Id: I9c71874b310bc1d2789bc062c5c50903754a30b7


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ed08865c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ed08865c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ed08865c

Branch: refs/heads/feature-branch-AMBARI-21307
Commit: ed08865c4da057fc5e051da5375ad7ca5c494203
Parents: 3ac9f55
Author: Miklos Gergely <mgergely@hortonworks.com>
Authored: Wed Aug 2 06:11:23 2017 +0200
Committer: Miklos Gergely <mgergely@hortonworks.com>
Committed: Wed Aug 2 06:11:23 2017 +0200

----------------------------------------------------------------------
 .../ambari-logsearch-server/pom.xml             | 40 ++++++++++----------
 .../configurer/SolrAuditAliasConfigurer.java    |  4 +-
 .../configurer/SolrCollectionConfigurer.java    |  4 +-
 .../logsearch/dao/SolrSchemaFieldDao.java       |  3 +-
 .../handler/AbstractSolrConfigHandler.java      |  2 +
 .../handler/CreateCollectionHandler.java        | 28 +++++++-------
 .../handler/ReloadCollectionHandler.java        |  5 +--
 .../logsearch/solr/ResponseDataGenerator.java   |  3 +-
 8 files changed, 44 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ed08865c/ambari-logsearch/ambari-logsearch-server/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/pom.xml b/ambari-logsearch/ambari-logsearch-server/pom.xml
index ebca2d5..4db1f61 100755
--- a/ambari-logsearch/ambari-logsearch-server/pom.xml
+++ b/ambari-logsearch/ambari-logsearch-server/pom.xml
@@ -500,32 +500,32 @@
       <artifactId>jersey-common</artifactId>
       <version>${jersey.version}</version>
     </dependency>
-  <dependency>
-    <groupId>javax.servlet</groupId>
-    <artifactId>javax.servlet-api</artifactId>
-    <version>3.1.0</version>
-  </dependency>
-      <dependency>
-    <groupId>log4j</groupId>
-    <artifactId>log4j</artifactId>
-    <version>1.2.17</version>
-  </dependency>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>javax.servlet-api</artifactId>
+      <version>3.1.0</version>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <version>1.2.17</version>
+    </dependency>
     <dependency>
       <groupId>org.apache.solr</groupId>
       <artifactId>solr-solrj</artifactId>
       <version>${solr.version}</version>
     </dependency>
     <dependency>
-    <groupId>org.apache.solr</groupId>
-    <artifactId>solr-core</artifactId>
-    <version>${solr.version}</version>
-    <exclusions>
-      <exclusion>
-        <groupId>*</groupId>
-        <artifactId>*</artifactId>
-      </exclusion>
-    </exclusions>
-  </dependency>
+      <groupId>org.apache.solr</groupId>
+      <artifactId>solr-core</artifactId>
+      <version>${solr.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>*</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
     <dependency>
       <groupId>org.apache.lucene</groupId>
       <artifactId>lucene-core</artifactId>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed08865c/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/configurer/SolrAuditAliasConfigurer.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/configurer/SolrAuditAliasConfigurer.java
b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/configurer/SolrAuditAliasConfigurer.java
index 1eca94b..679c1f5 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/configurer/SolrAuditAliasConfigurer.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/configurer/SolrAuditAliasConfigurer.java
@@ -115,9 +115,7 @@ public class SolrAuditAliasConfigurer implements Configurer {
     String collectionsCSV = null;
     if (!collectionToAdd.isEmpty()) {
       collectionsCSV = StringUtils.join(collectionToAdd, ',');
-      CollectionAdminRequest.CreateAlias aliasCreateRequest = new CollectionAdminRequest.CreateAlias();
-      aliasCreateRequest.setAliasName(aliasNameIn);
-      aliasCreateRequest.setAliasedCollections(collectionsCSV);
+      CollectionAdminRequest.CreateAlias aliasCreateRequest = CollectionAdminRequest.createAlias(aliasNameIn,
collectionsCSV);
       CollectionAdminResponse createResponse = aliasCreateRequest.process(solrClient);
       if (createResponse.getStatus() != 0) {
         LOG.error("Error creating alias. alias=" + aliasNameIn + ", collectionList=" + collectionsCSV

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed08865c/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/configurer/SolrCollectionConfigurer.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/configurer/SolrCollectionConfigurer.java
b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/configurer/SolrCollectionConfigurer.java
index 225f5a3..6de34ce 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/configurer/SolrCollectionConfigurer.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/configurer/SolrCollectionConfigurer.java
@@ -123,7 +123,7 @@ public class SolrCollectionConfigurer implements Configurer {
 
   private CloudSolrClient createClient(String solrUrl, String zookeeperConnectString, String
defaultCollection) {
     if (StringUtils.isNotEmpty(zookeeperConnectString)) {
-      CloudSolrClient cloudSolrClient = new CloudSolrClient(zookeeperConnectString);
+      CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder().withZkHost(zookeeperConnectString).build();
       cloudSolrClient.setDefaultCollection(defaultCollection);
       return cloudSolrClient;
     } else if (StringUtils.isNotEmpty(solrUrl)) {
@@ -138,7 +138,7 @@ public class SolrCollectionConfigurer implements Configurer {
     boolean securityEnabled = solrDaoBase.getSolrKerberosConfig().isEnabled();
     if (securityEnabled) {
       System.setProperty("java.security.auth.login.config", jaasFile);
-      HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
+      HttpClientUtil.addConfigurer(new Krb5HttpClientConfigurer());
       LOG.info("setupSecurity() called for kerberos configuration, jaas file: " + jaasFile);
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed08865c/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
index 71f9f29..5a36599 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
@@ -133,7 +133,7 @@ public class SolrSchemaFieldDao {
   @SuppressWarnings("unchecked")
   private List<LukeResponse> getLukeResponsesForCores(CloudSolrClient solrClient) {
     ZkStateReader zkStateReader = solrClient.getZkStateReader();
-    Collection<Slice> activeSlices = zkStateReader.getClusterState().getActiveSlices(solrClient.getDefaultCollection());
+    Collection<Slice> activeSlices = zkStateReader.getClusterState().getCollection(solrClient.getDefaultCollection()).getActiveSlices();
     
     List<LukeResponse> lukeResponses = new ArrayList<>();
     for (Slice slice : activeSlices) {
@@ -141,6 +141,7 @@ public class SolrSchemaFieldDao {
         try (CloseableHttpClient httpClient = HttpClientUtil.createClient(null)) {
           HttpGet request = new HttpGet(replica.getCoreUrl() + LUKE_REQUEST_URL_SUFFIX);
           HttpResponse response = httpClient.execute(request);
+          @SuppressWarnings("resource") // JavaBinCodec implements Closeable, yet it can't
be closed if it is used for unmarshalling only
           NamedList<Object> lukeData = (NamedList<Object>) new JavaBinCodec().unmarshal(response.getEntity().getContent());
           LukeResponse lukeResponse = new LukeResponse();
           lukeResponse.setResponse(lukeData);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed08865c/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/handler/AbstractSolrConfigHandler.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/handler/AbstractSolrConfigHandler.java
b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/handler/AbstractSolrConfigHandler.java
index 6f3d8ca..28e8ad7 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/handler/AbstractSolrConfigHandler.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/handler/AbstractSolrConfigHandler.java
@@ -88,10 +88,12 @@ public abstract class AbstractSolrConfigHandler implements SolrZkRequestHandler<
    */
   public abstract String getConfigFileName();
 
+  @SuppressWarnings("unused")
   public void doIfConfigNotExist(SolrPropsConfig solrPropsConfig, ZkConfigManager zkConfigManager)
throws IOException {
     // Do nothing
   };
 
+  @SuppressWarnings("unused")
   public void uploadMissingConfigFiles(SolrZkClient zkClient, ZkConfigManager zkConfigManager,
String configName) throws IOException {
     // do Nothing
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed08865c/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/handler/CreateCollectionHandler.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/handler/CreateCollectionHandler.java
b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/handler/CreateCollectionHandler.java
index b6e9def..8b4c7bf 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/handler/CreateCollectionHandler.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/handler/CreateCollectionHandler.java
@@ -31,6 +31,7 @@ import org.apache.solr.client.solrj.impl.CloudSolrClient;
 import org.apache.solr.client.solrj.impl.HttpClientUtil;
 import org.apache.solr.client.solrj.request.CollectionAdminRequest;
 import org.apache.solr.client.solrj.response.CollectionAdminResponse;
+import org.apache.solr.common.cloud.DocCollection;
 import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.cloud.Slice;
 import org.apache.solr.common.cloud.ZkStateReader;
@@ -94,13 +95,11 @@ public class CreateCollectionHandler implements SolrZkRequestHandler<Boolean>
{
     // Check if collection is already in zookeeper
     if (!allCollectionList.contains(solrPropsConfig.getCollection())) {
       LOG.info("Creating collection " + solrPropsConfig.getCollection() + ", shardsList="
+ shardsList);
-      CollectionAdminRequest.Create collectionCreateRequest = new CollectionAdminRequest.Create();
-      collectionCreateRequest.setCollectionName(solrPropsConfig.getCollection());
+      CollectionAdminRequest.Create collectionCreateRequest = CollectionAdminRequest.createCollection(
+          solrPropsConfig.getCollection(), solrPropsConfig.getConfigName(), solrPropsConfig.getNumberOfShards(),
+          solrPropsConfig.getReplicationFactor());
       collectionCreateRequest.setRouterName("implicit");
       collectionCreateRequest.setShards(shardsListStr);
-      collectionCreateRequest.setNumShards(solrPropsConfig.getNumberOfShards());
-      collectionCreateRequest.setReplicationFactor(solrPropsConfig.getReplicationFactor());
-      collectionCreateRequest.setConfigName(solrPropsConfig.getConfigName());
       collectionCreateRequest.setRouterField(ROUTER_FIELD);
       collectionCreateRequest.setMaxShardsPerNode(solrPropsConfig.getReplicationFactor()
* solrPropsConfig.getNumberOfShards());
 
@@ -128,9 +127,8 @@ public class CreateCollectionHandler implements SolrZkRequestHandler<Boolean>
{
         if (!existingShards.contains(shard)) {
           try {
             LOG.info("Going to add Shard " + shard + " to collection " + solrPropsConfig.getCollection());
-            CollectionAdminRequest.CreateShard createShardRequest = new CollectionAdminRequest.CreateShard();
-            createShardRequest.setCollectionName(solrPropsConfig.getCollection());
-            createShardRequest.setShardName(shard);
+            CollectionAdminRequest.CreateShard createShardRequest =
+                CollectionAdminRequest.createShard(solrPropsConfig.getCollection(), shard);
             CollectionAdminResponse response = createShardRequest.process(solrClient);
             if (response.getStatus() != 0) {
               LOG.error("Error creating shard " + shard + " in collection " + solrPropsConfig.getCollection()
+ ", response=" + response);
@@ -150,7 +148,8 @@ public class CreateCollectionHandler implements SolrZkRequestHandler<Boolean>
{
     return returnValue;
   }
 
-  private boolean createCollection(CloudSolrClient solrClient, SolrPropsConfig solrPropsConfig,
List<String> allCollectionList) throws SolrServerException, IOException {
+  private boolean createCollection(CloudSolrClient solrClient, SolrPropsConfig solrPropsConfig,
List<String> allCollectionList)
+      throws SolrServerException, IOException {
 
     if (allCollectionList.contains(solrPropsConfig.getCollection())) {
       LOG.info("Collection " + solrPropsConfig.getCollection() + " is already there. Won't
create it");
@@ -160,11 +159,9 @@ public class CreateCollectionHandler implements SolrZkRequestHandler<Boolean>
{
     LOG.info("Creating collection " + solrPropsConfig.getCollection() + ", numberOfShards="
+ solrPropsConfig.getNumberOfShards() +
       ", replicationFactor=" + solrPropsConfig.getReplicationFactor());
 
-    CollectionAdminRequest.Create collectionCreateRequest = new CollectionAdminRequest.Create();
-    collectionCreateRequest.setCollectionName(solrPropsConfig.getCollection());
-    collectionCreateRequest.setNumShards(solrPropsConfig.getNumberOfShards());
-    collectionCreateRequest.setReplicationFactor(solrPropsConfig.getReplicationFactor());
-    collectionCreateRequest.setConfigName(solrPropsConfig.getConfigName());
+    CollectionAdminRequest.Create collectionCreateRequest = CollectionAdminRequest.createCollection(
+        solrPropsConfig.getCollection(), solrPropsConfig.getConfigName(), solrPropsConfig.getNumberOfShards(),
+        solrPropsConfig.getReplicationFactor());
     collectionCreateRequest.setMaxShardsPerNode(calculateMaxShardsPerNode(solrPropsConfig));
     CollectionAdminResponse createResponse = collectionCreateRequest.process(solrClient);
     if (createResponse.getStatus() != 0) {
@@ -194,7 +191,8 @@ public class CreateCollectionHandler implements SolrZkRequestHandler<Boolean>
{
 
   private Collection<Slice> getSlices(CloudSolrClient solrClient, SolrPropsConfig solrPropsConfig)
{
     ZkStateReader reader = solrClient.getZkStateReader();
-    return reader.getClusterState().getSlices(solrPropsConfig.getCollection());
+    DocCollection collection = reader.getClusterState().getCollection(solrPropsConfig.getCollection());
+    return collection.getSlices();
   }
 
   private Collection<String> getShards(Collection<Slice> slices, SolrPropsConfig
solrPropsConfig) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed08865c/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/handler/ReloadCollectionHandler.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/handler/ReloadCollectionHandler.java
b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/handler/ReloadCollectionHandler.java
index 52f3366..601bdba 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/handler/ReloadCollectionHandler.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/handler/ReloadCollectionHandler.java
@@ -33,9 +33,8 @@ public class ReloadCollectionHandler implements SolrZkRequestHandler<Boolean>
{
     boolean result = false;
     try {
       LOG.info("Reload collection - '{}'", solrPropsConfig.getCollection());
-      CollectionAdminRequest.Reload reloadCollectionRequest = new CollectionAdminRequest.Reload();
-      reloadCollectionRequest.setCollectionName(solrPropsConfig.getCollection());
-      reloadCollectionRequest.process(solrClient);
+      CollectionAdminRequest.Reload request = CollectionAdminRequest.reloadCollection(solrPropsConfig.getCollection());
+      request.process(solrClient);
       result = true;
     } catch (Exception e) {
       LOG.error(String.format("Reload collection ('%s') failed.", solrPropsConfig.getCollection()),
e);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed08865c/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/ResponseDataGenerator.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/ResponseDataGenerator.java
b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/ResponseDataGenerator.java
index 74e9c11..e3c1a24 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/ResponseDataGenerator.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/ResponseDataGenerator.java
@@ -134,12 +134,13 @@ public class ResponseDataGenerator {
     return dataList;
   }
 
+  @SuppressWarnings("rawtypes")
   public List<NameValueData> generateNameValueDataList(List<RangeFacet> rangeFacet)
{
     List<NameValueData> nameValues = new ArrayList<>();
     if (rangeFacet == null) {
       return nameValues;
     }
-    RangeFacet range = rangeFacet.get(0);
+    RangeFacet<?, ?> range = rangeFacet.get(0);
 
     if (range == null) {
       return nameValues;


Mime
View raw message