-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-3995. Fix s3g met NPE exception while write file by multiPartUpload #1228
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
Closed
Closed
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
c5116f8
Add internal ozones3 python client and sample config.
timmylicheng eff899a
[Tencent] Fix timeout threshold is too small to exit safemode when se…
runzhiwang 5f5af8b
[Tencent] Stats for metadata.
timmylicheng 116222d
change ip to 0.0.0.0
runzhiwang 961d9ad
Revert 'change ip to 0.0.0.0'
043c4c1
fix Acceptance Tests in landun for branch master
31f1a7a
default width of docker-compose terminal output is too narrow (80)
ad65b7d
fix conflict in OzoneManager.java
453a885
Revert "[Tencent] Stats for metadata."
21d32f1
Merge branch 'github/master' at 57a8388
22ff24a
[tencent] make npm avoid proxy config in maven
e7f6d52
1) merge GitHub/master to Jun 15
91f5649
Merge branch github/master to f6e3ff at Jul 2
7a116ea
Merge branch github/master to f6e3ff at Jul 2
e1a68f2
Merge remote-tracking branch 'github/master'
runzhiwang d0b0b53
Merge remote-tracking branch 'github/master'
runzhiwang 78bc9b2
Merge remote-tracking branch 'github/master'
runzhiwang 7d179a7
Merge remote-tracking branch 'github/master'
runzhiwang 6137b3f
Merge remote-tracking branch 'github/master'
runzhiwang 1188e57
Merge remote-tracking branch 'github/master'
runzhiwang e0c390e
Merge remote-tracking branch 'github/master'
runzhiwang dac7631
Merge remote-tracking branch 'github/master'
runzhiwang 7a124ce
Merge remote-tracking branch 'github/master'
runzhiwang 8aa1486
Merge remote-tracking branch 'github/master'
runzhiwang 6085517
HDDS-3995. Fix s3g met NPE exception while write file by multiPartUpl…
maobaolong ee9750e
merge github/master
runzhiwang 267d88d
TENCENT. fix failed ci
runzhiwang 84c5e5e
'merge-github-master' into 'master' (merge request !41)
runzhiwang d08b1c4
Merge remote-tracking branch 'github/master'
runzhiwang d1b5483
Merge remote-tracking branch 'github/master'
runzhiwang c3bd027
Merge remote-tracking branch 'github/master'
runzhiwang cb786b7
Merge remote-tracking branch 'github/master'
runzhiwang dbc85f5
Merge remote-tracking branch 'github/master'
runzhiwang f3107fa
Merge remote-tracking branch 'github/master'
runzhiwang ffa3807
Merge remote-tracking branch 'github/master'
runzhiwang dc415b4
Merge remote-tracking branch 'github/master'
runzhiwang fe2520d
Merge remote-tracking branch 'github/master'
runzhiwang 2fec8c0
Merge remote-tracking branch 'github/master'
runzhiwang 4114aad
Merge remote-tracking branch 'github/master'
runzhiwang 310dd39
Merge remote-tracking branch 'github/master'
runzhiwang aa14d80
Merge remote-tracking branch 'github/master'
runzhiwang d278411
Merge remote-tracking branch 'github/master'
runzhiwang 9211a97
Merge remote-tracking branch 'github/master'
runzhiwang efa0d7e
Merge remote-tracking branch 'github/master'
runzhiwang cbfa2d7
Merge remote-tracking branch 'github/master'
runzhiwang b28c68a
Merge remote-tracking branch 'github/master'
runzhiwang d4ef49e
replace close method to avoid swallow the exception
maobaolong e92c16e
Add the missing line
maobaolong 7009722
Merge branch 'master' of git.code.oa.com:DataLake/hadoop-ozone into H…
maobaolong 342d654
Merge branch 'HDDS-3995' of https://github.com/maobaolong/hadoop-ozon…
maobaolong a6fe6fa
fix findbugs issue.
maobaolong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import boto3 | ||
| from botocore.config import Config | ||
| from botocore.exceptions import ClientError | ||
| import xml.etree.ElementTree as ET | ||
| from itertools import izip_longest | ||
| from random import randrange | ||
|
|
||
| # Ozone doesn't care access key and secret key in non-SafeMode | ||
| AWS_ACCESS_KEY_ID = '12345678' | ||
| AWS_SECRET_ACCESS_KEY = '12345678' | ||
|
|
||
| # Ozone S3 gateway endpoints | ||
| root = ET.parse('ozone_idex_config.xml').getroot() | ||
| endpoints = root.findall('property/entry') | ||
| SERVER_LIST = [] | ||
| for endpoint in endpoints: | ||
| SERVER_LIST.append(endpoint.get('ozone.s3g.endpoint')) | ||
| #endpoint = 'http://localhost:9878' | ||
|
|
||
| # Ozone S3 bucket name | ||
| bucket_name = 'idex_bucket' | ||
|
|
||
| def round_robin(cur = [0]): | ||
| length = len(SERVER_LIST) | ||
| ret = SERVER_LIST[cur[0] % length] | ||
| cur[0] = (cur[0] + 1) % length | ||
| return ret | ||
|
|
||
| def s3_resource(): | ||
| session = boto3.session.Session(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) | ||
| endpoint = round_robin([randrange(len(SERVER_LIST))]) | ||
| s3 = session.resource(service_name='s3', endpoint_url=endpoint) | ||
| print("current endpoint: " + endpoint) | ||
| return s3 | ||
|
|
||
| class OzoneS3: | ||
| @staticmethod | ||
| def upload_file(file_path): | ||
| try: | ||
| s3_resource().Bucket(bucket_name).upload_file(file_path, file_path) | ||
| except Exception as e: | ||
| print("retry one time. exception: " + str(e)) | ||
| s3_resource().Bucket(bucket_name).upload_file(file_path, file_path) | ||
|
|
||
|
|
||
| @staticmethod | ||
| def upload_stream(key, byte_stream): | ||
| try: | ||
| s3_resource().Object(bucket_name, key).put(Body=byte_stream) | ||
| except Exception as e: | ||
| s3_resource().Object(bucket_name, key).put(Body=byte_stream) | ||
|
|
||
| @staticmethod | ||
| def download_file(key, output_file_path): | ||
| try: | ||
| s3_resource().Bucket(bucket_name).download_file(key, output_file_path) | ||
| except Exception as e: | ||
| s3_resource().Bucket(bucket_name).download_file(key, output_file_path) | ||
|
|
||
| @staticmethod | ||
| def download_stream(key): | ||
| try: | ||
| obj = s3_resource().Object(bucket_name, key) | ||
| return obj.get()['Body'].read() | ||
| except Exception as e: | ||
| obj = s3_resource().Object(bucket_name, key) | ||
| return obj.get()['Body'].read() | ||
|
|
||
| @staticmethod | ||
| def iter_n(iterable, n, fillvalue=None): | ||
| args = [iter(iterable)] * n | ||
| return izip_longest(*args, fillvalue=fillvalue) | ||
|
|
||
| @staticmethod | ||
| def download_stream_iter(key): | ||
| try: | ||
| obj = s3_resource().Object(bucket_name, key) | ||
| return obj.get()['Body'] | ||
| except Exception as e: | ||
| obj = s3_resource().Object(bucket_name, key) | ||
| return obj.get()['Body'] | ||
|
|
||
| @staticmethod | ||
| def delete(key): | ||
| try: | ||
| s3_resource().Object(bucket_name, key).delete() | ||
| except Exception as e: | ||
| s3_resource().Object(bucket_name, key).delete() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Python interface for ozone thru s3 gateway. | ||
|
|
||
| In order to use this OzoneS3.py, make sure python3 is installed in your env. Then put s3 gateway endpoint in ozone_client_confg.xml. | ||
| If you have multiple s3 gateway endpoint, put separate entries in ozone_client_config.xml. OzoneS3.py will randomly pick one. | ||
|
|
||
| Bucket is hardcoded in OzoneS3.py. In terms of s3 gateway of Ozone, please refer to https://hadoop.apache.org/ozone/docs/0.4.0-alpha/s3.html . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ozone_config> | ||
| <property> | ||
| <entry ozone.s3g.endpoint='http://localhost:9878'/> | ||
| <entry ozone.s3g.endpoint='http://127.0.0.1:9878'/> | ||
| </property> | ||
| </ozone_config> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these changes related to this PR? It has files named under directory Tencent.