Skip to content

Commit 1f42527

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.
1 parent 999da98 commit 1f42527

File tree

8 files changed

+15
-251
lines changed

8 files changed

+15
-251
lines changed

hadoop-project/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@
12791279
<dependency>
12801280
<groupId>com.aliyun.oss</groupId>
12811281
<artifactId>aliyun-sdk-oss</artifactId>
1282-
<version>3.0.0</version>
1282+
<version>2.8.3</version>
12831283
<exclusions>
12841284
<exclusion>
12851285
<groupId>org.apache.httpcomponents</groupId>

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

Lines changed: 2 additions & 3 deletions
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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,14 @@ public void initialize(URI uri, Configuration conf, String user,
150150
"null or empty. Please set proper endpoint with 'fs.oss.endpoint'.");
151151
}
152152
CredentialsProvider provider =
153-
AliyunOSSUtils.getCredentialsProvider(uri, conf);
153+
AliyunOSSUtils.getCredentialsProvider(conf);
154154
ossClient = new OSSClient(endPoint, provider, clientConf);
155155
uploadPartSize = AliyunOSSUtils.getMultipartSizeProperty(conf,
156156
MULTIPART_UPLOAD_PART_SIZE_KEY, MULTIPART_UPLOAD_PART_SIZE_DEFAULT);
157157

158158
serverSideEncryptionAlgorithm =
159159
conf.get(SERVER_SIDE_ENCRYPTION_ALGORITHM_KEY, "");
160160

161-
bucketName = uri.getHost();
162-
163161
String cannedACLName = conf.get(CANNED_ACL_KEY, CANNED_ACL_DEFAULT);
164162
if (StringUtils.isNotEmpty(cannedACLName)) {
165163
CannedAccessControlList cannedACL =
@@ -169,6 +167,7 @@ public void initialize(URI uri, Configuration conf, String user,
169167
}
170168

171169
maxKeys = conf.getInt(MAX_PAGING_KEYS_KEY, MAX_PAGING_KEYS_DEFAULT);
170+
bucketName = uri.getHost();
172171
}
173172

174173
/**

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

Lines changed: 3 additions & 5 deletions
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

Lines changed: 0 additions & 115 deletions
This file was deleted.

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

Lines changed: 0 additions & 22 deletions
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
/**
@@ -45,27 +44,6 @@ private Constants() {
4544
public static final String ACCESS_KEY_SECRET = "fs.oss.accessKeySecret";
4645
public static final String SECURITY_TOKEN = "fs.oss.securityToken";
4746

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

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

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -128,58 +128,8 @@ please raise your issues with them.
128128
</property>
129129

130130
<property>
131-
<name>fs.oss.impl</name>
132-
<value>org.apache.hadoop.fs.aliyun.oss.AliyunOSSFileSystem</value>
133-
</property>
134-
135-
<property>
136-
<name>fs.oss.assumed.role.arn</name>
137-
<description>
138-
Role ARN for the role to be assumed.
139-
Required if the fs.oss.credentials.provider is
140-
org.apache.hadoop.fs.aliyun.oss.AssumedRoleCredentialProvider.
141-
</description>
142-
</property>
143-
144-
<property>
145-
<name>fs.oss.assumed.role.sts.endpoint</name>
146-
<description>
147-
STS Token Service endpoint.
148-
Required if the fs.oss.credentials.provider is
149-
org.apache.hadoop.fs.aliyun.oss.AssumedRoleCredentialProvider.
150-
</description>
151-
</property>
152-
153-
<property>
154-
<name>fs.oss.assumed.role.session.name</name>
155-
<value />
156-
<description>
157-
Session name for the assumed role, must be valid characters
158-
according to Aliyun API. It is optional, will be generated by
159-
oss java sdk if it is empty.
160-
Only used if the fs.oss.credentials.provider is
161-
org.apache.hadoop.fs.aliyun.oss.AssumedRoleCredentialProvider.
162-
</description>
163-
</property>
164-
165-
<property>
166-
<name>fs.oss.assumed.role.session.duration</name>
167-
<value />
168-
<description>
169-
Duration of assumed roles before it is expired. Default is 30 minutes.
170-
Only used if the fs.oss.credentials.provider is
171-
org.apache.hadoop.fs.aliyun.oss.AssumedRoleCredentialProvider.
172-
</description>
173-
</property>
174-
175-
<property>
176-
<name>fs.oss.assumed.role.sts.expiredFactor</name>
177-
<value />
178-
<description>
179-
Sts token will be refreshed after (expiredFactor * duration) seconds.
180-
Only used if the fs.oss.credentials.provider is
181-
org.apache.hadoop.fs.aliyun.oss.AssumedRoleCredentialProvider.
182-
</description>
131+
<name>fs.oss.impl</name>
132+
<value>org.apache.hadoop.fs.aliyun.oss.AliyunOSSFileSystem</value>
183133
</property>
184134

185135
<property>

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

Lines changed: 5 additions & 50 deletions
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)