summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-06-23 21:02:49 +0000
committerGerrit Code Review <review@openstack.org>2016-06-23 21:02:49 +0000
commit8cd6d7b0ca41a8ba9b036e8d94acbcced7751853 (patch)
treed0538c32299e92568233aaa9de4953f48106ce48
parent5e1f04f4f836d25f0c168d66b04ab4fefc05d4d3 (diff)
parentfffdc5ad6b3d0a06b78ae39a78a6e697d4bcb7c0 (diff)
Merge "hadoop-swiftfs: Allow configuring container.tenant"5.0.0.0b35.0.0.0b2
-rw-r--r--hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/http/RestClientBindings.java1
-rw-r--r--hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/http/SwiftProtocolConstants.java2
-rw-r--r--hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/http/SwiftRestClient.java42
3 files changed, 45 insertions, 0 deletions
diff --git a/hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/http/RestClientBindings.java b/hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/http/RestClientBindings.java
index a55d7d1..17c7521 100644
--- a/hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/http/RestClientBindings.java
+++ b/hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/http/RestClientBindings.java
@@ -155,6 +155,7 @@ public final class RestClientBindings {
155 copy(conf, prefix + DOT_DOMAIN_NAME, props, SWIFT_DOMAIN_NAME_PROPERTY, false); 155 copy(conf, prefix + DOT_DOMAIN_NAME, props, SWIFT_DOMAIN_NAME_PROPERTY, false);
156 copy(conf, prefix + DOT_DOMAIN_ID, props, SWIFT_DOMAIN_ID_PROPERTY, false); 156 copy(conf, prefix + DOT_DOMAIN_ID, props, SWIFT_DOMAIN_ID_PROPERTY, false);
157 copy(conf, prefix + DOT_TENANT, props, SWIFT_TENANT_PROPERTY, false); 157 copy(conf, prefix + DOT_TENANT, props, SWIFT_TENANT_PROPERTY, false);
158 copy(conf, prefix + DOT_CONTAINER_TENANT, props, SWIFT_CONTAINER_TENANT_PROPERTY, false);
158 copy(conf, prefix + DOT_REGION, props, SWIFT_REGION_PROPERTY, false); 159 copy(conf, prefix + DOT_REGION, props, SWIFT_REGION_PROPERTY, false);
159 copy(conf, prefix + DOT_HTTP_PORT, props, SWIFT_HTTP_PORT_PROPERTY, false); 160 copy(conf, prefix + DOT_HTTP_PORT, props, SWIFT_HTTP_PORT_PROPERTY, false);
160 copy(conf, prefix + 161 copy(conf, prefix +
diff --git a/hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/http/SwiftProtocolConstants.java b/hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/http/SwiftProtocolConstants.java
index b80c3cd..a1f4d61 100644
--- a/hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/http/SwiftProtocolConstants.java
+++ b/hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/http/SwiftProtocolConstants.java
@@ -207,6 +207,7 @@ public class SwiftProtocolConstants {
207 public static final String DOT_AUTH_URL = ".auth.url"; 207 public static final String DOT_AUTH_URL = ".auth.url";
208 public static final String DOT_AUTH_ENDPOINT_PREFIX = ".auth.endpoint.prefix"; 208 public static final String DOT_AUTH_ENDPOINT_PREFIX = ".auth.endpoint.prefix";
209 public static final String DOT_TENANT = ".tenant"; 209 public static final String DOT_TENANT = ".tenant";
210 public static final String DOT_CONTAINER_TENANT = ".container.tenant";
210 public static final String DOT_USERNAME = ".username"; 211 public static final String DOT_USERNAME = ".username";
211 public static final String DOT_PASSWORD = ".password"; 212 public static final String DOT_PASSWORD = ".password";
212 public static final String DOT_TRUST_ID = ".trust.id"; 213 public static final String DOT_TRUST_ID = ".trust.id";
@@ -233,6 +234,7 @@ public class SwiftProtocolConstants {
233 public static final String SWIFT_AUTH_ENDPOINT_PREFIX = 234 public static final String SWIFT_AUTH_ENDPOINT_PREFIX =
234 FS_SWIFT + DOT_AUTH_ENDPOINT_PREFIX; 235 FS_SWIFT + DOT_AUTH_ENDPOINT_PREFIX;
235 public static final String SWIFT_TENANT_PROPERTY = FS_SWIFT + DOT_TENANT; 236 public static final String SWIFT_TENANT_PROPERTY = FS_SWIFT + DOT_TENANT;
237 public static final String SWIFT_CONTAINER_TENANT_PROPERTY = FS_SWIFT + DOT_CONTAINER_TENANT;
236 public static final String SWIFT_USERNAME_PROPERTY = FS_SWIFT + DOT_USERNAME; 238 public static final String SWIFT_USERNAME_PROPERTY = FS_SWIFT + DOT_USERNAME;
237 public static final String SWIFT_PASSWORD_PROPERTY = FS_SWIFT + DOT_PASSWORD; 239 public static final String SWIFT_PASSWORD_PROPERTY = FS_SWIFT + DOT_PASSWORD;
238 public static final String SWIFT_TRUST_ID_PROPERTY = FS_SWIFT + DOT_TRUST_ID; 240 public static final String SWIFT_TRUST_ID_PROPERTY = FS_SWIFT + DOT_TRUST_ID;
diff --git a/hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/http/SwiftRestClient.java b/hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/http/SwiftRestClient.java
index ea32a6e..cc94b7a 100644
--- a/hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/http/SwiftRestClient.java
+++ b/hadoop-swiftfs/src/main/java/org/apache/hadoop/fs/swift/http/SwiftRestClient.java
@@ -180,6 +180,7 @@ public final class SwiftRestClient {
180 */ 180 */
181 private final String container; 181 private final String container;
182 private final String serviceDescription; 182 private final String serviceDescription;
183 private final String containerTenant;
183 184
184 /** 185 /**
185 * Access token (Secret) 186 * Access token (Secret)
@@ -502,6 +503,9 @@ public final class SwiftRestClient {
502 region = props.getProperty(SWIFT_REGION_PROPERTY); 503 region = props.getProperty(SWIFT_REGION_PROPERTY);
503 //tenant is optional 504 //tenant is optional
504 tenant = props.getProperty(SWIFT_TENANT_PROPERTY); 505 tenant = props.getProperty(SWIFT_TENANT_PROPERTY);
506 //containerTenant is optional
507 containerTenant = props.getProperty(SWIFT_CONTAINER_TENANT_PROPERTY);
508
505 //service is used for diagnostics 509 //service is used for diagnostics
506 serviceProvider = props.getProperty(SWIFT_SERVICE_PROPERTY); 510 serviceProvider = props.getProperty(SWIFT_SERVICE_PROPERTY);
507 container = props.getProperty(SWIFT_CONTAINER_PROPERTY); 511 container = props.getProperty(SWIFT_CONTAINER_PROPERTY);
@@ -1303,6 +1307,15 @@ public final class SwiftRestClient {
1303 1307
1304 accessToken = access.getToken(); 1308 accessToken = access.getToken();
1305 String path = getAuthEndpointPrefix() + accessToken.getTenant().getId(); 1309 String path = getAuthEndpointPrefix() + accessToken.getTenant().getId();
1310
1311 // Overwrite the user tenant with the shared container tenant id (container.tenant)
1312 if (containerTenant != null) {
1313 path = getAuthEndpointPrefix() + containerTenant;
1314 if (LOG.isDebugEnabled()) {
1315 LOG.debug("overwritten path: " + path);
1316 }
1317 }
1318
1306 String host = endpointURI.getHost(); 1319 String host = endpointURI.getHost();
1307 try { 1320 try {
1308 objectLocation = new URI(endpointURI.getScheme(), 1321 objectLocation = new URI(endpointURI.getScheme(),
@@ -1318,6 +1331,13 @@ public final class SwiftRestClient {
1318 + " + " + path, 1331 + " + " + path,
1319 e); 1332 e);
1320 } 1333 }
1334
1335 // Overwrite the user tenant with the shared container tenant id (container.tenant)
1336 if (containerTenant != null) {
1337 endpointURI = objectLocation;
1338 }
1339
1340
1321 setAuthDetails(endpointURI, objectLocation, accessToken); 1341 setAuthDetails(endpointURI, objectLocation, accessToken);
1322 1342
1323 if (LOG.isDebugEnabled()) { 1343 if (LOG.isDebugEnabled()) {
@@ -1377,6 +1397,15 @@ public final class SwiftRestClient {
1377 1397
1378 URI objectLocation = null; 1398 URI objectLocation = null;
1379 String path = getAuthEndpointPrefix() + token.getTenant().getId(); 1399 String path = getAuthEndpointPrefix() + token.getTenant().getId();
1400
1401 // Overwrite the user tenant with the shared container tenant id (container.tenant)
1402 if (containerTenant != null) {
1403 path = getAuthEndpointPrefix() + containerTenant;
1404 if (LOG.isDebugEnabled()) {
1405 LOG.debug("overwritten path: " + path);
1406 }
1407 }
1408
1380 try { 1409 try {
1381 objectLocation = new URI(endpointURI.getScheme(), 1410 objectLocation = new URI(endpointURI.getScheme(),
1382 null, 1411 null,
@@ -1392,6 +1421,11 @@ public final class SwiftRestClient {
1392 e); 1421 e);
1393 } 1422 }
1394 1423
1424 // Overwrite the user tenant with the shared container tenant id (container.tenant)
1425 if (containerTenant != null) {
1426 endpointURI = objectLocation;
1427 }
1428
1395 setAuthDetails(endpointURI, objectLocation, token); 1429 setAuthDetails(endpointURI, objectLocation, token);
1396 createDefaultContainer(); 1430 createDefaultContainer();
1397 return token; 1431 return token;
@@ -1971,6 +2005,14 @@ public final class SwiftRestClient {
1971 } 2005 }
1972 2006
1973 /** 2007 /**
2008 * Get the tenant to which this client is bound
2009 * @return the tenant
2010 */
2011 public String getContainerTenant() {
2012 return containerTenant;
2013 }
2014
2015 /**
1974 * Get the username this client identifies itself as 2016 * Get the username this client identifies itself as
1975 * @return the username 2017 * @return the username
1976 */ 2018 */