Skip to content

Commit

Permalink
Merge branch 'master' into dep-license
Browse files Browse the repository at this point in the history
  • Loading branch information
imbajin authored Nov 9, 2022
2 parents 4f9d88e + caa4b26 commit 88cfd21
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 82 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@ hs_err_pid*
.mtj.tmp/
# blueJ files
*.ctxt
.flattened-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,9 @@ private static Configuration loadConfigFile(File configFile) {
case "yml":
case "yaml":
Parameters params = new Parameters();
FileBasedConfigurationBuilder<FileBasedConfiguration>
builder = new FileBasedConfigurationBuilder(
YAMLConfiguration.class)
.configure(params.fileBased()
.setFile(configFile));
FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
new FileBasedConfigurationBuilder(YAMLConfiguration.class)
.configure(params.fileBased().setFile(configFile));
config = builder.getConfiguration();
break;
case "xml":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import java.util.HashSet;
import java.util.List;

import javax.annotation.Nullable;

import org.apache.commons.lang3.StringUtils;

import com.google.common.base.Predicate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.hugegraph.func;

public interface TriFunction <T1, T2, T3, R> {
public interface TriFunction<T1, T2, T3, R> {

R apply(T1 v1, T2 v2, T3 v3);
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
public final class PerfUtil {

private static final Logger LOG = Log.logger(PerfUtil.class);
private static final int DEFAUL_CAPATICY = 1024;
private static final int DEFAULT_CAPACITY = 1024;

private static final ThreadLocal<PerfUtil> INSTANCE = new ThreadLocal<>();

Expand All @@ -69,8 +69,8 @@ public final class PerfUtil {
private final Stopwatch root;

private PerfUtil() {
this.stopwatches = new HashMap<>(DEFAUL_CAPATICY);
this.callStack = new LocalStack<>(DEFAUL_CAPATICY);
this.stopwatches = new HashMap<>(DEFAULT_CAPACITY);
this.callStack = new LocalStack<>(DEFAULT_CAPACITY);
this.root = newStopwatch(Path.ROOT_NAME, Path.EMPTY);
}

Expand Down Expand Up @@ -403,32 +403,32 @@ public String toECharts() {
};

BiConsumer<List<Stopwatch>, List<Stopwatch>> fillChildrenTotal =
(itemsOfLn, itemsOfLnParent) -> {
for (Stopwatch parent : itemsOfLnParent) {
List<Stopwatch> children = itemsOfLn.stream().filter(c -> {
return c.parent().equals(parent.id());
}).collect(Collectors.toList());
(itemsOfLn, itemsOfLnParent) -> {
for (Stopwatch parent : itemsOfLnParent) {
List<Stopwatch> children = itemsOfLn.stream().filter(c -> {
return c.parent().equals(parent.id());
}).collect(Collectors.toList());

parent.fillChildrenTotal(children);
}
};
parent.fillChildrenTotal(children);
}
};

BiConsumer<List<Stopwatch>, List<Stopwatch>> fillOther =
(itemsOfLn, itemsOfLnParent) -> {
for (Stopwatch parent : itemsOfLnParent) {
Stream<Stopwatch> children = itemsOfLn.stream().filter(c -> {
return c.parent().equals(parent.id());
});
// Fill other cost
long sumCost = children.mapToLong(Stopwatch::totalCost).sum();
long otherCost = parent.totalCost() - sumCost;
if (otherCost > 0L) {
Stopwatch other = newStopwatch("~", parent.id());
other.totalCost(otherCost);
itemsOfLn.add(other);
}
}
};
(itemsOfLn, itemsOfLnParent) -> {
for (Stopwatch parent : itemsOfLnParent) {
Stream<Stopwatch> children = itemsOfLn.stream().filter(c -> {
return c.parent().equals(parent.id());
});
// Fill other cost
long sumCost = children.mapToLong(Stopwatch::totalCost).sum();
long otherCost = parent.totalCost() - sumCost;
if (otherCost > 0L) {
Stopwatch other = newStopwatch("~", parent.id());
other.totalCost(otherCost);
itemsOfLn.add(other);
}
}
};

Map<Path, Stopwatch> items = this.stopwatches;
Map<Integer, List<Stopwatch>> levelItems = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,47 @@
public interface Stopwatch extends Cloneable {

Path id();

String name();

Path parent();

void startTime(long startTime);

void endTime(long startTime);

void lastStartTime(long startTime);

long times();

long totalTimes();

long totalChildrenTimes();

long totalCost();

void totalCost(long otherCost);

long minCost();

long maxCost();

long totalWasted();

long totalSelfWasted();

long totalChildrenWasted();

void fillChildrenTotal(List<Stopwatch> children);

Stopwatch copy();

Stopwatch child(String name);

Stopwatch child(String name, Stopwatch watch);

boolean empty();

void clear();

default String toJson() {
Expand Down Expand Up @@ -97,11 +108,7 @@ public Path(Path parent, String name) {
if (parent == EMPTY) {
this.path = name;
} else {
int len = parent.length() + 1 + name.length();
StringBuilder sb = new StringBuilder(len);
sb.append(parent.path).append('/').append(name);

this.path = sb.toString();
this.path = parent.path + '/' + name;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.apache.hugegraph.rest;

import java.io.IOException;
import java.net.URI;
import java.security.KeyManagementException;
import java.security.SecureRandom;
Expand All @@ -32,19 +31,14 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import org.apache.commons.collections.MapUtils;
import org.apache.hugegraph.util.E;
import org.apache.hugegraph.util.ExecutorUtil;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientRequestContext;
import jakarta.ws.rs.client.ClientRequestFilter;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.client.Invocation.Builder;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Variant;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.http.HttpHeaders;
Expand All @@ -55,6 +49,8 @@
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.pool.PoolStats;
import org.apache.hugegraph.util.E;
import org.apache.hugegraph.util.ExecutorUtil;
import org.glassfish.jersey.SslConfigurator;
import org.glassfish.jersey.apache.connector.ApacheClientProperties;
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
Expand All @@ -69,12 +65,16 @@

import com.google.common.collect.ImmutableMap;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientRequestContext;
import jakarta.ws.rs.client.ClientRequestFilter;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.client.Invocation.Builder;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Variant;

public abstract class AbstractRestClient implements RestClient {

Expand Down Expand Up @@ -412,15 +412,14 @@ private Pair<Builder, Entity<?>> buildRequest(

/**
* parse user custom content-type, returns MediaType.APPLICATION_JSON_TYPE default.
* @param headers
* @return
* @param headers custom http header
*/
public static MediaType parseCustomContentType(MultivaluedMap<String, Object> headers) {
private static MediaType parseCustomContentType(MultivaluedMap<String, Object> headers) {
String customContentType = null;
if (MapUtils.isNotEmpty(headers) && headers.get("Content-Type") != null) {
Object contentTypeObj = headers.get("Content-Type");
if (contentTypeObj instanceof List) {
customContentType = ((List<?>) contentTypeObj).get(0).toString();
List<?> contentTypeObj = headers.get("Content-Type");
if (contentTypeObj != null && !contentTypeObj.isEmpty()) {
customContentType = contentTypeObj.get(0).toString();
}
return MediaType.valueOf(customContentType);
}
Expand Down Expand Up @@ -546,7 +545,7 @@ private static class ConfigBuilder {

private final ClientConfig config;

public ConfigBuilder() {
ConfigBuilder() {
this.config = new ClientConfig();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ private static class NumberMatcher extends BaseMatcher<Object> {
private final Number expected;
private final Function<Integer, Boolean> cmp;

public NumberMatcher(Number expected, Function<Integer, Boolean> cmp,
String symbol) {
NumberMatcher(Number expected, Function<Integer, Boolean> cmp, String symbol) {
this.expected = expected;
this.cmp = cmp;
this.symbol = symbol;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public static String getImplementationVersion(Class<?> clazz) {
String className = clazz.getSimpleName() + ".class";
String classPath = Objects.requireNonNull(clazz.getResource(className)).toString();
if (!classPath.startsWith("jar:file:")) {
// Class not from JAR
return null;
// Class not from JAR
return null;
}
int offset = classPath.lastIndexOf("!");
assert offset > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@

package org.apache.hugegraph.config;

import org.apache.hugegraph.config.ConfigOption;
import org.apache.hugegraph.config.OptionHolder;

import static org.apache.hugegraph.config.OptionChecker.allowValues;
import static org.apache.hugegraph.config.OptionChecker.disallowEmpty;
import static org.apache.hugegraph.config.OptionChecker.rangeInt;
Expand Down Expand Up @@ -128,7 +125,7 @@ public static synchronized RpcOptions instance() {
"rpc.client_load_balancer",
"The rpc client uses a load-balancing algorithm to " +
"access multiple rpc servers in one cluster. Default " +
"value is 'consistentHash', means forwording by request " +
"value is 'consistentHash', means forwarding by request " +
"parameters.",
allowValues("random", "localPref", "roundRobin",
"consistentHash", "weightRoundRobin"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public RpcClientProvider(HugeConfig config) {
this.consumerConfig = StringUtils.isNotBlank(rpcUrl) ?
new RpcConsumerConfig(config, rpcUrl) : null;
}

public boolean enabled() {
return this.consumerConfig != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public class RpcConsumerConfig implements RpcServiceConfig4Client {
private final List<ConsumerBootstrap<?>> bootstraps;

static {
ExtensionLoaderFactory.getExtensionLoader(Cluster.class)
.loadExtension(FanoutCluster.class);
ExtensionLoaderFactory.getExtensionLoader(Cluster.class)
.loadExtension(FanoutCluster.class);
}

public RpcConsumerConfig(HugeConfig config, String remoteUrls) {
Expand Down Expand Up @@ -148,7 +148,7 @@ private static class FanoutCluster extends AbstractCluster {

private static final Logger LOG = Log.logger(FanoutCluster.class);

public FanoutCluster(ConsumerBootstrap<?> consumerBootstrap) {
FanoutCluster(ConsumerBootstrap<?> consumerBootstrap) {
super(consumerBootstrap);
}

Expand Down
7 changes: 1 addition & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${compiler.source}</source>
<target>${compiler.target}</target>
Expand Down Expand Up @@ -136,7 +135,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<index>true</index>
Expand Down Expand Up @@ -222,7 +220,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.2.7</version>
<version>1.3.0</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
Expand Down Expand Up @@ -255,7 +253,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -268,7 +265,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -286,7 +282,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down

0 comments on commit 88cfd21

Please sign in to comment.