From 12e91104d6bbb9317c3535b56b631a5b529b5adc Mon Sep 17 00:00:00 2001 From: arvindkandhare Date: Fri, 26 May 2017 16:52:57 +0200 Subject: [PATCH] BOOKKEEPER-1010: Moving Guava to 20.0 This patch updates Guava to version 20.0 and shades it Author: arvindkandhare Author: eolivelli Reviewers: Sijie Guo, Enrico Olivelli Closes #166 from eolivelli/guava_version --- .../java/org/apache/bookkeeper/bookie/Journal.java | 8 ++++---- .../java/org/apache/bookkeeper/metastore/Value.java | 3 ++- .../org/apache/bookkeeper/replication/Auditor.java | 12 ++++++------ .../bookkeeper/replication/ReplicationWorker.java | 4 ++-- .../bookkeeper/stats/CodahaleMetricsProvider.java | 1 + compat-deps/bookkeeper-server-compat-4.0.0/pom.xml | 5 +++++ compat-deps/bookkeeper-server-compat-4.1.0/pom.xml | 5 +++++ compat-deps/bookkeeper-server-compat-4.2.0/pom.xml | 5 +++++ pom.xml | 2 +- 9 files changed, 31 insertions(+), 14 deletions(-) diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java index 04d9e7f8fa6..71063b9d7df 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java @@ -792,8 +792,8 @@ public void run() { ZeroBuffer.put(paddingBuff); 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 journalIds = listJournalIds(journalDirectory, null); @@ -822,7 +822,7 @@ public void run() { removePagesFromCache, conf.getJournalFormatVersionToWrite()); journalCreationStats.registerSuccessfulEvent( - journalCreationWatcher.stop().elapsedTime(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS); + journalCreationWatcher.stop().elapsed(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS); bc = logFile.getBufferedChannel(); @@ -890,7 +890,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()) { diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/metastore/Value.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/metastore/Value.java index ef89245615b..ae2423c547d 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/metastore/Value.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/metastore/Value.java @@ -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; @@ -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(); } diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java index f6a73fee793..112e14f106a 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java @@ -356,10 +356,9 @@ public void doCheckAllLedgers() { 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) { @@ -504,7 +503,7 @@ private void auditBookies() return; } - Stopwatch stopwatch = new Stopwatch().start(); + Stopwatch stopwatch = Stopwatch.createStarted(); // put exit cases here Map> ledgerDetails = generateBookie2LedgersIndex(); try { @@ -519,16 +518,17 @@ private void auditBookies() + "Will retry after a period"); return; } + try { List availableBookies = getAvailableBookies(); // find lost bookies Set knownBookies = ledgerDetails.keySet(); Collection 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(), + uRLPublishTimeForLostBookies.registerSuccessfulEvent(stopwatch.stop().elapsed(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS); } } finally { diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java index c1335a924aa..862e58710a2 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java @@ -210,12 +210,12 @@ 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 { diff --git a/bookkeeper-stats-providers/codahale-metrics-provider/src/main/java/org/apache/bookkeeper/stats/CodahaleMetricsProvider.java b/bookkeeper-stats-providers/codahale-metrics-provider/src/main/java/org/apache/bookkeeper/stats/CodahaleMetricsProvider.java index 33b3515a95a..15ac45f1cb1 100644 --- a/bookkeeper-stats-providers/codahale-metrics-provider/src/main/java/org/apache/bookkeeper/stats/CodahaleMetricsProvider.java +++ b/bookkeeper-stats-providers/codahale-metrics-provider/src/main/java/org/apache/bookkeeper/stats/CodahaleMetricsProvider.java @@ -48,6 +48,7 @@ import com.google.common.net.HostAndPort; +@SuppressWarnings("deprecation") public class CodahaleMetricsProvider implements StatsProvider { static final Logger LOG = LoggerFactory.getLogger(CodahaleMetricsProvider.class); diff --git a/compat-deps/bookkeeper-server-compat-4.0.0/pom.xml b/compat-deps/bookkeeper-server-compat-4.0.0/pom.xml index 412832492d6..a10f25eee24 100644 --- a/compat-deps/bookkeeper-server-compat-4.0.0/pom.xml +++ b/compat-deps/bookkeeper-server-compat-4.0.0/pom.xml @@ -78,6 +78,7 @@ com.google.protobuf:protobuf-java org.apache.*:* org.jboss.*:* + com.google.guava:guava commons-*:* @@ -100,6 +101,10 @@ org.jboss org.jboss.bk_v4_0_0 + + com.google + com.google.bk_v4_0_0 + diff --git a/compat-deps/bookkeeper-server-compat-4.1.0/pom.xml b/compat-deps/bookkeeper-server-compat-4.1.0/pom.xml index 02f8d9aa8de..72eb0ee8763 100644 --- a/compat-deps/bookkeeper-server-compat-4.1.0/pom.xml +++ b/compat-deps/bookkeeper-server-compat-4.1.0/pom.xml @@ -78,6 +78,7 @@ com.google.protobuf:protobuf-java org.apache.*:* org.jboss.*:* + com.google.guava:guava commons-*:* @@ -109,6 +110,10 @@ org.jboss org.jboss.bk_v4_1_0 + + com.google + com.google.bk_v4_1_0 + diff --git a/compat-deps/bookkeeper-server-compat-4.2.0/pom.xml b/compat-deps/bookkeeper-server-compat-4.2.0/pom.xml index f11182d61d5..873f7f96cd5 100644 --- a/compat-deps/bookkeeper-server-compat-4.2.0/pom.xml +++ b/compat-deps/bookkeeper-server-compat-4.2.0/pom.xml @@ -78,6 +78,7 @@ com.google.protobuf:protobuf-java org.apache.*:* org.jboss.*:* + com.google.guava:guava commons-*:* @@ -109,6 +110,10 @@ org.jboss org.jboss.bk_v4_2_0 + + com.google + com.google.bk_v4_2_0 + diff --git a/pom.xml b/pom.xml index 0ed8e6482e8..38794d3ee56 100644 --- a/pom.xml +++ b/pom.xml @@ -46,7 +46,7 @@ UTF-8 UTF-8 2.6.1 - 13.0.1 + 20.0 1.7.25 2.10.0 3.3.6