Skip to content

Commit

Permalink
[improve][build] Do not bundle swagger dependencies (apache#20687)
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun authored Jun 30, 2023
1 parent e098ff1 commit d718687
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 25 deletions.
2 changes: 0 additions & 2 deletions distribution/server/src/assemble/LICENSE.bin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,6 @@ The Apache Software License, Version 2.0
* Netty Reactive Streams -- com.typesafe.netty-netty-reactive-streams-2.0.6.jar
* Swagger
- io.swagger-swagger-annotations-1.6.2.jar
- io.swagger-swagger-core-1.6.2.jar
- io.swagger-swagger-models-1.6.2.jar
* DataSketches
- com.yahoo.datasketches-memory-0.8.3.jar
- com.yahoo.datasketches-sketches-core-0.8.3.jar
Expand Down
4 changes: 0 additions & 4 deletions distribution/shell/src/assemble/LICENSE.bin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,6 @@ The Apache Software License, Version 2.0
- listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar
* J2ObjC Annotations -- j2objc-annotations-1.3.jar
* Netty Reactive Streams -- netty-reactive-streams-2.0.6.jar
* Swagger
- swagger-annotations-1.6.2.jar
- swagger-core-1.6.2.jar
- swagger-models-1.6.2.jar
* DataSketches
- memory-0.8.3.jar
- sketches-core-0.8.3.jar
Expand Down
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -869,12 +869,14 @@ flexible messaging model and an intuitive client API.</description>
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<version>${swagger.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,11 @@ static long validateSizeString(String s) {
String subStr = s.substring(0, s.length() - 1);
long size;
try {
size = sizeUnit.contains(last)
? Long.parseLong(subStr)
: Long.parseLong(s);
size = SIZE_UNIT.contains(last) ? Long.parseLong(subStr) : Long.parseLong(s);
} catch (IllegalArgumentException e) {
throw new ParameterException(String.format("Invalid size '%s'. Valid formats are: %s",
s, "(4096, 100K, 10M, 16G, 2T)"));
throw new ParameterException(
String.format("Invalid size '%s'. Valid formats are: %s",
s, "(4096, 100K, 10M, 16G, 2T)"));
}
switch (last) {
case 'k':
Expand Down Expand Up @@ -223,15 +222,15 @@ <T> void print(T item) {

<T> void prettyPrint(T item) {
try {
System.out.println(writer.writeValueAsString(item));
System.out.println(WRITER.writeValueAsString(item));
} catch (Exception e) {
throw new RuntimeException(e);
}
}

private static ObjectMapper mapper = ObjectMapperFactory.create();
private static ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();
private static Set<Character> sizeUnit = Sets.newHashSet('k', 'K', 'm', 'M', 'g', 'G', 't', 'T');
private static final ObjectMapper MAPPER = ObjectMapperFactory.create();
private static final ObjectWriter WRITER = MAPPER.writerWithDefaultPrettyPrinter();
private static final Set<Character> SIZE_UNIT = Sets.newHashSet('k', 'K', 'm', 'M', 'g', 'G', 't', 'T');

abstract void run() throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import io.swagger.util.Json;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
Expand Down Expand Up @@ -2559,8 +2558,9 @@ private class GetPropertiesForNamespace extends CliCommand {

@Override
void run() throws Exception {
String namespace = validateNamespace(params);
Json.prettyPrint(getAdmin().namespaces().getProperties(namespace));
final String namespace = validateNamespace(params);
final Map<String, String> properties = getAdmin().namespaces().getProperties(namespace);
prettyPrint(properties);
}
}

Expand Down
5 changes: 5 additions & 0 deletions pulsar-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
<artifactId>netty-codec-socks</artifactId>
</dependency>

<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns</artifactId>
Expand Down
2 changes: 0 additions & 2 deletions pulsar-sql/presto-distribution/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,6 @@ The Apache Software License, Version 2.0
- zookeeper-jute-3.8.1.jar
* Apache Yetus Audience Annotations
- audience-annotations-0.12.0.jar
* Swagger
- swagger-annotations-1.6.2.jar
* Perfmark
- perfmark-api-0.19.0.jar
* RabbitMQ Java Client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.swagger.util.Json;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -1701,13 +1700,17 @@ private void publishAndConsumeMessages(String inputTopic,
Message<byte[]> msg = consumer.receive(30, TimeUnit.SECONDS);
if (msg == null) {
log.info("Input topic stats: {}",
Json.pretty(pulsarAdmin.topics().getStats(inputTopic, true)));
objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(
pulsarAdmin.topics().getStats(inputTopic, true)));
log.info("Output topic stats: {}",
Json.pretty(pulsarAdmin.topics().getStats(outputTopic, true)));
objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(
pulsarAdmin.topics().getStats(outputTopic, true)));
log.info("Input topic internal-stats: {}",
Json.pretty(pulsarAdmin.topics().getInternalStats(inputTopic, true)));
objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(
pulsarAdmin.topics().getInternalStats(inputTopic, true)));
log.info("Output topic internal-stats: {}",
Json.pretty(pulsarAdmin.topics().getInternalStats(outputTopic, true)));
objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(
pulsarAdmin.topics().getInternalStats(outputTopic, true)));
} else {
String logMsg = new String(msg.getValue(), UTF_8);
log.info("Received message: '{}'", logMsg);
Expand Down

0 comments on commit d718687

Please sign in to comment.