HADOOP-10101. Update guava dependency to the latest version. (ozawa)

This commit is contained in:
Tsuyoshi Ozawa 2017-03-25 10:06:52 +09:00
parent 1f66524432
commit 84ddedc0b2
23 changed files with 38 additions and 35 deletions

View File

@ -67,7 +67,7 @@ class XAttrCommands extends FsCommand {
"0x and 0s, respectively.\n" +
"<path>: The file or directory.\n";
private final static Function<String, XAttrCodec> enValueOfFunc =
Enums.valueOfFunction(XAttrCodec.class);
Enums.stringConverter(XAttrCodec.class);
private String name = null;
private boolean dump = false;

View File

@ -55,7 +55,6 @@ import org.apache.zookeeper.data.ACL;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
@InterfaceAudience.LimitedPrivate("HDFS")
@ -511,7 +510,7 @@ public abstract class ZKFailoverController {
doFence(target);
} catch (Throwable t) {
recordActiveAttempt(new ActiveAttemptRecord(false, "Unable to fence old active: " + StringUtils.stringifyException(t)));
Throwables.propagate(t);
throw t;
}
}

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.metrics2;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import static com.google.common.base.Preconditions.*;
@ -84,7 +85,7 @@ public abstract class AbstractMetric implements MetricsInfo {
}
@Override public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.add("info", info)
.add("value", value())
.toString();

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.metrics2;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import static com.google.common.base.Preconditions.*;
@ -80,7 +81,7 @@ public class MetricsTag implements MetricsInfo {
}
@Override public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.add("info", info)
.add("value", value())
.toString();

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.metrics2.impl;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.collect.Iterables;
@ -43,7 +44,7 @@ abstract class AbstractMetricsRecord implements MetricsRecord {
}
@Override public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.add("timestamp", timestamp())
.add("name", name())
.add("description", description())

View File

@ -18,7 +18,7 @@
package org.apache.hadoop.metrics2.impl;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.metrics2.MetricsInfo;
@ -48,7 +48,7 @@ public enum MsInfo implements MetricsInfo {
}
@Override public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.add("name", name()).add("description", desc)
.toString();
}

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.metrics2.lib;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import static com.google.common.base.Preconditions.*;
import org.apache.hadoop.metrics2.MetricsInfo;
@ -55,7 +56,7 @@ class MetricsInfoImpl implements MetricsInfo {
}
@Override public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.add("name", name).add("description", description)
.toString();
}

View File

@ -22,7 +22,7 @@ import java.util.Collection;
import java.util.Map;
import com.google.common.collect.Maps;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
@ -416,7 +416,7 @@ public class MetricsRegistry {
}
@Override public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.add("info", metricsInfo).add("tags", tags()).add("metrics", metrics())
.toString();
}

View File

@ -18,11 +18,11 @@
package org.apache.hadoop.metrics2.source;
import com.google.common.base.Objects;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.metrics2.MetricsInfo;
import com.google.common.base.MoreObjects;
/**
* JVM and logging related metrics info instances
*/
@ -60,7 +60,7 @@ public enum JvmMetricsInfo implements MetricsInfo {
@Override public String description() { return desc; }
@Override public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.add("name", name()).add("description", desc)
.toString();
}

View File

@ -31,7 +31,7 @@ import org.apache.hadoop.metrics2.AbstractMetric;
import org.apache.hadoop.metrics2.MetricsRecord;
import org.apache.hadoop.metrics2.MetricsTag;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Maps;
/**
@ -127,7 +127,7 @@ public class MetricsCache {
}
@Override public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.add("tags", tags).add("metrics", metrics)
.toString();
}

View File

@ -19,7 +19,6 @@
package org.apache.hadoop.util.curator;
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
import org.apache.curator.framework.recipes.locks.Reaper;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.framework.CuratorFramework;
@ -34,6 +33,7 @@ import org.slf4j.LoggerFactory;
import java.io.Closeable;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@ -82,7 +82,7 @@ public class ChildReaper implements Closeable
* @since 15.0
*/
public static <E> Set<E> newConcurrentHashSet() {
return Sets.newSetFromMap(new ConcurrentHashMap<E, Boolean>());
return Collections.newSetFromMap(new ConcurrentHashMap<E, Boolean>());
}
private enum State

View File

@ -18,7 +18,7 @@
package org.apache.hadoop.hdfs;
import com.google.common.collect.Iterators;
import java.util.Collections;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hdfs.inotify.EventBatch;
@ -72,7 +72,7 @@ public class DFSInotifyEventInputStream {
DFSInotifyEventInputStream(ClientProtocol namenode, Tracer tracer,
long lastReadTxid) {
this.namenode = namenode;
this.it = Iterators.emptyIterator();
this.it = Collections.emptyIterator();
this.lastReadTxid = lastReadTxid;
this.tracer = tracer;
}

View File

@ -1109,7 +1109,7 @@ public class DataStorage extends Storage {
}
linkWorkers.shutdown();
for (Future<Void> f : futures) {
Futures.get(f, IOException.class);
Futures.getChecked(f, IOException.class);
}
}

