Revision 55756
Added by Claudio Atzori almost 5 years ago
modules/dnet-index-solr-common/trunk/src/main/java/eu/dnetlib/functionality/index/utils/ZkServers.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.index.utils; |
|
2 |
|
|
3 |
import com.google.common.base.Splitter; |
|
4 |
import com.google.common.collect.Lists; |
|
5 |
import org.apache.commons.lang3.StringUtils; |
|
6 |
import org.apache.commons.logging.Log; |
|
7 |
import org.apache.commons.logging.LogFactory; |
|
8 |
|
|
9 |
import java.util.List; |
|
10 |
import java.util.Optional; |
|
11 |
|
|
12 |
public class ZkServers { |
|
13 |
|
|
14 |
private static final Log log = LogFactory.getLog(ZkServers.class); |
|
15 |
public static final String SEPARATOR = "/"; |
|
16 |
|
|
17 |
private List<String> hosts; |
|
18 |
|
|
19 |
private Optional<String> chroot; |
|
20 |
|
|
21 |
public static ZkServers newInstance(final String zkUrl) { |
|
22 |
|
|
23 |
//quorum0:2182,quorum1:2182,quorum2:2182,quorum3:2182,quorum4:2182/solr-dev-openaire |
|
24 |
String urls = zkUrl; |
|
25 |
final Optional<String> chRoot = Optional.of(SEPARATOR + StringUtils.substringAfterLast(zkUrl, SEPARATOR)); |
|
26 |
if (chRoot.isPresent() && StringUtils.isNotBlank(chRoot.get())) { |
|
27 |
log.debug(String.format("found zk chroot %s", chRoot)); |
|
28 |
urls = zkUrl.replace(chRoot.get(), ""); |
|
29 |
} |
|
30 |
|
|
31 |
final List<String> urlList = Lists.newArrayList(Splitter.on(",").omitEmptyStrings().split(urls)); |
|
32 |
log.debug(String.format("zk urls %s", zkUrl)); |
|
33 |
|
|
34 |
return new ZkServers(urlList, chRoot); |
|
35 |
} |
|
36 |
|
|
37 |
public ZkServers(List<String> hosts, Optional<String> chroot) { |
|
38 |
this.hosts = hosts; |
|
39 |
this.chroot = chroot; |
|
40 |
} |
|
41 |
|
|
42 |
public List<String> getHosts() { |
|
43 |
return hosts; |
|
44 |
} |
|
45 |
|
|
46 |
public void setHosts(List<String> hosts) { |
|
47 |
this.hosts = hosts; |
|
48 |
} |
|
49 |
|
|
50 |
public Optional<String> getChroot() { |
|
51 |
return chroot; |
|
52 |
} |
|
53 |
|
|
54 |
public void setChroot(Optional<String> chroot) { |
|
55 |
this.chroot = chroot; |
|
56 |
} |
|
57 |
} |
|
58 |
|
modules/dnet-index-solr-common/trunk/pom.xml | ||
---|---|---|
9 | 9 |
<modelVersion>4.0.0</modelVersion> |
10 | 10 |
<groupId>eu.dnetlib</groupId> |
11 | 11 |
<artifactId>dnet-index-solr-common</artifactId> |
12 |
<version>1.3.4-SNAPSHOT</version>
|
|
12 |
<version>2.3.4-SNAPSHOT</version>
|
|
13 | 13 |
<scm> |
14 | 14 |
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-index-solr-common/trunk</developerConnection> |
15 | 15 |
</scm> |
... | ... | |
17 | 17 |
<dependency> |
18 | 18 |
<groupId>org.apache.solr</groupId> |
19 | 19 |
<artifactId>solr-solrj</artifactId> |
20 |
<version>${apache.solr.version}</version>
|
|
20 |
<version>7.5.0</version>
|
|
21 | 21 |
<exclusions> |
22 | 22 |
<exclusion> |
23 | 23 |
<artifactId>wstx-asl</artifactId> |
... | ... | |
39 | 39 |
<artifactId>guava</artifactId> |
40 | 40 |
<version>${google.guava.version}</version> |
41 | 41 |
</dependency> |
42 |
<dependency> |
|
43 |
<groupId>commons-logging</groupId> |
|
44 |
<artifactId>commons-logging</artifactId> |
|
45 |
<version>${commons.logging.version}</version> |
|
46 |
</dependency> |
|
47 |
<dependency> |
|
48 |
<groupId>org.apache.commons</groupId> |
|
49 |
<artifactId>commons-lang3</artifactId> |
|
50 |
<version>3.5</version> |
|
51 |
</dependency> |
|
42 | 52 |
|
43 | 53 |
</dependencies> |
44 | 54 |
</project> |
Also available in: Unified diff
reintegrated branch solr75 -r53767:HEAD