Skip to content

Commit 83ef50f

Browse files
sunilgovindaajisaka
authored andcommitted
Revert "HADOOP-15759. AliyunOSS: Update oss-sdk version to 3.0.0. Contributed by Jinhu Wu."
This reverts commit e4fca6a. Revert "HADOOP-15671. AliyunOSS: Support Assume Roles in AliyunOSS. Contributed by Jinhu Wu." This reverts commit 2b63512. (cherry picked from commit 1f42527) (cherry picked from commit 71bee05)
1 parent d0699f4 commit 83ef50f

File tree

8 files changed

+13
-249
lines changed

8 files changed

+13
-249
lines changed

hadoop-project/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@
12611261
<dependency>
12621262
<groupId>com.aliyun.oss</groupId>
12631263
<artifactId>aliyun-sdk-oss</artifactId>
1264-
<version>3.0.0</version>
1264+
<version>2.8.3</version>
12651265
<exclusions>
12661266
<exclusion>
12671267
<groupId>org.apache.httpcomponents</groupId>

hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/AliyunOSSBlockOutputStream.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ public synchronized void close() throws IOException {
120120
if (null == partETags) {
121121
throw new IOException("Failed to multipart upload to oss, abort it.");
122122
}
123-
store.completeMultipartUpload(key, uploadId,
124-
new ArrayList<>(partETags));
123+
store.completeMultipartUpload(key, uploadId, partETags);
125124
}
126125
} finally {
127126
removePartFiles();
@@ -130,7 +129,7 @@ public synchronized void close() throws IOException {
130129
}
131130

132131
@Override
133-
public synchronized void write(int b) throws IOException {
132+
public void write(int b) throws IOException {
134133
singleByte[0] = (byte)b;
135134
write(singleByte, 0, 1);
136135
}

hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/AliyunOSSFileSystemStore.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public void initialize(URI uri, Configuration conf,
149149
"null or empty. Please set proper endpoint with 'fs.oss.endpoint'.");
150150
}
151151
CredentialsProvider provider =
152-
AliyunOSSUtils.getCredentialsProvider(uri, conf);
152+
AliyunOSSUtils.getCredentialsProvider(conf);
153153
ossClient = new OSSClient(endPoint, provider, clientConf);
154154
uploadPartSize = AliyunOSSUtils.getMultipartSizeProperty(conf,
155155
MULTIPART_UPLOAD_PART_SIZE_KEY, MULTIPART_UPLOAD_PART_SIZE_DEFAULT);
@@ -168,8 +168,6 @@ public void initialize(URI uri, Configuration conf,
168168
multipartThreshold = 1024 * 1024 * 1024;
169169
}
170170

171-
bucketName = uri.getHost();
172-
173171
String cannedACLName = conf.get(CANNED_ACL_KEY, CANNED_ACL_DEFAULT);
174172
if (StringUtils.isNotEmpty(cannedACLName)) {
175173
CannedAccessControlList cannedACL =
@@ -178,6 +176,7 @@ public void initialize(URI uri, Configuration conf,
178176
}
179177

180178
maxKeys = conf.getInt(MAX_PAGING_KEYS_KEY, MAX_PAGING_KEYS_DEFAULT);
179+
bucketName = uri.getHost();
181180
}
182181

183182
/**

hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/AliyunOSSUtils.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import java.io.File;
2222
import java.io.IOException;
23-
import java.net.URI;
2423

2524
import com.aliyun.oss.common.auth.CredentialsProvider;
2625
import com.google.common.base.Preconditions;
@@ -96,14 +95,13 @@ public static long calculatePartSize(long contentLength, long minPartSize) {
9695
* Create credential provider specified by configuration, or create default
9796
* credential provider if not specified.
9897
*
99-
* @param uri uri passed by caller
10098
* @param conf configuration
10199
* @return a credential provider
102100
* @throws IOException on any problem. Class construction issues may be
103101
* nested inside the IOE.
104102
*/
105-
public static CredentialsProvider getCredentialsProvider(
106-
URI uri, Configuration conf) throws IOException {
103+
public static CredentialsProvider getCredentialsProvider(Configuration conf)
104+
throws IOException {
107105
CredentialsProvider credentials;
108106

109107
String className = conf.getTrimmed(CREDENTIALS_PROVIDER_KEY);
@@ -119,7 +117,7 @@ public static CredentialsProvider getCredentialsProvider(
119117
try {
120118
credentials =
121119
(CredentialsProvider)credClass.getDeclaredConstructor(
122-
URI.class, Configuration.class).newInstance(uri, conf);
120+
Configuration.class).newInstance(conf);
123121
} catch (NoSuchMethodException | SecurityException e) {
124122
credentials =
125123
(CredentialsProvider)credClass.getDeclaredConstructor()

hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/AssumedRoleCredentialProvider.java

-115
This file was deleted.

hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/Constants.java

-22
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
package org.apache.hadoop.fs.aliyun.oss;
2020

21-
import com.aliyun.oss.common.utils.AuthUtils;
2221
import com.aliyun.oss.common.utils.VersionInfoUtils;
2322

2423
/**
@@ -43,27 +42,6 @@ private Constants() {
4342
public static final String ACCESS_KEY_SECRET = "fs.oss.accessKeySecret";
4443
public static final String SECURITY_TOKEN = "fs.oss.securityToken";
4544

46-
// Assume role configurations
47-
public static final String ROLE_ARN = "fs.oss.assumed.role.arn";
48-
public static final String ASSUMED_ROLE_DURATION =
49-
"fs.oss.assumed.role.session.duration";
50-
// Default session duration(in seconds)
51-
public static final long ASSUMED_ROLE_DURATION_DEFAULT = 30 * 60;
52-
53-
// Expired factor of sts token
54-
// For example, if session duration is 900s and expiredFactor is 0.8
55-
// sts token will be refreshed after 900 * 0.8s
56-
public static final String ASSUMED_ROLE_STS_EXPIRED_FACTOR =
57-
"fs.oss.assumed.role.sts.expiredFactor";
58-
59-
public static final double ASSUMED_ROLE_STS_EXPIRED_FACTOR_DEFAULT =
60-
AuthUtils.DEFAULT_EXPIRED_FACTOR;
61-
62-
public static final String ASSUMED_ROLE_STS_ENDPOINT =
63-
"fs.oss.assumed.role.sts.endpoint";
64-
public static final String ASSUMED_ROLE_SESSION_NAME =
65-
"fs.oss.assumed.role.session.name";
66-
6745
// Number of simultaneous connections to oss
6846
public static final String MAXIMUM_CONNECTIONS_KEY =
6947
"fs.oss.connection.maximum";

hadoop-tools/hadoop-aliyun/src/site/markdown/tools/hadoop-aliyun/index.md

-50
Original file line numberDiff line numberDiff line change
@@ -117,56 +117,6 @@ please raise your issues with them.
117117
</description>
118118
</property>
119119

120-
<property>
121-
<name>fs.oss.assumed.role.arn</name>
122-
<description>
123-
Role ARN for the role to be assumed.
124-
Required if the fs.oss.credentials.provider is
125-
org.apache.hadoop.fs.aliyun.oss.AssumedRoleCredentialProvider.
126-
</description>
127-
</property>
128-
129-
<property>
130-
<name>fs.oss.assumed.role.sts.endpoint</name>
131-
<description>
132-
STS Token Service endpoint.
133-
Required if the fs.oss.credentials.provider is
134-
org.apache.hadoop.fs.aliyun.oss.AssumedRoleCredentialProvider.
135-
</description>
136-
</property>
137-
138-
<property>
139-
<name>fs.oss.assumed.role.session.name</name>
140-
<value />
141-
<description>
142-
Session name for the assumed role, must be valid characters
143-
according to Aliyun API. It is optional, will be generated by
144-
oss java sdk if it is empty.
145-
Only used if the fs.oss.credentials.provider is
146-
org.apache.hadoop.fs.aliyun.oss.AssumedRoleCredentialProvider.
147-
</description>
148-
</property>
149-
150-
<property>
151-
<name>fs.oss.assumed.role.session.duration</name>
152-
<value />
153-
<description>
154-
Duration of assumed roles before it is expired. Default is 30 minutes.
155-
Only used if the fs.oss.credentials.provider is
156-
org.apache.hadoop.fs.aliyun.oss.AssumedRoleCredentialProvider.
157-
</description>
158-
</property>
159-
160-
<property>
161-
<name>fs.oss.assumed.role.sts.expiredFactor</name>
162-
<value />
163-
<description>
164-
Sts token will be refreshed after (expiredFactor * duration) seconds.
165-
Only used if the fs.oss.credentials.provider is
166-
org.apache.hadoop.fs.aliyun.oss.AssumedRoleCredentialProvider.
167-
</description>
168-
</property>
169-
170120
<property>
171121
<name>fs.oss.proxy.host</name>
172122
<description>Hostname of the (optinal) proxy server for Aliyun OSS connection</description>

hadoop-tools/hadoop-aliyun/src/test/java/org/apache/hadoop/fs/aliyun/oss/TestAliyunCredentials.java

+5-50
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.apache.hadoop.fs.aliyun.oss;
2020

2121
import com.aliyun.oss.common.auth.Credentials;
22-
import com.aliyun.oss.common.auth.CredentialsProvider;
2322
import com.aliyun.oss.common.auth.InvalidCredentialsException;
2423
import org.apache.hadoop.conf.Configuration;
2524
import org.apache.hadoop.fs.aliyun.oss.contract.AliyunOSSContract;
@@ -28,15 +27,9 @@
2827
import org.junit.Test;
2928

3029
import java.io.IOException;
31-
import java.lang.reflect.InvocationTargetException;
32-
import java.net.URI;
3330

3431
import static org.apache.hadoop.fs.aliyun.oss.Constants.ACCESS_KEY_ID;
3532
import static org.apache.hadoop.fs.aliyun.oss.Constants.ACCESS_KEY_SECRET;
36-
import static org.apache.hadoop.fs.aliyun.oss.Constants.ASSUMED_ROLE_SESSION_NAME;
37-
import static org.apache.hadoop.fs.aliyun.oss.Constants.ASSUMED_ROLE_STS_ENDPOINT;
38-
import static org.apache.hadoop.fs.aliyun.oss.Constants.CREDENTIALS_PROVIDER_KEY;
39-
import static org.apache.hadoop.fs.aliyun.oss.Constants.ROLE_ARN;
4033
import static org.apache.hadoop.fs.aliyun.oss.Constants.SECURITY_TOKEN;
4134

4235
/**
@@ -70,54 +63,16 @@ public void testCredentialMissingAccessKeySecret() throws Throwable {
7063
validateCredential(conf);
7164
}
7265

73-
@Test
74-
public void testCredentialMissingRoleArn() throws Throwable {
75-
Configuration conf = new Configuration();
76-
conf.set(CREDENTIALS_PROVIDER_KEY, AssumedRoleCredentialProvider.NAME);
77-
conf.set(ROLE_ARN, "");
78-
validateCredential(conf);
79-
}
80-
81-
@Test
82-
public void testCredentialMissingStsEndpoint() throws Throwable {
83-
Configuration conf = new Configuration();
84-
conf.set(CREDENTIALS_PROVIDER_KEY, AssumedRoleCredentialProvider.NAME);
85-
conf.set(ASSUMED_ROLE_STS_ENDPOINT, "");
86-
validateCredential(conf);
87-
}
88-
89-
@Test
90-
public void testCredentialInvalidSessionName() throws Throwable {
91-
Configuration conf = new Configuration();
92-
conf.set(CREDENTIALS_PROVIDER_KEY, AssumedRoleCredentialProvider.NAME);
93-
conf.set(ASSUMED_ROLE_SESSION_NAME, "hadoop oss");
94-
validateCredential(conf);
95-
}
96-
97-
private void validateCredential(URI uri, Configuration conf) {
66+
private void validateCredential(Configuration conf) {
9867
try {
99-
CredentialsProvider provider =
100-
AliyunOSSUtils.getCredentialsProvider(uri, conf);
68+
AliyunCredentialsProvider provider
69+
= new AliyunCredentialsProvider(conf);
10170
Credentials credentials = provider.getCredentials();
10271
fail("Expected a CredentialInitializationException, got " + credentials);
10372
} catch (InvalidCredentialsException expected) {
10473
// expected
10574
} catch (IOException e) {
106-
Throwable cause = e.getCause();
107-
if (cause instanceof InvocationTargetException) {
108-
boolean isInstance =
109-
((InvocationTargetException)cause).getTargetException()
110-
instanceof InvalidCredentialsException;
111-
if (!isInstance) {
112-
fail("Unexpected exception.");
113-
}
114-
} else {
115-
fail("Unexpected exception.");
116-
}
75+
fail("Unexpected exception.");
11776
}
11877
}
119-
120-
private void validateCredential(Configuration conf) {
121-
validateCredential(null, conf);
122-
}
123-
}
78+
}

0 commit comments

Comments
 (0)