View File

@ -28,7 +28,7 @@ import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@ -366,7 +366,7 @@ final class AclTransformation {
for (AclEntry entry: aclBuilder) {
scopeFound.add(entry.getScope());
if (entry.getType() == GROUP || entry.getName() != null) {
FsAction scopeUnionPerms = Objects.firstNonNull(
FsAction scopeUnionPerms = MoreObjects.firstNonNull(
unionPerms.get(entry.getScope()), FsAction.NONE);
unionPerms.put(entry.getScope(),
scopeUnionPerms.or(entry.getPermission()));

View File

@ -63,7 +63,7 @@ public class JournalSet implements JournalManager {
public int compare(EditLogInputStream elis1, EditLogInputStream elis2) {
// we want local logs to be ordered earlier in the collection, and true
// is considered larger than false, so we want to invert the booleans here
return ComparisonChain.start().compare(!elis1.isLocalLog(),
return ComparisonChain.start().compareFalseFirst(!elis1.isLocalLog(),
!elis2.isLocalLog()).result();
}
};

View File

@ -402,7 +402,7 @@ public class TestQJMWithFaults {
@Override
protected ExecutorService createSingleThreadExecutor() {
return MoreExecutors.sameThreadExecutor();
return MoreExecutors.newDirectExecutorService();
}
}

View File

@ -946,7 +946,7 @@ public class TestQuorumJournalManager {
protected ExecutorService createSingleThreadExecutor() {
// Don't parallelize calls to the quorum in the tests.
// This makes the tests more deterministic.
return MoreExecutors.sameThreadExecutor();
return MoreExecutors.newDirectExecutorService();
}
};

View File

@ -514,7 +514,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>11.0.2</version>
<version>21.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>

View File

@ -283,7 +283,7 @@ extends ApplicationSubmissionContext {
"maximum allowed length of a tag is " +
YarnConfiguration.APPLICATION_MAX_TAG_LENGTH);
}
if (!CharMatcher.ASCII.matchesAllOf(tag)) {
if (!CharMatcher.ascii().matchesAllOf(tag)) {
throw new IllegalArgumentException("A tag can only have ASCII " +
"characters! Invalid tag - " + tag);
}

View File

@ -275,7 +275,7 @@ public abstract class WebApp extends ServletModule {
static String getPrefix(String pathSpec) {
int start = 0;
while (CharMatcher.WHITESPACE.matches(pathSpec.charAt(start))) {
while (CharMatcher.whitespace().matches(pathSpec.charAt(start))) {
++start;
}
if (pathSpec.charAt(start) != '/') {
@ -291,7 +291,7 @@ public abstract class WebApp extends ServletModule {
char c;
do {
c = pathSpec.charAt(--ci);
} while (c == '/' || CharMatcher.WHITESPACE.matches(c));
} while (c == '/' || CharMatcher.whitespace().matches(c));
return pathSpec.substring(start, ci + 1);
}

View File

@ -590,7 +590,7 @@ public class RMAppManager implements EventHandler<RMAppManagerEvent>,
this.rmContext.getStateStore()
.updateApplicationStateSynchronously(appState, false, future);
Futures.get(future, YarnException.class);
Futures.getChecked(future, YarnException.class);
// update in-memory
((RMAppImpl) app).updateApplicationTimeout(newExpireTime);
@ -627,7 +627,7 @@ public class RMAppManager implements EventHandler<RMAppManagerEvent>,
return;
}
Futures.get(future, YarnException.class);
Futures.getChecked(future, YarnException.class);
// update in-memory
((RMAppImpl) app).setApplicationPriority(appPriority);
@ -710,7 +710,7 @@ public class RMAppManager implements EventHandler<RMAppManagerEvent>,
false, future);
try {
Futures.get(future, YarnException.class);
Futures.getChecked(future, YarnException.class);
} catch (YarnException ex) {
if (!toSuppressException) {
throw ex;

View File

@ -465,7 +465,7 @@ public class AllocationFileLoaderService extends AbstractService {
Set<String> reservableQueues,
Set<String> nonPreemptableQueues)
throws AllocationConfigurationException {
String queueName = CharMatcher.WHITESPACE.trimFrom(
String queueName = CharMatcher.whitespace().trimFrom(
element.getAttribute("name"));
if (queueName.contains(".")) {

View File

@ -535,6 +535,6 @@ public class QueueManager {
// use the same white space trim as in QueueMetrics() otherwise things fail
// guava uses a different definition for whitespace than java.
return !node.isEmpty() &&
node.equals(CharMatcher.WHITESPACE.trimFrom(node));
node.equals(CharMatcher.whitespace().trimFrom(node));
}
}