Skip to content

Branch 2.7.7 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 120 commits into
base: branch-2.7.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
7be4898
Preparing for 2.7.5 development
shvachko Jul 27, 2017
c521acd
HADOOP-14702. Fix formatting issue and regression caused by conversio…
iwasakims Aug 2, 2017
4ed7df2
Set the release date for 2.7.4.
shvachko Aug 5, 2017
ae85407
HDFS-12157. Do fsyncDirectory(..) outside of FSDataset lock. Contribu…
kihwal Aug 9, 2017
8e675d9
YARN-6959. RM may allocate wrong AM Container for new attempt. Contri…
jian-he Aug 17, 2017
3f5c67d
MAPREDUCE-6937. Backport MAPREDUCE-6870 to branch-2 while preserving …
haibchen Aug 30, 2017
39d3574
HDFS-9153. Pretty-format the output for DFSIO. Contributed by Kai Zheng.
Nov 23, 2015
abd741a
MAPREDUCE-6931. Remove TestDFSIO "Total Throughput" calculation. Cont…
shvachko Aug 22, 2017
70df729
HDFS-8797. WebHdfsFileSystem creates too many connections for pread. …
Jing9 Jul 23, 2015
c2350ec
HDFS-9107. Prevent NN's unrecoverable death spiral after full GC (Dar…
Sep 25, 2015
03892df
HADOOP-14827. Allow StopWatch to accept a Timer parameter for tests. …
jlowe Sep 6, 2017
0dca198
HDFS-12131. Add some of the FSNamesystem JMX values as metrics. Contr…
umbrant Aug 3, 2017
aa760e9
HADOOP-13442. Optimize UGI group lookups. Contributed by Daryn Sharp.
kihwal Aug 4, 2016
b40b8a0
HDFS-10738. Fix TestRefreshUserMappings.testRefreshSuperUserGroupsCon…
kihwal Aug 22, 2016
e89de1f
MAPREDUCE-6750. Fix TestHSAdminServer#testRefreshSuperUserGroups (Kih…
varunsaxena Aug 9, 2016
74e7c9b
HADOOP-14867. Update HDFS Federation setup document, for incorrect pr…
arp7 Sep 13, 2017
98986d1
Update CHANGES.txt for HADOOP-14827
jlowe Sep 13, 2017
b637f95
MAPREDUCE-6957. shuffle hangs after a node manager connection timeout…
jlowe Sep 13, 2017
0507a01
HDFS-10711. Optimize FSPermissionChecker group membership check. Cont…
kihwal Sep 2, 2016
f644b87
HDFS-12323. NameNode terminates after full GC thinking QJM unresponsi…
xkrogen Sep 14, 2017
ee7a94e
HDFS-12323. Add CHANGES.txt
shvachko Sep 15, 2017
897c10c
YARN-5195. RM intermittently crashed with NPE while handling APP_ATTE…
jlowe Sep 21, 2017
150222c
HADOOP-14881. LoadGenerator should use Time.monotonicNow() to measure…
jlowe Sep 25, 2017
ffe42e6
HADOOP-14902. LoadGenerator#genFile write close timing is incorrectly…
jlowe Sep 28, 2017
90aae39
YARN-7084. TestSchedulingMonitor#testRMStarts fails sporadically. Con…
erichadoop Sep 29, 2017
21db218
HDFS-8865. Improve quota initialization performance. Contributed by K…
xiao-chen Oct 2, 2017
0613956
Update CHANGES.txt for HDFS-8865
xiao-chen Oct 2, 2017
171a0bd
HDFS-9003. ForkJoin thread pool leaks. Contributed by Kihwal Lee.
Jing9 Sep 2, 2015
d101b98
HDFS-12578. TestDeadDatanode#testNonDFSUsedONDeadNodeReReg failing in…
xiao-chen Oct 13, 2017
754a375
HDFS-12596. Add TestFsck#testFsckCorruptWhenOneReplicaIsCorrupt back …
xiao-chen Oct 13, 2017
c068512
HDFS-12420. Add an option to disallow 'namenode format -force'. Contr…
arp7 Oct 5, 2017
5ef106a
HDFS-10984. Expose nntop output as metrics. Contributed by Siddharth …
xiaoyuyao Oct 11, 2016
53a261a
HDFS-12502. nntop should support a category based on FilesInGetListin…
zhe-thoughts Oct 19, 2017
3b45c27
Revert "HDFS-12502. nntop should support a category based on FilesInG…
zhe-thoughts Oct 24, 2017
bfa736b
Remove parent's env vars from child processes. Contributed by Vinayak…
naga-apache Oct 25, 2017
17e7c9d
HADOOP-14919. BZip2 drops records when reading data in splits. Contri…
jlowe Oct 31, 2017
0c86dc8
MAPREDUCE-6975. Logging task counters. Contributed by Prabhu Joseph.
naga-apache Nov 6, 2017
feb886f
Fixing Job History Server Configuration parsing. (Jason Lowe via asur…
xslogic Nov 9, 2017
6f876f4
HDFS-8829. Make SO_RCVBUF and SO_SNDBUF size configurable for DataTra…
Sep 14, 2015
0da13b9
HDFS-12823. Backport HDFS-9259 "Make SO_SNDBUF size configurable at D…
zhe-thoughts Nov 18, 2017
7252e18
HDFS-12832. INode.getFullPathName may throw ArrayIndexOutOfBoundsExce…
shvachko Nov 29, 2017
85eb32b
HDFS-12638. Delete copy-on-truncate block along with the original blo…
shvachko Dec 1, 2017
e650fcf
MAPREDUCE-5124. AM lacks flow control for task events. Contributed by…
jlowe Dec 1, 2017
bb44d8e
Revert MAPREDUCE-5124 from 2.7.5.
shvachko Dec 2, 2017
c3782d8
Preparing for 2.7.6 development
shvachko Dec 2, 2017
fbb44d7
MAPREDUCE-6165. [JDK8] TestCombineFileInputFormat failed on JDK8. Con…
oza May 5, 2015
261f8ab
Update CHANGES.txt for HADOOP-14867, HADOOP-14919, HDFS-12578, HDFS-1…
shvachko Dec 7, 2017
a4dd069
MAPREDUCE-5124. AM lacks flow control for task events. Contributed by…
jlowe Dec 8, 2017
94dfcd2
HDFS-12881. Output streams closed with IOUtils suppressing write erro…
jlowe Dec 15, 2017
dd5d00b
Set the release date for 2.7.5
shvachko Dec 15, 2017
cf99cd1
Update index.md.vm to reflect summary of changes in release 2.7.5
shvachko Dec 16, 2017
fb19423
YARN-7661. NodeManager metrics return wrong value after update node r…
jlowe Dec 18, 2017
5ec3335
YARN-3425. NPE from RMNodeLabelsManager.serviceStop when NodeLabelsMa…
wangdatan Apr 1, 2015
40faf49
YARN-4167. NPE on RMActiveServices#serviceStop when store is null. (B…
rohithsharmaks Sep 21, 2015
c3bbfa9
MAPREDUCE-7028. Concurrent task progress updates causing NPE in Appli…
jlowe Jan 3, 2018
1c798e7
HDFS-12347. TestBalancerRPCDelay#testBalancerRPCDelay fails very freq…
Dec 19, 2017
e03cee7
HADOOP-12181. Fix intermittent test failure of TestZKSignerSecretProv…
Nov 23, 2015
9e5fffa
HADOOP-12611. TestZKSignerSecretProvider#testMultipleInit occasionall…
rkanter Oct 7, 2016
88d951e
HADOOP-14246. Authentication Tokens should use SecureRandom instead o…
templedf Apr 12, 2017
17a673e
HADOOP-15177. Update the release year to 2018. Contributed by Bharat …
aajisaka Jan 18, 2018
ea57d10
HADOOP-14842. Hadoop 2.8.2 release build process get stuck due to jav…
JunpingDu Sep 8, 2017
83177a2
YARN-7590. Improve container-executor validation check. Contributed b…
szegedim Jan 18, 2018
dec5f3e
Move changes for YARN-7590 to hadoop-yarn-project/CHANGES.txt
shvachko Jan 18, 2018
d2531df
HADOOP-12751. While using kerberos Hadoop incorrectly assumes names w…
steveloughran May 6, 2016
9ff8597
HADOOP-13263. Reload cached groups in background after expiry. (Contr…
arp7 Jun 27, 2016
e029556
HADOOP-13375. o.a.h.security.TestGroupsCaching.testBackgroundRefreshC…
liuml07 Sep 1, 2016
314f09d
HDFS-11003. Expose XmitsInProgress through DataNodeMXBean. Contribute…
brahmareddybattula Oct 15, 2016
d37b73c
HADOOP-13508. FsPermission string constructor does not recognize stic…
jojochuang Dec 15, 2016
3345d11
HDFS-12371. BlockVerificationFailures and BlocksVerified show up as 0…
kihwal Sep 21, 2017
995e059
HADOOP-15143. NPE due to Invalid KerberosTicket in UGI. Contributed b…
jnp Jan 2, 2018
1ef88c9
MAPREDUCE-7020. Task timeout in uber mode can crash AM. Contributed b…
jlowe Jan 26, 2018
6ea2a93
HADOOP-15212. Add independent secret manager method for logging expir…
kihwal Feb 6, 2018
dc57c1d
HDFS-13120. Snapshot diff could be corrupted after concat. Contribute…
xiaoyuyao Feb 8, 2018
53a72f6
HDFS-7959. WebHdfs logging is missing on Datanode (Kihwal Lee via sjlee)
kihwal Aug 19, 2016
02f6030
HDFS-10453. ReplicationMonitor thread could stuck for long time due t…
arp7 Feb 12, 2018
6d3cf02
HDFS-10453. Update CHANGES.txt.
arp7 Feb 12, 2018
331d384
MAPREDUCE-7048. Uber AM can crash due to unknown task in statusUpdate…
jlowe Feb 12, 2018
3630c07
HADOOP-9477. Add posixGroups support for LDAP groups mapping service.…
Mar 12, 2015
faf87dd
HADOOP-12568. Update core-default.xml to describe posixGroups support…
aajisaka Nov 18, 2015
7a40641
xattr api cleanup
kihwal Feb 15, 2018
010ed19
MAPREDUCE-7052. TestFixedLengthInputFormat#testFormatCompressedIn is …
jlowe Feb 15, 2018
7f6ab3f
HDFS-13112. Token expiration edits may cause log corruption or deadlo…
kihwal Feb 15, 2018
75a303b
HADOOP-15206. BZip2 drops and duplicates records when input split siz…
jlowe Feb 16, 2018
829959a
HDFS-11187. Optimize disk access for last partial chunk checksum of F…
xiao-chen Feb 21, 2018
1f2ab8b
HDFS-4210. Throw helpful exception when DNS entry for JournalNode can…
xiao-chen Aug 30, 2016
7eb70a8
HADOOP-15283. Upgrade from findbugs 3.0.1 to spotbugs 3.1.2 in branch…
aajisaka Mar 4, 2018
06eafee
HADOOP-15279. increase maven heap size recommendations
aw-was-here Mar 1, 2018
98f9d6f
HADOOP-12001. Fixed LdapGroupsMapping to include configurable Posix U…
vinoduec Jun 15, 2015
00f7d72
HADOOP-12472. Make GenericTestUtils.assertExceptionContains robust. C…
Jing9 Oct 26, 2015
b2015d2
HADOOP-13105. Support timeouts in LDAP queries in LdapGroupsMapping. …
cnauroth Jun 3, 2016
fec04c4
Revert "HADOOP-13119. Add ability to secure log servlet using proxy u…
shvachko Mar 16, 2018
37403e1
HDFS-12884. BlockUnderConstructionFeature.truncateBlock should be of …
shvachko Mar 21, 2018
85502d3
HDFS-13195. DataNode conf page cannot display the current value after…
kihwal Mar 22, 2018
94bb6fa
HDFS-12299. Race Between update pipeline and DN Re-Registration. Cont…
kihwal Aug 25, 2017
65baefb
HADOOP-15345. Backport HADOOP-12185 to branch-2.7: NetworkTopology is…
Mar 28, 2018
caf518c
HADOOP-12862. LDAP Group Mapping over SSL can not specify trust store…
shvachko Mar 30, 2018
257d5a1
Revert "HDFS-12299. Race Between update pipeline and DN Re-Registrati…
shvachko Mar 30, 2018
4a5d0e5
HDFS-12299. Race Between update pipeline and DN Re-Registration. Cont…
shvachko Mar 30, 2018
d9df7cd
Update CHANGES.txt for HADOOP-15212, HADOOP-15345, HADOOP-15143, HDFS…
shvachko Mar 31, 2018
dbdf662
YARN-7249. Fix CapacityScheduler NPE issue when a container preempted…
erichadoop Sep 26, 2017
b4d24d8
Preparing for 2.7.7 development
shvachko Apr 6, 2018
f7830f3
HADOOP-14970. MiniHadoopClusterManager doesn't respect lack of format…
xkrogen Apr 13, 2018
027b8c0
Set the release date for 2.7.6
shvachko Apr 17, 2018
112041d
Update index.md.vm to reflect summary of changes in release 2.7.6
shvachko Apr 18, 2018
20c6b44
HDFS-12156. TestFSImage fails without -Pnative
aajisaka Mar 13, 2018
e877734
HDFS-13486. Backport HDFS-11817 (A faulty node can cause a lease leak…
jojochuang May 7, 2018
04219e5
Skip the proxy user check if the ugi has not been initialized. Contri…
shahrs87 May 21, 2018
45a1c68
Additional check when unpacking archives. Contributed by Jason Lowe a…
aajisaka May 23, 2018
7be1bc5
Addendum fix in container executor. Contributed by Wilfred Spiegelenb…
aajisaka May 23, 2018
be22e24
HADOOP-15486. Make NetworkTopology#netLock fair. Contributed by Nanda…
arp7 May 23, 2018
5b57f9c
HADOOP-15473. Configure serialFilter in KeyProvider to avoid Unrecove…
xiao-chen May 25, 2018
eaa2b80
Additional check when unpacking archives. Contributed by Wilfred Spie…
kihwal May 29, 2018
25052fb
HDFS-13602. Add checkOperation(WRITE) checks in FSNamesystem. Contrib…
sunchao May 31, 2018
8ae2ca4
HADOOP-15509 Preparing to release Hadoop 2.7.7: Update CHANGES.TXT files
steveloughran Jun 3, 2018
c1f6964
HADOOP-15509. Preparing for Hadoop 2.7.7 release: update maven versions.
steveloughran Jun 3, 2018
061c747
HADOOP-15509. Preparing for Hadoop 2.7.7 generate release notes.
steveloughran Jun 3, 2018
c2eac40
Set the release date for 2.7.7-RC0
steveloughran Jun 5, 2018
462e7a2
Set the release date for 2.7.7-RC0
steveloughran Jun 6, 2018
c1aad84
HADOOP-15509. Set the release date for 2.7.7-RC0 to 2018-07-06.
steveloughran Jul 6, 2018
e446276
HADOOP-15509. Set the release date for 2.7.7 to 2018-07-06.
steveloughran Jul 18, 2018
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
4 changes: 2 additions & 2 deletions BUILDING.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ If the build process fails with an out of memory error, you should be able to fi
it by increasing the memory used by maven -which can be done via the environment
variable MAVEN_OPTS.

Here is an example setting to allocate between 256 and 512 MB of heap space to
Here is an example setting to allocate between 256 MB and 1.5 GB of heap space to
Maven

export MAVEN_OPTS="-Xms256m -Xmx512m"
export MAVEN_OPTS="-Xms256m -Xmx1536m"

----------------------------------------------------------------------------------

Expand Down
23 changes: 12 additions & 11 deletions dev-support/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,26 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
RUN cd /usr/share/maven/lib && ln -s ../../java/commons-lang.jar .

#######
# Oracle Java
# Java OpenJDK
#######

RUN apt-get install -y software-properties-common
RUN add-apt-repository -y ppa:webupd8team/java
RUN apt-get update

# Auto-accept the Oracle JDK license
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
RUN apt-get install -y oracle-java8-installer
# Install OpenJDK 7
RUN apt-get install -y openjdk-7-jdk

######
# Install findbugs
# Install spotbugs (successor of findbugs)
######
RUN mkdir -p /opt/findbugs && \
curl -L https://sourceforge.net/projects/findbugs/files/findbugs/3.0.1/findbugs-noUpdateChecks-3.0.1.tar.gz/download \
-o /opt/findbugs.tar.gz && \
tar xzf /opt/findbugs.tar.gz --strip-components 1 -C /opt/findbugs
ENV FINDBUGS_HOME /opt/findbugs
RUN mkdir -p /opt/spotbugs && \
curl -L -s -S \
http://repo.maven.apache.org/maven2/com/github/spotbugs/spotbugs/3.1.2/spotbugs-3.1.2.tgz \
-o /opt/spotbugs.tar.gz && \
tar xzf /opt/spotbugs.tar.gz --strip-components 1 -C /opt/spotbugs
# Hadoop uses FINDBUGS_HOME to run spotbugs
ENV FINDBUGS_HOME /opt/spotbugs

####
# Install shellcheck
Expand All @@ -75,7 +76,7 @@ RUN cabal update && cabal install shellcheck --global
###
# Avoid out of memory errors in builds
###
ENV MAVEN_OPTS -Xms256m -Xmx512m
ENV MAVEN_OPTS -Xms256m -Xmx1536m

###
# Everything past this point is either not needed for testing or breaks Yetus.
Expand Down
4 changes: 2 additions & 2 deletions hadoop-assemblies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
<parent>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-project</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.7.7</version>
<relativePath>../hadoop-project</relativePath>
</parent>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-assemblies</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.7.7</version>
<name>Apache Hadoop Assemblies</name>
<description>Apache Hadoop Assemblies</description>

Expand Down
2 changes: 1 addition & 1 deletion hadoop-build-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<artifactId>hadoop-main</artifactId>
<groupId>org.apache.hadoop</groupId>
<version>2.7.4-SNAPSHOT</version>
<version>2.7.7</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hadoop-build-tools</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions hadoop-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
<parent>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-project-dist</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.7.7</version>
<relativePath>../hadoop-project-dist</relativePath>
</parent>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.7.7</version>
<packaging>jar</packaging>

<description>Apache Hadoop Client</description>
Expand Down
4 changes: 2 additions & 2 deletions hadoop-common-project/hadoop-annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
<parent>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-project</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.7.7</version>
<relativePath>../../hadoop-project</relativePath>
</parent>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-annotations</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.7.7</version>
<description>Apache Hadoop Annotations</description>
<name>Apache Hadoop Annotations</name>
<packaging>jar</packaging>
Expand Down
4 changes: 2 additions & 2 deletions hadoop-common-project/hadoop-auth-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
<parent>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-project</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.7.7</version>
<relativePath>../../hadoop-project</relativePath>
</parent>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-auth-examples</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.7.7</version>
<packaging>war</packaging>

<name>Apache Hadoop Auth Examples</name>
Expand Down
4 changes: 2 additions & 2 deletions hadoop-common-project/hadoop-auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
<parent>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-project</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.7.7</version>
<relativePath>../../hadoop-project</relativePath>
</parent>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-auth</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.7.7</version>
<packaging>jar</packaging>

<name>Apache Hadoop Auth</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ String apply(String[] params) throws IOException {
}
}
if (result != null && nonSimplePattern.matcher(result).find()) {
throw new NoMatchingRule("Non-simple name " + result +
" after auth_to_local rule " + this);
LOG.info("Non-simple name {} after auth_to_local rule {}",
result, this);
}
if (toLowerCase && result != null) {
result = result.toLowerCase(Locale.ENGLISH);
Expand Down Expand Up @@ -377,7 +377,7 @@ public static class NoMatchingRule extends IOException {
/**
* Get the translation of the principal name into an operating system
* user name.
* @return the short name
* @return the user name
* @throws IOException throws if something is wrong with the rules
*/
public String getShortName() throws IOException {
Expand All @@ -397,7 +397,8 @@ public String getShortName() throws IOException {
return result;
}
}
throw new NoMatchingRule("No rules applied to " + toString());
LOG.info("No auth_to_local rules applied to {}", this);
return toString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@

import com.google.common.annotations.VisibleForTesting;

import java.nio.charset.Charset;
import java.security.SecureRandom;
import java.util.Random;

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;

Expand All @@ -32,7 +33,7 @@ public class RandomSignerSecretProvider extends RolloverSignerSecretProvider {

public RandomSignerSecretProvider() {
super();
rand = new Random();
rand = new SecureRandom();
}

/**
Expand All @@ -48,6 +49,8 @@ public RandomSignerSecretProvider(long seed) {

@Override
protected byte[] generateNewSecret() {
return Long.toString(rand.nextLong()).getBytes(Charset.forName("UTF-8"));
byte[] secret = new byte[32]; // 32 bytes = 256 bits
rand.nextBytes(secret);
return secret;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
public abstract class RolloverSignerSecretProvider
extends SignerSecretProvider {

private static Logger LOG = LoggerFactory.getLogger(
static Logger LOG = LoggerFactory.getLogger(
RolloverSignerSecretProvider.class);
/**
* Stores the currently valid secrets. The current secret is the 0th element
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.google.common.annotations.VisibleForTesting;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.security.SecureRandom;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -176,7 +177,7 @@ public class ZKSignerSecretProvider extends RolloverSignerSecretProvider {

public ZKSignerSecretProvider() {
super();
rand = new Random();
rand = new SecureRandom();
}

/**
Expand Down Expand Up @@ -369,8 +370,11 @@ private synchronized void pullFromZK(boolean isInit) {
}
}

private byte[] generateRandomSecret() {
return Long.toString(rand.nextLong()).getBytes(Charset.forName("UTF-8"));
@VisibleForTesting
protected byte[] generateRandomSecret() {
byte[] secret = new byte[32]; // 32 bytes = 256 bits
rand.nextBytes(secret);
return secret;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,7 @@ public void testNameRules() throws Exception {
kn = new KerberosName("bar@BAR");
Assert.assertEquals("bar", kn.getShortName());
kn = new KerberosName("bar@FOO");
try {
kn.getShortName();
Assert.fail();
}
catch (Exception ex) {
}
Assert.assertEquals("bar@FOO", kn.getShortName());
}

@Test(timeout=60000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,14 @@ private void checkBadName(String name) {
}
}

private void checkBadTranslation(String from) {
System.out.println("Checking bad translation for " + from);
KerberosName nm = new KerberosName(from);
try {
nm.getShortName();
Assert.fail("didn't get exception for " + from);
} catch (IOException ie) {
// PASS
}
}

@Test
public void testAntiPatterns() throws Exception {
checkBadName("owen/owen/[email protected]");
checkBadName("owen@foo/bar.com");
checkBadTranslation("[email protected]");
checkBadTranslation("root/[email protected]");

// no rules applied, these should pass
checkTranslation("[email protected]", "[email protected]");
checkTranslation("root/[email protected]", "root/[email protected]");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,37 @@
package org.apache.hadoop.security.authentication.util;

import java.util.Random;

import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.junit.Assert;
import org.junit.Test;

import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;

public class TestRandomSignerSecretProvider {

// rollover every 50 msec
private final int timeout = 100;
private final long rolloverFrequency = timeout / 2;

{
LogManager.getLogger(
RolloverSignerSecretProvider.LOG.getName()).setLevel(Level.DEBUG);
}

@Test
public void testGetAndRollSecrets() throws Exception {
long rolloverFrequency = 15 * 1000; // rollover every 15 sec
// use the same seed so we can predict the RNG
// Use the same seed and a "plain" Random so we can predict the RNG
long seed = System.currentTimeMillis();
Random rand = new Random(seed);
byte[] secret1 = Long.toString(rand.nextLong()).getBytes();
byte[] secret2 = Long.toString(rand.nextLong()).getBytes();
byte[] secret3 = Long.toString(rand.nextLong()).getBytes();
RandomSignerSecretProvider secretProvider =
new RandomSignerSecretProvider(seed);
byte[] secret1 = generateNewSecret(rand);
byte[] secret2 = generateNewSecret(rand);
byte[] secret3 = generateNewSecret(rand);
MockRandomSignerSecretProvider secretProvider =
spy(new MockRandomSignerSecretProvider(seed));
try {
secretProvider.init(null, null, rolloverFrequency);

Expand All @@ -39,25 +54,58 @@ public void testGetAndRollSecrets() throws Exception {
Assert.assertEquals(2, allSecrets.length);
Assert.assertArrayEquals(secret1, allSecrets[0]);
Assert.assertNull(allSecrets[1]);
Thread.sleep(rolloverFrequency + 2000);
verify(secretProvider, timeout(timeout).atLeastOnce()).rollSecret();
secretProvider.realRollSecret();

currentSecret = secretProvider.getCurrentSecret();
allSecrets = secretProvider.getAllSecrets();
Assert.assertArrayEquals(secret2, currentSecret);
Assert.assertEquals(2, allSecrets.length);
Assert.assertArrayEquals(secret2, allSecrets[0]);
Assert.assertArrayEquals(secret1, allSecrets[1]);
Thread.sleep(rolloverFrequency + 2000);
verify(secretProvider, timeout(timeout).atLeast(2)).rollSecret();
secretProvider.realRollSecret();

currentSecret = secretProvider.getCurrentSecret();
allSecrets = secretProvider.getAllSecrets();
Assert.assertArrayEquals(secret3, currentSecret);
Assert.assertEquals(2, allSecrets.length);
Assert.assertArrayEquals(secret3, allSecrets[0]);
Assert.assertArrayEquals(secret2, allSecrets[1]);
Thread.sleep(rolloverFrequency + 2000);
verify(secretProvider, timeout(timeout).atLeast(3)).rollSecret();
secretProvider.realRollSecret();
} finally {
secretProvider.destroy();
}
}

/**
* A hack to test RandomSignerSecretProvider.
* We want to test that RandomSignerSecretProvider.rollSecret() is
* periodically called at the expected frequency, but we want to exclude the
* race-condition and not take a long time to run the test.
*/
private class MockRandomSignerSecretProvider
extends RandomSignerSecretProvider {
MockRandomSignerSecretProvider(long seed) {
super(seed);
}
@Override
protected synchronized void rollSecret() {
// this is a no-op: simply used for Mockito to verify that rollSecret()
// is periodically called at the expected frequency
}

public void realRollSecret() {
// the test code manually calls RandomSignerSecretProvider.rollSecret()
// to update the state
super.rollSecret();
}
}

private byte[] generateNewSecret(Random rand) {
byte[] secret = new byte[32];
rand.nextBytes(secret);
return secret;
}
}
Loading