Skip to content

Commit

Permalink
BOOKKEEPER-1010: Moving Guava to 20.0
Browse files Browse the repository at this point in the history
This patch updates Guava to version 20.0 and shades it

Author: arvindkandhare <arvind.kandhare@emc.com>
Author: eolivelli <eolivelli@apache.org>

Reviewers: Sijie Guo, Enrico Olivelli

Closes #166 from eolivelli/guava_version
  • Loading branch information
arvindkandhare authored and eolivelli committed May 26, 2017
1 parent 6698912 commit fd3331a
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,8 @@ public void run() {
final int journalAlignmentSize = conf.getJournalAlignmentSize();
JournalChannel logFile = null;
forceWriteThread.start();
Stopwatch journalCreationWatcher = new Stopwatch();
Stopwatch journalFlushWatcher = new Stopwatch();
Stopwatch journalCreationWatcher = Stopwatch.createUnstarted();
Stopwatch journalFlushWatcher = Stopwatch.createUnstarted();
long batchSize = 0;
try {
List<Long> journalIds = listJournalIds(journalDirectory, null);
Expand Down Expand Up @@ -836,7 +836,7 @@ public void run() {
removePagesFromCache,
journalFormatVersionToWrite);
journalCreationStats.registerSuccessfulEvent(
journalCreationWatcher.stop().elapsedTime(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
journalCreationWatcher.stop().elapsed(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);

bc = logFile.getBufferedChannel();

Expand Down Expand Up @@ -904,7 +904,7 @@ public void run() {
bc.flush(false);
lastFlushPosition = bc.position();
journalFlushStats.registerSuccessfulEvent(
journalFlushWatcher.stop().elapsedTime(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
journalFlushWatcher.stop().elapsed(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);

// Trace the lifetime of entries through persistence
if (LOG.isDebugEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;

import java.nio.charset.Charset;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -92,7 +93,7 @@ public int hashCode() {
HashFunction hf = Hashing.murmur3_32();
Hasher hc = hf.newHasher();
for (String key : fields.keySet()) {
hc.putString(key);
hc.putString(key, Charset.defaultCharset());
}
return hc.hash().asInt();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,11 @@ public void run() {
return;
}

Stopwatch stopwatch = new Stopwatch().start();
Stopwatch stopwatch = Stopwatch.createStarted();
checkAllLedgers();
checkAllLedgersTime.registerSuccessfulEvent(stopwatch.stop().elapsedMillis(),
TimeUnit.MILLISECONDS);
checkAllLedgersTime.registerSuccessfulEvent(stopwatch.stop()
.elapsed(TimeUnit.MILLISECONDS),
TimeUnit.MILLISECONDS);
} catch (KeeperException ke) {
LOG.error("Exception while running periodic check", ke);
} catch (InterruptedException ie) {
Expand Down Expand Up @@ -398,7 +399,7 @@ private void auditBookies()
return;
}

Stopwatch stopwatch = new Stopwatch().start();
Stopwatch stopwatch = Stopwatch.createStarted();
// put exit cases here
Map<String, Set<Long>> ledgerDetails = generateBookie2LedgersIndex();
try {
Expand All @@ -420,10 +421,12 @@ private void auditBookies()
Collection<String> lostBookies = CollectionUtils.subtract(knownBookies,
availableBookies);

bookieToLedgersMapCreationTime.registerSuccessfulEvent(stopwatch.elapsedMillis(), TimeUnit.MILLISECONDS);
bookieToLedgersMapCreationTime.registerSuccessfulEvent(stopwatch.elapsed(TimeUnit.MILLISECONDS),
TimeUnit.MILLISECONDS);
if (lostBookies.size() > 0) {
handleLostBookies(lostBookies, ledgerDetails);
uRLPublishTimeForLostBookies.registerSuccessfulEvent(stopwatch.stop().elapsedMillis(), TimeUnit.MILLISECONDS);
uRLPublishTimeForLostBookies.registerSuccessfulEvent(stopwatch.stop().elapsed(TimeUnit.MILLISECONDS),
TimeUnit.MILLISECONDS);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ private void rereplicate() throws InterruptedException, BKException,
long ledgerIdToReplicate = underreplicationManager
.getLedgerToRereplicate();

Stopwatch stopwatch = new Stopwatch().start();
Stopwatch stopwatch = Stopwatch.createStarted();
boolean success = false;
try {
success = rereplicate(ledgerIdToReplicate);
} finally {
long latencyMillis = stopwatch.stop().elapsedMillis();
long latencyMillis = stopwatch.stop().elapsed(TimeUnit.MILLISECONDS);
if (success) {
rereplicateOpStats.registerSuccessfulEvent(latencyMillis, TimeUnit.MILLISECONDS);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@SuppressWarnings("deprecation")
public class CodahaleMetricsProvider implements StatsProvider {

static final Logger LOG = LoggerFactory.getLogger(CodahaleMetricsProvider.class);
Expand Down
5 changes: 5 additions & 0 deletions compat-deps/bookkeeper-server-compat-4.0.0/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<include>com.google.protobuf:protobuf-java</include>
<include>org.apache.*:*</include>
<include>org.jboss.*:*</include>
<include>com.google.guava:guava</include>
<include>commons-*:*</include>
</includes>
<excludes>
Expand All @@ -83,6 +84,10 @@
<pattern>org.jboss</pattern>
<shadedPattern>org.jboss.bk_v4_0_0</shadedPattern>
</relocation>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>com.google.bk_v4_0_0</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
Expand Down
5 changes: 5 additions & 0 deletions compat-deps/bookkeeper-server-compat-4.1.0/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<include>com.google.protobuf:protobuf-java</include>
<include>org.apache.*:*</include>
<include>org.jboss.*:*</include>
<include>com.google.guava:guava</include>
<include>commons-*:*</include>
</includes>
<excludes>
Expand Down Expand Up @@ -92,6 +93,10 @@
<pattern>org.jboss</pattern>
<shadedPattern>org.jboss.bk_v4_1_0</shadedPattern>
</relocation>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>com.google.bk_v4_1_0</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
Expand Down
5 changes: 5 additions & 0 deletions compat-deps/bookkeeper-server-compat-4.2.0/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<include>com.google.protobuf:protobuf-java</include>
<include>org.apache.*:*</include>
<include>org.jboss.*:*</include>
<include>com.google.guava:guava</include>
<include>commons-*:*</include>
</includes>
<excludes>
Expand Down Expand Up @@ -92,6 +93,10 @@
<pattern>org.jboss</pattern>
<shadedPattern>org.jboss.bk_v4_2_0</shadedPattern>
</relocation>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>com.google.bk_v4_2_0</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<protobuf.version>2.6.1</protobuf.version>
<guava.version>13.0.1</guava.version>
<guava.version>20.0</guava.version>
<netty.version>4.1.10.Final</netty.version>
<zookeeper.version>3.5.1-alpha</zookeeper.version>
<slf4j.version>1.7.25</slf4j.version>
Expand Down

0 comments on commit fd3331a

Please sign in to comment.