You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ol...@apache.org on 2017/03/23 12:44:38 UTC
[85/88] [abbrv] ambari git commit: AMBARI-20541. Rename
ambari-logsearch-solr-client module to ambari-infra-solr-client (oleewere)
http://git-wip-us.apache.org/repos/asf/ambari/blob/53287368/ambari-logsearch/ambari-logsearch-solr-client/src/main/java/org/apache/ambari/logsearch/solr/util/ShardUtils.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-solr-client/src/main/java/org/apache/ambari/logsearch/solr/util/ShardUtils.java b/ambari-logsearch/ambari-logsearch-solr-client/src/main/java/org/apache/ambari/logsearch/solr/util/ShardUtils.java
deleted file mode 100644
index 3ea2685..0000000
--- a/ambari-logsearch/ambari-logsearch-solr-client/src/main/java/org/apache/ambari/logsearch/solr/util/ShardUtils.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.solr.util;
-
-import org.apache.solr.common.cloud.Replica;
-import org.apache.solr.common.cloud.Slice;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-
-public class ShardUtils {
-
- private static final Logger LOG = LoggerFactory.getLogger(ShardUtils.class);
-
- public static String generateShardListStr(int maxShardsPerNode) {
- String shardsListStr = "";
- for (int i = 0; i < maxShardsPerNode; i++) {
- if (i != 0) {
- shardsListStr += ",";
- }
- String shard = "shard" + i;
- shardsListStr += shard;
- }
- return shardsListStr;
- }
-
- public static List<String> generateShardList(int maxShardsPerNode) {
- List<String> shardsList = new ArrayList<>();
- for (int i = 0; i < maxShardsPerNode; i++) {
- shardsList.add("shard" + i);
- }
- return shardsList;
- }
-
- public static Collection<String> getShardNamesFromSlices(Collection<Slice> slices, String collection) {
- Collection<String> result = new HashSet<String>();
- Iterator<Slice> iter = slices.iterator();
- while (iter.hasNext()) {
- Slice slice = iter.next();
- for (Replica replica : slice.getReplicas()) {
- LOG.info("collectionName=" + collection + ", slice.name="
- + slice.getName() + ", slice.state=" + slice.getState()
- + ", replica.core=" + replica.getStr("core")
- + ", replica.state=" + replica.getStr("state"));
- result.add(slice.getName());
- }
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/53287368/ambari-logsearch/ambari-logsearch-solr-client/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-solr-client/src/main/resources/log4j.properties b/ambari-logsearch/ambari-logsearch-solr-client/src/main/resources/log4j.properties
deleted file mode 100644
index e8dca12..0000000
--- a/ambari-logsearch/ambari-logsearch-solr-client/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2011 The Apache Software Foundation
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-log4j.rootLogger=INFO,stdout,stderr
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Threshold=INFO
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%m%n
-
-log4j.appender.stderr=org.apache.log4j.ConsoleAppender
-log4j.appender.stderr.Threshold=ERROR
-log4j.appender.stderr.Target=System.err
-log4j.appender.stderr.layout=org.apache.log4j.PatternLayout
-log4j.appender.stderr.layout.ConversionPattern=%m%n
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/53287368/ambari-logsearch/ambari-logsearch-solr-client/src/main/resources/solrCloudCli.sh
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-solr-client/src/main/resources/solrCloudCli.sh b/ambari-logsearch/ambari-logsearch-solr-client/src/main/resources/solrCloudCli.sh
deleted file mode 100644
index cd47f06..0000000
--- a/ambari-logsearch/ambari-logsearch-solr-client/src/main/resources/solrCloudCli.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-JVM="java"
-sdir="`dirname \"$0\"`"
-
-PATH=$JAVA_HOME/bin:$PATH $JVM -classpath "$sdir:$sdir/libs/*" org.apache.ambari.logsearch.solr.AmbariSolrCloudCLI ${1+"$@"}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/53287368/ambari-logsearch/ambari-logsearch-solr-client/src/test/java/org/apache/ambari/logsearch/solr/AmbariSolrCloudClientTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-solr-client/src/test/java/org/apache/ambari/logsearch/solr/AmbariSolrCloudClientTest.java b/ambari-logsearch/ambari-logsearch-solr-client/src/test/java/org/apache/ambari/logsearch/solr/AmbariSolrCloudClientTest.java
deleted file mode 100644
index edc9b5c..0000000
--- a/ambari-logsearch/ambari-logsearch-solr-client/src/test/java/org/apache/ambari/logsearch/solr/AmbariSolrCloudClientTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.solr;
-
-import static org.easymock.EasyMock.anyString;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.apache.solr.client.solrj.request.CollectionAdminRequest;
-import org.apache.solr.client.solrj.response.CollectionAdminResponse;
-import org.apache.solr.common.cloud.SolrZkClient;
-import org.apache.solr.common.util.NamedList;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class AmbariSolrCloudClientTest {
-
- private AmbariSolrCloudClient underTest;
-
- private CloudSolrClient mockedSolrClient;
-
- private SolrZkClient mockedSolrZkClient;
-
- private CollectionAdminResponse mockedResponse;
-
- @Before
- public void setUp() {
- AmbariSolrCloudClientBuilder builder = new AmbariSolrCloudClientBuilder();
-
- mockedSolrClient = createMock(CloudSolrClient.class);
- mockedSolrZkClient = createMock(SolrZkClient.class);
- mockedResponse = createMock(CollectionAdminResponse.class);
-
- builder.solrCloudClient = mockedSolrClient;
- builder.solrZkClient = mockedSolrZkClient;
-
- underTest = builder
- .withZkConnectString("localhost1:2181,localhost2:2182")
- .withCollection("collection1")
- .withConfigSet("configSet")
- .withShards(1)
- .withReplication(1)
- .withMaxShardsPerNode(2)
- .withInterval(1)
- .withRetry(2)
- .withRouterName("routerName")
- .withRouterField("routerField")
- .build();
- }
-
- @Test
- public void testCreateCollectionWhenCollectionDoesNotExist() throws Exception {
- // GIVEN
- NamedList<Object> namedList = new NamedList<>();
- namedList.add("collections", Arrays.asList("collection1", "collection2"));
-
- expect(mockedSolrClient.request(anyObject(CollectionAdminRequest.class), anyString())).andReturn(namedList).times(1);
- replay(mockedSolrClient);
-
- // WHEN
- String result = underTest.createCollection();
- // THEN
- assertEquals("collection1", result);
- verify(mockedSolrClient);
- }
-
- @Test
- public void testCreateCollectionWhenCollectionExists() throws Exception {
- // GIVEN
- NamedList<Object> namedList = new NamedList<>();
- namedList.add("collections", Arrays.asList("collection2", "collection3"));
-
- expect(mockedSolrClient.request(anyObject(CollectionAdminRequest.class), anyString())).andReturn(namedList).times(2);
- replay(mockedSolrClient);
-
- // WHEN
- String result = underTest.createCollection();
- // THEN
- assertEquals("collection1", result);
- verify(mockedSolrClient);
- }
-
- @Test
- public void testListCollections() throws Exception {
- // GIVEN
- NamedList<Object> namedList = new NamedList<>();
- namedList.add("collections", Arrays.asList("collection1", "collection2"));
-
- expect(mockedSolrClient.request(anyObject(CollectionAdminRequest.class), anyString())).andReturn(namedList);
-
- replay(mockedSolrClient);
- // WHEN
- List<String> result = underTest.listCollections();
-
- // THEN
- assertTrue(result.contains("collection1"));
- assertTrue(result.contains("collection2"));
- assertEquals(2, result.size());
- }
-
- @Test(expected = AmbariSolrCloudClientException.class)
- public void testRetries() throws Exception {
- // GIVEN
- expect(mockedSolrClient.request(anyObject(CollectionAdminRequest.class), anyString())).andThrow(new RuntimeException("ex")).times(2);
- replay(mockedSolrClient);
- // WHEN
- underTest.listCollections();
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/53287368/ambari-logsearch/docker/Dockerfile
----------------------------------------------------------------------
diff --git a/ambari-logsearch/docker/Dockerfile b/ambari-logsearch/docker/Dockerfile
index dfa1462..6e8ea3e 100644
--- a/ambari-logsearch/docker/Dockerfile
+++ b/ambari-logsearch/docker/Dockerfile
@@ -69,8 +69,8 @@ ENV SOLR_INCLUDE /root/config/solr/solr-env.sh
ENV LOGSEARCH_INCLUDE /root/config/logsearch/logsearch-env.sh
ENV LOGFEEDER_INCLUDE /root/config/logfeeder/logfeeder-env.sh
-RUN mkdir -p /var/run/ambari-logsearch-solr /var/log/ambari-logsearch-solr /var/run/ambari-logsearch-solr-client \
- /var/log/ambari-logsearch-solr-client /root/logsearch_solr_index/data \
+RUN mkdir -p /var/run/ambari-logsearch-solr /var/log/ambari-logsearch-solr /var/run/ambari-infra-solr-client \
+ /var/log/ambari-infra-solr-client /root/logsearch_solr_index/data \
/var/run/ambari-logsearch-portal /var/log/ambari-logsearch-portal \
/var/run/ambari-logsearch-logfeeder /var/log/ambari-logsearch-logfeeder
http://git-wip-us.apache.org/repos/asf/ambari/blob/53287368/ambari-logsearch/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-logsearch/pom.xml b/ambari-logsearch/pom.xml
index 2846f5f..9397c22 100644
--- a/ambari-logsearch/pom.xml
+++ b/ambari-logsearch/pom.xml
@@ -34,8 +34,8 @@
<module>ambari-logsearch-server</module>
<module>ambari-logsearch-web</module>
<module>ambari-logsearch-logfeeder</module>
- <module>ambari-logsearch-solr-client</module>
<module>ambari-logsearch-it</module>
+ <module>ambari-infra-solr-client</module>
<module>ambari-infra-solr-plugin</module>
</modules>
<properties>