refactor(pulsar-query): 优化pulsar项目依赖和代码性能
This commit is contained in:
56
pom.xml
56
pom.xml
@@ -101,6 +101,62 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pl.tkowalcz.tjahzi</groupId>
|
||||
<artifactId>logback-appender</artifactId>
|
||||
<version>0.9.23</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.loki4j</groupId>
|
||||
<artifactId>loki-logback-appender-jdk8</artifactId>
|
||||
<version>1.4.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.failsafe</groupId>
|
||||
<artifactId>failsafe</artifactId>
|
||||
<version>3.2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.collections</groupId>
|
||||
<artifactId>eclipse-collections</artifactId>
|
||||
<version>10.4.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.collections</groupId>
|
||||
<artifactId>eclipse-collections-api</artifactId>
|
||||
<version>10.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-eclipse-collections</artifactId>
|
||||
<version>2.13.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.7.16</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.ulisesbocchio</groupId>
|
||||
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||
<version>3.0.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.pulsar</groupId>
|
||||
<artifactId>pulsar-client</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.pulsar</groupId>
|
||||
<artifactId>pulsar-client-admin</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.lanyuanxiaoyao.service.configuration.entity.pulsar;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.eclipse.collections.api.map.ImmutableMap;
|
||||
|
||||
/**
|
||||
* Pulsar 信息
|
||||
@@ -12,10 +11,10 @@ import java.util.stream.Collectors;
|
||||
* @date 2023-04-28
|
||||
*/
|
||||
public class PulsarInfo {
|
||||
public static final List<PulsarInfo> DEFAULT_INFOS = ListUtil.of(
|
||||
public static final ImmutableList<PulsarInfo> DEFAULT_INFOS = Lists.immutable.of(
|
||||
new PulsarInfo(
|
||||
"main",
|
||||
ListUtil.of(
|
||||
Lists.immutable.of(
|
||||
"132.122.113.167:16680",
|
||||
"132.122.113.168:16680",
|
||||
"132.122.113.169:16680",
|
||||
@@ -32,7 +31,7 @@ public class PulsarInfo {
|
||||
),
|
||||
new PulsarInfo(
|
||||
"acct",
|
||||
ListUtil.of(
|
||||
Lists.immutable.of(
|
||||
"132.122.115.158:16650",
|
||||
"132.122.115.159:16650",
|
||||
"132.122.115.160:16650",
|
||||
@@ -45,7 +44,7 @@ public class PulsarInfo {
|
||||
),
|
||||
new PulsarInfo(
|
||||
"order",
|
||||
ListUtil.of(
|
||||
Lists.immutable.of(
|
||||
"132.122.115.158:16660",
|
||||
"132.122.115.159:16660",
|
||||
"132.122.115.160:16660",
|
||||
@@ -58,7 +57,7 @@ public class PulsarInfo {
|
||||
),
|
||||
new PulsarInfo(
|
||||
"cust",
|
||||
ListUtil.of(
|
||||
Lists.immutable.of(
|
||||
"132.122.113.167:16670",
|
||||
"132.122.113.168:16670",
|
||||
"132.122.113.169:16670",
|
||||
@@ -74,34 +73,24 @@ public class PulsarInfo {
|
||||
"132.122.113.167:18108"
|
||||
)
|
||||
);
|
||||
public static final Map<String, PulsarInfo> PULSAR_CLIENT_INFO_MAPPING = DEFAULT_INFOS.stream()
|
||||
.flatMap(info -> info.getBrokers()
|
||||
.stream()
|
||||
.map(url -> new Pair<>(url, info)))
|
||||
.collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
|
||||
public static final Map<String, String> PULSAR_CLIENT_NAME_MAPPING = PULSAR_CLIENT_INFO_MAPPING.entrySet()
|
||||
.stream()
|
||||
.map(entry -> new Pair<>(entry.getKey(), entry.getValue().name))
|
||||
.collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
|
||||
public static final Map<String, String> PULSAR_CLIENT_ADMIN_MAPPING = PULSAR_CLIENT_INFO_MAPPING.entrySet()
|
||||
.stream()
|
||||
.map(entry -> new Pair<>(entry.getKey(), entry.getValue().admin))
|
||||
.collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
|
||||
public static final Map<String, String> PULSAR_CLIENT_PRESTO_MAPPING = PULSAR_CLIENT_INFO_MAPPING.entrySet()
|
||||
.stream()
|
||||
.map(entry -> new Pair<>(entry.getKey(), entry.getValue().presto))
|
||||
.collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
|
||||
public static final Map<String, PulsarInfo> PULSAR_NAME_INFO_MAPPING = DEFAULT_INFOS.stream()
|
||||
.collect(Collectors.toMap(PulsarInfo::getName, info -> info));
|
||||
public static final ImmutableMap<String, PulsarInfo> PULSAR_CLIENT_INFO_MAPPING = DEFAULT_INFOS
|
||||
.flatCollect(info -> info.getBrokers()
|
||||
.collect(url -> new Pair<>(url, info)))
|
||||
.toMap(Pair::getLeft, Pair::getRight)
|
||||
.toImmutable();
|
||||
public static final ImmutableMap<String, String> PULSAR_CLIENT_NAME_MAPPING = PULSAR_CLIENT_INFO_MAPPING.collectValues((key, value) -> value.getName());
|
||||
public static final ImmutableMap<String, String> PULSAR_CLIENT_ADMIN_MAPPING = PULSAR_CLIENT_INFO_MAPPING.collectValues((key, value) -> value.getAdmin());
|
||||
public static final ImmutableMap<String, String> PULSAR_CLIENT_PRESTO_MAPPING = PULSAR_CLIENT_INFO_MAPPING.collectValues((key, value) -> value.getPresto());
|
||||
public static final ImmutableMap<String, PulsarInfo> PULSAR_NAME_INFO_MAPPING = DEFAULT_INFOS.toMap(PulsarInfo::getName, info -> info).toImmutable();
|
||||
private String name;
|
||||
private List<String> brokers;
|
||||
private ImmutableList<String> brokers;
|
||||
private String presto;
|
||||
private String admin;
|
||||
|
||||
public PulsarInfo() {
|
||||
}
|
||||
|
||||
public PulsarInfo(String name, List<String> brokers, String presto, String admin) {
|
||||
public PulsarInfo(String name, ImmutableList<String> brokers, String presto, String admin) {
|
||||
this.name = name;
|
||||
this.brokers = brokers;
|
||||
this.presto = presto;
|
||||
@@ -112,7 +101,7 @@ public class PulsarInfo {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<String> getBrokers() {
|
||||
public ImmutableList<String> getBrokers() {
|
||||
return brokers;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,48 +61,39 @@
|
||||
<dependency>
|
||||
<groupId>pl.tkowalcz.tjahzi</groupId>
|
||||
<artifactId>logback-appender</artifactId>
|
||||
<version>0.9.23</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.loki4j</groupId>
|
||||
<artifactId>loki-logback-appender-jdk8</artifactId>
|
||||
<version>1.4.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.failsafe</groupId>
|
||||
<artifactId>failsafe</artifactId>
|
||||
<version>3.2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.collections</groupId>
|
||||
<artifactId>eclipse-collections</artifactId>
|
||||
<version>10.4.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.collections</groupId>
|
||||
<artifactId>eclipse-collections-api</artifactId>
|
||||
<version>10.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-eclipse-collections</artifactId>
|
||||
<version>2.13.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.7.16</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.ulisesbocchio</groupId>
|
||||
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||
<version>3.0.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -25,7 +25,6 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.pulsar</groupId>
|
||||
<artifactId>pulsar-client</artifactId>
|
||||
<version>2.8.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.validation</groupId>
|
||||
@@ -36,7 +35,6 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.pulsar</groupId>
|
||||
<artifactId>pulsar-client-admin</artifactId>
|
||||
<version>2.8.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.validation</groupId>
|
||||
|
||||
Reference in New Issue
Block a user