Skip to content

Commit

Permalink
Upgrade BookKeeper to 4.14.1 (apache#10686)
Browse files Browse the repository at this point in the history
* upgrade BookKeeper to 4.14.0

* format code

* upgrade bookkeeper to 4.14.1 to fix prometheus metric bug

* update license

Co-authored-by: chenhang <[email protected]>
  • Loading branch information
hangc0276 and chenhang authored Jun 1, 2021
1 parent 9239387 commit e6b35d9
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 48 deletions.
50 changes: 25 additions & 25 deletions distribution/server/src/assemble/LICENSE.bin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -390,31 +390,31 @@ The Apache Software License, Version 2.0
- org.apache.logging.log4j-log4j-1.2-api-2.14.0.jar
* Java Native Access JNA -- net.java.dev.jna-jna-4.2.0.jar
* BookKeeper
- org.apache.bookkeeper-bookkeeper-common-4.13.0.jar
- org.apache.bookkeeper-bookkeeper-common-allocator-4.13.0.jar
- org.apache.bookkeeper-bookkeeper-proto-4.13.0.jar
- org.apache.bookkeeper-bookkeeper-server-4.13.0.jar
- org.apache.bookkeeper-bookkeeper-tools-framework-4.13.0.jar
- org.apache.bookkeeper-circe-checksum-4.13.0.jar
- org.apache.bookkeeper-cpu-affinity-4.13.0.jar
- org.apache.bookkeeper-statelib-4.13.0.jar
- org.apache.bookkeeper-stream-storage-api-4.13.0.jar
- org.apache.bookkeeper-stream-storage-common-4.13.0.jar
- org.apache.bookkeeper-stream-storage-java-client-4.13.0.jar
- org.apache.bookkeeper-stream-storage-java-client-base-4.13.0.jar
- org.apache.bookkeeper-stream-storage-proto-4.13.0.jar
- org.apache.bookkeeper-stream-storage-server-4.13.0.jar
- org.apache.bookkeeper-stream-storage-service-api-4.13.0.jar
- org.apache.bookkeeper-stream-storage-service-impl-4.13.0.jar
- org.apache.bookkeeper.http-http-server-4.13.0.jar
- org.apache.bookkeeper.http-vertx-http-server-4.13.0.jar
- org.apache.bookkeeper.stats-bookkeeper-stats-api-4.13.0.jar
- org.apache.bookkeeper.stats-prometheus-metrics-provider-4.13.0.jar
- org.apache.distributedlog-distributedlog-common-4.13.0.jar
- org.apache.distributedlog-distributedlog-core-4.13.0-tests.jar
- org.apache.distributedlog-distributedlog-core-4.13.0.jar
- org.apache.distributedlog-distributedlog-protocol-4.13.0.jar
- org.apache.bookkeeper.stats-codahale-metrics-provider-4.13.0.jar
- org.apache.bookkeeper-bookkeeper-common-4.14.1.jar
- org.apache.bookkeeper-bookkeeper-common-allocator-4.14.1.jar
- org.apache.bookkeeper-bookkeeper-proto-4.14.1.jar
- org.apache.bookkeeper-bookkeeper-server-4.14.1.jar
- org.apache.bookkeeper-bookkeeper-tools-framework-4.14.1.jar
- org.apache.bookkeeper-circe-checksum-4.14.1.jar
- org.apache.bookkeeper-cpu-affinity-4.14.1.jar
- org.apache.bookkeeper-statelib-4.14.1.jar
- org.apache.bookkeeper-stream-storage-api-4.14.1.jar
- org.apache.bookkeeper-stream-storage-common-4.14.1.jar
- org.apache.bookkeeper-stream-storage-java-client-4.14.1.jar
- org.apache.bookkeeper-stream-storage-java-client-base-4.14.1.jar
- org.apache.bookkeeper-stream-storage-proto-4.14.1.jar
- org.apache.bookkeeper-stream-storage-server-4.14.1.jar
- org.apache.bookkeeper-stream-storage-service-api-4.14.1.jar
- org.apache.bookkeeper-stream-storage-service-impl-4.14.1.jar
- org.apache.bookkeeper.http-http-server-4.14.1.jar
- org.apache.bookkeeper.http-vertx-http-server-4.14.1.jar
- org.apache.bookkeeper.stats-bookkeeper-stats-api-4.14.1.jar
- org.apache.bookkeeper.stats-prometheus-metrics-provider-4.14.1.jar
- org.apache.distributedlog-distributedlog-common-4.14.1.jar
- org.apache.distributedlog-distributedlog-core-4.14.1-tests.jar
- org.apache.distributedlog-distributedlog-core-4.14.1.jar
- org.apache.distributedlog-distributedlog-protocol-4.14.1.jar
- org.apache.bookkeeper.stats-codahale-metrics-provider-4.14.1.jar
* Apache HTTP Client
- org.apache.httpcomponents-httpclient-4.5.13.jar
- org.apache.httpcomponents-httpcore-4.4.13.jar
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ flexible messaging model and an intuitive client API.</description>
<!-- apache commons -->
<commons-compress.version>1.19</commons-compress.version>

<bookkeeper.version>4.13.0</bookkeeper.version>
<bookkeeper.version>4.14.1</bookkeeper.version>
<zookeeper.version>3.6.2</zookeeper.version>
<snappy.version>1.1.7</snappy.version> <!-- ZooKeeper server -->
<dropwizardmetrics.version>3.2.5</dropwizardmetrics.version> <!-- ZooKeeper server -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class DataSketchesOpStatsLogger implements OpStatsLogger {
private final LongAdder successSumAdder = new LongAdder();
private final LongAdder failSumAdder = new LongAdder();

DataSketchesOpStatsLogger() {
public DataSketchesOpStatsLogger() {
this.current = new ThreadLocalAccessor();
this.replacement = new ThreadLocalAccessor();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class DataSketchesSummaryLogger {
private final LongAdder countAdder = new LongAdder();
private final LongAdder sumAdder = new LongAdder();

DataSketchesSummaryLogger() {
public DataSketchesSummaryLogger() {
this.current = new ThreadLocalAccessor();
this.replacement = new ThreadLocalAccessor();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* 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.pulsar.broker.stats.prometheus.metrics;

import java.util.concurrent.atomic.LongAdder;
import org.apache.bookkeeper.stats.Counter;

/**
* {@link Counter} implementation based on {@link LongAdder}.
*
* <p>LongAdder keeps a counter per-thread and then aggregates to get the result, in order to avoid contention between
* multiple threads.
*/
public class LongAdderCounter implements Counter {
private final LongAdder counter = new LongAdder();

public LongAdderCounter() {

}

@Override
public void clear() {
counter.reset();
}

@Override
public void inc() {
counter.increment();
}

@Override
public void dec() {
counter.decrement();
}

@Override
public void add(long delta) {
counter.add(delta);
}

@Override
public Long get() {
return counter.sum();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class ObserverGauge extends SimpleCollector<ObserverGauge.Child> implemen
public static class Builder extends SimpleCollector.Builder<Builder, ObserverGauge> {
private Supplier<Number> supplier;

public Builder() {}

public Builder supplier(Supplier<Number> supplier) {
this.supplier = supplier;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.apache.bookkeeper.stats.CachingStatsProvider;
import org.apache.bookkeeper.stats.StatsLogger;
import org.apache.bookkeeper.stats.StatsProvider;
import org.apache.bookkeeper.stats.prometheus.LongAdderCounter;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils;

Expand All @@ -52,9 +51,9 @@ public class PrometheusMetricsProvider implements StatsProvider {
/**
* These acts a registry of the metrics defined in this provider.
*/
final ConcurrentMap<String, LongAdderCounter> counters = new ConcurrentSkipListMap<>();
final ConcurrentMap<String, SimpleGauge<? extends Number>> gauges = new ConcurrentSkipListMap<>();
final ConcurrentMap<String, DataSketchesOpStatsLogger> opStats = new ConcurrentSkipListMap<>();
public final ConcurrentMap<String, LongAdderCounter> counters = new ConcurrentSkipListMap<>();
public final ConcurrentMap<String, SimpleGauge<? extends Number>> gauges = new ConcurrentSkipListMap<>();
public final ConcurrentMap<String, DataSketchesOpStatsLogger> opStats = new ConcurrentSkipListMap<>();

public PrometheusMetricsProvider() {
this.cachingStatsProvider = new CachingStatsProvider(new StatsProvider() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.bookkeeper.stats.Gauge;
import org.apache.bookkeeper.stats.OpStatsLogger;
import org.apache.bookkeeper.stats.StatsLogger;
import org.apache.bookkeeper.stats.prometheus.LongAdderCounter;

/**
* A {@code Prometheus} based {@link StatsLogger} implementation.
Expand All @@ -34,7 +33,7 @@ public class PrometheusStatsLogger implements StatsLogger {
private final PrometheusMetricsProvider provider;
private final String scope;

PrometheusStatsLogger(PrometheusMetricsProvider provider, String scope) {
public PrometheusStatsLogger(PrometheusMetricsProvider provider, String scope) {
this.provider = provider;
this.scope = scope;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ private static void writeSum(Writer w, DataSketchesOpStatsLogger opStat, String
.append(Double.toString(opStat.getSum(success))).append('\n');
}

static void writeMetricsCollectedByPrometheusClient(Writer w, CollectorRegistry registry) throws IOException {
public static void writeMetricsCollectedByPrometheusClient(Writer w, CollectorRegistry registry)
throws IOException {
Enumeration<MetricFamilySamples> metricFamilySamples = registry.metricFamilySamples();
while (metricFamilySamples.hasMoreElements()) {
MetricFamilySamples metricFamily = metricFamilySamples.nextElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public SimpleGauge(final Gauge<T> gauge) {
this.gauge = gauge;
}

Number getSample() {
public Number getSample() {
return gauge.getSample();
}
}
24 changes: 12 additions & 12 deletions pulsar-sql/presto-distribution/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -413,18 +413,18 @@ The Apache Software License, Version 2.0
- async-http-client-2.12.1.jar
- async-http-client-netty-utils-2.12.1.jar
* Apache Bookkeeper
- bookkeeper-common-4.13.0.jar
- bookkeeper-common-allocator-4.13.0.jar
- bookkeeper-proto-4.13.0.jar
- bookkeeper-server-4.13.0.jar
- bookkeeper-stats-api-4.13.0.jar
- bookkeeper-tools-framework-4.13.0.jar
- circe-checksum-4.13.0.jar
- codahale-metrics-provider-4.13.0.jar
- cpu-affinity-4.13.0.jar
- http-server-4.13.0.jar
- prometheus-metrics-provider-4.13.0.jar
- codahale-metrics-provider-4.13.0.jar
- bookkeeper-common-4.14.1.jar
- bookkeeper-common-allocator-4.14.1.jar
- bookkeeper-proto-4.14.1.jar
- bookkeeper-server-4.14.1.jar
- bookkeeper-stats-api-4.14.1.jar
- bookkeeper-tools-framework-4.14.1.jar
- circe-checksum-4.14.1.jar
- codahale-metrics-provider-4.14.1.jar
- cpu-affinity-4.14.1.jar
- http-server-4.14.1.jar
- prometheus-metrics-provider-4.14.1.jar
- codahale-metrics-provider-4.14.1.jar
* Apache Commons
- commons-cli-1.2.jar
- commons-codec-1.10.jar
Expand Down

0 comments on commit e6b35d9

Please sign in to comment.