Skip to content

Commit 7c15239

Browse files
authored
Merge branch 'apache:trunk' into YARN-11610
2 parents 9dbdadf + 0c10bab commit 7c15239

File tree

150 files changed

+6725
-737
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+6725
-737
lines changed

BUILDING.txt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,22 +319,28 @@ Controlling the redistribution of the protobuf-2.5 dependency
319319
the Hadoop codebase; alongside the move to Protobuf 3.x a private successor
320320
class, org.apache.hadoop.ipc.internal.ShadedProtobufHelper is now used.
321321

322-
The hadoop-common JAR still declares a dependency on protobuf-2.5, but this
323-
is likely to change in the future. The maven scope of the dependency can be
324-
set with the common.protobuf2.scope option.
325-
It can be set to "provided" in a build:
326-
-Dcommon.protobuf2.scope=provided
327-
If this is done then protobuf-2.5.0.jar will no longer be exported as a dependency,
328-
and will then be omitted from the share/hadoop/common/lib/ directory of
329-
any Hadoop distribution built. Any application declaring a dependency on hadoop-commmon
330-
will no longer get the dependency; if they need it then they must explicitly declare it:
322+
The hadoop-common module no longer exports its compile-time dependency on
323+
protobuf-2.5. Hadoop distributions no longer include it.
324+
Any application declaring a dependency on hadoop-commmon will no longer get
325+
the artifact added to their classpath.
326+
If is still required, then they must explicitly declare it:
331327

332328
<dependency>
333329
<groupId>com.google.protobuf</groupId>
334330
<artifactId>protobuf-java</artifactId>
335331
<version>2.5.0</version>
336332
</dependency>
337333

334+
In Hadoop builds the scope of the dependency can be set with the
335+
option "common.protobuf2.scope".
336+
This can be upgraded from "provided" to "compile" on the maven command line:
337+
338+
-Dcommon.protobuf2.scope=compile
339+
340+
If this is done then protobuf-2.5.0.jar will again be exported as a
341+
hadoop-common dependency, and included in the share/hadoop/common/lib/
342+
directory of any Hadoop distribution built.
343+
338344
----------------------------------------------------------------------------------
339345
Building components separately
340346

LICENSE-binary

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ hadoop-tools/hadoop-sls/src/main/html/js/thirdparty/d3.v3.js
392392
hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/d3-3.5.17.min.js
393393
leveldb v1.13
394394

395-
com.google.protobuf:protobuf-java:2.5.0
396395
com.google.protobuf:protobuf-java:3.6.1
397396
com.google.re2j:re2j:1.1
398397
com.jcraft:jsch:0.1.54

hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/ZKSignerSecretProvider.java

