Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public static final String getServicePrincipal(String service,
*/
static final String[] getPrincipalNames(String keytabFileName) throws IOException {
Keytab keytab = Keytab.loadKeytab(new File(keytabFileName));
Set<String> principals = new HashSet<String>();
Set<String> principals = new HashSet<>();
List<PrincipalName> entries = keytab.getPrincipals();
for (PrincipalName entry : entries) {
principals.add(entry.getName().replace("\\", "/"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
public static <T> T doAs(String principal, final Callable<T> callable) throws Exception {
LoginContext loginContext = null;
try {
Set<Principal> principals = new HashSet<Principal>();
Set<Principal> principals = new HashSet<>();
principals.add(new KerberosPrincipal(KerberosTestUtils.getClientPrincipal()));
Subject subject = new Subject(false, principals, new HashSet<Object>(), new HashSet<Object>());
Subject subject = new Subject(false, principals, new HashSet<>(), new HashSet<>());
loginContext = new LoginContext("", subject, null, new KerberosConfiguration(principal));
loginContext.login();
subject = loginContext.getSubject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ private void updatePropertiesWithDeprecatedKeys(
private void handleDeprecation() {
LOG.debug("Handling deprecation for all properties in config...");
DeprecationContext deprecations = deprecationContext.get();
Set<Object> keys = new HashSet<Object>();
Set<Object> keys = new HashSet<>();
keys.addAll(getProps().keySet());
for (Object item: keys) {
LOG.debug("Handling deprecation for " + (String)item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2372,8 +2372,7 @@ public FileStatus next(final AbstractFileSystem fs, final Path p)
Set<AbstractFileSystem> resolveAbstractFileSystems(final Path f)
throws IOException {
final Path absF = fixRelativePart(f);
final HashSet<AbstractFileSystem> result
= new HashSet<AbstractFileSystem>();
final HashSet<AbstractFileSystem> result = new HashSet<>();
new FSLinkResolver<Void>() {
@Override
public Void next(final AbstractFileSystem fs, final Path p)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ synchronized void returnToPool(ChannelSftp channel) {
ConnectionInfo info = con2infoMap.get(channel);
HashSet<ChannelSftp> cons = idleConnections.get(info);
if (cons == null) {
cons = new HashSet<ChannelSftp>();
cons = new HashSet<>();
idleConnections.put(info, cons);
}
cons.add(channel);
Expand All @@ -94,7 +94,7 @@ synchronized void shutdown() {
Set<ChannelSftp> cons = con2infoMap.keySet();
if (cons != null && cons.size() > 0) {
// make a copy since we need to modify the underlying Map
Set<ChannelSftp> copy = new HashSet<ChannelSftp>(cons);
Set<ChannelSftp> copy = new HashSet<>(cons);
// Initiate disconnect from all outstanding connections
for (ChannelSftp con : copy) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public String getOptValue(String option) {
* @return Set{@literal <}String{@literal >} of the enabled options
*/
public Set<String> getOpts() {
Set<String> optSet = new HashSet<String>();
Set<String> optSet = new HashSet<>();
for (Map.Entry<String, Boolean> entry : options.entrySet()) {
if (entry.getValue()) {
optSet.add(entry.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private static void addExpression(Class<?> clazz) {
private Expression rootExpression;

/** Set of path items returning a {@link Result#STOP} result. */
private HashSet<Path> stopPaths = new HashSet<Path>();
private HashSet<Path> stopPaths = new HashSet<>();

/** Register the expressions with the expression factory. */
private static void registerExpressions(ExpressionFactory factory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ public FileSystem[] getChildFileSystems() {
List<InodeTree.MountPoint<FileSystem>> mountPoints =
fsState.getMountPoints();
Map<String, FileSystem> fsMap = initializeMountedFileSystems(mountPoints);
Set<FileSystem> children = new HashSet<FileSystem>();
Set<FileSystem> children = new HashSet<>();
for (InodeTree.MountPoint<FileSystem> mountPoint : mountPoints) {
FileSystem targetFs = fsMap.get(mountPoint.src);
children.addAll(Arrays.asList(targetFs.getChildFileSystems()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private static <T> boolean payback(Map<Class<T>, Set<T>> pool, T codec) {
synchronized (pool) {
codecSet = pool.get(codecClass);
if (codecSet == null) {
codecSet = new HashSet<T>();
codecSet = new HashSet<>();
pool.put(codecClass, codecSet);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public synchronized boolean accept(Class<?> c) {

private void getPackages() {
String[] pkgList = getConf().getStrings(AVRO_REFLECT_PACKAGES);
packages = new HashSet<String>();
packages = new HashSet<>();
if (pkgList != null) {
for (String pkg : pkgList) {
packages.add(pkg.trim());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void fetchServerMethods(Method method) throws IOException {
}
int[] serverMethodsCodes = serverInfo.getMethods();
if (serverMethodsCodes != null) {
serverMethods = new HashSet<Integer>(serverMethodsCodes.length);
serverMethods = new HashSet<>(serverMethodsCodes.length);
for (int m : serverMethodsCodes) {
this.serverMethods.add(Integer.valueOf(m));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
package org.apache.hadoop.metrics2.lib;

import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;

import static org.apache.hadoop.util.Preconditions.*;
import org.apache.hadoop.util.Sets;

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
Expand All @@ -44,7 +43,7 @@
public class MutableRates extends MutableMetric {
static final Logger LOG = LoggerFactory.getLogger(MutableRates.class);
private final MetricsRegistry registry;
private final Set<Class<?>> protocolCache = Sets.newHashSet();
private final Set<Class<?>> protocolCache = new HashSet<>();

MutableRates(MetricsRegistry registry) {
this.registry = checkNotNull(registry, "metrics registry");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

package org.apache.hadoop.metrics2.lib;

import org.apache.hadoop.util.Sets;
import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -52,7 +52,7 @@ public class MutableRatesWithAggregation extends MutableMetric {
LoggerFactory.getLogger(MutableRatesWithAggregation.class);
private final Map<String, MutableRate> globalMetrics =
new ConcurrentHashMap<>();
private final Set<Class<?>> protocolCache = Sets.newHashSet();
private final Set<Class<?>> protocolCache = new HashSet<>();

private final ConcurrentLinkedDeque<WeakReference<ConcurrentMap<String, ThreadSafeSampleStat>>>
weakReferenceQueue = new ConcurrentLinkedDeque<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public String dumpTopology() {
builder.append("Mapping: ").append(toString()).append("\n");
if (rack != null) {
builder.append("Map:\n");
Set<String> switches = new HashSet<String>();
Set<String> switches = new HashSet<>();
for (Map.Entry<String, String> entry : rack.entrySet()) {
builder.append(" ")
.append(entry.getKey())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ private void interAddNodeWithEmptyRack(Node node) {
String rackname = node.getNetworkLocation();
Set<String> nodes = rackMap.get(rackname);
if (nodes == null) {
nodes = new HashSet<String>();
nodes = new HashSet<>();
}
if (!decommissionNodes.contains(node.getName())) {
nodes.add(node.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void cacheGroupsAdd(List<String> groups) throws IOException {

@Override
public synchronized Set<String> getGroupsSet(String user) throws IOException {
Set<String> groupSet = new HashSet<String>();
Set<String> groupSet = new HashSet<>();

Set<String> groups = null;
for (GroupMappingServiceProvider provider : providersList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static List<String> getNetgroupNames() {
}

private static Set<String> getGroups() {
Set<String> allGroups = new HashSet<String> ();
Set<String> allGroups = new HashSet<>();
for (Set<String> userGroups : userToNetgroupsMap.values()) {
allGroups.addAll(userGroups);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public AccessControlList(String users, String groups) {
* @param userGroupStrings build ACL from array of Strings
*/
private void buildACL(String[] userGroupStrings) {
users = new HashSet<String>();
groups = new HashSet<String>();
users = new HashSet<>();
groups = new HashSet<>();
for (String aclPart : userGroupStrings) {
if (aclPart != null && isWildCardACLValue(aclPart)) {
allAllowed = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void refresh() {
}

public static void refresh(Configuration conf){
Collection<String> tempServers = new HashSet<String>();
Collection<String> tempServers = new HashSet<>();
// trusted proxy servers such as http proxies
for (String host : conf.getTrimmedStrings(CONF_HADOOP_PROXYSERVERS)) {
InetSocketAddress addr = new InetSocketAddress(host, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ public void init(FilterConfig filterConfig) throws ServletException {

void parseBrowserUserAgents(String userAgents) {
String[] agentsArray = userAgents.split(",");
browserUserAgents = new HashSet<Pattern>();
browserUserAgents = new HashSet<>();
for (String patternString : agentsArray) {
browserUserAgents.add(Pattern.compile(patternString));
}
}

void parseMethodsToIgnore(String mti) {
String[] methods = mti.split(",");
methodsToIgnore = new HashSet<String>();
methodsToIgnore = new HashSet<>();
for (int i = 0; i < methods.length; i++) {
methodsToIgnore.add(methods[i]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ public String getTrackingId() {
/** Remove expired delegation tokens from cache */
private void removeExpiredToken() throws IOException {
long now = Time.now();
Set<TokenIdent> expiredTokens = new HashSet<TokenIdent>();
Set<TokenIdent> expiredTokens = new HashSet<>();
synchronized (this) {
Iterator<Map.Entry<TokenIdent, DelegationTokenInformation>> i =
currentTokens.entrySet().iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public abstract class DelegationTokenAuthenticationHandler

public static final String TOKEN_KIND = PREFIX + "token-kind";

private static final Set<String> DELEGATION_TOKEN_OPS = new HashSet<String>();
private static final Set<String> DELEGATION_TOKEN_OPS = new HashSet<>();

public static final String DELEGATION_TOKEN_UGI_ATTRIBUTE =
"hadoop.security.delegation-token.ugi";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public FileBasedIPList(String fileName) {
lines = null;
}
if (lines != null) {
addressList = new MachineList(new HashSet<String>(Arrays.asList(lines)));
addressList = new MachineList(new HashSet<>(Arrays.asList(lines)));
} else {
addressList = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static void readFileToMapWithFileInputStream(String type,
if (xmlInput) {
readXmlFileToMapWithFileInputStream(type, filename, inputStream, map);
} else {
HashSet<String> nodes = new HashSet<String>();
HashSet<String> nodes = new HashSet<>();
readFileToSetWithFileInputStream(type, filename, inputStream, nodes);
for (String node : nodes) {
map.put(node, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ TimeUnit getTimeUnit() {
}

private final Set<HookEntry> hooks =
Collections.synchronizedSet(new HashSet<HookEntry>());
Collections.synchronizedSet(new HashSet<>());

private AtomicBoolean shutdownInProgress = new AtomicBoolean(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public void initializeMemberVariables() {
};

// Initialize used variables
xmlPropsToSkipCompare = new HashSet<String>();
xmlPrefixToSkipCompare = new HashSet<String>();
configurationPropsToSkipCompare = new HashSet<String>();
xmlPropsToSkipCompare = new HashSet<>();
xmlPrefixToSkipCompare = new HashSet<>();
configurationPropsToSkipCompare = new HashSet<>();

// Set error modes
errorIfMissingConfigProps = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package org.apache.hadoop.crypto.key;

import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeoutException;
Expand All @@ -32,7 +34,6 @@
import org.junit.Assert;
import org.junit.Test;

import org.apache.hadoop.util.Sets;

public class TestValueQueue {
Logger LOG = LoggerFactory.getLogger(TestValueQueue.class);
Expand Down Expand Up @@ -103,10 +104,10 @@ public void testWarmUp() throws Exception {
Assert.assertEquals(5, fillInfos[0].num);
Assert.assertEquals(5, fillInfos[1].num);
Assert.assertEquals(5, fillInfos[2].num);
Assert.assertEquals(Sets.newHashSet("k1", "k2", "k3"),
Sets.newHashSet(fillInfos[0].key,
Assert.assertEquals(new HashSet<>(Arrays.asList("k1", "k2", "k3")),
new HashSet<>(Arrays.asList(fillInfos[0].key,
fillInfos[1].key,
fillInfos[2].key));
fillInfos[2].key)));
vq.shutdown();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import java.security.NoSuchAlgorithmException;
import java.security.PrivilegedExceptionAction;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.TimeUnit;

Expand All @@ -65,7 +67,6 @@
import org.junit.rules.Timeout;
import org.mockito.Mockito;

import org.apache.hadoop.util.Sets;

public class TestLoadBalancingKMSClientProvider {

Expand All @@ -86,34 +87,34 @@ public void testCreation() throws Exception {
KMSClientProvider[] providers =
((LoadBalancingKMSClientProvider) kp).getProviders();
assertEquals(1, providers.length);
assertEquals(Sets.newHashSet("http://host1:9600/kms/foo/v1/"),
Sets.newHashSet(providers[0].getKMSUrl()));
assertEquals(new HashSet<>(Collections.singleton("http://host1:9600/kms/foo/v1/")),
new HashSet<>(Collections.singleton(providers[0].getKMSUrl())));

kp = new KMSClientProvider.Factory().createProvider(new URI(
"kms://http@host1;host2;host3:9600/kms/foo"), conf);
assertTrue(kp instanceof LoadBalancingKMSClientProvider);
providers =
((LoadBalancingKMSClientProvider) kp).getProviders();
assertEquals(3, providers.length);
assertEquals(Sets.newHashSet("http://host1:9600/kms/foo/v1/",
assertEquals(new HashSet<>(Arrays.asList("http://host1:9600/kms/foo/v1/",
"http://host2:9600/kms/foo/v1/",
"http://host3:9600/kms/foo/v1/"),
Sets.newHashSet(providers[0].getKMSUrl(),
"http://host3:9600/kms/foo/v1/")),
new HashSet<>(Arrays.asList(providers[0].getKMSUrl(),
providers[1].getKMSUrl(),
providers[2].getKMSUrl()));
providers[2].getKMSUrl())));

kp = new KMSClientProvider.Factory().createProvider(new URI(
"kms://http@host1;host2;host3:9600/kms/foo"), conf);
assertTrue(kp instanceof LoadBalancingKMSClientProvider);
providers =
((LoadBalancingKMSClientProvider) kp).getProviders();
assertEquals(3, providers.length);
assertEquals(Sets.newHashSet("http://host1:9600/kms/foo/v1/",
assertEquals(new HashSet<>(Arrays.asList("http://host1:9600/kms/foo/v1/",
"http://host2:9600/kms/foo/v1/",
"http://host3:9600/kms/foo/v1/"),
Sets.newHashSet(providers[0].getKMSUrl(),
"http://host3:9600/kms/foo/v1/")),
new HashSet<>(Arrays.asList(providers[0].getKMSUrl(),
providers[1].getKMSUrl(),
providers[2].getKMSUrl()));
providers[2].getKMSUrl())));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public class TestCommandFormat {

@Before
public void setUp() {
args = new ArrayList<String>();
expectedOpts = new HashSet<String>();
expectedArgs = new ArrayList<String>();
args = new ArrayList<>();
expectedOpts = new HashSet<>();
expectedArgs = new ArrayList<>();
}

@Test
Expand Down Expand Up @@ -205,6 +205,6 @@ private static List<String> listOf(String ... objects) {
}

private static Set<String> setOf(String ... objects) {
return new HashSet<String>(listOf(objects));
return new HashSet<>(listOf(objects));
}
}
Loading