Lines changed: 34 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,13 @@
1616
import org.apache.hadoop.classification.VisibleForTesting;
1717
import java.nio.ByteBuffer;
1818
import java.security.SecureRandom;
19-
import java.util.Collections;
20-
import java.util.List;
2119
import java.util.Properties;
2220
import java.util.Random;
23-
import javax.security.auth.login.Configuration;
2421
import javax.servlet.ServletContext;
25-
import org.apache.curator.RetryPolicy;
2622
import org.apache.curator.framework.CuratorFramework;
27-
import org.apache.curator.framework.CuratorFrameworkFactory;
28-
import org.apache.curator.framework.api.ACLProvider;
29-
import org.apache.curator.framework.imps.DefaultACLProvider;
30-
import org.apache.curator.retry.ExponentialBackoffRetry;
3123
import org.apache.hadoop.classification.InterfaceAudience;
3224
import org.apache.hadoop.classification.InterfaceStability;
3325
import org.apache.zookeeper.KeeperException;
34-
import org.apache.zookeeper.ZooDefs.Perms;
35-
import org.apache.zookeeper.client.ZKClientConfig;
36-
import org.apache.zookeeper.data.ACL;
37-
import org.apache.zookeeper.data.Id;
3826
import org.apache.zookeeper.data.Stat;
3927
import org.slf4j.Logger;
4028
import org.slf4j.LoggerFactory;
@@ -92,6 +80,16 @@ public class ZKSignerSecretProvider extends RolloverSignerSecretProvider {
9280
public static final String ZOOKEEPER_KERBEROS_PRINCIPAL =
9381
CONFIG_PREFIX + "kerberos.principal";
9482

83+
public static final String ZOOKEEPER_SSL_ENABLED = CONFIG_PREFIX + "ssl.enabled";
84+
public static final String ZOOKEEPER_SSL_KEYSTORE_LOCATION =
85+
CONFIG_PREFIX + "ssl.keystore.location";
86+
public static final String ZOOKEEPER_SSL_KEYSTORE_PASSWORD =
87+
CONFIG_PREFIX + "ssl.keystore.password";
88+
public static final String ZOOKEEPER_SSL_TRUSTSTORE_LOCATION =
89+
CONFIG_PREFIX + "ssl.truststore.location";
90+
public static final String ZOOKEEPER_SSL_TRUSTSTORE_PASSWORD =
91+
CONFIG_PREFIX + "ssl.truststore.password";
92+
9593
/**
9694
* Constant for the property that specifies whether or not the Curator client
9795
* should disconnect from ZooKeeper on shutdown. The default is "true". Only
@@ -350,80 +348,33 @@ protected byte[] generateRandomSecret() {
350348
* This method creates the Curator client and connects to ZooKeeper.
351349
* @param config configuration properties
352350
* @return A Curator client
353-
* @throws Exception thrown if an error occurred
354351
*/
355-
protected CuratorFramework createCuratorClient(Properties config)
356-
throws Exception {
357-
String connectionString = config.getProperty(
358-
ZOOKEEPER_CONNECTION_STRING, "localhost:2181");
359-
360-
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
361-
ACLProvider aclProvider;
352+
protected CuratorFramework createCuratorClient(Properties config) {
353+
String connectionString = config.getProperty(ZOOKEEPER_CONNECTION_STRING, "localhost:2181");
362354
String authType = config.getProperty(ZOOKEEPER_AUTH_TYPE, "none");
363-
if (authType.equals("sasl")) {
364-
LOG.info("Connecting to ZooKeeper with SASL/Kerberos"
365-
+ "and using 'sasl' ACLs");
366-
String principal = setJaasConfiguration(config);
367-
System.setProperty(ZKClientConfig.LOGIN_CONTEXT_NAME_KEY,
368-
JAAS_LOGIN_ENTRY_NAME);
369-
System.setProperty("zookeeper.authProvider.1",
370-
"org.apache.zookeeper.server.auth.SASLAuthenticationProvider");
371-
aclProvider = new SASLOwnerACLProvider(principal);
372-
} else { // "none"
373-
LOG.info("Connecting to ZooKeeper without authentication");
374-
aclProvider = new DefaultACLProvider(); // open to everyone
375-
}
376-
CuratorFramework cf = CuratorFrameworkFactory.builder()
377-
.connectString(connectionString)
378-
.retryPolicy(retryPolicy)
379-
.aclProvider(aclProvider)
380-
.build();
381-
cf.start();
382-
return cf;
383-
}
384-
385-
private String setJaasConfiguration(Properties config) throws Exception {
386-
String keytabFile = config.getProperty(ZOOKEEPER_KERBEROS_KEYTAB).trim();
387-
if (keytabFile == null || keytabFile.length() == 0) {
388-
throw new IllegalArgumentException(ZOOKEEPER_KERBEROS_KEYTAB
389-
+ " must be specified");
390-
}
391-
String principal = config.getProperty(ZOOKEEPER_KERBEROS_PRINCIPAL)
392-
.trim();
393-
if (principal == null || principal.length() == 0) {
394-
throw new IllegalArgumentException(ZOOKEEPER_KERBEROS_PRINCIPAL
395-
+ " must be specified");
396-
}
355+
String keytab = config.getProperty(ZOOKEEPER_KERBEROS_KEYTAB, "").trim();
356+
String principal = config.getProperty(ZOOKEEPER_KERBEROS_PRINCIPAL, "").trim();
397357

398-
// This is equivalent to writing a jaas.conf file and setting the system
399-
// property, "java.security.auth.login.config", to point to it
400-
JaasConfiguration jConf =
401-
new JaasConfiguration(JAAS_LOGIN_ENTRY_NAME, principal, keytabFile);
402-
Configuration.setConfiguration(jConf);
403-
return principal.split("[/@]")[0];
404-
}
358+
boolean sslEnabled = Boolean.parseBoolean(config.getProperty(ZOOKEEPER_SSL_ENABLED, "false"));
359+
String keystoreLocation = config.getProperty(ZOOKEEPER_SSL_KEYSTORE_LOCATION, "");
360+
String keystorePassword = config.getProperty(ZOOKEEPER_SSL_KEYSTORE_PASSWORD, "");
361+
String truststoreLocation = config.getProperty(ZOOKEEPER_SSL_TRUSTSTORE_LOCATION, "");
362+
String truststorePassword = config.getProperty(ZOOKEEPER_SSL_TRUSTSTORE_PASSWORD, "");
405363

406-
/**
407-
* Simple implementation of an {@link ACLProvider} that simply returns an ACL
408-
* that gives all permissions only to a single principal.
409-
*/
410-
private static class SASLOwnerACLProvider implements ACLProvider {
411-
412-
private final List<ACL> saslACL;
413-
414-
private SASLOwnerACLProvider(String principal) {
415-
this.saslACL = Collections.singletonList(
416-
new ACL(Perms.ALL, new Id("sasl", principal)));
417-
}
418-
419-
@Override
420-
public List<ACL> getDefaultAcl() {
421-
return saslACL;
422-
}
423-
424-
@Override
425-
public List<ACL> getAclForPath(String path) {
426-
return saslACL;
427-
}
364+
CuratorFramework zkClient =
365+
ZookeeperClient.configure()
366+
.withConnectionString(connectionString)
367+
.withAuthType(authType)
368+
.withKeytab(keytab)
369+
.withPrincipal(principal)
370+
.withJaasLoginEntryName(JAAS_LOGIN_ENTRY_NAME)
371+
.enableSSL(sslEnabled)
372+
.withKeystore(keystoreLocation)
373+
.withKeystorePassword(keystorePassword)
374+
.withTruststore(truststoreLocation)
375+
.withTruststorePassword(truststorePassword)
376+
.create();
377+
zkClient.start();
378+
return zkClient;
428379
}
429380
}

0 commit comments

Comments
 (0)